ui_cinematics.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. #include "ui_local.h"
  20. #define ART_BACK0 "menu/art/back_0"
  21. #define ART_BACK1 "menu/art/back_1"
  22. #define ART_FRAMEL "menu/art/frame2_l"
  23. #define ART_FRAMER "menu/art/frame1_r"
  24. #define VERTICAL_SPACING 30
  25. #define ID_BACK 10
  26. #define ID_CIN_IDLOGO 11
  27. #define ID_CIN_INTRO 12
  28. #define ID_CIN_TIER1 13
  29. #define ID_CIN_TIER2 14
  30. #define ID_CIN_TIER3 15
  31. #define ID_CIN_TIER4 16
  32. #define ID_CIN_TIER5 17
  33. #define ID_CIN_TIER6 18
  34. #define ID_CIN_TIER7 19
  35. #define ID_CIN_END 20
  36. typedef struct {
  37. menuframework_s menu;
  38. menutext_s banner;
  39. menubitmap_s framel;
  40. menubitmap_s framer;
  41. menutext_s cin_idlogo;
  42. menutext_s cin_intro;
  43. menutext_s cin_tier1;
  44. menutext_s cin_tier2;
  45. menutext_s cin_tier3;
  46. menutext_s cin_tier4;
  47. menutext_s cin_tier5;
  48. menutext_s cin_tier6;
  49. menutext_s cin_tier7;
  50. menutext_s cin_end;
  51. menubitmap_s back;
  52. } cinematicsMenuInfo_t;
  53. static cinematicsMenuInfo_t cinematicsMenuInfo;
  54. static char *cinematics[] = {
  55. "idlogo",
  56. "intro",
  57. "tier1",
  58. "tier2",
  59. "tier3",
  60. "tier4",
  61. "tier5",
  62. "tier6",
  63. "tier7",
  64. "end"
  65. };
  66. /*
  67. ===============
  68. UI_CinematicsMenu_BackEvent
  69. ===============
  70. */
  71. static void UI_CinematicsMenu_BackEvent( void *ptr, int event ) {
  72. if( event != QM_ACTIVATED ) {
  73. return;
  74. }
  75. UI_PopMenu();
  76. }
  77. /*
  78. ===============
  79. UI_CinematicsMenu_Event
  80. ===============
  81. */
  82. static void UI_CinematicsMenu_Event( void *ptr, int event ) {
  83. int n;
  84. if (event != QM_ACTIVATED)
  85. return;
  86. n = ((menucommon_s*)ptr)->id - ID_CIN_IDLOGO;
  87. trap_Cvar_Set( "nextmap", va( "ui_cinematics %i", n ) );
  88. if( uis.demoversion && ((menucommon_s*)ptr)->id == ID_CIN_END ) {
  89. trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect; cinematic demoEnd.RoQ 1\n" );
  90. }
  91. else {
  92. trap_Cmd_ExecuteText( EXEC_APPEND, va( "disconnect; cinematic %s.RoQ\n", cinematics[n] ) );
  93. }
  94. }
  95. /*
  96. ===============
  97. UI_CinematicsMenu_Init
  98. ===============
  99. */
  100. static void UI_CinematicsMenu_Init( void ) {
  101. int y;
  102. UI_CinematicsMenu_Cache();
  103. memset( &cinematicsMenuInfo, 0, sizeof(cinematicsMenuInfo) );
  104. cinematicsMenuInfo.menu.fullscreen = qtrue;
  105. cinematicsMenuInfo.banner.generic.type = MTYPE_BTEXT;
  106. cinematicsMenuInfo.banner.generic.x = 320;
  107. cinematicsMenuInfo.banner.generic.y = 16;
  108. cinematicsMenuInfo.banner.string = "CINEMATICS";
  109. cinematicsMenuInfo.banner.color = color_white;
  110. cinematicsMenuInfo.banner.style = UI_CENTER;
  111. cinematicsMenuInfo.framel.generic.type = MTYPE_BITMAP;
  112. cinematicsMenuInfo.framel.generic.name = ART_FRAMEL;
  113. cinematicsMenuInfo.framel.generic.flags = QMF_INACTIVE;
  114. cinematicsMenuInfo.framel.generic.x = 0;
  115. cinematicsMenuInfo.framel.generic.y = 78;
  116. cinematicsMenuInfo.framel.width = 256;
  117. cinematicsMenuInfo.framel.height = 329;
  118. cinematicsMenuInfo.framer.generic.type = MTYPE_BITMAP;
  119. cinematicsMenuInfo.framer.generic.name = ART_FRAMER;
  120. cinematicsMenuInfo.framer.generic.flags = QMF_INACTIVE;
  121. cinematicsMenuInfo.framer.generic.x = 376;
  122. cinematicsMenuInfo.framer.generic.y = 76;
  123. cinematicsMenuInfo.framer.width = 256;
  124. cinematicsMenuInfo.framer.height = 334;
  125. y = 100;
  126. cinematicsMenuInfo.cin_idlogo.generic.type = MTYPE_PTEXT;
  127. cinematicsMenuInfo.cin_idlogo.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  128. cinematicsMenuInfo.cin_idlogo.generic.x = 320;
  129. cinematicsMenuInfo.cin_idlogo.generic.y = y;
  130. cinematicsMenuInfo.cin_idlogo.generic.id = ID_CIN_IDLOGO;
  131. cinematicsMenuInfo.cin_idlogo.generic.callback = UI_CinematicsMenu_Event;
  132. cinematicsMenuInfo.cin_idlogo.string = "ID LOGO";
  133. cinematicsMenuInfo.cin_idlogo.color = color_red;
  134. cinematicsMenuInfo.cin_idlogo.style = UI_CENTER;
  135. y += VERTICAL_SPACING;
  136. cinematicsMenuInfo.cin_intro.generic.type = MTYPE_PTEXT;
  137. cinematicsMenuInfo.cin_intro.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  138. cinematicsMenuInfo.cin_intro.generic.x = 320;
  139. cinematicsMenuInfo.cin_intro.generic.y = y;
  140. cinematicsMenuInfo.cin_intro.generic.id = ID_CIN_INTRO;
  141. cinematicsMenuInfo.cin_intro.generic.callback = UI_CinematicsMenu_Event;
  142. cinematicsMenuInfo.cin_intro.string = "INTRO";
  143. cinematicsMenuInfo.cin_intro.color = color_red;
  144. cinematicsMenuInfo.cin_intro.style = UI_CENTER;
  145. if( uis.demoversion ) {
  146. cinematicsMenuInfo.cin_intro.generic.flags |= QMF_GRAYED;
  147. }
  148. y += VERTICAL_SPACING;
  149. cinematicsMenuInfo.cin_tier1.generic.type = MTYPE_PTEXT;
  150. cinematicsMenuInfo.cin_tier1.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  151. cinematicsMenuInfo.cin_tier1.generic.x = 320;
  152. cinematicsMenuInfo.cin_tier1.generic.y = y;
  153. cinematicsMenuInfo.cin_tier1.generic.id = ID_CIN_TIER1;
  154. cinematicsMenuInfo.cin_tier1.generic.callback = UI_CinematicsMenu_Event;
  155. cinematicsMenuInfo.cin_tier1.string = "Tier 1";
  156. cinematicsMenuInfo.cin_tier1.color = color_red;
  157. cinematicsMenuInfo.cin_tier1.style = UI_CENTER;
  158. if( !UI_CanShowTierVideo( 1 ) ) {
  159. cinematicsMenuInfo.cin_tier1.generic.flags |= QMF_GRAYED;
  160. }
  161. y += VERTICAL_SPACING;
  162. cinematicsMenuInfo.cin_tier2.generic.type = MTYPE_PTEXT;
  163. cinematicsMenuInfo.cin_tier2.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  164. cinematicsMenuInfo.cin_tier2.generic.x = 320;
  165. cinematicsMenuInfo.cin_tier2.generic.y = y;
  166. cinematicsMenuInfo.cin_tier2.generic.id = ID_CIN_TIER2;
  167. cinematicsMenuInfo.cin_tier2.generic.callback = UI_CinematicsMenu_Event;
  168. cinematicsMenuInfo.cin_tier2.string = "Tier 2";
  169. cinematicsMenuInfo.cin_tier2.color = color_red;
  170. cinematicsMenuInfo.cin_tier2.style = UI_CENTER;
  171. if( !UI_CanShowTierVideo( 2 ) ) {
  172. cinematicsMenuInfo.cin_tier2.generic.flags |= QMF_GRAYED;
  173. }
  174. y += VERTICAL_SPACING;
  175. cinematicsMenuInfo.cin_tier3.generic.type = MTYPE_PTEXT;
  176. cinematicsMenuInfo.cin_tier3.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  177. cinematicsMenuInfo.cin_tier3.generic.x = 320;
  178. cinematicsMenuInfo.cin_tier3.generic.y = y;
  179. cinematicsMenuInfo.cin_tier3.generic.id = ID_CIN_TIER3;
  180. cinematicsMenuInfo.cin_tier3.generic.callback = UI_CinematicsMenu_Event;
  181. cinematicsMenuInfo.cin_tier3.string = "Tier 3";
  182. cinematicsMenuInfo.cin_tier3.color = color_red;
  183. cinematicsMenuInfo.cin_tier3.style = UI_CENTER;
  184. if( !UI_CanShowTierVideo( 3 ) ) {
  185. cinematicsMenuInfo.cin_tier3.generic.flags |= QMF_GRAYED;
  186. }
  187. y += VERTICAL_SPACING;
  188. cinematicsMenuInfo.cin_tier4.generic.type = MTYPE_PTEXT;
  189. cinematicsMenuInfo.cin_tier4.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  190. cinematicsMenuInfo.cin_tier4.generic.x = 320;
  191. cinematicsMenuInfo.cin_tier4.generic.y = y;
  192. cinematicsMenuInfo.cin_tier4.generic.id = ID_CIN_TIER4;
  193. cinematicsMenuInfo.cin_tier4.generic.callback = UI_CinematicsMenu_Event;
  194. cinematicsMenuInfo.cin_tier4.string = "Tier 4";
  195. cinematicsMenuInfo.cin_tier4.color = color_red;
  196. cinematicsMenuInfo.cin_tier4.style = UI_CENTER;
  197. if( !UI_CanShowTierVideo( 4 ) ) {
  198. cinematicsMenuInfo.cin_tier4.generic.flags |= QMF_GRAYED;
  199. }
  200. y += VERTICAL_SPACING;
  201. cinematicsMenuInfo.cin_tier5.generic.type = MTYPE_PTEXT;
  202. cinematicsMenuInfo.cin_tier5.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  203. cinematicsMenuInfo.cin_tier5.generic.x = 320;
  204. cinematicsMenuInfo.cin_tier5.generic.y = y;
  205. cinematicsMenuInfo.cin_tier5.generic.id = ID_CIN_TIER5;
  206. cinematicsMenuInfo.cin_tier5.generic.callback = UI_CinematicsMenu_Event;
  207. cinematicsMenuInfo.cin_tier5.string = "Tier 5";
  208. cinematicsMenuInfo.cin_tier5.color = color_red;
  209. cinematicsMenuInfo.cin_tier5.style = UI_CENTER;
  210. if( !UI_CanShowTierVideo( 5 ) ) {
  211. cinematicsMenuInfo.cin_tier5.generic.flags |= QMF_GRAYED;
  212. }
  213. y += VERTICAL_SPACING;
  214. cinematicsMenuInfo.cin_tier6.generic.type = MTYPE_PTEXT;
  215. cinematicsMenuInfo.cin_tier6.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  216. cinematicsMenuInfo.cin_tier6.generic.x = 320;
  217. cinematicsMenuInfo.cin_tier6.generic.y = y;
  218. cinematicsMenuInfo.cin_tier6.generic.id = ID_CIN_TIER6;
  219. cinematicsMenuInfo.cin_tier6.generic.callback = UI_CinematicsMenu_Event;
  220. cinematicsMenuInfo.cin_tier6.string = "Tier 6";
  221. cinematicsMenuInfo.cin_tier6.color = color_red;
  222. cinematicsMenuInfo.cin_tier6.style = UI_CENTER;
  223. if( !UI_CanShowTierVideo( 6 ) ) {
  224. cinematicsMenuInfo.cin_tier6.generic.flags |= QMF_GRAYED;
  225. }
  226. y += VERTICAL_SPACING;
  227. cinematicsMenuInfo.cin_tier7.generic.type = MTYPE_PTEXT;
  228. cinematicsMenuInfo.cin_tier7.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  229. cinematicsMenuInfo.cin_tier7.generic.x = 320;
  230. cinematicsMenuInfo.cin_tier7.generic.y = y;
  231. cinematicsMenuInfo.cin_tier7.generic.id = ID_CIN_TIER7;
  232. cinematicsMenuInfo.cin_tier7.generic.callback = UI_CinematicsMenu_Event;
  233. cinematicsMenuInfo.cin_tier7.string = "Tier 7";
  234. cinematicsMenuInfo.cin_tier7.color = color_red;
  235. cinematicsMenuInfo.cin_tier7.style = UI_CENTER;
  236. if( !UI_CanShowTierVideo( 7 ) ) {
  237. cinematicsMenuInfo.cin_tier7.generic.flags |= QMF_GRAYED;
  238. }
  239. y += VERTICAL_SPACING;
  240. cinematicsMenuInfo.cin_end.generic.type = MTYPE_PTEXT;
  241. cinematicsMenuInfo.cin_end.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  242. cinematicsMenuInfo.cin_end.generic.x = 320;
  243. cinematicsMenuInfo.cin_end.generic.y = y;
  244. cinematicsMenuInfo.cin_end.generic.id = ID_CIN_END;
  245. cinematicsMenuInfo.cin_end.generic.callback = UI_CinematicsMenu_Event;
  246. cinematicsMenuInfo.cin_end.string = "END";
  247. cinematicsMenuInfo.cin_end.color = color_red;
  248. cinematicsMenuInfo.cin_end.style = UI_CENTER;
  249. if( !UI_CanShowTierVideo( 8 ) ) {
  250. cinematicsMenuInfo.cin_end.generic.flags |= QMF_GRAYED;
  251. }
  252. cinematicsMenuInfo.back.generic.type = MTYPE_BITMAP;
  253. cinematicsMenuInfo.back.generic.name = ART_BACK0;
  254. cinematicsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
  255. cinematicsMenuInfo.back.generic.id = ID_BACK;
  256. cinematicsMenuInfo.back.generic.callback = UI_CinematicsMenu_BackEvent;
  257. cinematicsMenuInfo.back.generic.x = 0;
  258. cinematicsMenuInfo.back.generic.y = 480-64;
  259. cinematicsMenuInfo.back.width = 128;
  260. cinematicsMenuInfo.back.height = 64;
  261. cinematicsMenuInfo.back.focuspic = ART_BACK1;
  262. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.banner );
  263. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framel );
  264. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framer );
  265. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_idlogo );
  266. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_intro );
  267. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier1 );
  268. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier2 );
  269. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier3 );
  270. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier4 );
  271. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier5 );
  272. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier6 );
  273. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier7 );
  274. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_end );
  275. Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.back );
  276. }
  277. /*
  278. =================
  279. UI_CinematicsMenu_Cache
  280. =================
  281. */
  282. void UI_CinematicsMenu_Cache( void ) {
  283. trap_R_RegisterShaderNoMip( ART_BACK0 );
  284. trap_R_RegisterShaderNoMip( ART_BACK1 );
  285. trap_R_RegisterShaderNoMip( ART_FRAMEL );
  286. trap_R_RegisterShaderNoMip( ART_FRAMER );
  287. }
  288. /*
  289. ===============
  290. UI_CinematicsMenu
  291. ===============
  292. */
  293. void UI_CinematicsMenu( void ) {
  294. UI_CinematicsMenu_Init();
  295. UI_PushMenu( &cinematicsMenuInfo.menu );
  296. }
  297. /*
  298. ===============
  299. UI_CinematicsMenu_f
  300. ===============
  301. */
  302. void UI_CinematicsMenu_f( void ) {
  303. int n;
  304. n = atoi( UI_Argv( 1 ) );
  305. UI_CinematicsMenu();
  306. Menu_SetCursorToItem( &cinematicsMenuInfo.menu, cinematicsMenuInfo.menu.items[n + 3] );
  307. }