MAPEDDLG.CPP 81 KB

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