MAPEDDLG.CPP 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705
  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/MAPEDDLG.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 : MAPEDDLG.CPP *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : November 18, 1994 *
  26. * *
  27. * Last Update : September 4, 1996 [JLB] *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * Map Editor dialogs & main menu options *
  31. *-------------------------------------------------------------------------*
  32. * Functions: *
  33. * MapEditClass::Handle_Triggers -- processes the trigger dialogs *
  34. * MapEditClass::Load_Scenario -- loads a scenario INI file *
  35. * MapEditClass::New_Scenario -- creates a new scenario *
  36. * MapEditClass::Pick_Scenario -- dialog for choosing scenario *
  37. * MapEditClass::Save_Scenario -- saves current scenario to an INI file *
  38. * MapEditClass::Scenario_Dialog -- scenario global parameters dialog *
  39. * MapEditClass::Select_Trigger -- lets user select a trigger *
  40. * MapEditClass::Size_Map -- lets user set size & location of map *
  41. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  42. #include "function.h"
  43. #ifdef SCENARIO_EDITOR
  44. /***************************************************************************
  45. * MapEditClass::New_Scenario -- creates a new scenario *
  46. * *
  47. * - Prompts user for scenario data (house, scenario #); sets globals *
  48. * PlayerPtr (for house) & Scenario (for scenario #) *
  49. * - Prompts user for map size *
  50. * - Initializes the scenario by calling Clear_Scenario(), which calls *
  51. * everybody's Init() routine *
  52. * *
  53. * INPUT: *
  54. * none. *
  55. * *
  56. * OUTPUT: *
  57. * 0 = new scenario created, -1 = not *
  58. * *
  59. * WARNINGS: *
  60. * none. *
  61. * *
  62. * HISTORY: *
  63. * 10/21/1994 BR : Created. *
  64. *=========================================================================*/
  65. int MapEditClass::New_Scenario(void)
  66. {
  67. int scen_num;
  68. ScenarioPlayerType player;
  69. ScenarioDirType dir;
  70. ScenarioVarType var;
  71. Disect_Scenario_Name(Scen.ScenarioName, scen_num, player, dir, var);
  72. int rc;
  73. HousesType house;
  74. /*
  75. ** Force the house save value to match the player house.
  76. */
  77. if (PlayerPtr) {
  78. switch (PlayerPtr->Class->House) {
  79. case HOUSE_SPAIN:
  80. player = SCEN_PLAYER_SPAIN;
  81. break;
  82. case HOUSE_GREECE:
  83. player = SCEN_PLAYER_GREECE;
  84. break;
  85. default:
  86. case HOUSE_USSR:
  87. player = SCEN_PLAYER_USSR;
  88. break;
  89. }
  90. }
  91. /*
  92. ** Prompt for scenario info
  93. */
  94. rc = Pick_Scenario("New Scenario", scen_num, player, dir, var);
  95. if (rc != 0) {
  96. return(-1);
  97. }
  98. ScenarioInit++;
  99. /*
  100. ** Blow away everything
  101. */
  102. Clear_Scenario();
  103. /*
  104. ** Set parameters
  105. */
  106. // Scen.Scenario = scen_num;
  107. // Scen.ScenPlayer = player;
  108. // Scen.ScenDir = dir;
  109. // Scen.ScenVar = var;
  110. Scen.Set_Scenario_Name(scen_num, player, dir, var);
  111. /*
  112. ** Create houses
  113. */
  114. for (house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
  115. new HouseClass(house);
  116. }
  117. switch (player) {
  118. case SCEN_PLAYER_MPLAYER:
  119. PlayerPtr = HouseClass::As_Pointer(HOUSE_MULTI1);
  120. PlayerPtr->IsHuman = true;
  121. LastHouse = HOUSE_MULTI1;
  122. break;
  123. case SCEN_PLAYER_USSR:
  124. PlayerPtr = HouseClass::As_Pointer(HOUSE_USSR);
  125. PlayerPtr->IsHuman = true;
  126. Base.House = HOUSE_SPAIN;
  127. LastHouse = HOUSE_GOOD;
  128. break;
  129. case SCEN_PLAYER_SPAIN:
  130. PlayerPtr = HouseClass::As_Pointer(HOUSE_SPAIN);
  131. PlayerPtr->IsHuman = true;
  132. Base.House = HOUSE_USSR;
  133. LastHouse = HOUSE_GOOD;
  134. break;
  135. case SCEN_PLAYER_GREECE:
  136. PlayerPtr = HouseClass::As_Pointer(HOUSE_GREECE);
  137. PlayerPtr->IsHuman = true;
  138. Base.House = HOUSE_USSR;
  139. LastHouse = HOUSE_GOOD;
  140. break;
  141. }
  142. /*
  143. ** Init the entire map
  144. */
  145. // Init_Clear();
  146. Fill_In_Data();
  147. /*
  148. ** Prompt for map size
  149. */
  150. Size_Map(-1, -1, 30, 30);
  151. /*
  152. ** Set the Home & Reinforcement Cells to the center of the map
  153. */
  154. Scen.Waypoint[WAYPT_REINF] = XY_Cell(MapCellX + MapCellWidth / 2, MapCellY + MapCellHeight / 2);
  155. Scen.Waypoint[WAYPT_HOME] = XY_Cell(MapCellX + MapCellWidth / 2, MapCellY + MapCellHeight / 2);
  156. (*this)[TacticalCoord].IsWaypoint = 1;
  157. Flag_Cell(Coord_Cell(TacticalCoord));
  158. Set_Tactical_Position(Cell_Coord(Scen.Waypoint[WAYPT_HOME] - (MAP_CELL_W * 4 * RESFACTOR) - (5 * RESFACTOR)));
  159. ScenarioInit--;
  160. return(0);
  161. }
  162. /***************************************************************************
  163. * MapEditClass::Load_Scenario -- loads a scenario INI file *
  164. * *
  165. * - Prompts user for scenario data (house, scenario #); sets globals *
  166. * PlayerPtr (for house) & Scenario (for scenario #) *
  167. * - Loads the INI file for that scenario *
  168. * *
  169. * INPUT: *
  170. * none. *
  171. * *
  172. * OUTPUT: *
  173. * 0. *
  174. * *
  175. * WARNINGS: *
  176. * none. *
  177. * *
  178. * HISTORY: *
  179. * 10/21/1994 BR : Created. *
  180. *=========================================================================*/
  181. int MapEditClass::Load_Scenario(void)
  182. {
  183. int scen_num;
  184. ScenarioPlayerType player;
  185. ScenarioDirType dir;
  186. ScenarioVarType var;
  187. Disect_Scenario_Name(Scen.ScenarioName, scen_num, player, dir, var);
  188. int rc;
  189. NodeNameType * who; // node to add to Players
  190. /*
  191. ** Prompt for scenario info
  192. */
  193. rc = Pick_Scenario("Load Scenario", scen_num, player, dir, var);
  194. if (rc != 0) {
  195. return(-1);
  196. }
  197. /*
  198. ** Set parameters
  199. */
  200. // Scen.Scenario = scen_num;
  201. // Scen.ScenPlayer = player;
  202. // Scen.ScenDir = dir;
  203. // Scen.ScenVar = var;
  204. Scen.Set_Scenario_Name(scen_num, player, dir, var);
  205. /*
  206. ** Read_Scenario_Ini() must be able to set PlayerPtr to the right house:
  207. ** - Reading the INI will create the house objects
  208. ** - PlayerPtr must be set before any Techno objects are created
  209. ** - For GDI or NOD scenarios, PlayerPtr is set by reading the INI;
  210. ** but for multiplayer, it's set via the Players vector; so, here we have
  211. ** to set various multiplayer variables to fool the Assign_Houses() routine
  212. ** into working properly.
  213. */
  214. if (player == SCEN_PLAYER_MPLAYER) {
  215. Clear_Vector(&Session.Players);
  216. who = new NodeNameType;
  217. strcpy(who->Name, Session.Handle);
  218. who->Player.House = Session.House;
  219. who->Player.Color = Session.ColorIdx;
  220. Session.Players.Add (who);
  221. Session.NumPlayers = 1;
  222. LastHouse = HOUSE_MULTI1;
  223. } else {
  224. #ifdef NEVER
  225. if (ScenPlayer==SCEN_PLAYER_JP) {
  226. PlayerPtr = HouseClass::As_Pointer(HOUSE_MULTI4);
  227. PlayerPtr->IsHuman = true;
  228. Base.House = HOUSE_MULTI4;
  229. } else {
  230. #endif
  231. LastHouse = HOUSE_GOOD;
  232. }
  233. /*
  234. ** Blow away everything
  235. */
  236. Clear_Scenario();
  237. /*
  238. ** Read the INI
  239. */
  240. if (Read_Scenario_INI(Scen.ScenarioName) == 0) {
  241. if(Scen.Scenario < 20 && Scen.ScenarioName[2] == 'G'){
  242. WWMessageBox().Process("Please insert Red Alert CD1");
  243. }else if(Scen.Scenario < 20 && Scen.ScenarioName[2] == 'U')
  244. WWMessageBox().Process("Please insert Red Alert CD2");
  245. else
  246. WWMessageBox().Process("Unable to read scenario!");
  247. HidPage.Clear();
  248. Flag_To_Redraw(true);
  249. Render();
  250. } else {
  251. Fill_In_Data();
  252. GamePalette.Set();
  253. // Set_Palette(GamePalette);
  254. }
  255. return(0);
  256. }
  257. /***************************************************************************
  258. * MapEditClass::Save_Scenario -- saves current scenario to an INI file *
  259. * *
  260. * - Prompts user for scenario data (house, scenario #); sets globals *
  261. * PlayerPtr (for house) & Scenario (for scenario #) *
  262. * - Saves the INI file for this scenario *
  263. * *
  264. * INPUT: *
  265. * none. *
  266. * *
  267. * OUTPUT: *
  268. * 0 = OK, -1 = error/cancel *
  269. * *
  270. * WARNINGS: *
  271. * none. *
  272. * *
  273. * HISTORY: *
  274. * 10/21/1994 BR : Created. *
  275. *=========================================================================*/
  276. int MapEditClass::Save_Scenario(void)
  277. {
  278. int scen_num;
  279. ScenarioPlayerType player;
  280. ScenarioDirType dir;
  281. ScenarioVarType var;
  282. Disect_Scenario_Name(Scen.ScenarioName, scen_num, player, dir, var);
  283. int rc;
  284. // FILE * fp;
  285. // char fname[13];
  286. /*
  287. ** Prompt for scenario info
  288. */
  289. rc = Pick_Scenario("Save Scenario", scen_num, player, dir, var);
  290. if (rc != 0) {
  291. return(-1);
  292. }
  293. /*
  294. ** Warning if scenario already exists
  295. */
  296. // Scen.Set_Scenario_Name(scen_num, player, dir, var);
  297. // fp = fopen(fname, "rb");
  298. // if (fp) {
  299. // fclose(fp);
  300. // rc = WWMessageBox().Process("File exists. Replace?", TXT_YES, TXT_NO);
  301. // HidPage.Clear();
  302. // Flag_To_Redraw(true);
  303. // Render();
  304. // if (rc==1) {
  305. // return(-1);
  306. // }
  307. // }
  308. /*
  309. ** Set parameters
  310. */
  311. // Scen.Scenario = scen_num;
  312. // Scen.ScenPlayer = player;
  313. // Scen.ScenDir = dir;
  314. // Scen.ScenVar = var;
  315. Scen.Set_Scenario_Name(scen_num, player, dir, var);
  316. /*
  317. ** Player may have changed from GDI to NOD, so change playerptr accordingly
  318. */
  319. switch (player) {
  320. case SCEN_PLAYER_USSR:
  321. PlayerPtr = HouseClass::As_Pointer(HOUSE_USSR);
  322. PlayerPtr->IsHuman = true;
  323. // Base.House = HOUSE_SPAIN;
  324. LastHouse = HOUSE_GOOD;
  325. break;
  326. case SCEN_PLAYER_SPAIN:
  327. PlayerPtr = HouseClass::As_Pointer(HOUSE_SPAIN);
  328. PlayerPtr->IsHuman = true;
  329. // Base.House = HOUSE_USSR;
  330. LastHouse = HOUSE_GOOD;
  331. break;
  332. case SCEN_PLAYER_GREECE:
  333. PlayerPtr = HouseClass::As_Pointer(HOUSE_GREECE);
  334. PlayerPtr->IsHuman = true;
  335. // Base.House = HOUSE_USSR;
  336. LastHouse = HOUSE_GOOD;
  337. break;
  338. }
  339. /*
  340. ** Write the INI
  341. */
  342. Write_Scenario_INI(Scen.ScenarioName);
  343. return(0);
  344. }
  345. /***************************************************************************
  346. * MapEditClass::Pick_Scenario -- dialog for choosing scenario *
  347. * *
  348. * Prompts user for: *
  349. * - House (GDI, NOD) *
  350. * - Scenario # *
  351. * *
  352. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  353. * ³ Caption ³ *
  354. * ³ ³ *
  355. * ³ Scenario ___ ³ *
  356. * ³ Version ___ ³ *
  357. * ³ ³ *
  358. * ³ [East] [West] ³ *
  359. * ³ ³ *
  360. * ³ [ GDI ] ³ *
  361. * ³ [ NOD ] ³ *
  362. * ³ [Multi-Player] ³ *
  363. * ³ ³ *
  364. * ³ [OK] [Cancel] ³ *
  365. * ³ ³ *
  366. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  367. * *
  368. * INPUT: *
  369. * caption string to use as a title *
  370. * scen_nump output: ptr to scenario # *
  371. * playerp output: ptr to player type *
  372. * dirp output: ptr to direction *
  373. * varp output: ptr to variation *
  374. * multi 1 = allow to change single/multiplayer; 0 = not *
  375. * *
  376. * OUTPUT: *
  377. * 0 = OK, -1 = cancel *
  378. * *
  379. * WARNINGS: *
  380. * none. *
  381. * *
  382. * HISTORY: *
  383. * 10/21/1994 BR : Created. *
  384. * 09/04/1996 JLB : Simplified *
  385. *=========================================================================*/
  386. int MapEditClass::Pick_Scenario(char const * caption, int & scen_nump, ScenarioPlayerType & playerp, ScenarioDirType & dirp, ScenarioVarType & varp)
  387. {
  388. /*
  389. ** Dialog & button dimensions
  390. */
  391. enum {
  392. D_DIALOG_W = 200, // dialog width
  393. D_DIALOG_H = 164, // dialog height
  394. D_DIALOG_X = ((320 - D_DIALOG_W) / 2), // centered x-coord
  395. D_DIALOG_Y = ((200 - D_DIALOG_H) / 2), // centered y-coord
  396. D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2), // coord of x-center
  397. D_TXT8_H = 11, // ht of 8-pt text
  398. D_MARGIN = 7, // margin width/height
  399. D_SCEN_W = 45, // Scenario # width
  400. D_SCEN_H = 9, // Scenario # height
  401. D_SCEN_X = D_DIALOG_CX + 5, // Scenario # x
  402. D_SCEN_Y = D_DIALOG_Y + D_MARGIN + D_TXT8_H + D_MARGIN, // Scenario # y
  403. D_VARA_W = 13, // Version A width
  404. D_VARA_H = 9, // Version A height
  405. D_VARA_X = D_DIALOG_CX - (D_VARA_W * 5) / 2, // Version A x
  406. D_VARA_Y = D_SCEN_Y + D_SCEN_H + D_MARGIN, // Version A y
  407. D_VARB_W = 13, // Version B width
  408. D_VARB_H = 9, // Version B height
  409. D_VARB_X = D_VARA_X + D_VARA_W, // Version B x
  410. D_VARB_Y = D_SCEN_Y + D_SCEN_H + D_MARGIN, // Version B y
  411. D_VARC_W = 13, // Version C width
  412. D_VARC_H = 9, // Version C height
  413. D_VARC_X = D_VARB_X + D_VARB_W, // Version C x
  414. D_VARC_Y = D_SCEN_Y + D_SCEN_H + D_MARGIN, // Version C y
  415. D_VARD_W = 13, // Version D width
  416. D_VARD_H = 9, // Version D height
  417. D_VARD_X = D_VARC_X + D_VARC_W, // Version D x
  418. D_VARD_Y = D_SCEN_Y + D_SCEN_H + D_MARGIN, // Version D y
  419. D_VARLOSE_W = 13, // Version Lose width
  420. D_VARLOSE_H = 9, // Version Lose height
  421. D_VARLOSE_X = D_VARD_X + D_VARD_W, // Version Lose x
  422. D_VARLOSE_Y = D_SCEN_Y + D_SCEN_H + D_MARGIN, // Version Lose y
  423. D_EAST_W = 50, // EAST width
  424. D_EAST_H = 9, // EAST height
  425. D_EAST_X = D_DIALOG_CX - D_EAST_W - 5, // EAST x
  426. D_EAST_Y = D_VARLOSE_Y + D_VARLOSE_H + D_MARGIN,// EAST y
  427. D_WEST_W = 50, // WEST width
  428. D_WEST_H = 9, // WEST height
  429. D_WEST_X = D_DIALOG_CX + 5, // WEST x
  430. D_WEST_Y = D_VARLOSE_Y + D_VARLOSE_H + D_MARGIN,// EAST y
  431. D_GDI_W = 90, // GDI width
  432. D_GDI_H = 9, // GDI height
  433. D_GDI_X = D_DIALOG_CX - (D_GDI_W / 2), // GDI x
  434. D_GDI_Y = D_EAST_Y + D_EAST_H + D_MARGIN, // GDI y
  435. D_NOD_W = 90, // NOD width
  436. D_NOD_H = 9, // NOD height
  437. D_NOD_X = D_DIALOG_CX - (D_NOD_W / 2), // NOD x
  438. D_NOD_Y = D_GDI_Y + D_GDI_H, // NOD y
  439. D_NEU_W = 90, // Neutral width
  440. D_NEU_H = 9, // Neutral height
  441. D_NEU_X = D_DIALOG_CX - (D_NOD_W / 2), // Neutral x
  442. D_NEU_Y = D_NOD_Y + D_NOD_H, // Neutral y
  443. D_MPLAYER_W = 90, // Multi-Player width
  444. D_MPLAYER_H = 9, // Multi-Player height
  445. D_MPLAYER_X = D_DIALOG_CX - (D_MPLAYER_W / 2), // Multi-Player x
  446. D_MPLAYER_Y = D_NEU_Y + D_NEU_H, // Multi-Player y
  447. D_OK_W = 45, // OK width
  448. D_OK_H = 9, // OK height
  449. D_OK_X = D_DIALOG_CX - D_OK_W - 5, // OK x
  450. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - D_OK_H - (D_MARGIN+15), // OK y
  451. D_CANCEL_W = 45, // Cancel width
  452. D_CANCEL_H = 9, // Cancel height
  453. D_CANCEL_X = D_DIALOG_CX + 5, // Cancel x
  454. D_CANCEL_Y = D_DIALOG_Y + D_DIALOG_H - D_CANCEL_H - (D_MARGIN+15), // Cancel y
  455. };
  456. /*
  457. ** Button enumerations
  458. */
  459. enum {
  460. BUTTON_GDI=100,
  461. BUTTON_NOD,
  462. BUTTON_NEUTRAL,
  463. BUTTON_MPLAYER,
  464. BUTTON_EAST,
  465. BUTTON_WEST,
  466. BUTTON_OK,
  467. BUTTON_CANCEL,
  468. BUTTON_SCENARIO,
  469. BUTTON_VAR_A,
  470. BUTTON_VAR_B,
  471. BUTTON_VAR_C,
  472. BUTTON_VAR_D,
  473. };
  474. /*
  475. ** Dialog variables
  476. */
  477. bool cancel = false; // true = user cancels
  478. /*
  479. ** Other Variables
  480. */
  481. char scen_buf[10]={0}; // buffer for editing scenario #
  482. /*
  483. ** Buttons
  484. */
  485. ControlClass * commands = NULL; // the button list
  486. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  487. EditClass editbtn (BUTTON_SCENARIO, scen_buf, 5, TPF_EFNT|TPF_NOSHADOW, D_SCEN_X, D_SCEN_Y, D_SCEN_W, D_SCEN_H, EditClass::ALPHANUMERIC);
  488. #else
  489. EditClass editbtn (BUTTON_SCENARIO, scen_buf, 5, TPF_EFNT|TPF_NOSHADOW, D_SCEN_X, D_SCEN_Y, D_SCEN_W, D_SCEN_H, EditClass::NUMERIC);
  490. #endif
  491. TextButtonClass varabtn(BUTTON_VAR_A, "A", TPF_EBUTTON, D_VARA_X, D_VARA_Y, D_VARA_W, D_VARA_H);
  492. TextButtonClass varbbtn(BUTTON_VAR_B, "B", TPF_EBUTTON, D_VARB_X, D_VARB_Y, D_VARB_W, D_VARB_H);
  493. TextButtonClass varcbtn(BUTTON_VAR_C, "C", TPF_EBUTTON, D_VARC_X, D_VARC_Y, D_VARC_W, D_VARC_H);
  494. TextButtonClass vardbtn(BUTTON_VAR_D, "D", TPF_EBUTTON, D_VARD_X, D_VARD_Y, D_VARD_W, D_VARD_H);
  495. TextButtonClass gdibtn(BUTTON_GDI, "North (Spain)", TPF_EBUTTON, D_GDI_X, D_GDI_Y, D_GDI_W, D_GDI_H);
  496. TextButtonClass nodbtn(BUTTON_NOD, "South (Greece)", TPF_EBUTTON, D_NOD_X, D_NOD_Y, D_NOD_W, D_NOD_H);
  497. TextButtonClass neubtn(BUTTON_NEUTRAL, HouseTypeClass::As_Reference(HOUSE_USSR).IniName, TPF_EBUTTON, D_NEU_X, D_NEU_Y, D_NEU_W, D_NEU_H);
  498. TextButtonClass playermbtn(BUTTON_MPLAYER, "Multiplayer", TPF_EBUTTON, D_MPLAYER_X, D_MPLAYER_Y, D_MPLAYER_W, D_MPLAYER_H);
  499. TextButtonClass eastbtn(BUTTON_EAST, "East", TPF_EBUTTON, D_EAST_X, D_EAST_Y, D_EAST_W, D_EAST_H);
  500. TextButtonClass westbtn(BUTTON_WEST, "West", TPF_EBUTTON, D_WEST_X, D_WEST_Y, D_WEST_W, D_WEST_H);
  501. TextButtonClass okbtn(BUTTON_OK, TXT_OK, TPF_EBUTTON, D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  502. TextButtonClass cancelbtn(BUTTON_CANCEL, TXT_CANCEL, TPF_EBUTTON, D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W, D_CANCEL_H);
  503. /*
  504. ** Initialize
  505. */
  506. Set_Logic_Page(SeenBuff);
  507. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  508. if (scen_nump < 100) {
  509. sprintf(scen_buf, "%d", scen_nump); // init edit buffer
  510. } else {
  511. char first = scen_nump / 36;
  512. char second = scen_nump % 36;
  513. scen_buf[0] = first + 'A';
  514. //Mono_Printf("picking map, scen# = %d, first = %c, second = %d (numeric)\n",scen_nump, scen_buf[0],second);Keyboard->Get();Keyboard->Get();
  515. if (second < 10) {
  516. scen_buf[1] = second + '0';
  517. } else {
  518. scen_buf[1] = (second-10) + 'A';
  519. }
  520. scen_buf[2] = 0;
  521. }
  522. #else
  523. sprintf(scen_buf, "%d", scen_nump); // init edit buffer
  524. #endif
  525. editbtn.Set_Text(scen_buf, 5);
  526. varabtn.Turn_Off();
  527. varbbtn.Turn_Off();
  528. varcbtn.Turn_Off();
  529. vardbtn.Turn_Off();
  530. switch (varp) {
  531. case SCEN_VAR_A:
  532. varabtn.Turn_On();
  533. break;
  534. case SCEN_VAR_B:
  535. varbbtn.Turn_On();
  536. break;
  537. case SCEN_VAR_C:
  538. varcbtn.Turn_On();
  539. break;
  540. case SCEN_VAR_D:
  541. vardbtn.Turn_On();
  542. break;
  543. }
  544. /*
  545. ** Create the button list
  546. */
  547. commands = &editbtn;
  548. varabtn.Add_Tail(*commands);
  549. varbbtn.Add_Tail(*commands);
  550. varcbtn.Add_Tail(*commands);
  551. vardbtn.Add_Tail(*commands);
  552. gdibtn.Add_Tail(*commands);
  553. nodbtn.Add_Tail(*commands);
  554. neubtn.Add_Tail(*commands);
  555. playermbtn.Add_Tail(*commands);
  556. eastbtn.Add_Tail(*commands);
  557. westbtn.Add_Tail(*commands);
  558. okbtn.Add_Tail(*commands);
  559. cancelbtn.Add_Tail(*commands);
  560. /*
  561. ** Init the button states
  562. */
  563. gdibtn.Turn_Off();
  564. nodbtn.Turn_Off();
  565. neubtn.Turn_Off();
  566. playermbtn.Turn_Off();
  567. if (playerp == SCEN_PLAYER_MPLAYER) {
  568. playermbtn.Turn_On();
  569. } else {
  570. if (PlayerPtr) {
  571. switch (PlayerPtr->Class->House) {
  572. case HOUSE_SPAIN:
  573. gdibtn.Turn_On();
  574. break;
  575. case HOUSE_GREECE:
  576. nodbtn.Turn_On();
  577. break;
  578. case HOUSE_USSR:
  579. neubtn.Turn_On();
  580. break;
  581. }
  582. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  583. } else {
  584. switch (Scen.ScenarioName[2]) {
  585. case 'G':
  586. gdibtn.Turn_On();
  587. break;
  588. case 'U':
  589. nodbtn.Turn_On();
  590. break;
  591. case 'M':
  592. playermbtn.Turn_On();
  593. break;
  594. }
  595. #endif
  596. }
  597. }
  598. eastbtn.Turn_Off();
  599. westbtn.Turn_Off();
  600. if (dirp == SCEN_DIR_EAST) {
  601. eastbtn.Turn_On();
  602. } else {
  603. westbtn.Turn_On();
  604. }
  605. /*
  606. ** Main Processing Loop
  607. */
  608. bool display = true;
  609. bool process = true;
  610. while (process) {
  611. /*
  612. ** Invoke game callback
  613. */
  614. Call_Back();
  615. /*
  616. ** Refresh display if needed
  617. */
  618. if (display) {
  619. Hide_Mouse();
  620. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  621. Draw_Caption(caption, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  622. Fancy_Text_Print("Scenario", D_DIALOG_CX - 5, D_SCEN_Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_RIGHT | TPF_EFNT | TPF_NOSHADOW);
  623. commands->Draw_All();
  624. Show_Mouse();
  625. display = false;
  626. }
  627. /*
  628. ** Get user input
  629. */
  630. KeyNumType input = commands->Input();
  631. /*
  632. ** Process input
  633. */
  634. switch (input) {
  635. /*
  636. ** Handle a click on one of the scenario variation group buttons.
  637. */
  638. case (BUTTON_VAR_A | KN_BUTTON):
  639. case (BUTTON_VAR_B | KN_BUTTON):
  640. case (BUTTON_VAR_C | KN_BUTTON):
  641. case (BUTTON_VAR_D | KN_BUTTON):
  642. varabtn.Turn_Off();
  643. varbbtn.Turn_Off();
  644. varcbtn.Turn_Off();
  645. vardbtn.Turn_Off();
  646. switch (input) {
  647. case (BUTTON_VAR_A | KN_BUTTON):
  648. varp = SCEN_VAR_A;
  649. varabtn.Turn_On();
  650. break;
  651. case (BUTTON_VAR_B | KN_BUTTON):
  652. varp = SCEN_VAR_B;
  653. varbbtn.Turn_On();
  654. break;
  655. case (BUTTON_VAR_C | KN_BUTTON):
  656. varp = SCEN_VAR_C;
  657. varcbtn.Turn_On();
  658. break;
  659. case (BUTTON_VAR_D | KN_BUTTON):
  660. varp = SCEN_VAR_D;
  661. vardbtn.Turn_On();
  662. break;
  663. }
  664. break;
  665. /*
  666. ** Handle a click on the east/west variation group.
  667. */
  668. case (BUTTON_EAST | KN_BUTTON):
  669. case (BUTTON_WEST | KN_BUTTON):
  670. westbtn.Turn_Off();
  671. eastbtn.Turn_Off();
  672. switch (input) {
  673. case (BUTTON_EAST | KN_BUTTON):
  674. dirp = SCEN_DIR_EAST;
  675. eastbtn.Turn_On();
  676. break;
  677. case (BUTTON_WEST | KN_BUTTON):
  678. dirp = SCEN_DIR_WEST;
  679. westbtn.Turn_On();
  680. break;
  681. }
  682. break;
  683. /*
  684. ** Handle a click on one of the player category
  685. ** group buttons.
  686. */
  687. case (BUTTON_GDI | KN_BUTTON):
  688. case (BUTTON_NOD | KN_BUTTON):
  689. case (BUTTON_NEUTRAL | KN_BUTTON):
  690. case (BUTTON_MPLAYER | KN_BUTTON):
  691. gdibtn.Turn_Off();
  692. nodbtn.Turn_Off();
  693. neubtn.Turn_Off();
  694. playermbtn.Turn_Off();
  695. switch (input) {
  696. case (BUTTON_GDI | KN_BUTTON):
  697. playerp = SCEN_PLAYER_SPAIN;
  698. gdibtn.Turn_On();
  699. break;
  700. case (BUTTON_NOD | KN_BUTTON):
  701. playerp = SCEN_PLAYER_GREECE;
  702. nodbtn.Turn_On();
  703. break;
  704. case (BUTTON_NEUTRAL | KN_BUTTON):
  705. playerp = SCEN_PLAYER_USSR;
  706. neubtn.Turn_On();
  707. break;
  708. case (BUTTON_MPLAYER | KN_BUTTON):
  709. playerp = SCEN_PLAYER_MPLAYER;
  710. playermbtn.Turn_On();
  711. break;
  712. }
  713. break;
  714. case (KN_RETURN):
  715. case (BUTTON_OK | KN_BUTTON):
  716. cancel = false;
  717. process = false;
  718. break;
  719. case (KN_ESC):
  720. case (BUTTON_CANCEL | KN_BUTTON):
  721. cancel = true;
  722. process = false;
  723. break;
  724. case (BUTTON_SCENARIO | KN_BUTTON):
  725. break;
  726. default:
  727. break;
  728. }
  729. }
  730. /*
  731. ** Redraw the display
  732. */
  733. HidPage.Clear();
  734. Flag_To_Redraw(true);
  735. Render();
  736. /*
  737. ** If cancel, just return
  738. */
  739. if (cancel) {
  740. return(-1);
  741. }
  742. /*
  743. ** Save selections & return
  744. */
  745. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  746. if (scen_buf[0] <= '9' && scen_buf[1] <= '9') {
  747. scen_nump = atoi(scen_buf);
  748. } else {
  749. char first = scen_buf[0];
  750. char second = scen_buf[1];
  751. if (first <= '9') {
  752. first -= '0';
  753. } else {
  754. if (first >= 'a' && first <= 'z') {
  755. first -= 'a';
  756. } else {
  757. first -= 'A';
  758. }
  759. }
  760. if (second <= '9') {
  761. second -= '0';
  762. } else {
  763. if (second >= 'a' && second <= 'z') {
  764. second = (second - 'a') + 10;
  765. } else {
  766. second = (second - 'A') + 10;
  767. }
  768. }
  769. scen_nump = (first * 36) + second;
  770. //Mono_Printf("Converted to: %d, %d = %d\n",first, second, scen_nump);Keyboard->Get();Keyboard->Get();
  771. }
  772. #else
  773. scen_nump = atoi(scen_buf);
  774. #endif
  775. return(0);
  776. }
  777. /***************************************************************************
  778. * MapEditClass::Size_Map -- lets user set size & location of map *
  779. * *
  780. * Lets the user select a side of the map and expand/shrink it to the *
  781. * desired size, or move the whole map around the available map area. *
  782. * *
  783. * The entire available map area is displayed, but the map is limited such *
  784. * that there's always one blank cell around the map; this lets objects *
  785. * properly exit the screen, since they have a blank undisplayed cell to *
  786. * exit onto. *
  787. * *
  788. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  789. * ³ ³ *
  790. * ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ Clear Terrain ³ *
  791. * ³ ³ ³ Water ³ *
  792. * ³ ³ ³ Tiberium ³ *
  793. * ³ ³ ³ Rock/Wall/Road ³ *
  794. * ³ ³ (Map Area) ³ GDI Unit ³ *
  795. * ³ ³ ³ NOD Unit ³ *
  796. * ³ ³ ³ Neutral Unit ³ *
  797. * ³ ³ ³ Terrain Object ³ *
  798. * ³ ³ ³ Starting Cell ³ *
  799. * ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ *
  800. * ³ ³ *
  801. * ³ X Y Width Height ³ *
  802. * ³ ## ## ## ## ³ *
  803. * ³ ³ *
  804. * ³ ³ *
  805. * ³ [OK] [Cancel] ³ *
  806. * ³ ³ *
  807. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  808. * *
  809. * INPUT: *
  810. * x,y,w,h: initial size parameters (-1 = center the thing) *
  811. * *
  812. * OUTPUT: *
  813. * 0 = OK, -1 = cancel *
  814. * *
  815. * WARNINGS: *
  816. * none. *
  817. * *
  818. * HISTORY: *
  819. * 10/21/1994 BR : Created. *
  820. *=========================================================================*/
  821. int MapEditClass::Size_Map(int x, int y, int w, int h)
  822. {
  823. /*
  824. ** Dialog & button dimensions
  825. */
  826. enum {
  827. D_DIALOG_W = 350, // dialog width
  828. D_DIALOG_H = 225, // dialog height
  829. D_DIALOG_X = 0, // centered x-coord
  830. D_DIALOG_Y = 0, // centered y-coord
  831. // D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2), // coord of x-center
  832. D_TXT8_H = 11, // ht of 8-pt text
  833. D_MARGIN = 7, // margin width/height
  834. D_BORD_X1 = D_DIALOG_X + 45,
  835. // D_BORD_X1 = D_DIALOG_X + (D_DIALOG_W / 2 - MAP_CELL_W) / 2,
  836. D_BORD_Y1 = D_DIALOG_Y + 25,
  837. D_BORD_X2 = D_BORD_X1 + MAP_CELL_W + 1,
  838. D_BORD_Y2 = D_BORD_Y1 + MAP_CELL_H + 1,
  839. D_OK_W = 45, // OK width
  840. D_OK_H = 9, // OK height
  841. D_OK_X = D_DIALOG_X + 45, // OK x
  842. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - D_OK_H - (D_MARGIN + 10), // OK y
  843. D_CANCEL_W = 45, // Cancel width
  844. D_CANCEL_H = 9, // Cancel height
  845. D_CANCEL_X = D_DIALOG_X + D_DIALOG_W - (35 + D_CANCEL_W), // Cancel x
  846. D_CANCEL_Y = D_DIALOG_Y + D_DIALOG_H - D_CANCEL_H - (D_MARGIN + 10), // Cancel y
  847. };
  848. /*
  849. ** Button enumerations:
  850. */
  851. enum {
  852. BUTTON_OK=100,
  853. BUTTON_CANCEL,
  854. };
  855. /*
  856. ** Redraw values: in order from "top" to "bottom" layer of the dialog
  857. */
  858. typedef enum {
  859. REDRAW_NONE = 0,
  860. REDRAW_MAP, // includes map interior & coord values
  861. REDRAW_BACKGROUND, // includes box, map board, key, coord labels, btns
  862. REDRAW_ALL = REDRAW_BACKGROUND
  863. } RedrawType;
  864. /*
  865. ** Dialog variables:
  866. */
  867. RedrawType display; // requested redraw level
  868. bool cancel = false; // true = user cancels
  869. KeyNumType input; // user input
  870. int grabbed = 0; // 1=TLeft,2=TRight,3=BRight,4=BLeft
  871. int map_x1; // map coords x1, pixel coords
  872. int map_x2; // map coords x2, pixel coords
  873. int map_y1; // map coords y1, pixel coords
  874. int map_y2; // map coords y2, pixel coords
  875. int delta1, delta2; // mouse-click proximity
  876. int mx,my; // last-saved mouse coords
  877. // char txt[40];
  878. int txt_x,txt_y; // for displaying text
  879. // unsigned index; // for drawing map symbology
  880. CELL cell; // for drawing map symbology
  881. int color; // for drawing map symbology
  882. ObjectClass * occupier; // cell's occupier
  883. RemapControlType * scheme = GadgetClass::Get_Color_Scheme();
  884. /*
  885. ** Buttons
  886. */
  887. ControlClass * commands = NULL;
  888. TextButtonClass okbtn (BUTTON_OK, TXT_OK, TPF_EBUTTON, D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  889. TextButtonClass cancelbtn (BUTTON_CANCEL, TXT_CANCEL, TPF_EBUTTON, D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W, D_CANCEL_H);
  890. /*
  891. ** Initialize
  892. */
  893. Set_Logic_Page(SeenBuff);
  894. /*
  895. ** Set up the actual map area relative to the map's border coords
  896. */
  897. if (x==-1) {
  898. map_x1 = D_BORD_X1 + (MAP_CELL_W - w) / 2 + 1;
  899. } else {
  900. map_x1 = D_BORD_X1 + x + 1;
  901. }
  902. if (y==-1) {
  903. map_y1 = D_BORD_Y1 + (MAP_CELL_H - h) / 2 + 1;
  904. } else {
  905. map_y1 = D_BORD_Y1 + y + 1;
  906. }
  907. map_x2 = map_x1 + w - 1;
  908. map_y2 = map_y1 + h - 1;
  909. /*
  910. ** Build the button list
  911. */
  912. commands = &okbtn;
  913. cancelbtn.Add_Tail(*commands);
  914. /*
  915. ** Main processing loop
  916. */
  917. display = REDRAW_ALL;
  918. bool process = true;
  919. while (process) {
  920. /*
  921. ** Invoke game callback
  922. */
  923. Call_Back();
  924. /*
  925. ** Refresh display if needed
  926. */
  927. if (display) {
  928. Hide_Mouse();
  929. /*
  930. ** Redraw the background, map border, key, and coord labels
  931. */
  932. if (display >= REDRAW_BACKGROUND) {
  933. /*
  934. ** Background
  935. */
  936. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  937. Draw_Caption(TXT_SIZE_MAP, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  938. /*
  939. ** Draw the map border
  940. */
  941. if (LogicPage->Lock()) {
  942. LogicPage->Draw_Rect(D_BORD_X1, D_BORD_Y1, D_BORD_X2, D_BORD_Y2, scheme->Shadow);
  943. // for (index = D_BORD_X1; index < D_BORD_X2;
  944. // index += (320/ICON_PIXEL_W)) {
  945. // LogicPage->Put_Pixel(index, D_BORD_Y1-1, scheme->Shadow);
  946. // LogicPage->Put_Pixel(index, D_BORD_Y2+1, scheme->Shadow);
  947. // }
  948. // for (index = D_BORD_Y1; index < D_BORD_Y2-8;
  949. // index += (200/ICON_PIXEL_H)) {
  950. // LogicPage->Put_Pixel(D_BORD_X1-1, index, scheme->Shadow);
  951. // LogicPage->Put_Pixel(D_BORD_X2+1, index, scheme->Shadow);
  952. // }
  953. /*
  954. ** Draw the map "key"
  955. */
  956. txt_x = D_BORD_X2 + 15;
  957. txt_y = D_BORD_Y1;
  958. Plain_Text_Print("Clear Terrain", txt_x, txt_y, GroundColor[LAND_CLEAR], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  959. txt_y += 8;
  960. Plain_Text_Print("Water", txt_x, txt_y, GroundColor[LAND_WATER], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  961. txt_y += 8;
  962. Plain_Text_Print("Tiberium", txt_x, txt_y, GroundColor[LAND_TIBERIUM], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  963. txt_y += 8;
  964. Plain_Text_Print("Rock", txt_x, txt_y, GroundColor[LAND_ROCK], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  965. txt_y += 8;
  966. Plain_Text_Print("Wall", txt_x, txt_y, GroundColor[LAND_WALL], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  967. txt_y += 8;
  968. Plain_Text_Print("Beach", txt_x, txt_y, GroundColor[LAND_BEACH], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  969. txt_y += 8;
  970. Plain_Text_Print("Rough", txt_x, txt_y, GroundColor[LAND_ROUGH], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  971. txt_y += 8;
  972. Plain_Text_Print("River", txt_x, txt_y, GroundColor[LAND_RIVER], TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  973. // txt_y += 8;
  974. // Plain_Text_Print("GDI Unit", txt_x, txt_y, YELLOW, TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  975. // txt_y += 8;
  976. // Plain_Text_Print("Nod Unit", txt_x, txt_y, RED, TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  977. // txt_y += 8;
  978. // Plain_Text_Print("Neutral Unit", txt_x, txt_y, PURPLE, TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  979. txt_y += 8;
  980. Plain_Text_Print("Terrain Object", txt_x, txt_y, DKGREEN, TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  981. txt_y += 8;
  982. Plain_Text_Print("Starting Cell", txt_x, txt_y, WHITE, TBLACK, TPF_DROPSHADOW | TPF_EFNT);
  983. /*
  984. ** Draw the coordinate labels
  985. */
  986. txt_x = D_DIALOG_X + D_DIALOG_W / 8;
  987. txt_y = D_DIALOG_Y + D_DIALOG_H - D_OK_H - 43;
  988. Fancy_Text_Print(" X", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW);
  989. txt_x += (D_DIALOG_W - 20) / 4;
  990. Fancy_Text_Print(" Y", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW);
  991. txt_x += (D_DIALOG_W - 20) / 4;
  992. Fancy_Text_Print(" Width", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW);
  993. txt_x += (D_DIALOG_W - 20) / 4;
  994. Fancy_Text_Print(" Height", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW);
  995. LogicPage->Unlock();
  996. }
  997. /*
  998. ** Redraw the buttons
  999. */
  1000. commands->Flag_List_To_Redraw();
  1001. }
  1002. /*
  1003. ** Redraw the map symbology & location
  1004. */
  1005. if (display >= REDRAW_MAP) {
  1006. if (LogicPage->Lock()) {
  1007. /*
  1008. ** Erase the map interior
  1009. */
  1010. LogicPage->Fill_Rect(D_BORD_X1 + 1, D_BORD_Y1 + 1, D_BORD_X2 - 1, D_BORD_Y2 - 1, BLACK);
  1011. /*
  1012. ** Draw Land map symbols (use color according to Ground[] array).
  1013. */
  1014. for (cell=0; cell < MAP_CELL_TOTAL; cell++) {
  1015. occupier = (*this)[cell].Cell_Occupier();
  1016. if (occupier == NULL) {
  1017. color = GroundColor[(*this)[cell].Land_Type()];
  1018. LogicPage->Put_Pixel(D_BORD_X1 + Cell_X(cell) + 1, D_BORD_Y1 + Cell_Y(cell) + 1, color);
  1019. }
  1020. }
  1021. /*
  1022. ** Draw the actual map location
  1023. */
  1024. LogicPage->Draw_Rect(map_x1, map_y1, map_x2, map_y2, WHITE);
  1025. switch (grabbed) {
  1026. case 1:
  1027. LogicPage->Draw_Line(map_x1, map_y1, map_x1 + 5, map_y1, BLUE);
  1028. LogicPage->Draw_Line(map_x1, map_y1, map_x1, map_y1 + 5, BLUE);
  1029. break;
  1030. case 2:
  1031. LogicPage->Draw_Line(map_x2, map_y1, map_x2 - 5, map_y1, BLUE);
  1032. LogicPage->Draw_Line(map_x2, map_y1, map_x2, map_y1 + 5, BLUE);
  1033. break;
  1034. case 3:
  1035. LogicPage->Draw_Line(map_x2, map_y2, map_x2 - 5, map_y2, BLUE);
  1036. LogicPage->Draw_Line(map_x2, map_y2, map_x2, map_y2 - 5, BLUE);
  1037. break;
  1038. case 4:
  1039. LogicPage->Draw_Line(map_x1, map_y2, map_x1 + 5, map_y2, BLUE);
  1040. LogicPage->Draw_Line(map_x1, map_y2, map_x1, map_y2 - 5, BLUE);
  1041. break;
  1042. case 5:
  1043. LogicPage->Draw_Rect(map_x1, map_y1, map_x2, map_y2, BLUE);
  1044. break;
  1045. default:
  1046. break;
  1047. }
  1048. /*
  1049. ** Draw Unit map symbols (Use the radar map color according to
  1050. ** that specified in the house type class object.
  1051. ** DKGREEN = terrain object
  1052. */
  1053. for (cell=0; cell < MAP_CELL_TOTAL; cell++) {
  1054. occupier = (*this)[cell].Cell_Occupier();
  1055. if (occupier) {
  1056. color = DKGREEN;
  1057. if (occupier && occupier->Owner() != HOUSE_NONE) {
  1058. color = ColorRemaps[HouseClass::As_Pointer(occupier->Owner())->RemapColor].Color;
  1059. }
  1060. LogicPage->Put_Pixel(D_BORD_X1 + Cell_X(cell) + 1, D_BORD_Y1 + Cell_Y(cell) + 1, color);
  1061. }
  1062. }
  1063. /*
  1064. ** Draw Home location
  1065. */
  1066. LogicPage->Put_Pixel(D_BORD_X1 + Cell_X(Scen.Waypoint[WAYPT_HOME]) + 1, D_BORD_Y1 + Cell_Y(Scen.Waypoint[WAYPT_HOME]) + 1, WHITE);
  1067. /*
  1068. ** Erase old coordinates
  1069. */
  1070. // LogicPage->Fill_Rect( D_DIALOG_X + 7,
  1071. // D_DIALOG_Y + D_DIALOG_H - D_OK_H - 22,
  1072. // D_DIALOG_X + D_DIALOG_W - 7,
  1073. // D_DIALOG_Y + D_DIALOG_H - D_OK_H - 22 + 10, BLACK);
  1074. /*
  1075. ** Draw the coordinates
  1076. */
  1077. txt_x = D_DIALOG_X + D_DIALOG_W / 8;
  1078. txt_y = D_DIALOG_Y + D_DIALOG_H - D_OK_H - 32;
  1079. Fancy_Text_Print("%5d", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), BLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW, map_x1 - D_BORD_X1 - 1);
  1080. txt_x += (D_DIALOG_W - 20) / 4;
  1081. Fancy_Text_Print("%5d", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), BLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW, map_y1 - D_BORD_Y1 - 1);
  1082. txt_x += (D_DIALOG_W - 20) / 4;
  1083. Fancy_Text_Print("%5d", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), BLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW, map_x2 - map_x1 + 1);
  1084. txt_x += (D_DIALOG_W - 20) / 4;
  1085. Fancy_Text_Print("%5d", txt_x, txt_y, GadgetClass::Get_Color_Scheme(), BLACK, TPF_CENTER | TPF_EFNT | TPF_NOSHADOW, map_y2 - map_y1 + 1);
  1086. LogicPage->Unlock();
  1087. }
  1088. }
  1089. Show_Mouse();
  1090. display = REDRAW_NONE;
  1091. }
  1092. /*
  1093. ** Process user input
  1094. */
  1095. input = commands->Input();
  1096. /*
  1097. ** Normal button processing: This is done when the mouse button is NOT
  1098. ** being held down ('grabbed' is 0).
  1099. */
  1100. if (grabbed == 0) {
  1101. switch (input) {
  1102. case (KN_RETURN):
  1103. case (BUTTON_OK | KN_BUTTON):
  1104. cancel = false;
  1105. process = false;
  1106. break;
  1107. case (KN_ESC):
  1108. case (BUTTON_CANCEL | KN_BUTTON):
  1109. cancel = true;
  1110. process = false;
  1111. break;
  1112. case KN_LMOUSE:
  1113. /*
  1114. ** Grab top left
  1115. */
  1116. delta1 = abs(Keyboard->MouseQX - map_x1);
  1117. delta2 = abs(Keyboard->MouseQY - map_y1);
  1118. if (delta1 < 3 && delta2 < 3) {
  1119. grabbed = 1;
  1120. mx = Keyboard->MouseQX;
  1121. my = Keyboard->MouseQY;
  1122. display = REDRAW_MAP;
  1123. break;
  1124. }
  1125. /*
  1126. ** Grab top right
  1127. */
  1128. delta1 = abs(Keyboard->MouseQX - map_x2);
  1129. delta2 = abs(Keyboard->MouseQY - map_y1);
  1130. if (delta1 < 3 && delta2 < 3) {
  1131. grabbed = 2;
  1132. mx = Keyboard->MouseQX;
  1133. my = Keyboard->MouseQY;
  1134. display = REDRAW_MAP;
  1135. break;
  1136. }
  1137. /*
  1138. ** Grab bottom right
  1139. */
  1140. delta1 = abs(Keyboard->MouseQX - map_x2);
  1141. delta2 = abs(Keyboard->MouseQY - map_y2);
  1142. if (delta1 < 3 && delta2 < 3) {
  1143. grabbed = 3;
  1144. mx = Keyboard->MouseQX;
  1145. my = Keyboard->MouseQY;
  1146. display = REDRAW_MAP;
  1147. break;
  1148. }
  1149. /*
  1150. ** Grab bottom left
  1151. */
  1152. delta1 = abs(Keyboard->MouseQX - map_x1);
  1153. delta2 = abs(Keyboard->MouseQY - map_y2);
  1154. if (delta1 < 3 && delta2 < 3) {
  1155. grabbed = 4;
  1156. mx = Keyboard->MouseQX;
  1157. my = Keyboard->MouseQY;
  1158. display = REDRAW_MAP;
  1159. break;
  1160. }
  1161. /*
  1162. ** Grab the whole map
  1163. */
  1164. delta1 = abs(Keyboard->MouseQX - ((map_x1 + map_x2) / 2));
  1165. delta2 = abs(Keyboard->MouseQY - ((map_y1 + map_y2) / 2));
  1166. if (delta1 < (map_x2 - map_x1) / 4 &&
  1167. delta2 < (map_y2 - map_y1) / 4) {
  1168. grabbed = 5;
  1169. mx = Keyboard->MouseQX;
  1170. my = Keyboard->MouseQY;
  1171. display = REDRAW_MAP;
  1172. }
  1173. break;
  1174. default:
  1175. break;
  1176. }
  1177. } else {
  1178. /*
  1179. ** Mouse motion processing: This is done while the left mouse button IS
  1180. ** being held down.
  1181. ** - First, check for the button release; if detected, un-grab
  1182. ** - Then, handle mouse motion. WWLIB doesn't pass through a KN_MOUSE_MOVE
  1183. ** value while the button is being held down, so this case must be
  1184. ** trapped as a default.
  1185. */
  1186. switch (input) {
  1187. case ((int)KN_LMOUSE | (int)KN_RLSE_BIT):
  1188. grabbed = 0;
  1189. display = REDRAW_MAP;
  1190. break;
  1191. default:
  1192. delta1 = Get_Mouse_X() - mx;
  1193. delta2 = Get_Mouse_Y() - my;
  1194. if (delta1==0 && delta2==0) {
  1195. break;
  1196. }
  1197. /*
  1198. ** Move top left
  1199. */
  1200. if (grabbed==1) {
  1201. map_x1 += delta1;
  1202. if (map_x1 > map_x2 - 2) {
  1203. map_x1 = map_x2 - 2;
  1204. } else {
  1205. if (map_x1 < D_BORD_X1 + 2) {
  1206. map_x1 = D_BORD_X1 + 2;
  1207. }
  1208. }
  1209. map_y1 += delta2;
  1210. if (map_y1 > map_y2 - 2) {
  1211. map_y1 = map_y2 - 2;
  1212. } else {
  1213. if (map_y1 < D_BORD_Y1 + 2) {
  1214. map_y1 = D_BORD_Y1 + 2;
  1215. }
  1216. }
  1217. display = REDRAW_MAP;
  1218. mx = Get_Mouse_X();
  1219. my = Get_Mouse_Y();
  1220. }
  1221. /*
  1222. ** Move top right
  1223. */
  1224. if (grabbed==2) {
  1225. map_x2 += delta1;
  1226. if (map_x2 < map_x1 + 2) {
  1227. map_x2 = map_x1 + 2;
  1228. } else {
  1229. if (map_x2 > D_BORD_X2 - 2) {
  1230. map_x2 = D_BORD_X2 - 2;
  1231. }
  1232. }
  1233. map_y1 += delta2;
  1234. if (map_y1 > map_y2 - 2) {
  1235. map_y1 = map_y2 - 2;
  1236. } else {
  1237. if (map_y1 < D_BORD_Y1 + 2) {
  1238. map_y1 = D_BORD_Y1 + 2;
  1239. }
  1240. }
  1241. display = REDRAW_MAP;
  1242. mx = Get_Mouse_X();
  1243. my = Get_Mouse_Y();
  1244. }
  1245. /*
  1246. ** Move bottom right
  1247. */
  1248. if (grabbed==3) {
  1249. map_x2 += delta1;
  1250. if (map_x2 < map_x1 + 2) {
  1251. map_x2 = map_x1 + 2;
  1252. } else {
  1253. if (map_x2 > D_BORD_X2 - 2) {
  1254. map_x2 = D_BORD_X2 - 2;
  1255. }
  1256. }
  1257. map_y2 += delta2;
  1258. if (map_y2 < map_y1 + 2) {
  1259. map_y2 = map_y1 + 2;
  1260. } else {
  1261. if (map_y2 > D_BORD_Y2 - 2) {
  1262. map_y2 = D_BORD_Y2 - 2;
  1263. }
  1264. }
  1265. display = REDRAW_MAP;
  1266. mx = Get_Mouse_X();
  1267. my = Get_Mouse_Y();
  1268. }
  1269. /*
  1270. ** Move bottom left
  1271. */
  1272. if (grabbed==4) {
  1273. map_x1 += delta1;
  1274. if (map_x1 > map_x2 - 2) {
  1275. map_x1 = map_x2 - 2;
  1276. } else {
  1277. if (map_x1 < D_BORD_X1 + 2) {
  1278. map_x1 = D_BORD_X1 + 2;
  1279. }
  1280. }
  1281. map_y2 += delta2;
  1282. if (map_y2 < map_y1 + 2) {
  1283. map_y2 = map_y1 + 2;
  1284. } else {
  1285. if (map_y2 > D_BORD_Y2 - 2) {
  1286. map_y2 = D_BORD_Y2 - 2;
  1287. }
  1288. }
  1289. display = REDRAW_MAP;
  1290. mx = Get_Mouse_X();
  1291. my = Get_Mouse_Y();
  1292. }
  1293. /*
  1294. ** Move whole map
  1295. */
  1296. if (grabbed==5) {
  1297. if (map_x1 + delta1 > D_BORD_X1 + 1 && map_x2 + delta1 < D_BORD_X2 - 1) {
  1298. map_x1 += delta1;
  1299. map_x2 += delta1;
  1300. }
  1301. if (map_y1 + delta2 > D_BORD_Y1 + 1 && map_y2 + delta2 < D_BORD_Y2 - 1) {
  1302. map_y1 += delta2;
  1303. map_y2 += delta2;
  1304. }
  1305. display = REDRAW_MAP;
  1306. mx = Get_Mouse_X();
  1307. my = Get_Mouse_Y();
  1308. }
  1309. break;
  1310. }
  1311. }
  1312. }
  1313. /*
  1314. ** Redraw the display
  1315. */
  1316. HidPage.Clear();
  1317. Flag_To_Redraw(true);
  1318. Render();
  1319. /*
  1320. ** If cancel, just return
  1321. */
  1322. if (cancel) {
  1323. return(-1);
  1324. }
  1325. /*
  1326. ** Save selections
  1327. */
  1328. MapCellX = map_x1 - D_BORD_X1 - 1;
  1329. MapCellY = map_y1 - D_BORD_Y1 - 1;
  1330. MapCellWidth = map_x2 - map_x1 + 1;
  1331. MapCellHeight = map_y2 - map_y1 + 1;
  1332. /*
  1333. ** Clip Home Cell to new map size
  1334. */
  1335. if (Cell_X(Scen.Waypoint[WAYPT_HOME]) < MapCellX) {
  1336. Scen.Waypoint[WAYPT_HOME] = XY_Cell(MapCellX, Cell_Y(Scen.Waypoint[WAYPT_HOME]));
  1337. }
  1338. if (Cell_X(Scen.Waypoint[WAYPT_HOME]) > MapCellX + MapCellWidth - 1) {
  1339. Scen.Waypoint[WAYPT_HOME] = XY_Cell(MapCellX + MapCellWidth - 1, Cell_Y(Scen.Waypoint[WAYPT_HOME]));
  1340. }
  1341. if (Cell_Y(Scen.Waypoint[WAYPT_HOME]) < MapCellY) {
  1342. Scen.Waypoint[WAYPT_HOME] = XY_Cell(Cell_X(Scen.Waypoint[WAYPT_HOME]), MapCellY);
  1343. }
  1344. if (Cell_Y(Scen.Waypoint[WAYPT_HOME]) > MapCellY + MapCellHeight - 1) {
  1345. Scen.Waypoint[WAYPT_HOME] = XY_Cell(Cell_X(Scen.Waypoint[WAYPT_HOME]), MapCellY + MapCellHeight - 1);
  1346. }
  1347. return(0);
  1348. }
  1349. /***************************************************************************
  1350. * MapEditClass::Scenario_Dialog -- scenario global parameters dialog *
  1351. * *
  1352. * Edits the house specific and general scenario options. *
  1353. * *
  1354. * *
  1355. * INPUT: *
  1356. * none. *
  1357. * *
  1358. * OUTPUT: *
  1359. * 0 = OK, -1 = cancel *
  1360. * *
  1361. * WARNINGS: *
  1362. * Uses HIDBUFF. *
  1363. * *
  1364. * HISTORY: *
  1365. * 11/14/1994 BR : Created. *
  1366. * 02/13/1996 JLB : Revamped to new system. *
  1367. *=========================================================================*/
  1368. int MapEditClass::Scenario_Dialog(void)
  1369. {
  1370. TheaterType orig_theater = Scen.Theater; // original theater
  1371. HousesType house = PlayerPtr->Class->House;
  1372. HousesType newhouse = house;
  1373. HouseStaticClass hdata[HOUSE_COUNT];
  1374. /*
  1375. ** Fill in the house data for each house that exists.
  1376. */
  1377. for (HousesType h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1378. HouseClass * hptr = HouseClass::As_Pointer(h);
  1379. if (hptr) {
  1380. hdata[h] = hptr->Control;
  1381. }
  1382. }
  1383. /*
  1384. ** Dialog & button dimensions
  1385. */
  1386. enum {
  1387. D_DIALOG_W = 320 * RESFACTOR,
  1388. D_DIALOG_H = 200 * RESFACTOR,
  1389. D_DIALOG_X = ((320 * RESFACTOR - D_DIALOG_W) / 2),
  1390. D_DIALOG_Y = ((200 * RESFACTOR - D_DIALOG_H) / 2),
  1391. D_OK_W = 45,
  1392. D_OK_H = 9,
  1393. D_OK_X = D_DIALOG_X + 15 * RESFACTOR,
  1394. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - 15 * RESFACTOR,
  1395. D_CANCEL_W = 45,
  1396. D_CANCEL_H = 9,
  1397. D_CANCEL_X = D_DIALOG_X + D_DIALOG_W - (D_CANCEL_W+15*RESFACTOR),
  1398. D_CANCEL_Y = D_DIALOG_Y + D_DIALOG_H - 15*RESFACTOR
  1399. };
  1400. /*
  1401. ** Button enumerations:
  1402. */
  1403. enum {
  1404. LIST_THEATER=100,
  1405. BUTTON_DESCRIPTION,
  1406. BUTTON_ALLIES,
  1407. BUTTON_CONTROL,
  1408. BUTTON_SMARTIES,
  1409. BUTTON_BASE,
  1410. BUTTON_NOSPYPLANE,
  1411. BUTTON_INHERIT,
  1412. BUTTON_TIMER,
  1413. BUTTON_THEME,
  1414. BUTTON_RECORD,
  1415. BUTTON_EVAC,
  1416. BUTTON_MONEYTIB,
  1417. BUTTON_TECH,
  1418. BUTTON_TRUCKCRATE,
  1419. BUTTON_ENDOFGAME,
  1420. BUTTON_SKIPSCORE,
  1421. BUTTON_ONETIME,
  1422. BUTTON_NOMAPSEL,
  1423. BUTTON_HOUSE,
  1424. BUTTON_CREDITS,
  1425. BUTTON_SOURCE,
  1426. BUTTON_MAXUNIT,
  1427. BUTTON_INTRO,
  1428. BUTTON_BRIEFING,
  1429. BUTTON_ACTION,
  1430. BUTTON_WIN,
  1431. BUTTON_LOSE,
  1432. BUTTON_OK,
  1433. BUTTON_CANCEL,
  1434. };
  1435. /*
  1436. ** Initialize
  1437. */
  1438. Set_Logic_Page(SeenBuff);
  1439. ControlClass * commands = NULL; // the button list
  1440. /*
  1441. ** Theater choice drop down list.
  1442. */
  1443. char theatertext[45] = "";
  1444. DropListClass theaterbtn(LIST_THEATER, theatertext, sizeof(theatertext)-1,
  1445. TPF_EFNT|TPF_NOSHADOW,
  1446. D_DIALOG_X+15*RESFACTOR, D_DIALOG_Y+30, 65, 8*5,
  1447. MFCD::Retrieve("EBTN-UP.SHP"),
  1448. MFCD::Retrieve("EBTN-DN.SHP"));
  1449. for (TheaterType t = THEATER_FIRST; t < THEATER_COUNT; t++) {
  1450. theaterbtn.Add_Item(Theaters[t].Name);
  1451. }
  1452. theaterbtn.Set_Selected_Index(orig_theater);
  1453. char description[DESCRIP_MAX] = "";
  1454. strcpy(description, Scen.Description);
  1455. EditClass desc(BUTTON_DESCRIPTION, description, sizeof(description), TPF_EFNT|TPF_NOSHADOW, theaterbtn.X+theaterbtn.Width+15, theaterbtn.Y, 160);
  1456. /*
  1457. ** Button that tells if this scenario should inherit buildings from the previous.
  1458. */
  1459. CheckBoxClass inherit(BUTTON_INHERIT, theaterbtn.X+theaterbtn.Width+15+250, theaterbtn.Y);
  1460. if (Scen.IsToInherit) {
  1461. inherit.Turn_On();
  1462. } else {
  1463. inherit.Turn_Off();
  1464. }
  1465. /*
  1466. ** Records scenario disposition into holding slot.
  1467. */
  1468. CheckBoxClass record(BUTTON_RECORD, inherit.X, inherit.Y+8);
  1469. if (Scen.IsToCarryOver) {
  1470. record.Turn_On();
  1471. } else {
  1472. record.Turn_Off();
  1473. }
  1474. /*
  1475. ** Should Tanya/civilian be automatically evacuated?
  1476. */
  1477. CheckBoxClass tanya(BUTTON_EVAC, record.X, record.Y+8);
  1478. if (Scen.IsTanyaEvac) {
  1479. tanya.Turn_On();
  1480. } else {
  1481. tanya.Turn_Off();
  1482. }
  1483. /*
  1484. ** End of game with with scenario?
  1485. */
  1486. CheckBoxClass endofgame(BUTTON_ENDOFGAME, tanya.X, tanya.Y+8);
  1487. if (Scen.IsEndOfGame) {
  1488. endofgame.Turn_On();
  1489. } else {
  1490. endofgame.Turn_Off();
  1491. }
  1492. /*
  1493. ** Timer inherit logic.
  1494. */
  1495. CheckBoxClass timercarry(BUTTON_TIMER, endofgame.X, endofgame.Y+8);
  1496. if (Scen.IsInheritTimer) {
  1497. timercarry.Turn_On();
  1498. } else {
  1499. timercarry.Turn_Off();
  1500. }
  1501. /*
  1502. ** Disable spy plane option?
  1503. */
  1504. CheckBoxClass nospyplane(BUTTON_NOSPYPLANE, timercarry.X, timercarry.Y+8);
  1505. if (Scen.IsNoSpyPlane) {
  1506. nospyplane.Turn_On();
  1507. } else {
  1508. nospyplane.Turn_Off();
  1509. }
  1510. /*
  1511. ** Skip the score screen?
  1512. */
  1513. CheckBoxClass skipscore(BUTTON_SKIPSCORE, nospyplane.X, nospyplane.Y+8);
  1514. if (Scen.IsSkipScore) {
  1515. skipscore.Turn_On();
  1516. } else {
  1517. skipscore.Turn_Off();
  1518. }
  1519. /*
  1520. ** Skip the map selection screen for next mission. Presume goes to
  1521. ** variation "B"?
  1522. */
  1523. CheckBoxClass nomapsel(BUTTON_NOMAPSEL, skipscore.X, skipscore.Y+8);
  1524. if (Scen.IsNoMapSel) {
  1525. nomapsel.Turn_On();
  1526. } else {
  1527. nomapsel.Turn_Off();
  1528. }
  1529. /*
  1530. ** Return to main menu after mission completes?
  1531. */
  1532. CheckBoxClass onetime(BUTTON_ONETIME, nomapsel.X, nomapsel.Y+8);
  1533. if (Scen.IsOneTimeOnly) {
  1534. onetime.Turn_On();
  1535. } else {
  1536. onetime.Turn_Off();
  1537. }
  1538. /*
  1539. ** Trucks carry a wood crate?
  1540. */
  1541. CheckBoxClass truckcrate(BUTTON_TRUCKCRATE, onetime.X, onetime.Y+8);
  1542. if (Scen.IsTruckCrate) {
  1543. truckcrate.Turn_On();
  1544. } else {
  1545. truckcrate.Turn_Off();
  1546. }
  1547. /*
  1548. ** Transfer credits into tiberium storage at scenario start?
  1549. */
  1550. CheckBoxClass moneytib(BUTTON_MONEYTIB, truckcrate.X, truckcrate.Y+8);
  1551. if (Scen.IsMoneyTiberium) {
  1552. moneytib.Turn_On();
  1553. } else {
  1554. moneytib.Turn_Off();
  1555. }
  1556. /*
  1557. ** Intro movie name.
  1558. */
  1559. char introtext[_MAX_FNAME+_MAX_EXT];
  1560. DropListClass intro(BUTTON_INTRO, introtext, sizeof(introtext),
  1561. TPF_EFNT|TPF_NOSHADOW,
  1562. theaterbtn.X, theaterbtn.Y+theaterbtn.Height+24, 50, 7*10,
  1563. MFCD::Retrieve("EBTN-UP.SHP"),
  1564. MFCD::Retrieve("EBTN-DN.SHP"));
  1565. intro.Add_Item("<none>");
  1566. for (VQType v = VQ_FIRST; v < VQ_COUNT; v++) {
  1567. intro.Add_Item(VQName[v]);
  1568. }
  1569. intro.Set_Selected_Index((int)Scen.IntroMovie + 1);
  1570. /*
  1571. ** Briefing movie name.
  1572. */
  1573. char brieftext[_MAX_FNAME+_MAX_EXT];
  1574. DropListClass briefing(BUTTON_BRIEFING, brieftext, sizeof(brieftext),
  1575. TPF_EFNT|TPF_NOSHADOW,
  1576. intro.X+intro.Width+10, intro.Y, 50, 7*10,
  1577. MFCD::Retrieve("EBTN-UP.SHP"),
  1578. MFCD::Retrieve("EBTN-DN.SHP"));
  1579. briefing.Add_Item("<none>");
  1580. for (v = VQ_FIRST; v < VQ_COUNT; v++) {
  1581. briefing.Add_Item(VQName[v]);
  1582. }
  1583. briefing.Set_Selected_Index((int)Scen.BriefMovie + 1);
  1584. char actiontext[_MAX_FNAME+_MAX_EXT];
  1585. DropListClass action(BUTTON_ACTION, actiontext, sizeof(actiontext),
  1586. TPF_EFNT|TPF_NOSHADOW,
  1587. briefing.X+briefing.Width+10, briefing.Y, 50, 7*10,
  1588. MFCD::Retrieve("EBTN-UP.SHP"),
  1589. MFCD::Retrieve("EBTN-DN.SHP"));
  1590. action.Add_Item("<none>");
  1591. for (v = VQ_FIRST; v < VQ_COUNT; v++) {
  1592. action.Add_Item(VQName[v]);
  1593. }
  1594. action.Set_Selected_Index((int)Scen.ActionMovie + 1);
  1595. char wintext[_MAX_FNAME+_MAX_EXT];
  1596. DropListClass win(BUTTON_WIN, wintext, sizeof(wintext),
  1597. TPF_EFNT|TPF_NOSHADOW,
  1598. action.X+action.Width+10, action.Y, 50, 7*10,
  1599. MFCD::Retrieve("EBTN-UP.SHP"),
  1600. MFCD::Retrieve("EBTN-DN.SHP"));
  1601. win.Add_Item("<none>");
  1602. for (v = VQ_FIRST; v < VQ_COUNT; v++) {
  1603. win.Add_Item(VQName[v]);
  1604. }
  1605. win.Set_Selected_Index((int)Scen.WinMovie + 1);
  1606. char losetext[_MAX_FNAME+_MAX_EXT];
  1607. DropListClass lose(BUTTON_LOSE, losetext, sizeof(losetext),
  1608. TPF_EFNT|TPF_NOSHADOW,
  1609. win.X+win.Width+10, win.Y, 50, 7*10,
  1610. MFCD::Retrieve("EBTN-UP.SHP"),
  1611. MFCD::Retrieve("EBTN-DN.SHP"));
  1612. lose.Add_Item("<none>");
  1613. for (v = VQ_FIRST; v < VQ_COUNT; v++) {
  1614. lose.Add_Item(VQName[v]);
  1615. }
  1616. lose.Set_Selected_Index((int)Scen.LoseMovie + 1);
  1617. /*
  1618. ** House choice list.
  1619. */
  1620. ListClass housebtn(BUTTON_HOUSE,
  1621. D_DIALOG_X+15*RESFACTOR, D_DIALOG_Y+105, 55, 7*10,
  1622. TPF_EFNT|TPF_NOSHADOW,
  1623. MFCD::Retrieve("EBTN-UP.SHP"),
  1624. MFCD::Retrieve("EBTN-DN.SHP"));
  1625. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1626. housebtn.Add_Item(HouseTypeClass::As_Reference(h).IniName);
  1627. }
  1628. housebtn.Set_Selected_Index(PlayerPtr->Class->House);
  1629. /*
  1630. ** Base house choice drop down list.
  1631. */
  1632. char basetext[35];
  1633. DropListClass basebtn(BUTTON_BASE, basetext, sizeof(basetext),
  1634. TPF_EFNT|TPF_NOSHADOW,
  1635. D_DIALOG_X+15*RESFACTOR, D_DIALOG_Y+80, 65, 7*10,
  1636. MFCD::Retrieve("EBTN-UP.SHP"),
  1637. MFCD::Retrieve("EBTN-DN.SHP"));
  1638. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1639. basebtn.Add_Item(HouseTypeClass::As_Reference(h).IniName);
  1640. }
  1641. if (Base.House != HOUSE_NONE) {
  1642. basebtn.Set_Selected_Index(Base.House);
  1643. }
  1644. /*
  1645. ** Opening scenario theme.
  1646. */
  1647. char themetext[65];
  1648. DropListClass themebtn(BUTTON_THEME, themetext, sizeof(themetext),
  1649. TPF_EFNT|TPF_NOSHADOW,
  1650. basebtn.X+basebtn.Width+15*RESFACTOR, basebtn.Y, 85, 7*10,
  1651. MFCD::Retrieve("EBTN-UP.SHP"),
  1652. MFCD::Retrieve("EBTN-DN.SHP"));
  1653. themebtn.Add_Item("<none>");
  1654. for (ThemeType th = THEME_FIRST; th < THEME_COUNT; th++) {
  1655. themebtn.Add_Item(Theme.Full_Name(th));
  1656. }
  1657. if (Scen.TransitTheme != THEME_NONE) {
  1658. themebtn.Set_Selected_Index(Scen.TransitTheme+1);
  1659. } else {
  1660. themebtn.Set_Selected_Index(0);
  1661. }
  1662. /*
  1663. ** Build level (technology).
  1664. */
  1665. SliderClass techlevel(BUTTON_TECH, housebtn.X+housebtn.Width+15, housebtn.Y, 100, 8);
  1666. techlevel.Set_Maximum(16);
  1667. char statictechbuff[15];
  1668. StaticButtonClass techstatic(0, "999", TPF_EFNT|TPF_NOSHADOW, techlevel.X+techlevel.Width-20, techlevel.Y-7);
  1669. /*
  1670. ** Starting credits.
  1671. */
  1672. SliderClass creditbtn(BUTTON_CREDITS, housebtn.X+housebtn.Width+15, techlevel.Y+20, 100, 8);
  1673. creditbtn.Set_Maximum(201);
  1674. char staticcreditbuff[15];
  1675. StaticButtonClass creditstatic(0, "999999999", TPF_EFNT|TPF_NOSHADOW, creditbtn.X+creditbtn.Width-50, creditbtn.Y-7);
  1676. /*
  1677. ** Maximum unit/infantry slider.
  1678. */
  1679. SliderClass maxunit(BUTTON_MAXUNIT, housebtn.X+housebtn.Width+15, creditbtn.Y+20, 100, 8);
  1680. maxunit.Set_Maximum(501);
  1681. char staticmaxunitbuff[15];
  1682. StaticButtonClass maxunitstatic(0, "999999", TPF_EFNT|TPF_NOSHADOW, maxunit.X+maxunit.Width-30, maxunit.Y-7);
  1683. /*
  1684. ** Source of ground delivery reinforcements.
  1685. */
  1686. char sourcetext[25] = "";
  1687. ListClass sourcebtn(BUTTON_SOURCE,
  1688. housebtn.X+housebtn.Width+15, maxunit.Y+20, 100, 7*4,
  1689. TPF_EFNT|TPF_NOSHADOW,
  1690. MFCD::Retrieve("EBTN-UP.SHP"),
  1691. MFCD::Retrieve("EBTN-DN.SHP"));
  1692. for (SourceType source = SOURCE_FIRST; source <= SOURCE_WEST; source++) {
  1693. sourcebtn.Add_Item(SourceName[source]);
  1694. }
  1695. /*
  1696. ** Smartness lider.
  1697. */
  1698. SliderClass smarties(BUTTON_SMARTIES, sourcebtn.X, sourcebtn.Y+sourcebtn.Height+15, 35, 8);
  1699. smarties.Set_Maximum(Rule.MaxIQ+1);
  1700. char staticsmartiesbuff[15];
  1701. StaticButtonClass smartiesstatic(0, "9999", TPF_EFNT|TPF_NOSHADOW, smarties.X+smarties.Width-20, smarties.Y-7);
  1702. /*
  1703. ** List box of who is allied with whom.
  1704. */
  1705. CheckListClass allies(BUTTON_ALLIES,
  1706. techlevel.X+techlevel.Width+5, housebtn.Y, 65, 7*10,
  1707. TPF_EFNT|TPF_NOSHADOW,
  1708. MFCD::Retrieve("EBTN-UP.SHP"),
  1709. MFCD::Retrieve("EBTN-DN.SHP"));
  1710. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1711. allies.Add_Item(HouseTypeClass::As_Reference(h).IniName);
  1712. if (hdata[house].Allies & (1L << h)) {
  1713. allies.Check_Item(h, true);
  1714. }
  1715. }
  1716. allies.Set_Selected_Index(0);
  1717. /*
  1718. ** List box of who the player can control.
  1719. */
  1720. CheckListClass control(BUTTON_CONTROL,
  1721. allies.X+allies.Width+10, housebtn.Y, 65, 7*10,
  1722. TPF_EFNT|TPF_NOSHADOW,
  1723. MFCD::Retrieve("EBTN-UP.SHP"),
  1724. MFCD::Retrieve("EBTN-DN.SHP"));
  1725. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1726. control.Add_Item(HouseTypeClass::As_Reference(h).IniName);
  1727. if (HouseClass::As_Pointer(h)->IsPlayerControl) {
  1728. control.Check_Item(h, true);
  1729. }
  1730. }
  1731. control.Set_Selected_Index(0);
  1732. /*
  1733. ** Create the ubiquitous "ok" and "cancel" buttons.
  1734. */
  1735. TextButtonClass okbtn(BUTTON_OK, TXT_OK, TPF_EBUTTON, D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  1736. TextButtonClass cancelbtn(BUTTON_CANCEL, TXT_CANCEL, TPF_EBUTTON, D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W, D_CANCEL_H);
  1737. /*
  1738. ** Create the list
  1739. */
  1740. commands = &okbtn;
  1741. cancelbtn.Add_Tail(*commands);
  1742. theaterbtn.Add_Tail(*commands);
  1743. themebtn.Add_Tail(*commands);
  1744. housebtn.Add_Tail(*commands);
  1745. techlevel.Add_Tail(*commands);
  1746. techstatic.Add_Tail(*commands);
  1747. sourcebtn.Add_Tail(*commands);
  1748. creditbtn.Add_Tail(*commands);
  1749. creditstatic.Add_Tail(*commands);
  1750. maxunitstatic.Add_Tail(*commands);
  1751. moneytib.Add_Tail(*commands);
  1752. smartiesstatic.Add_Tail(*commands);
  1753. allies.Add_Tail(*commands);
  1754. control.Add_Tail(*commands);
  1755. maxunit.Add_Tail(*commands);
  1756. nospyplane.Add_Tail(*commands);
  1757. skipscore.Add_Tail(*commands);
  1758. nomapsel.Add_Tail(*commands);
  1759. onetime.Add_Tail(*commands);
  1760. inherit.Add_Tail(*commands);
  1761. timercarry.Add_Tail(*commands);
  1762. tanya.Add_Tail(*commands);
  1763. record.Add_Tail(*commands);
  1764. truckcrate.Add_Tail(*commands);
  1765. endofgame.Add_Tail(*commands);
  1766. briefing.Add_Tail(*commands);
  1767. intro.Add_Tail(*commands);
  1768. action.Add_Tail(*commands);
  1769. win.Add_Tail(*commands);
  1770. lose.Add_Tail(*commands);
  1771. basebtn.Add_Tail(*commands);
  1772. smarties.Add_Tail(*commands);
  1773. desc.Add_Tail(*commands);
  1774. /*
  1775. ** Main Processing Loop
  1776. */
  1777. bool housechange = true;
  1778. bool display = true;
  1779. bool process = true;
  1780. bool cancel = false; // true = user cancels
  1781. bool dotext = true; // display the text.
  1782. bool fetch = false; // Fetch data from dialog into tracking structure.
  1783. //Set_Logic_Page(SeenBuff);
  1784. while (process) {
  1785. /*
  1786. ** Invoke game callback
  1787. */
  1788. Call_Back();
  1789. /*
  1790. ** If the house changes, then all the gadgets that reflect the settings of the
  1791. ** house should change as well.
  1792. */
  1793. if (housechange) {
  1794. HouseStaticClass * hstatic = &hdata[newhouse];
  1795. creditbtn.Set_Value(hstatic->InitialCredits/100);
  1796. techlevel.Set_Value(hstatic->TechLevel);
  1797. sourcebtn.Set_Selected_Index(hstatic->Edge);
  1798. maxunit.Set_Value(hstatic->MaxUnit + hstatic->MaxInfantry);
  1799. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1800. allies.Check_Item(h, hstatic->Allies & (1L << h));
  1801. }
  1802. smarties.Set_Value(hstatic->IQ);
  1803. house = newhouse;
  1804. housechange = false;
  1805. display = true;
  1806. }
  1807. /*
  1808. ** Refresh display if needed
  1809. */
  1810. if (display) {
  1811. Hide_Mouse();
  1812. /*
  1813. ** Draw the background
  1814. */
  1815. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  1816. Draw_Caption(TXT_SCENARIO_OPTIONS, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  1817. /*
  1818. ** Display the text that doesn't need drawing except when the entire dialog
  1819. ** needs to be redrawn.
  1820. */
  1821. Fancy_Text_Print("Tech Level =", techlevel.X, techlevel.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1822. Fancy_Text_Print("Credits =", creditbtn.X, creditbtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1823. Fancy_Text_Print("Unit Max =", maxunit.X, maxunit.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1824. Fancy_Text_Print("IQ =", smarties.X, smarties.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1825. Fancy_Text_Print("Prebuild Base:", basebtn.X, basebtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1826. Fancy_Text_Print("Theater:", theaterbtn.X, theaterbtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1827. Fancy_Text_Print("Scenario Name:", desc.X, desc.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1828. Fancy_Text_Print("Country:", housebtn.X, housebtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1829. Fancy_Text_Print("Home Edge:", sourcebtn.X, sourcebtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1830. Fancy_Text_Print("Allies:", allies.X, allies.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1831. Fancy_Text_Print("Plyr Control:", control.X, control.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1832. Fancy_Text_Print("Theme:", themebtn.X, themebtn.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1833. Fancy_Text_Print("Intro:", intro.X, intro.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1834. Fancy_Text_Print("Briefing:", briefing.X, briefing.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1835. Fancy_Text_Print("Action:", action.X, action.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1836. Fancy_Text_Print("Win:", win.X, win.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1837. Fancy_Text_Print("Lose:", lose.X, lose.Y-7, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1838. Fancy_Text_Print("Store scenario?", record.X+10, record.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1839. Fancy_Text_Print("Inherit stored scenario?", inherit.X+10, inherit.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1840. Fancy_Text_Print("Auto evac. Tanya (civilian)?", tanya.X+10, tanya.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1841. Fancy_Text_Print("Last mission of game?", endofgame.X+10, endofgame.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1842. Fancy_Text_Print("Inherit mission timer from last scenario?", timercarry.X+10, timercarry.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1843. Fancy_Text_Print("Disable spy plane?", nospyplane.X+10, nospyplane.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1844. Fancy_Text_Print("Skip the score screen?", skipscore.X+10, skipscore.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1845. Fancy_Text_Print("No map selection (force var 'B')?", nomapsel.X+10, nomapsel.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1846. Fancy_Text_Print("Return to main menu after scenario finishes?", onetime.X+10, onetime.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1847. Fancy_Text_Print("Truck carries wood crate?", truckcrate.X+10, truckcrate.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1848. Fancy_Text_Print("Initial money is transferred to silos?", moneytib.X+10, moneytib.Y, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_EFNT|TPF_NOSHADOW);
  1849. theaterbtn.Collapse();
  1850. themebtn.Collapse();
  1851. intro.Collapse();
  1852. briefing.Collapse();
  1853. action.Collapse();
  1854. win.Collapse();
  1855. lose.Collapse();
  1856. basebtn.Collapse();
  1857. commands->Draw_All(true);
  1858. Show_Mouse();
  1859. display = false;
  1860. dotext = true;
  1861. }
  1862. /*
  1863. ** Display the text of the buttons that could change their text as a
  1864. ** result of slider interaction.
  1865. */
  1866. if (dotext) {
  1867. dotext = false;
  1868. Hide_Mouse();
  1869. sprintf(statictechbuff, "%2d", techlevel.Get_Value());
  1870. techstatic.Set_Text(statictechbuff);
  1871. techstatic.Draw_Me();
  1872. sprintf(staticcreditbuff, "$%-7d", creditbtn.Get_Value() * 100);
  1873. creditstatic.Set_Text(staticcreditbuff);
  1874. creditstatic.Draw_Me();
  1875. sprintf(staticmaxunitbuff, "%4d", maxunit.Get_Value());
  1876. maxunitstatic.Set_Text(staticmaxunitbuff);
  1877. maxunitstatic.Draw_Me();
  1878. sprintf(staticsmartiesbuff, "%2d", smarties.Get_Value());
  1879. smartiesstatic.Set_Text(staticsmartiesbuff);
  1880. smartiesstatic.Draw_Me();
  1881. Show_Mouse();
  1882. }
  1883. /*
  1884. ** Get user input
  1885. */
  1886. KeyNumType input = commands->Input();
  1887. /*
  1888. ** Process input
  1889. */
  1890. switch (input) {
  1891. case BUTTON_ALLIES|KN_BUTTON:
  1892. allies.Check_Item(house, true);
  1893. break;
  1894. case BUTTON_CONTROL|KN_BUTTON:
  1895. control.Check_Item(house, true);
  1896. break;
  1897. case BUTTON_THEME|KN_BUTTON:
  1898. case BUTTON_INTRO|KN_BUTTON:
  1899. case BUTTON_BRIEFING|KN_BUTTON:
  1900. case BUTTON_ACTION|KN_BUTTON:
  1901. case BUTTON_WIN|KN_BUTTON:
  1902. case BUTTON_LOSE|KN_BUTTON:
  1903. case BUTTON_BASE|KN_BUTTON:
  1904. case LIST_THEATER|KN_BUTTON:
  1905. briefing.Collapse();
  1906. action.Collapse();
  1907. win.Collapse();
  1908. themebtn.Collapse();
  1909. intro.Collapse();
  1910. lose.Collapse();
  1911. basebtn.Collapse();
  1912. theaterbtn.Collapse();
  1913. display = true;
  1914. break;
  1915. case BUTTON_SMARTIES|KN_BUTTON:
  1916. case BUTTON_MAXUNIT|KN_BUTTON:
  1917. case BUTTON_CREDITS|KN_BUTTON:
  1918. case BUTTON_TECH|KN_BUTTON:
  1919. briefing.Collapse();
  1920. action.Collapse();
  1921. win.Collapse();
  1922. lose.Collapse();
  1923. basebtn.Collapse();
  1924. themebtn.Collapse();
  1925. theaterbtn.Collapse();
  1926. dotext = true;
  1927. break;
  1928. case BUTTON_HOUSE|KN_BUTTON:
  1929. newhouse = HousesType(housebtn.Current_Index());
  1930. housechange = true;
  1931. briefing.Collapse();
  1932. action.Collapse();
  1933. themebtn.Collapse();
  1934. win.Collapse();
  1935. intro.Collapse();
  1936. lose.Collapse();
  1937. basebtn.Collapse();
  1938. theaterbtn.Collapse();
  1939. fetch = true;
  1940. break;
  1941. case (KN_RETURN):
  1942. case (BUTTON_OK | KN_BUTTON):
  1943. cancel = false;
  1944. process = false;
  1945. fetch = true;
  1946. break;
  1947. case (KN_ESC):
  1948. case (BUTTON_CANCEL | KN_BUTTON):
  1949. cancel = true;
  1950. process = false;
  1951. break;
  1952. default:
  1953. break;
  1954. }
  1955. /*
  1956. ** If the house changes, then all the gadgets that reflect the settings of the
  1957. ** house should change as well.
  1958. */
  1959. if (fetch) {
  1960. fetch = false;
  1961. HouseStaticClass * hstatic = &hdata[house];
  1962. Base.House = HousesType(basebtn.Current_Index());
  1963. hstatic->InitialCredits = creditbtn.Get_Value() * 100;
  1964. hstatic->Edge = SourceType(sourcebtn.Current_Index());
  1965. hstatic->TechLevel = techlevel.Get_Value();
  1966. hstatic->MaxUnit = maxunit.Get_Value()/2;
  1967. hstatic->MaxInfantry = maxunit.Get_Value()/2;
  1968. hstatic->IQ = smarties.Get_Value();
  1969. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1970. if (allies.Is_Checked(h)) {
  1971. hstatic->Allies |= (1L << h);
  1972. } else {
  1973. hstatic->Allies &= ~(1L << h);
  1974. }
  1975. }
  1976. }
  1977. }
  1978. /*
  1979. ** Redraw the map
  1980. */
  1981. HidPage.Clear();
  1982. Flag_To_Redraw(true);
  1983. Render();
  1984. /*
  1985. ** If cancel, just return
  1986. */
  1987. if (cancel) {
  1988. return(-1);
  1989. }
  1990. /*
  1991. ** Copy the dialog data back into the appropriate game data locations.
  1992. */
  1993. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1994. HouseClass * hptr = HouseClass::As_Pointer(h);
  1995. if (hptr != NULL) {
  1996. hptr->Control = hdata[h];
  1997. hptr->Allies = hdata[h].Allies;
  1998. if (control.Is_Checked(h)) {
  1999. hptr->IsPlayerControl = true;
  2000. } else {
  2001. hptr->IsPlayerControl = false;
  2002. }
  2003. }
  2004. }
  2005. PlayerPtr->IsPlayerControl = true;
  2006. strncpy(Scen.Description, desc.Get_Text(), sizeof(Scen.Description));
  2007. Scen.Description[sizeof(Scen.Description)-1] = '\0';
  2008. Scen.IntroMovie = VQType(intro.Current_Index()-1);
  2009. Scen.BriefMovie = VQType(briefing.Current_Index()-1);
  2010. Scen.ActionMovie = VQType(action.Current_Index()-1);
  2011. Scen.WinMovie = VQType(win.Current_Index()-1);
  2012. Scen.LoseMovie = VQType(lose.Current_Index()-1);
  2013. Scen.IsToInherit = inherit.IsOn;
  2014. Scen.IsToCarryOver = record.IsOn;
  2015. Scen.IsTanyaEvac = tanya.IsOn;
  2016. Scen.IsEndOfGame = endofgame.IsOn;
  2017. Scen.IsInheritTimer = timercarry.IsOn;
  2018. Scen.IsNoSpyPlane = nospyplane.IsOn;
  2019. Scen.IsSkipScore = skipscore.IsOn;
  2020. Scen.IsNoMapSel = nomapsel.IsOn;
  2021. Scen.IsOneTimeOnly = onetime.IsOn;
  2022. Scen.IsTruckCrate = truckcrate.IsOn;
  2023. Scen.IsMoneyTiberium = moneytib.IsOn;
  2024. Scen.TransitTheme = ThemeType(themebtn.Current_Index()-1);
  2025. /*
  2026. ** Change the theater:
  2027. ** - 1st set the Theater global
  2028. ** - scan all cells to check their TType for compatibility with the new
  2029. ** theater; if not compatible, set TType to TEMPLATE_NONE & TIcon to 0
  2030. ** - Then, re-initialize the TypeClasses for the new Theater
  2031. */
  2032. TheaterType theater = TheaterType(theaterbtn.Current_Index());
  2033. if (theater != orig_theater) {
  2034. unsigned char theater_mask; // template/terrain mask
  2035. TerrainClass * terrain; // cell's terrain pointer
  2036. /*
  2037. ** Loop through all cells
  2038. */
  2039. for (CELL i = 0; i < MAP_CELL_TOTAL; i++) {
  2040. /*
  2041. ** If this cell has a template icon & that template isn't compatible
  2042. ** with this theater, set the icon to NONE
  2043. */
  2044. if ((*this)[i].TType != TEMPLATE_NONE) {
  2045. theater_mask = TemplateTypeClass::As_Reference((*this)[i].TType).Theater;
  2046. if ( (theater_mask & (1 << theater))==0) {
  2047. (*this)[i].TType = TEMPLATE_NONE;
  2048. (*this)[i].TIcon = 0;
  2049. }
  2050. }
  2051. /*
  2052. ** If this cell has terrain in it, and that terrain isn't compatible
  2053. ** with this theater, delete the terrain object.
  2054. */
  2055. terrain = (*this)[i].Cell_Terrain();
  2056. if (terrain != NULL) {
  2057. theater_mask = terrain->Class->Theater;
  2058. if ( (theater_mask & (1<<theater))==0) {
  2059. delete terrain;
  2060. }
  2061. }
  2062. }
  2063. /*
  2064. ** Remove any old theater specific uncompressed shapes
  2065. */
  2066. #ifdef WIN32
  2067. Reset_Theater_Shapes();
  2068. #endif //WIN32
  2069. /*
  2070. ** Force shapes to reload
  2071. */
  2072. LastTheater = THEATER_NONE;
  2073. /*
  2074. ** Re-init the object Type Classes for this theater
  2075. */
  2076. Init_Theater(theater);
  2077. TerrainTypeClass::Init(theater);
  2078. TemplateTypeClass::Init(theater);
  2079. OverlayTypeClass::Init(theater);
  2080. UnitTypeClass::Init(theater);
  2081. InfantryTypeClass::Init(theater);
  2082. BuildingTypeClass::Init(theater);
  2083. BulletTypeClass::Init(theater);
  2084. AnimTypeClass::Init(theater);
  2085. AircraftTypeClass::Init(theater);
  2086. VesselTypeClass::Init(theater);
  2087. SmudgeTypeClass::Init(theater);
  2088. // LastTheater = theater;
  2089. }
  2090. return(0);
  2091. }
  2092. /***************************************************************************
  2093. * Handle_Triggers -- processes the trigger dialogs *
  2094. * *
  2095. * INPUT: *
  2096. * none. *
  2097. * *
  2098. * OUTPUT: *
  2099. * none. *
  2100. * *
  2101. * WARNINGS: *
  2102. * none. *
  2103. * *
  2104. * HISTORY: *
  2105. * 11/29/1994 BR : Created. *
  2106. *=========================================================================*/
  2107. void MapEditClass::Handle_Triggers(void)
  2108. {
  2109. int rc;
  2110. /*
  2111. ** Trigger dialog processing loop:
  2112. ** - Invoke the trigger selection dialog. If a trigger's selected, break
  2113. ** & return
  2114. ** - If user wants to edit the current trigger, do so
  2115. ** - If user wants to create new trigger, new a TriggerClass & edit it
  2116. ** - If user wants to delete trigger, delete the current trigger
  2117. ** - Keep looping until 'OK'
  2118. */
  2119. while (1) {
  2120. /*
  2121. ** Select trigger
  2122. */
  2123. rc = Select_Trigger();
  2124. /*
  2125. ** 'OK'; break
  2126. */
  2127. if (rc==0) break;
  2128. /*
  2129. ** 'Edit'
  2130. */
  2131. if (rc==1 && CurTrigger) {
  2132. if (CurTrigger->Edit()) {
  2133. Changed = 1;
  2134. }
  2135. HidPage.Clear();
  2136. Flag_To_Redraw(true);
  2137. Render();
  2138. }
  2139. /*
  2140. ** 'New'
  2141. */
  2142. if (rc==2) {
  2143. /*
  2144. ** Create a new trigger
  2145. */
  2146. CurTrigger = new TriggerTypeClass();
  2147. if (CurTrigger) {
  2148. /*
  2149. ** delete it if user cancels
  2150. */
  2151. if (!CurTrigger->Edit()) {
  2152. delete CurTrigger;
  2153. CurTrigger = NULL;
  2154. } else {
  2155. Changed = 1;
  2156. }
  2157. HidPage.Clear();
  2158. Flag_To_Redraw(true);
  2159. Render();
  2160. } else {
  2161. /*
  2162. ** Unable to create; issue warning
  2163. */
  2164. WWMessageBox().Process("No more triggers available.");
  2165. HidPage.Clear();
  2166. Flag_To_Redraw(true);
  2167. Render();
  2168. }
  2169. }
  2170. /*
  2171. ** 'Delete'
  2172. */
  2173. if (rc==3) {
  2174. if (CurTrigger) {
  2175. Detach_This_From_All(CurTrigger->As_Target(), true);
  2176. delete CurTrigger;
  2177. //CurTrigger->Remove();
  2178. CurTrigger = NULL;
  2179. Changed = 1;
  2180. }
  2181. }
  2182. }
  2183. /*
  2184. ** Let the CurTrigger global exist if the trigger can be placed on the
  2185. ** ground or on a game object.
  2186. */
  2187. if (CurTrigger && !(CurTrigger->Attaches_To() & (ATTACH_OBJECT|ATTACH_CELL))) {
  2188. CurTrigger = NULL;
  2189. }
  2190. }
  2191. /***************************************************************************
  2192. * MapEditClass::Select_Trigger -- lets user select a trigger *
  2193. * *
  2194. * CurTrigger can be NULL when this function is called. *
  2195. * *
  2196. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  2197. * ³ Triggers ³ *
  2198. * ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ³ *
  2199. * ³ ³ Name Event Action House Team ³³ ³ *
  2200. * ³ ³ Name Event Action House Team ÃÄ´ ³ *
  2201. * ³ ³ Name Event Action House Team ³ ³ ³ *
  2202. * ³ ³ Name Event Action House Team ³ ³ ³ *
  2203. * ³ ³ ³ ³ ³ *
  2204. * ³ ³ ³ ³ ³ *
  2205. * ³ ³ ÃÄ´ ³ *
  2206. * ³ ³ ³³ ³ *
  2207. * ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ³ *
  2208. * ³ ³ *
  2209. * ³ [Edit] [New] [Delete] [OK] ³ *
  2210. * ³ ³ *
  2211. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  2212. * *
  2213. * INPUT: *
  2214. * none. *
  2215. * *
  2216. * OUTPUT: *
  2217. * 0 = OK, 1 = Edit, 2 = New, 3 = Delete *
  2218. * *
  2219. * WARNINGS: *
  2220. * Uses HIDBUFF. *
  2221. * *
  2222. * HISTORY: *
  2223. * 11/29/1994 BR : Created. *
  2224. * 05/07/1996 JLB : Streamlined and sort trigger list. *
  2225. *=========================================================================*/
  2226. int MapEditClass::Select_Trigger(void)
  2227. {
  2228. /*
  2229. ** Dialog & button dimensions
  2230. */
  2231. enum {
  2232. D_DIALOG_W = 400,
  2233. D_DIALOG_H = 250,
  2234. D_DIALOG_X = 0,
  2235. D_DIALOG_Y = 0,
  2236. D_TXT8_H = 11,
  2237. D_MARGIN = 35,
  2238. D_LIST_W = (D_DIALOG_W-(D_MARGIN*2))-10,
  2239. D_LIST_H = D_DIALOG_H-70,
  2240. D_LIST_X = D_DIALOG_X + (D_DIALOG_W-D_LIST_W)/2,
  2241. D_LIST_Y = D_DIALOG_Y + 25,
  2242. BUTTON_W = 45,
  2243. BUTTON_H = 9,
  2244. D_EDIT_W = BUTTON_W,
  2245. D_EDIT_H = BUTTON_H,
  2246. D_EDIT_X = D_DIALOG_X + D_DIALOG_W - (((D_EDIT_W+10)*4)+25),
  2247. D_EDIT_Y = D_DIALOG_Y + D_DIALOG_H - 20 - D_EDIT_H,
  2248. D_NEW_W = BUTTON_W,
  2249. D_NEW_H = BUTTON_H,
  2250. D_NEW_X = D_EDIT_X + D_EDIT_W + 10,
  2251. D_NEW_Y = D_DIALOG_Y + D_DIALOG_H - 20 - D_NEW_H,
  2252. D_DELETE_W = BUTTON_W,
  2253. D_DELETE_H = BUTTON_H,
  2254. D_DELETE_X = D_NEW_X + D_NEW_W + 10,
  2255. D_DELETE_Y = D_DIALOG_Y + D_DIALOG_H - 20 - D_DELETE_H,
  2256. D_OK_W = BUTTON_W,
  2257. D_OK_H = BUTTON_H,
  2258. D_OK_X = D_DELETE_X + D_DELETE_W + 10,
  2259. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - 20 - D_OK_H,
  2260. };
  2261. /*
  2262. ** Button enumerations:
  2263. */
  2264. enum {
  2265. TRIGGER_LIST=100,
  2266. BUTTON_EDIT,
  2267. BUTTON_NEW,
  2268. BUTTON_DELETE,
  2269. BUTTON_OK,
  2270. };
  2271. /*
  2272. ** Dialog variables:
  2273. */
  2274. bool edit_trig = false; // true = user wants to edit
  2275. bool new_trig = false; // true = user wants to new
  2276. bool del_trig = false; // true = user wants to new
  2277. int i; // loop counter
  2278. /*
  2279. ** Buttons
  2280. */
  2281. ControlClass * commands = NULL; // the button list
  2282. TListClass<CCPtr<TriggerTypeClass> > triggerlist(TRIGGER_LIST, D_LIST_X, D_LIST_Y, D_LIST_W, D_LIST_H,
  2283. TPF_EFNT|TPF_NOSHADOW,
  2284. MFCD::Retrieve("EBTN-UP.SHP"),
  2285. MFCD::Retrieve("EBTN-DN.SHP"));
  2286. TextButtonClass editbtn(BUTTON_EDIT, "Edit", TPF_EBUTTON, D_EDIT_X, D_EDIT_Y, D_EDIT_W, D_EDIT_H);
  2287. TextButtonClass newbtn(BUTTON_NEW, "New", TPF_EBUTTON, D_NEW_X, D_NEW_Y, D_NEW_W, D_NEW_H);
  2288. TextButtonClass deletebtn(BUTTON_DELETE, "Delete", TPF_EBUTTON, D_DELETE_X, D_DELETE_Y, D_DELETE_W, D_DELETE_H);
  2289. TextButtonClass okbtn(BUTTON_OK, TXT_OK, TPF_EBUTTON, D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  2290. /*
  2291. ** Initialize
  2292. */
  2293. Set_Logic_Page(SeenBuff);
  2294. /*
  2295. ** Fill in the list box
  2296. */
  2297. for (i = 0; i < TriggerTypes.Count(); i++) {
  2298. triggerlist.Add_Item(TriggerTypes.Ptr(i));
  2299. }
  2300. PNBubble_Sort(&triggerlist[0], triggerlist.Count());
  2301. if (CurTrigger) {
  2302. triggerlist.Set_Selected_Index(CurTrigger);
  2303. } else {
  2304. triggerlist.Set_Selected_Index(0);
  2305. }
  2306. /*
  2307. ** Set CurTrigger if it isn't
  2308. */
  2309. if (TriggerTypes.Count()==0) {
  2310. CurTrigger = NULL;
  2311. } else {
  2312. CurTrigger = triggerlist.Current_Item();
  2313. // if (!CurTrigger) {
  2314. // CurTrigger = &*triggerlist.Current_Item();
  2315. // }
  2316. }
  2317. /*
  2318. ** Create the list
  2319. */
  2320. commands = &triggerlist;
  2321. editbtn.Add_Tail(*commands);
  2322. newbtn.Add_Tail(*commands);
  2323. deletebtn.Add_Tail(*commands);
  2324. okbtn.Add_Tail(*commands);
  2325. /*
  2326. ** Main Processing Loop
  2327. */
  2328. bool display = true;
  2329. bool process = true;
  2330. while (process) {
  2331. /*
  2332. ** Invoke game callback
  2333. */
  2334. Call_Back();
  2335. /*
  2336. ** Refresh display if requested.
  2337. */
  2338. if (display /*&& LogicPage->Lock()*/) {
  2339. Hide_Mouse();
  2340. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  2341. Draw_Caption(TXT_TRIGGER_EDITOR, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  2342. commands->Flag_List_To_Redraw();
  2343. commands->Draw_All();
  2344. Show_Mouse();
  2345. display = false;
  2346. // LogicPage->Unlock();
  2347. }
  2348. /*
  2349. ** Get user input
  2350. */
  2351. KeyNumType input = commands->Input();
  2352. /*
  2353. ** Process input
  2354. */
  2355. switch (input) {
  2356. case (TRIGGER_LIST | KN_BUTTON):
  2357. CurTrigger = &*triggerlist.Current_Item();
  2358. // CurTrigger = (TriggerTypeClass *)&*triggerlist.Current_Item();
  2359. break;
  2360. case (BUTTON_EDIT | KN_BUTTON):
  2361. if (CurTrigger) { // only allow if there's one selected
  2362. process = false;
  2363. edit_trig = true;
  2364. }
  2365. break;
  2366. case (BUTTON_NEW | KN_BUTTON):
  2367. process = false;
  2368. new_trig = true;
  2369. break;
  2370. case (BUTTON_DELETE | KN_BUTTON):
  2371. process = false;
  2372. del_trig = true;
  2373. break;
  2374. case (KN_RETURN):
  2375. case (BUTTON_OK | KN_BUTTON):
  2376. process = false;
  2377. break;
  2378. }
  2379. }
  2380. /*
  2381. ** Redraw the display
  2382. */
  2383. HidPage.Clear();
  2384. Flag_To_Redraw(true);
  2385. Render();
  2386. if (edit_trig) return(1);
  2387. if (new_trig) return(2);
  2388. if (del_trig) return(3);
  2389. return(0);
  2390. }
  2391. #endif