ui_team.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. //
  19. //
  20. // ui_team.c
  21. //
  22. #include "ui_local.h"
  23. #define TEAMMAIN_FRAME "menu/art/cut_frame"
  24. #define ID_JOINRED 100
  25. #define ID_JOINBLUE 101
  26. #define ID_JOINGAME 102
  27. #define ID_SPECTATE 103
  28. typedef struct
  29. {
  30. menuframework_s menu;
  31. menubitmap_s frame;
  32. menutext_s joinred;
  33. menutext_s joinblue;
  34. menutext_s joingame;
  35. menutext_s spectate;
  36. } teammain_t;
  37. static teammain_t s_teammain;
  38. // bk001204 - unused
  39. //static menuframework_s s_teammain_menu;
  40. //static menuaction_s s_teammain_orders;
  41. //static menuaction_s s_teammain_voice;
  42. //static menuaction_s s_teammain_joinred;
  43. //static menuaction_s s_teammain_joinblue;
  44. //static menuaction_s s_teammain_joingame;
  45. //static menuaction_s s_teammain_spectate;
  46. /*
  47. ===============
  48. TeamMain_MenuEvent
  49. ===============
  50. */
  51. static void TeamMain_MenuEvent( void* ptr, int event ) {
  52. if( event != QM_ACTIVATED ) {
  53. return;
  54. }
  55. switch( ((menucommon_s*)ptr)->id ) {
  56. case ID_JOINRED:
  57. trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
  58. UI_ForceMenuOff();
  59. break;
  60. case ID_JOINBLUE:
  61. trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
  62. UI_ForceMenuOff();
  63. break;
  64. case ID_JOINGAME:
  65. trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
  66. UI_ForceMenuOff();
  67. break;
  68. case ID_SPECTATE:
  69. trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
  70. UI_ForceMenuOff();
  71. break;
  72. }
  73. }
  74. /*
  75. ===============
  76. TeamMain_MenuInit
  77. ===============
  78. */
  79. void TeamMain_MenuInit( void ) {
  80. int y;
  81. int gametype;
  82. char info[MAX_INFO_STRING];
  83. memset( &s_teammain, 0, sizeof(s_teammain) );
  84. TeamMain_Cache();
  85. s_teammain.menu.wrapAround = qtrue;
  86. s_teammain.menu.fullscreen = qfalse;
  87. s_teammain.frame.generic.type = MTYPE_BITMAP;
  88. s_teammain.frame.generic.flags = QMF_INACTIVE;
  89. s_teammain.frame.generic.name = TEAMMAIN_FRAME;
  90. s_teammain.frame.generic.x = 142;
  91. s_teammain.frame.generic.y = 118;
  92. s_teammain.frame.width = 359;
  93. s_teammain.frame.height = 256;
  94. y = 194;
  95. s_teammain.joinred.generic.type = MTYPE_PTEXT;
  96. s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  97. s_teammain.joinred.generic.id = ID_JOINRED;
  98. s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
  99. s_teammain.joinred.generic.x = 320;
  100. s_teammain.joinred.generic.y = y;
  101. s_teammain.joinred.string = "JOIN RED";
  102. s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT;
  103. s_teammain.joinred.color = colorRed;
  104. y += 20;
  105. s_teammain.joinblue.generic.type = MTYPE_PTEXT;
  106. s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  107. s_teammain.joinblue.generic.id = ID_JOINBLUE;
  108. s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
  109. s_teammain.joinblue.generic.x = 320;
  110. s_teammain.joinblue.generic.y = y;
  111. s_teammain.joinblue.string = "JOIN BLUE";
  112. s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT;
  113. s_teammain.joinblue.color = colorRed;
  114. y += 20;
  115. s_teammain.joingame.generic.type = MTYPE_PTEXT;
  116. s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  117. s_teammain.joingame.generic.id = ID_JOINGAME;
  118. s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
  119. s_teammain.joingame.generic.x = 320;
  120. s_teammain.joingame.generic.y = y;
  121. s_teammain.joingame.string = "JOIN GAME";
  122. s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT;
  123. s_teammain.joingame.color = colorRed;
  124. y += 20;
  125. s_teammain.spectate.generic.type = MTYPE_PTEXT;
  126. s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  127. s_teammain.spectate.generic.id = ID_SPECTATE;
  128. s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
  129. s_teammain.spectate.generic.x = 320;
  130. s_teammain.spectate.generic.y = y;
  131. s_teammain.spectate.string = "SPECTATE";
  132. s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT;
  133. s_teammain.spectate.color = colorRed;
  134. y += 20;
  135. trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
  136. gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
  137. // set initial states
  138. switch( gametype ) {
  139. case GT_SINGLE_PLAYER:
  140. case GT_FFA:
  141. case GT_TOURNAMENT:
  142. s_teammain.joinred.generic.flags |= QMF_GRAYED;
  143. s_teammain.joinblue.generic.flags |= QMF_GRAYED;
  144. break;
  145. default:
  146. case GT_TEAM:
  147. case GT_CTF:
  148. s_teammain.joingame.generic.flags |= QMF_GRAYED;
  149. break;
  150. }
  151. Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
  152. Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
  153. Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
  154. Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
  155. Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
  156. }
  157. /*
  158. ===============
  159. TeamMain_Cache
  160. ===============
  161. */
  162. void TeamMain_Cache( void ) {
  163. trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
  164. }
  165. /*
  166. ===============
  167. UI_TeamMainMenu
  168. ===============
  169. */
  170. void UI_TeamMainMenu( void ) {
  171. TeamMain_MenuInit();
  172. UI_PushMenu ( &s_teammain.menu );
  173. }