ui_setup.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. =======================================================================
  21. SETUP MENU
  22. =======================================================================
  23. */
  24. #include "ui_local.h"
  25. #define SETUP_MENU_VERTICAL_SPACING 34
  26. #define ART_BACK0 "menu/art/back_0"
  27. #define ART_BACK1 "menu/art/back_1"
  28. #define ART_FRAMEL "menu/art/frame2_l"
  29. #define ART_FRAMER "menu/art/frame1_r"
  30. #define ID_CUSTOMIZEPLAYER 10
  31. #define ID_CUSTOMIZECONTROLS 11
  32. #define ID_SYSTEMCONFIG 12
  33. #define ID_GAME 13
  34. #define ID_CDKEY 14
  35. #define ID_LOAD 15
  36. #define ID_SAVE 16
  37. #define ID_DEFAULTS 17
  38. #define ID_BACK 18
  39. typedef struct {
  40. menuframework_s menu;
  41. menutext_s banner;
  42. menubitmap_s framel;
  43. menubitmap_s framer;
  44. menutext_s setupplayer;
  45. menutext_s setupcontrols;
  46. menutext_s setupsystem;
  47. menutext_s game;
  48. menutext_s cdkey;
  49. // menutext_s load;
  50. // menutext_s save;
  51. menutext_s defaults;
  52. menubitmap_s back;
  53. } setupMenuInfo_t;
  54. static setupMenuInfo_t setupMenuInfo;
  55. /*
  56. =================
  57. Setup_ResetDefaults_Action
  58. =================
  59. */
  60. static void Setup_ResetDefaults_Action( qboolean result ) {
  61. if( !result ) {
  62. return;
  63. }
  64. trap_Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
  65. trap_Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
  66. trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
  67. }
  68. /*
  69. =================
  70. Setup_ResetDefaults_Draw
  71. =================
  72. */
  73. static void Setup_ResetDefaults_Draw( void ) {
  74. UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset *ALL*", UI_CENTER|UI_SMALLFONT, color_yellow );
  75. UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "options to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow );
  76. }
  77. /*
  78. ===============
  79. UI_SetupMenu_Event
  80. ===============
  81. */
  82. static void UI_SetupMenu_Event( void *ptr, int event ) {
  83. if( event != QM_ACTIVATED ) {
  84. return;
  85. }
  86. switch( ((menucommon_s*)ptr)->id ) {
  87. case ID_CUSTOMIZEPLAYER:
  88. UI_PlayerSettingsMenu();
  89. break;
  90. case ID_CUSTOMIZECONTROLS:
  91. UI_ControlsMenu();
  92. break;
  93. case ID_SYSTEMCONFIG:
  94. UI_GraphicsOptionsMenu();
  95. break;
  96. case ID_GAME:
  97. UI_PreferencesMenu();
  98. break;
  99. case ID_CDKEY:
  100. UI_CDKeyMenu();
  101. break;
  102. // case ID_LOAD:
  103. // UI_LoadConfigMenu();
  104. // break;
  105. // case ID_SAVE:
  106. // UI_SaveConfigMenu();
  107. // break;
  108. case ID_DEFAULTS:
  109. UI_ConfirmMenu( "SET TO DEFAULTS?", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action );
  110. break;
  111. case ID_BACK:
  112. UI_PopMenu();
  113. break;
  114. }
  115. }
  116. /*
  117. ===============
  118. UI_SetupMenu_Init
  119. ===============
  120. */
  121. static void UI_SetupMenu_Init( void ) {
  122. int y;
  123. UI_SetupMenu_Cache();
  124. memset( &setupMenuInfo, 0, sizeof(setupMenuInfo) );
  125. setupMenuInfo.menu.wrapAround = qtrue;
  126. setupMenuInfo.menu.fullscreen = qtrue;
  127. setupMenuInfo.banner.generic.type = MTYPE_BTEXT;
  128. setupMenuInfo.banner.generic.x = 320;
  129. setupMenuInfo.banner.generic.y = 16;
  130. setupMenuInfo.banner.string = "SETUP";
  131. setupMenuInfo.banner.color = color_white;
  132. setupMenuInfo.banner.style = UI_CENTER;
  133. setupMenuInfo.framel.generic.type = MTYPE_BITMAP;
  134. setupMenuInfo.framel.generic.name = ART_FRAMEL;
  135. setupMenuInfo.framel.generic.flags = QMF_INACTIVE;
  136. setupMenuInfo.framel.generic.x = 0;
  137. setupMenuInfo.framel.generic.y = 78;
  138. setupMenuInfo.framel.width = 256;
  139. setupMenuInfo.framel.height = 329;
  140. setupMenuInfo.framer.generic.type = MTYPE_BITMAP;
  141. setupMenuInfo.framer.generic.name = ART_FRAMER;
  142. setupMenuInfo.framer.generic.flags = QMF_INACTIVE;
  143. setupMenuInfo.framer.generic.x = 376;
  144. setupMenuInfo.framer.generic.y = 76;
  145. setupMenuInfo.framer.width = 256;
  146. setupMenuInfo.framer.height = 334;
  147. y = 134;
  148. setupMenuInfo.setupplayer.generic.type = MTYPE_PTEXT;
  149. setupMenuInfo.setupplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  150. setupMenuInfo.setupplayer.generic.x = 320;
  151. setupMenuInfo.setupplayer.generic.y = y;
  152. setupMenuInfo.setupplayer.generic.id = ID_CUSTOMIZEPLAYER;
  153. setupMenuInfo.setupplayer.generic.callback = UI_SetupMenu_Event;
  154. setupMenuInfo.setupplayer.string = "PLAYER";
  155. setupMenuInfo.setupplayer.color = color_red;
  156. setupMenuInfo.setupplayer.style = UI_CENTER;
  157. y += SETUP_MENU_VERTICAL_SPACING;
  158. setupMenuInfo.setupcontrols.generic.type = MTYPE_PTEXT;
  159. setupMenuInfo.setupcontrols.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  160. setupMenuInfo.setupcontrols.generic.x = 320;
  161. setupMenuInfo.setupcontrols.generic.y = y;
  162. setupMenuInfo.setupcontrols.generic.id = ID_CUSTOMIZECONTROLS;
  163. setupMenuInfo.setupcontrols.generic.callback = UI_SetupMenu_Event;
  164. setupMenuInfo.setupcontrols.string = "CONTROLS";
  165. setupMenuInfo.setupcontrols.color = color_red;
  166. setupMenuInfo.setupcontrols.style = UI_CENTER;
  167. y += SETUP_MENU_VERTICAL_SPACING;
  168. setupMenuInfo.setupsystem.generic.type = MTYPE_PTEXT;
  169. setupMenuInfo.setupsystem.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  170. setupMenuInfo.setupsystem.generic.x = 320;
  171. setupMenuInfo.setupsystem.generic.y = y;
  172. setupMenuInfo.setupsystem.generic.id = ID_SYSTEMCONFIG;
  173. setupMenuInfo.setupsystem.generic.callback = UI_SetupMenu_Event;
  174. setupMenuInfo.setupsystem.string = "SYSTEM";
  175. setupMenuInfo.setupsystem.color = color_red;
  176. setupMenuInfo.setupsystem.style = UI_CENTER;
  177. y += SETUP_MENU_VERTICAL_SPACING;
  178. setupMenuInfo.game.generic.type = MTYPE_PTEXT;
  179. setupMenuInfo.game.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  180. setupMenuInfo.game.generic.x = 320;
  181. setupMenuInfo.game.generic.y = y;
  182. setupMenuInfo.game.generic.id = ID_GAME;
  183. setupMenuInfo.game.generic.callback = UI_SetupMenu_Event;
  184. setupMenuInfo.game.string = "GAME OPTIONS";
  185. setupMenuInfo.game.color = color_red;
  186. setupMenuInfo.game.style = UI_CENTER;
  187. y += SETUP_MENU_VERTICAL_SPACING;
  188. setupMenuInfo.cdkey.generic.type = MTYPE_PTEXT;
  189. setupMenuInfo.cdkey.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  190. setupMenuInfo.cdkey.generic.x = 320;
  191. setupMenuInfo.cdkey.generic.y = y;
  192. setupMenuInfo.cdkey.generic.id = ID_CDKEY;
  193. setupMenuInfo.cdkey.generic.callback = UI_SetupMenu_Event;
  194. setupMenuInfo.cdkey.string = "CD Key";
  195. setupMenuInfo.cdkey.color = color_red;
  196. setupMenuInfo.cdkey.style = UI_CENTER;
  197. if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
  198. #if 0
  199. y += SETUP_MENU_VERTICAL_SPACING;
  200. setupMenuInfo.load.generic.type = MTYPE_PTEXT;
  201. setupMenuInfo.load.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  202. setupMenuInfo.load.generic.x = 320;
  203. setupMenuInfo.load.generic.y = y;
  204. setupMenuInfo.load.generic.id = ID_LOAD;
  205. setupMenuInfo.load.generic.callback = UI_SetupMenu_Event;
  206. setupMenuInfo.load.string = "LOAD";
  207. setupMenuInfo.load.color = color_red;
  208. setupMenuInfo.load.style = UI_CENTER;
  209. y += SETUP_MENU_VERTICAL_SPACING;
  210. setupMenuInfo.save.generic.type = MTYPE_PTEXT;
  211. setupMenuInfo.save.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  212. setupMenuInfo.save.generic.x = 320;
  213. setupMenuInfo.save.generic.y = y;
  214. setupMenuInfo.save.generic.id = ID_SAVE;
  215. setupMenuInfo.save.generic.callback = UI_SetupMenu_Event;
  216. setupMenuInfo.save.string = "SAVE";
  217. setupMenuInfo.save.color = color_red;
  218. setupMenuInfo.save.style = UI_CENTER;
  219. #endif
  220. y += SETUP_MENU_VERTICAL_SPACING;
  221. setupMenuInfo.defaults.generic.type = MTYPE_PTEXT;
  222. setupMenuInfo.defaults.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  223. setupMenuInfo.defaults.generic.x = 320;
  224. setupMenuInfo.defaults.generic.y = y;
  225. setupMenuInfo.defaults.generic.id = ID_DEFAULTS;
  226. setupMenuInfo.defaults.generic.callback = UI_SetupMenu_Event;
  227. setupMenuInfo.defaults.string = "DEFAULTS";
  228. setupMenuInfo.defaults.color = color_red;
  229. setupMenuInfo.defaults.style = UI_CENTER;
  230. }
  231. setupMenuInfo.back.generic.type = MTYPE_BITMAP;
  232. setupMenuInfo.back.generic.name = ART_BACK0;
  233. setupMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
  234. setupMenuInfo.back.generic.id = ID_BACK;
  235. setupMenuInfo.back.generic.callback = UI_SetupMenu_Event;
  236. setupMenuInfo.back.generic.x = 0;
  237. setupMenuInfo.back.generic.y = 480-64;
  238. setupMenuInfo.back.width = 128;
  239. setupMenuInfo.back.height = 64;
  240. setupMenuInfo.back.focuspic = ART_BACK1;
  241. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.banner );
  242. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framel );
  243. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framer );
  244. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer );
  245. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );
  246. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem );
  247. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game );
  248. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.cdkey );
  249. // Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.load );
  250. // Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.save );
  251. if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
  252. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.defaults );
  253. }
  254. Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.back );
  255. }
  256. /*
  257. =================
  258. UI_SetupMenu_Cache
  259. =================
  260. */
  261. void UI_SetupMenu_Cache( void ) {
  262. trap_R_RegisterShaderNoMip( ART_BACK0 );
  263. trap_R_RegisterShaderNoMip( ART_BACK1 );
  264. trap_R_RegisterShaderNoMip( ART_FRAMEL );
  265. trap_R_RegisterShaderNoMip( ART_FRAMER );
  266. }
  267. /*
  268. ===============
  269. UI_SetupMenu
  270. ===============
  271. */
  272. void UI_SetupMenu( void ) {
  273. UI_SetupMenu_Init();
  274. UI_PushMenu( &setupMenuInfo.menu );
  275. }