ui_display.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. DISPLAY OPTIONS MENU
  22. =======================================================================
  23. */
  24. #include "ui_local.h"
  25. #define ART_FRAMEL "menu/art/frame2_l"
  26. #define ART_FRAMER "menu/art/frame1_r"
  27. #define ART_BACK0 "menu/art/back_0"
  28. #define ART_BACK1 "menu/art/back_1"
  29. #define ID_GRAPHICS 10
  30. #define ID_DISPLAY 11
  31. #define ID_SOUND 12
  32. #define ID_NETWORK 13
  33. #define ID_BRIGHTNESS 14
  34. #define ID_SCREENSIZE 15
  35. #define ID_BACK 16
  36. typedef struct {
  37. menuframework_s menu;
  38. menutext_s banner;
  39. menubitmap_s framel;
  40. menubitmap_s framer;
  41. menutext_s graphics;
  42. menutext_s display;
  43. menutext_s sound;
  44. menutext_s network;
  45. menuslider_s brightness;
  46. menuslider_s screensize;
  47. menubitmap_s back;
  48. } displayOptionsInfo_t;
  49. static displayOptionsInfo_t displayOptionsInfo;
  50. /*
  51. =================
  52. UI_DisplayOptionsMenu_Event
  53. =================
  54. */
  55. static void UI_DisplayOptionsMenu_Event( void* ptr, int event ) {
  56. if( event != QM_ACTIVATED ) {
  57. return;
  58. }
  59. switch( ((menucommon_s*)ptr)->id ) {
  60. case ID_GRAPHICS:
  61. UI_PopMenu();
  62. UI_GraphicsOptionsMenu();
  63. break;
  64. case ID_DISPLAY:
  65. break;
  66. case ID_SOUND:
  67. UI_PopMenu();
  68. UI_SoundOptionsMenu();
  69. break;
  70. case ID_NETWORK:
  71. UI_PopMenu();
  72. UI_NetworkOptionsMenu();
  73. break;
  74. case ID_BRIGHTNESS:
  75. trap_Cvar_SetValue( "r_gamma", displayOptionsInfo.brightness.curvalue / 10.0f );
  76. break;
  77. case ID_SCREENSIZE:
  78. trap_Cvar_SetValue( "cg_viewsize", displayOptionsInfo.screensize.curvalue * 10 );
  79. break;
  80. case ID_BACK:
  81. UI_PopMenu();
  82. break;
  83. }
  84. }
  85. /*
  86. ===============
  87. UI_DisplayOptionsMenu_Init
  88. ===============
  89. */
  90. static void UI_DisplayOptionsMenu_Init( void ) {
  91. int y;
  92. memset( &displayOptionsInfo, 0, sizeof(displayOptionsInfo) );
  93. UI_DisplayOptionsMenu_Cache();
  94. displayOptionsInfo.menu.wrapAround = qtrue;
  95. displayOptionsInfo.menu.fullscreen = qtrue;
  96. displayOptionsInfo.banner.generic.type = MTYPE_BTEXT;
  97. displayOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
  98. displayOptionsInfo.banner.generic.x = 320;
  99. displayOptionsInfo.banner.generic.y = 16;
  100. displayOptionsInfo.banner.string = "SYSTEM SETUP";
  101. displayOptionsInfo.banner.color = color_white;
  102. displayOptionsInfo.banner.style = UI_CENTER;
  103. displayOptionsInfo.framel.generic.type = MTYPE_BITMAP;
  104. displayOptionsInfo.framel.generic.name = ART_FRAMEL;
  105. displayOptionsInfo.framel.generic.flags = QMF_INACTIVE;
  106. displayOptionsInfo.framel.generic.x = 0;
  107. displayOptionsInfo.framel.generic.y = 78;
  108. displayOptionsInfo.framel.width = 256;
  109. displayOptionsInfo.framel.height = 329;
  110. displayOptionsInfo.framer.generic.type = MTYPE_BITMAP;
  111. displayOptionsInfo.framer.generic.name = ART_FRAMER;
  112. displayOptionsInfo.framer.generic.flags = QMF_INACTIVE;
  113. displayOptionsInfo.framer.generic.x = 376;
  114. displayOptionsInfo.framer.generic.y = 76;
  115. displayOptionsInfo.framer.width = 256;
  116. displayOptionsInfo.framer.height = 334;
  117. displayOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
  118. displayOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  119. displayOptionsInfo.graphics.generic.id = ID_GRAPHICS;
  120. displayOptionsInfo.graphics.generic.callback = UI_DisplayOptionsMenu_Event;
  121. displayOptionsInfo.graphics.generic.x = 216;
  122. displayOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
  123. displayOptionsInfo.graphics.string = "GRAPHICS";
  124. displayOptionsInfo.graphics.style = UI_RIGHT;
  125. displayOptionsInfo.graphics.color = color_red;
  126. displayOptionsInfo.display.generic.type = MTYPE_PTEXT;
  127. displayOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY;
  128. displayOptionsInfo.display.generic.id = ID_DISPLAY;
  129. displayOptionsInfo.display.generic.callback = UI_DisplayOptionsMenu_Event;
  130. displayOptionsInfo.display.generic.x = 216;
  131. displayOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
  132. displayOptionsInfo.display.string = "DISPLAY";
  133. displayOptionsInfo.display.style = UI_RIGHT;
  134. displayOptionsInfo.display.color = color_red;
  135. displayOptionsInfo.sound.generic.type = MTYPE_PTEXT;
  136. displayOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  137. displayOptionsInfo.sound.generic.id = ID_SOUND;
  138. displayOptionsInfo.sound.generic.callback = UI_DisplayOptionsMenu_Event;
  139. displayOptionsInfo.sound.generic.x = 216;
  140. displayOptionsInfo.sound.generic.y = 240;
  141. displayOptionsInfo.sound.string = "SOUND";
  142. displayOptionsInfo.sound.style = UI_RIGHT;
  143. displayOptionsInfo.sound.color = color_red;
  144. displayOptionsInfo.network.generic.type = MTYPE_PTEXT;
  145. displayOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  146. displayOptionsInfo.network.generic.id = ID_NETWORK;
  147. displayOptionsInfo.network.generic.callback = UI_DisplayOptionsMenu_Event;
  148. displayOptionsInfo.network.generic.x = 216;
  149. displayOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
  150. displayOptionsInfo.network.string = "NETWORK";
  151. displayOptionsInfo.network.style = UI_RIGHT;
  152. displayOptionsInfo.network.color = color_red;
  153. y = 240 - 1 * (BIGCHAR_HEIGHT+2);
  154. displayOptionsInfo.brightness.generic.type = MTYPE_SLIDER;
  155. displayOptionsInfo.brightness.generic.name = "Brightness:";
  156. displayOptionsInfo.brightness.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
  157. displayOptionsInfo.brightness.generic.callback = UI_DisplayOptionsMenu_Event;
  158. displayOptionsInfo.brightness.generic.id = ID_BRIGHTNESS;
  159. displayOptionsInfo.brightness.generic.x = 400;
  160. displayOptionsInfo.brightness.generic.y = y;
  161. displayOptionsInfo.brightness.minvalue = 5;
  162. displayOptionsInfo.brightness.maxvalue = 20;
  163. if( !uis.glconfig.deviceSupportsGamma ) {
  164. displayOptionsInfo.brightness.generic.flags |= QMF_GRAYED;
  165. }
  166. y += BIGCHAR_HEIGHT+2;
  167. displayOptionsInfo.screensize.generic.type = MTYPE_SLIDER;
  168. displayOptionsInfo.screensize.generic.name = "Screen Size:";
  169. displayOptionsInfo.screensize.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
  170. displayOptionsInfo.screensize.generic.callback = UI_DisplayOptionsMenu_Event;
  171. displayOptionsInfo.screensize.generic.id = ID_SCREENSIZE;
  172. displayOptionsInfo.screensize.generic.x = 400;
  173. displayOptionsInfo.screensize.generic.y = y;
  174. displayOptionsInfo.screensize.minvalue = 3;
  175. displayOptionsInfo.screensize.maxvalue = 10;
  176. displayOptionsInfo.back.generic.type = MTYPE_BITMAP;
  177. displayOptionsInfo.back.generic.name = ART_BACK0;
  178. displayOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
  179. displayOptionsInfo.back.generic.callback = UI_DisplayOptionsMenu_Event;
  180. displayOptionsInfo.back.generic.id = ID_BACK;
  181. displayOptionsInfo.back.generic.x = 0;
  182. displayOptionsInfo.back.generic.y = 480-64;
  183. displayOptionsInfo.back.width = 128;
  184. displayOptionsInfo.back.height = 64;
  185. displayOptionsInfo.back.focuspic = ART_BACK1;
  186. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.banner );
  187. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framel );
  188. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framer );
  189. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.graphics );
  190. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.display );
  191. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.sound );
  192. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.network );
  193. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.brightness );
  194. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.screensize );
  195. Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.back );
  196. displayOptionsInfo.brightness.curvalue = trap_Cvar_VariableValue("r_gamma") * 10;
  197. displayOptionsInfo.screensize.curvalue = trap_Cvar_VariableValue( "cg_viewsize")/10;
  198. }
  199. /*
  200. ===============
  201. UI_DisplayOptionsMenu_Cache
  202. ===============
  203. */
  204. void UI_DisplayOptionsMenu_Cache( void ) {
  205. trap_R_RegisterShaderNoMip( ART_FRAMEL );
  206. trap_R_RegisterShaderNoMip( ART_FRAMER );
  207. trap_R_RegisterShaderNoMip( ART_BACK0 );
  208. trap_R_RegisterShaderNoMip( ART_BACK1 );
  209. }
  210. /*
  211. ===============
  212. UI_DisplayOptionsMenu
  213. ===============
  214. */
  215. void UI_DisplayOptionsMenu( void ) {
  216. UI_DisplayOptionsMenu_Init();
  217. UI_PushMenu( &displayOptionsInfo.menu );
  218. Menu_SetCursorToItem( &displayOptionsInfo.menu, &displayOptionsInfo.display );
  219. }