MAPSEL.CPP 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/MAPSEL.CPP 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : MAPSEL.CPP *
  22. * *
  23. * Programmer : Barry W. Green *
  24. * *
  25. * Start Date : April 17, 1995 *
  26. * *
  27. * Last Update : April 27, 1995 [BWG] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * Bit_It_In -- Pixel fade graphic copy. *
  32. * Map_Selection -- Starts the whole process of selecting next map to go to *
  33. * Print_Statistics -- Prints statistics on country selected *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "function.h"
  36. void Cycle_Call_Back_Delay(int time, PaletteClass &pal);
  37. extern int ControlQ;
  38. int Mouse_Over_Spot(int house, int scenario);
  39. void Set_Mouse(MouseType shape, int &start, int &count, int &delay, int &xspot, int &yspot);
  40. //VG for ant mission progression
  41. const char* antmission[] = {NULL, "SCA01EA.INI", "SCA02EA.INI", "SCA03EA.INI", "SCA04EA.INI"};
  42. struct point {
  43. int x;
  44. int y;
  45. } const MapCoords[2][14][3] = {
  46. {
  47. {{185,123},{ -1, -1},{ -1, -1}},
  48. {{173,112},{ -1, -1},{ -1, -1}},
  49. {{196,100},{200,112},{ -1, -1}},
  50. {{175,113},{ -1, -1},{ -1, -1}},
  51. {{187, 91},{202, 93},{206,105}},
  52. {{207,161},{212,172},{ -1, -1}},
  53. {{172, 92},{ -1, -1},{ -1, -1}},
  54. {{132,119},{146,125},{ -1, -1}},
  55. {{199, 73},{205, 86},{ -1, -1}},
  56. {{236,114},{ -1, -1},{ -1, -1}},
  57. {{219, 64},{225, 76},{ -1, -1}},
  58. {{256, 69},{ -1, -1},{ -1, -1}},
  59. {{262, 77},{ -1, -1},{ -1, -1}},
  60. {{249, 97},{ -1, -1},{ -1, -1}}
  61. },
  62. // Soviet coords
  63. {
  64. {{178,105},{ -1, -1},{ -1, -1}},
  65. {{163,101},{163,113},{ -1, -1}},
  66. {{160, 89},{ -1, -1},{ -1, -1}},
  67. {{142,101},{142,117},{ -1, -1}},
  68. {{212,163},{ -1, -1},{ -1, -1}},
  69. {{155,133},{171,144},{ -1, -1}},
  70. {{216,103},{ -1, -1},{ -1, -1}},
  71. {{132,145},{154,154},{ -1, -1}},
  72. {{122,117},{ -1, -1},{ -1, -1}},
  73. {{117,130},{ -1, -1},{ -1, -1}},
  74. {{ 99,107},{109,146},{ -1, -1}},
  75. {{134,125},{ -1, -1},{ -1, -1}},
  76. {{ 32,156},{ 46,171},{ -1, -1}},
  77. {{108, 97},{ -1, -1},{ -1, -1}}
  78. }
  79. };
  80. #ifndef WIN32
  81. extern short StreamLowImpact;
  82. #endif //WIN32
  83. /***********************************************************************************************
  84. * Map_Selection -- Starts the whole process of selecting next map to go to *
  85. * *
  86. * *
  87. * INPUT: *
  88. * *
  89. * OUTPUT: none *
  90. * *
  91. * WARNINGS: none *
  92. * *
  93. * HISTORY: *
  94. * 07/18/1996 BWG : Created. *
  95. *=============================================================================================*/
  96. extern int CopyType;
  97. #ifndef WIN32
  98. extern short StreamLowImpact;
  99. #endif
  100. char const * Map_Selection(void)
  101. {
  102. return NULL;
  103. #if (0)//PG
  104. static char scenarioname[_MAX_FNAME+_MAX_EXT];
  105. #ifdef FIXIT_ANTS
  106. if (AntsEnabled) {
  107. strcpy(scenarioname, Scen.ScenarioName);
  108. char buf[10];
  109. sprintf(buf, "%02d", Scen.Scenario+1);
  110. memcpy(&scenarioname[3], buf, 2);
  111. return(scenarioname);
  112. }
  113. #endif
  114. char _filename[]="MSAA.WSA";
  115. int house = (PlayerPtr->Class->House == HOUSE_USSR || PlayerPtr->Class->House == HOUSE_UKRAINE);
  116. _filename[2] = house ? 'S' : 'A';
  117. _filename[3] = Scen.Scenario + 'A';
  118. PaletteClass mappalette;
  119. int scenario = Scen.Scenario;
  120. int selection;
  121. static CDTimerClass<SystemTimerClass> timer;
  122. int start = 0;
  123. int count = 0;
  124. int delay = 0;
  125. int xspot = 0;
  126. int yspot = 0;
  127. void const * appear1 = MFCD::Retrieve("MAPWIPE2.AUD");
  128. void const * bleep11 = MFCD::Retrieve("BLEEP11.AUD");
  129. void const * country4 = MFCD::Retrieve("MAPWIPE5.AUD");
  130. void const * toney7 = MFCD::Retrieve("TONEY7.AUD");
  131. void const * bleep17 = MFCD::Retrieve("BLEEP17.AUD");
  132. void const * scold1 = MFCD::Retrieve("TONEY4.AUD");
  133. void const * country1 = MFCD::Retrieve("TONEY10.AUD");
  134. #ifdef WIN32
  135. GraphicBufferClass *pseudoseenbuff = new GraphicBufferClass(320, 200, (void*)NULL);
  136. #endif
  137. // fixed oldvolume = Options.ScoreVolume;
  138. // Options.Set_Score_Volume(fixed(4, 10));
  139. Theme.Queue_Song(THEME_MAP);
  140. void *anim = Open_Animation(_filename, NULL, 0L, (WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE), mappalette);
  141. Keyboard->Clear();
  142. SeenPage.Clear();
  143. mappalette.Set(FADE_PALETTE_FAST, Call_Back);
  144. #ifdef WIN32
  145. pseudoseenbuff->Clear();
  146. Animate_Frame(anim, *pseudoseenbuff, 1);
  147. for(int x=0; x<256; x++) memset(&PaletteInterpolationTable[x][0],x,256);
  148. CopyType = 1;
  149. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , 0);
  150. #else
  151. HidPage.Clear();
  152. Animate_Frame(anim, HidPage, 1);
  153. HidPage.Blit(SeenPage);
  154. #endif
  155. int frame = 1;
  156. StreamLowImpact = true;
  157. #ifdef WIN32
  158. Play_Sample(appear1, 255, Options.Normalize_Volume(170));
  159. #else
  160. Play_Sample(appear1, 255, Options.Normalize_Volume(55));
  161. #endif
  162. while (frame < Get_Animation_Frame_Count(anim)) {
  163. #ifdef WIN32
  164. CopyType = 1;
  165. Animate_Frame(anim, *pseudoseenbuff, frame++);
  166. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , NULL);
  167. CopyType = 0;
  168. #else
  169. Animate_Frame(anim, SeenPage, frame++);
  170. #endif
  171. Call_Back_Delay(2);
  172. switch(frame) {
  173. case 16:
  174. #ifdef WIN32
  175. Play_Sample(bleep11, 255, Options.Normalize_Volume(170));
  176. #else
  177. Play_Sample(bleep11, 255, Options.Normalize_Volume(55));
  178. #endif
  179. break;
  180. case 30:
  181. #ifdef WIN32
  182. Play_Sample(country4, 255, Options.Normalize_Volume(170));
  183. #else
  184. Play_Sample(country4, 255, Options.Normalize_Volume(55));
  185. #endif
  186. break;
  187. case 51:
  188. #ifdef WIN32
  189. Play_Sample(toney7, 255, Options.Normalize_Volume(170));
  190. #else
  191. Play_Sample(toney7, 255, Options.Normalize_Volume(55));
  192. #endif
  193. break;
  194. case 61:
  195. #ifdef WIN32
  196. Play_Sample(bleep17, 255, Options.Normalize_Volume(170));
  197. #else
  198. Play_Sample(bleep17, 255, Options.Normalize_Volume(55));
  199. #endif
  200. break;
  201. }
  202. }
  203. StreamLowImpact = false;
  204. Call_Back();
  205. Close_Animation(anim);
  206. Show_Mouse();
  207. Keyboard->Clear();
  208. bool done = 0;
  209. MouseType shape = MOUSE_NORMAL;
  210. while (!done) {
  211. #ifdef WIN32
  212. /*
  213. ** If we have just received input focus again after running in the background then
  214. ** we need to redraw.
  215. */
  216. if (AllSurfaces.SurfacesRestored) {
  217. AllSurfaces.SurfacesRestored=FALSE;
  218. CopyType = 1;
  219. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , NULL);
  220. CopyType = 0;
  221. }
  222. #endif
  223. Cycle_Call_Back_Delay(1, mappalette);
  224. int choice = Mouse_Over_Spot(house, scenario);
  225. if (choice == -1) {
  226. shape = MOUSE_NORMAL;
  227. } else {
  228. shape = MOUSE_CAN_ATTACK;
  229. }
  230. Set_Mouse(shape, start, count, delay, xspot, yspot);
  231. if (timer == 0) {
  232. frame++;
  233. frame %= count;
  234. timer = delay;
  235. Set_Mouse_Cursor(xspot, yspot, Extract_Shape(MouseClass::MouseShapes, start + frame));
  236. }
  237. if (Keyboard->Check()) {
  238. if ((Keyboard->Get() & 0x10FF) == KN_LMOUSE) {
  239. if (choice != -1) {
  240. done = 1;
  241. selection = choice;
  242. #ifdef WIN32
  243. Play_Sample(country1, 255, Options.Normalize_Volume(170));
  244. #else
  245. Play_Sample(country1, 255, Options.Normalize_Volume(50));
  246. #endif
  247. } else {
  248. #ifdef WIN32
  249. Play_Sample(scold1, 255, Options.Normalize_Volume(170));
  250. #else
  251. Play_Sample(scold1, 255, Options.Normalize_Volume(50));
  252. #endif
  253. }
  254. }
  255. }
  256. }
  257. Hide_Mouse();
  258. /*
  259. ** Restore the mouse to normal shape before leaving this routine.
  260. */
  261. Set_Mouse(MOUSE_NORMAL, start, count, delay, xspot, yspot);
  262. Set_Mouse_Cursor(xspot, yspot, Extract_Shape(MouseClass::MouseShapes, start));
  263. Keyboard->Clear();
  264. // BlackPalette.Set(FADE_PALETTE_SLOW, Call_Back);
  265. // SeenPage.Clear();
  266. Fancy_Text_Print(TXT_STAND_BY, 160 * RESFACTOR, 190 * RESFACTOR, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER|TPF_6PT_GRAD|TPF_DROPSHADOW);
  267. /*
  268. ** Create the new scenario filename from the selection. The filename is
  269. ** derived from the previous filename but it has the scenario number
  270. ** incremented and the chosen variation set.
  271. */
  272. //V.G. added so Ant Missions would progress
  273. if(Scen.ScenarioName[2] == 'A'){
  274. int antnum = Scen.Scenario++;
  275. if(antnum > 4) antnum = 1;
  276. strcpy(scenarioname, antmission[antnum]);
  277. }
  278. else{
  279. strcpy(scenarioname, Scen.ScenarioName);
  280. char buf[10];
  281. sprintf(buf, "%02d", Scen.Scenario+1);
  282. memcpy(&scenarioname[3], buf, 2);
  283. scenarioname[6] = 'A' + selection;
  284. }
  285. Theme.Fade_Out();
  286. // Options.Set_Score_Volume(oldvolume);
  287. // Scen.ScenVar = (ScenarioVarType)selection;
  288. //Mono_Printf("Chose variant %d \n", selection);
  289. return(scenarioname);
  290. #endif
  291. }
  292. int Mouse_Over_Spot(int house, int scenario)
  293. {
  294. int retval = -1;
  295. for (int selection = 0; selection < 3 && MapCoords[house][scenario][selection].x != -1; selection++) {
  296. int mousex = Get_Mouse_X() / RESFACTOR;
  297. int mousey = Get_Mouse_Y() / RESFACTOR;
  298. if (mousex >= MapCoords[house][scenario][selection].x &&
  299. mousey >= MapCoords[house][scenario][selection].y &&
  300. mousex <= MapCoords[house][scenario][selection].x+11 &&
  301. mousey <= MapCoords[house][scenario][selection].y+9) {
  302. retval = selection;
  303. break;
  304. }
  305. }
  306. return(retval);
  307. }
  308. void Cycle_Call_Back_Delay(int time, PaletteClass &pal)
  309. {
  310. static CDTimerClass<SystemTimerClass> _ftimer;
  311. static bool _up = false;
  312. static int val = 255;
  313. while(time--) {
  314. /*
  315. ** Process the fading white color.
  316. */
  317. if (!_ftimer) {
  318. _ftimer = TIMER_SECOND/6;
  319. #define STEP_RATE 20
  320. if (_up) {
  321. val += STEP_RATE;
  322. if (val > 150) {
  323. val = 150;
  324. _up = false;
  325. }
  326. } else {
  327. val -= STEP_RATE;
  328. if (val < 0x20) {
  329. val = 0x20;
  330. _up = true;
  331. }
  332. }
  333. /*
  334. ** Set the pulse color as the proportional value between white and the
  335. ** minimum value for pulsing.
  336. */
  337. pal[254] = GamePalette[WHITE];
  338. pal[254].Adjust(val, BlackColor);
  339. pal.Set();
  340. }
  341. Call_Back_Delay(1);
  342. }
  343. }
  344. void Set_Mouse(MouseType shape, int &start, int &count, int &delay, int &xspot, int &yspot)
  345. {
  346. switch(shape) {
  347. case MOUSE_NORMAL:
  348. start = 0;
  349. count = 1;
  350. delay = 0;
  351. xspot = 0;
  352. yspot = 0;
  353. break;
  354. default:
  355. start = 21;
  356. count = 8;
  357. delay = 4;
  358. xspot = 14;
  359. yspot = 11;
  360. break;
  361. }
  362. }