MAPEDIT.CPP 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/MAPEDIT.CPP 2 3/13/97 2:05p Steve_tall $ */
  15. /***************************************************************************
  16. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  17. ***************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : MAPEDIT.CPP *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : October 20, 1994 *
  26. * *
  27. * Last Update : February 2, 1995 [BR] *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * Map Editor overloaded routines & utility routines *
  31. *-------------------------------------------------------------------------*
  32. * Map Editor modules: *
  33. * (Yes, they're all one huge class.) *
  34. * mapedit.cpp: overloaded routines, utility routines *
  35. * mapeddlg.cpp: map editor dialogs, most of the main menu options *
  36. * mapedplc.cpp: object-placing routines *
  37. * mapedsel.cpp: object-selection & manipulation routines *
  38. * mapedtm.cpp: team-editing routines *
  39. *-------------------------------------------------------------------------*
  40. * Functions: *
  41. * MapEditClass::AI -- The map editor's main logic *
  42. * MapEditClass::Read_INI -- overloaded Read_INI function *
  43. * MapEditClass::AI_Menu -- menu of AI options *
  44. * MapEditClass::Add_To_List -- adds a TypeClass to the chooseable list *
  45. * MapEditClass::Clear_List -- clears the internal chooseable object list*
  46. * MapEditClass::Cycle_House -- finds next valid house for object type *
  47. * MapEditClass::Draw_It -- overloaded Redraw routine *
  48. * MapEditClass::Fatal -- exits with error message *
  49. * MapEditClass::Main_Menu -- main menu processor for map editor *
  50. * MapEditClass::MapEditClass -- class constructor *
  51. * MapEditClass::Mouse_Moved -- checks for mouse motion *
  52. * MapEditClass::One_Time -- one-time initialization *
  53. * MapEditClass::Verify_House -- sees if given house can own given obj *
  54. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  55. #include "function.h"
  56. #ifdef SCENARIO_EDITOR
  57. /*
  58. ** Array of all missions supported by the map editor
  59. */
  60. MissionType MapEditClass::MapEditMissions[] = {
  61. MISSION_GUARD,
  62. MISSION_STICKY,
  63. MISSION_HARMLESS,
  64. MISSION_HARVEST,
  65. MISSION_GUARD_AREA,
  66. MISSION_RETURN,
  67. MISSION_AMBUSH,
  68. MISSION_HUNT,
  69. MISSION_SLEEP,
  70. };
  71. #define NUM_EDIT_MISSIONS (sizeof(MapEditClass::MapEditMissions) / sizeof(MapEditClass::MapEditMissions[0]))
  72. /*
  73. ** For menu processing
  74. */
  75. extern int UnknownKey; // in menus.cpp
  76. char MapEditClass::HealthBuf[20];
  77. /***************************************************************************
  78. * MapEditClass::MapEditClass -- class constructor *
  79. * *
  80. * INPUT: *
  81. * none. *
  82. * *
  83. * OUTPUT: *
  84. * none. *
  85. * *
  86. * WARNINGS: *
  87. * none. *
  88. * *
  89. * HISTORY: *
  90. * 10/20/1994 BR : Created. *
  91. *=========================================================================*/
  92. MapEditClass::MapEditClass(void)
  93. {
  94. /*
  95. ** Init data members.
  96. */
  97. // ScenVar = SCEN_VAR_A;
  98. ObjCount = 0;
  99. LastChoice = 0;
  100. LastHouse = HOUSE_GOOD;
  101. GrabbedObject = 0;
  102. for (int i=0; i < NUM_EDIT_CLASSES; i++) {
  103. NumType[i] = 0;
  104. TypeOffset[i] = 0;
  105. }
  106. Scen.Waypoint[WAYPT_HOME] = 0;
  107. CurrentCell = 0;
  108. CurTeam = NULL;
  109. CurTrigger = NULL;
  110. Changed = 0;
  111. LMouseDown = 0;
  112. BaseBuilding = false;
  113. // BasePercent = 100;
  114. }
  115. /***************************************************************************
  116. * MapEditClass::One_Time -- one-time initialization *
  117. * *
  118. * INPUT: *
  119. * none. *
  120. * *
  121. * OUTPUT: *
  122. * none. *
  123. * *
  124. * WARNINGS: *
  125. * none. *
  126. * *
  127. * HISTORY: *
  128. * 02/02/1995 BR : Created. *
  129. *=========================================================================*/
  130. void MapEditClass::One_Time(void)
  131. {
  132. MouseClass::One_Time();
  133. /*
  134. ** The map: a single large "button"
  135. */
  136. #ifdef WIN32
  137. MapArea = new ControlClass(MAP_AREA, 0, 8, 640-8, 400-8, GadgetClass::LEFTPRESS | GadgetClass::LEFTRELEASE, false);
  138. #else
  139. MapArea = new ControlClass(MAP_AREA, 0, 8, 312, 192, GadgetClass::LEFTPRESS | GadgetClass::LEFTRELEASE, false);
  140. #endif
  141. /*
  142. ** House buttons
  143. */
  144. HouseList = new ListClass(POPUP_HOUSELIST, POPUP_HOUSE_X, POPUP_HOUSE_Y, POPUP_HOUSE_W, POPUP_HOUSE_H,
  145. TPF_EFNT|TPF_NOSHADOW,
  146. MFCD::Retrieve("EBTN-UP.SHP"),
  147. MFCD::Retrieve("EBTN-DN.SHP"));
  148. for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
  149. HouseList->Add_Item(HouseTypeClass::As_Reference(house).IniName);
  150. }
  151. /*
  152. ** The mission list box
  153. */
  154. MissionList = new ListClass(POPUP_MISSIONLIST,
  155. POPUP_MISSION_X, POPUP_MISSION_Y, POPUP_MISSION_W, POPUP_MISSION_H,
  156. TPF_EFNT|TPF_NOSHADOW,
  157. MFCD::Retrieve("EBTN-UP.SHP"),
  158. MFCD::Retrieve("EBTN-DN.SHP"));
  159. for (int i = 0; i < NUM_EDIT_MISSIONS; i++) {
  160. MissionList->Add_Item(MissionClass::Mission_Name(MapEditMissions[i]));
  161. }
  162. /*
  163. ** The health bar
  164. */
  165. HealthGauge = new TriColorGaugeClass(POPUP_HEALTHGAUGE,
  166. POPUP_HEALTH_X, POPUP_HEALTH_Y, POPUP_HEALTH_W, POPUP_HEALTH_H);
  167. HealthGauge->Use_Thumb(true);
  168. HealthGauge->Set_Maximum(0x100);
  169. HealthGauge->Set_Red_Limit(0x3f - 1);
  170. HealthGauge->Set_Yellow_Limit(0x7f - 1);
  171. /*
  172. ** The health text label
  173. */
  174. HealthBuf[0] = 0;
  175. HealthText = new TextLabelClass(HealthBuf,
  176. POPUP_HEALTH_X + POPUP_HEALTH_W / 2,
  177. POPUP_HEALTH_Y + POPUP_HEALTH_H + 1,
  178. GadgetClass::Get_Color_Scheme(),
  179. TPF_CENTER | TPF_FULLSHADOW | TPF_EFNT);
  180. /*
  181. ** Building attribute buttons.
  182. */
  183. Sellable = new TextButtonClass(POPUP_SELLABLE, TXT_SELLABLE, TPF_EBUTTON, 320-65, 200-25, 60);
  184. Rebuildable = new TextButtonClass(POPUP_REBUILDABLE, TXT_REBUILD, TPF_EBUTTON, 320-65, 200-15, 60);
  185. /*
  186. ** The facing dial
  187. */
  188. FacingDial = new Dial8Class(POPUP_FACINGDIAL, POPUP_FACEBOX_X,
  189. POPUP_FACEBOX_Y, POPUP_FACEBOX_W, POPUP_FACEBOX_H, (DirType)0);
  190. /*
  191. ** The base percent-built slider & its label
  192. */
  193. BaseGauge = new GaugeClass(POPUP_BASEPERCENT, POPUP_BASE_X, POPUP_BASE_Y, POPUP_BASE_W, POPUP_BASE_H);
  194. BaseLabel = new TextLabelClass ("Base:", POPUP_BASE_X - 3, POPUP_BASE_Y, GadgetClass::Get_Color_Scheme(),
  195. TPF_RIGHT | TPF_NOSHADOW | TPF_EFNT);
  196. BaseGauge->Set_Maximum(100);
  197. BaseGauge->Set_Value(Scen.Percent);
  198. }
  199. /***********************************************************************************************
  200. * MapeditClass::Init_IO -- Reinitializes the radar map at scenario start. *
  201. * *
  202. * INPUT: none *
  203. * *
  204. * OUTPUT: none *
  205. * *
  206. * WARNINGS: none *
  207. * *
  208. * HISTORY: *
  209. * 12/22/1994 JLB : Created. *
  210. *=============================================================================================*/
  211. void MapEditClass::Init_IO(void)
  212. {
  213. /*
  214. ** For normal game mode, jump to the parent's Init routine.
  215. */
  216. if (!Debug_Map) {
  217. MouseClass::Init_IO();
  218. } else {
  219. /*
  220. ** For editor mode, add the map area to the button input list
  221. */
  222. Buttons = 0;
  223. Add_A_Button(*BaseGauge);
  224. Add_A_Button(*BaseLabel);
  225. Add_A_Button(*MapArea);
  226. }
  227. }
  228. /***************************************************************************
  229. * MapEditClass::Clear_List -- clears the internal chooseable object list *
  230. * *
  231. * INPUT: *
  232. * none. *
  233. * *
  234. * OUTPUT: *
  235. * none. *
  236. * *
  237. * WARNINGS: *
  238. * none. *
  239. * *
  240. * HISTORY: *
  241. * 10/20/1994 BR : Created. *
  242. *=========================================================================*/
  243. void MapEditClass::Clear_List(void)
  244. {
  245. /*
  246. ** Set # object type ptrs to 0, set NumType for each type to 0
  247. */
  248. ObjCount = 0;
  249. for (int i = 0; i < NUM_EDIT_CLASSES; i++) {
  250. NumType[i] = 0;
  251. }
  252. }
  253. /***************************************************************************
  254. * MapEditClass::Add_To_List -- adds a TypeClass to the chooseable list *
  255. * *
  256. * Use this routine to add an object to the game object selection list. *
  257. * This list is used by the Add_Object function. All items located in the *
  258. * list will appear and be chooseable by that function. Make sure to *
  259. * clear the list before adding a sequence of items to it. Clearing *
  260. * the list is accomplished by the Clear_List() function. *
  261. * *
  262. * INPUT: *
  263. * object ptr to ObjectTypeClass to add *
  264. * *
  265. * OUTPUT: *
  266. * bool: was the object added to the list? A failure could occur if *
  267. * NULL were passed in or the list is full. *
  268. * *
  269. * WARNINGS: *
  270. * none. *
  271. * *
  272. * HISTORY: *
  273. * 06/04/1994 JLB : Created. *
  274. *=========================================================================*/
  275. bool MapEditClass::Add_To_List(ObjectTypeClass const * object)
  276. {
  277. /*
  278. ** Add the object if there's room.
  279. */
  280. if (object && ObjCount < MAX_EDIT_OBJECTS) {
  281. Objects[ObjCount++] = object;
  282. /*
  283. ** Update type counters.
  284. */
  285. switch (object->What_Am_I()) {
  286. case RTTI_TEMPLATETYPE:
  287. NumType[0]++;
  288. break;
  289. case RTTI_OVERLAYTYPE:
  290. NumType[1]++;
  291. break;
  292. case RTTI_SMUDGETYPE:
  293. NumType[2]++;
  294. break;
  295. case RTTI_TERRAINTYPE:
  296. NumType[3]++;
  297. break;
  298. case RTTI_UNITTYPE:
  299. NumType[4]++;
  300. break;
  301. case RTTI_INFANTRYTYPE:
  302. NumType[5]++;
  303. break;
  304. case RTTI_VESSELTYPE:
  305. NumType[6]++;
  306. break;
  307. case RTTI_BUILDINGTYPE:
  308. NumType[7]++;
  309. break;
  310. case RTTI_AIRCRAFTTYPE:
  311. NumType[8]++;
  312. break;
  313. }
  314. return(true);
  315. }
  316. return(false);
  317. }
  318. /***************************************************************************
  319. * MapEditClass::AI -- The map editor's main logic *
  320. * *
  321. * This routine overloads the parent's (DisplayClass) AI function. *
  322. * It checks for any input specific to map editing, and calls the parent *
  323. * AI routine to handle scrolling and other mainstream map stuff. *
  324. * *
  325. * If this detects one of its special input keys, it sets 'input' to 0 *
  326. * before calling the parent AI routine; this prevents input conflict. *
  327. * *
  328. * SUPPORTED INPUT: *
  329. * General: *
  330. * F2/RMOUSE: main menu *
  331. * F6: toggles show-passable mode *
  332. * HOME: go to the Home Cell (scenario's start position)*
  333. * SHIFT-HOME: set the Home Cell to the current TacticalCell*
  334. * ESC: exits to DOS *
  335. * Object Placement: *
  336. * INSERT: go into placement mode *
  337. * ESC: exit placement mode *
  338. * LEFT/RIGHT: prev/next placement object *
  339. * PGUP/PGDN: prev/next placement category *
  340. * HOME: 1st placement object (clear template) *
  341. * h/H: toggle house of placement object *
  342. * LMOUSE: place the placement object *
  343. * MOUSE MOTION: "paint" with the placement object *
  344. * Object selection: *
  345. * LMOUSE: select & "grab" current object *
  346. * If no object is present where the mouse is *
  347. * clicked, the current object is de-selected *
  348. * If the same object is clicked on, it stays *
  349. * selected. Also displays the object-editing *
  350. * gadgets. *
  351. * LMOUSE RLSE: release currently-grabbed object *
  352. * MOUSE MOTION: if an object is grabbed, moves the object *
  353. * SHIFT|ALT|ARROW: moves object in that direction *
  354. * DELETE deletes currently-selected object *
  355. * Object-editing controls: *
  356. * POPUP_GDI: makes GDI the owner of this object *
  357. * POPUP_NOD: makes NOD the owner of this object *
  358. * POPUP_MISSIONLIST: sets that mission for this object *
  359. * POPUP_HEALTHGAUGE: sets that health value for this object *
  360. * POPUP_FACINGDIAL: sets the object's facing *
  361. * *
  362. * Changed is set when you: *
  363. * - place an object *
  364. * - move a grabbed object *
  365. * - delete an object *
  366. * - size the map *
  367. * - create a new scenario *
  368. * Changed is cleared when you: *
  369. * - Save the scenario *
  370. * - Load a scenario *
  371. * - Play the scenario *
  372. * *
  373. * INPUT: *
  374. * input KN_ value, 0 if none *
  375. * *
  376. * OUTPUT: *
  377. * none. *
  378. * *
  379. * WARNINGS: *
  380. * none. *
  381. * *
  382. * HISTORY: *
  383. * 10/20/1994 BR : Created. *
  384. *=========================================================================*/
  385. void MapEditClass::AI(KeyNumType & input, int x, int y)
  386. {
  387. int rc;
  388. MissionType mission;
  389. int strength;
  390. CELL cell;
  391. int i;
  392. int found; // for removing a waypoint label
  393. int waypt_idx; // for labelling a waypoint
  394. BaseNodeClass * node; // for removing from an AI Base
  395. HousesType house;
  396. char wayname[4];
  397. /*
  398. ** Trap 'F2' regardless of whether we're in game or editor mode
  399. */
  400. if (Debug_Flag) {
  401. if ((input == KN_F2 && Session.Type == GAME_NORMAL) || input == (KN_F2 | KN_CTRL_BIT)) {
  402. ScenarioInit = 0;
  403. /*
  404. ** If we're in editor mode & Changed is set, prompt for saving changes
  405. */
  406. if (Debug_Map && Changed) {
  407. rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO);
  408. HidPage.Clear();
  409. Flag_To_Redraw(true);
  410. Render();
  411. /*
  412. ** User wants to save
  413. */
  414. if (rc == 0) {
  415. /*
  416. ** If save cancelled, abort game
  417. */
  418. if (Save_Scenario()!=0) {
  419. input = KN_NONE;
  420. } else {
  421. Changed = 0;
  422. Go_Editor(!Debug_Map);
  423. }
  424. } else {
  425. /*
  426. ** User doesn't want to save
  427. */
  428. Go_Editor(!Debug_Map);
  429. }
  430. } else {
  431. /*
  432. ** If we're in game mode, set Changed to 0 (so if we didn't save our
  433. ** changes above, they won't keep coming back to haunt us with continual
  434. ** Save Changes? prompts!)
  435. */
  436. if (!Debug_Map) {
  437. Changed = 0;
  438. }
  439. BaseGauge->Set_Value(Scen.Percent);
  440. Go_Editor(!Debug_Map);
  441. }
  442. }
  443. }
  444. /*
  445. ** For normal game mode, jump to the parent's AI routine.
  446. */
  447. if (!Debug_Map) {
  448. MouseClass::AI(input, x, y);
  449. return;
  450. }
  451. ::Frame++;
  452. /*
  453. ** Do special mouse processing if the mouse is over the map
  454. */
  455. if (Get_Mouse_X() > TacPixelX && Get_Mouse_X() <
  456. TacPixelX + Lepton_To_Pixel(TacLeptonWidth) &&
  457. Get_Mouse_Y() > TacPixelY && Get_Mouse_Y() <
  458. TacPixelY + Lepton_To_Pixel(TacLeptonHeight)) {
  459. /*
  460. ** When the mouse moves over a scrolling edge, ScrollClass changes its
  461. ** shape to the appropriate arrow or NO symbol; it's our job to change it
  462. ** back to normal (or whatever the shape is set to by Set_Default_Mouse())
  463. ** when it re-enters the map area.
  464. */
  465. if (CurTrigger) {
  466. Override_Mouse_Shape(MOUSE_CAN_MOVE);
  467. } else {
  468. Override_Mouse_Shape(MOUSE_NORMAL);
  469. }
  470. }
  471. /*
  472. ** Set 'ZoneCell' to track the mouse cursor around over the map. Do this
  473. ** even if the map is scrolling.
  474. */
  475. if (Get_Mouse_X() >= TacPixelX && Get_Mouse_X() <=
  476. TacPixelX + Lepton_To_Pixel(TacLeptonWidth) &&
  477. Get_Mouse_Y() >= TacPixelY && Get_Mouse_Y() <=
  478. TacPixelY + Lepton_To_Pixel(TacLeptonHeight)) {
  479. cell = Click_Cell_Calc(Get_Mouse_X(), Get_Mouse_Y());
  480. if (cell != -1) {
  481. Set_Cursor_Pos(cell);
  482. if (PendingObject) {
  483. Flag_To_Redraw(true);
  484. }
  485. }
  486. }
  487. /*
  488. ** Check for mouse motion while left button is down.
  489. */
  490. rc = Mouse_Moved();
  491. if (LMouseDown && rc) {
  492. /*
  493. ** "Paint" mode: place current object, and restart placement
  494. */
  495. if (PendingObject) {
  496. Flag_To_Redraw(true);
  497. if (Place_Object() == 0) {
  498. Changed = 1;
  499. Start_Placement();
  500. }
  501. } else {
  502. /*
  503. ** Move the currently-grabbed object
  504. */
  505. if (GrabbedObject) {
  506. GrabbedObject->Mark(MARK_CHANGE);
  507. if (Move_Grabbed_Object() == 0) {
  508. Changed = 1;
  509. }
  510. }
  511. }
  512. }
  513. /*
  514. ** Trap special editing keys; if one is detected, set 'input' to 0 to
  515. ** prevent a conflict with parent's AI().
  516. */
  517. switch (input) {
  518. /*
  519. ** F2/RMOUSE = pop up main menu
  520. */
  521. case KN_RMOUSE:
  522. /*
  523. ** Turn off placement mode
  524. */
  525. if (PendingObject) {
  526. if (BaseBuilding) {
  527. Cancel_Base_Building();
  528. } else {
  529. Cancel_Placement();
  530. }
  531. }
  532. /*
  533. ** Turn off trigger placement mode
  534. */
  535. if (CurTrigger) {
  536. Stop_Trigger_Placement();
  537. }
  538. /*
  539. ** Unselect object & hide popup controls
  540. */
  541. if (CurrentObject.Count()) {
  542. CurrentObject[0]->Unselect();
  543. Popup_Controls();
  544. }
  545. Main_Menu();
  546. input = KN_NONE;
  547. break;
  548. /*
  549. ** F6 = toggle passable/impassable display
  550. */
  551. case KN_F6:
  552. Debug_Passable = (Debug_Passable == false);
  553. HidPage.Clear();
  554. Flag_To_Redraw(true);
  555. input = KN_NONE;
  556. break;
  557. /*
  558. ** INSERT = go into object-placement mode
  559. */
  560. case KN_INSERT:
  561. if (!PendingObject) {
  562. /*
  563. ** Unselect current object, hide popup controls
  564. */
  565. if (CurrentObject.Count()) {
  566. CurrentObject[0]->Unselect();
  567. Popup_Controls();
  568. }
  569. /*
  570. ** Go into placement mode
  571. */
  572. Start_Placement();
  573. }
  574. input = KN_NONE;
  575. break;
  576. /*
  577. ** ESC = exit placement mode, or exit to DOS
  578. */
  579. case KN_ESC:
  580. /*
  581. ** Exit object placement mode
  582. */
  583. if (PendingObject) {
  584. if (BaseBuilding) {
  585. Cancel_Base_Building();
  586. } else {
  587. Cancel_Placement();
  588. }
  589. input = KN_NONE;
  590. break;
  591. } else {
  592. /*
  593. ** Exit trigger placement mode
  594. */
  595. if (CurTrigger) {
  596. Stop_Trigger_Placement();
  597. input = KN_NONE;
  598. break;
  599. } else {
  600. rc = WWMessageBox().Process("Exit Scenario Editor?", TXT_YES, TXT_NO);
  601. HidPage.Clear();
  602. Flag_To_Redraw(true);
  603. Render();
  604. /*
  605. ** User doesn't want to exit; return to editor
  606. */
  607. if (rc==1) {
  608. input = KN_NONE;
  609. break;
  610. }
  611. /*
  612. ** If changed, prompt for saving
  613. */
  614. if (Changed) {
  615. rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO);
  616. HidPage.Clear();
  617. Flag_To_Redraw(true);
  618. Render();
  619. /*
  620. ** User wants to save
  621. */
  622. if (rc == 0) {
  623. /*
  624. ** If save cancelled, abort exit
  625. */
  626. if (Save_Scenario()!=0) {
  627. input = KN_NONE;
  628. break;
  629. } else {
  630. Changed = 0;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. //Prog_End();
  637. Emergency_Exit(0);
  638. break;
  639. /*
  640. ** LEFT = go to previous placement object
  641. */
  642. case KN_LEFT:
  643. if (PendingObject) {
  644. Place_Prev();
  645. }
  646. input = KN_NONE;
  647. break;
  648. /*
  649. ** RIGHT = go to next placement object
  650. */
  651. case KN_RIGHT:
  652. if (PendingObject) {
  653. Place_Next();
  654. }
  655. input = KN_NONE;
  656. break;
  657. /*
  658. ** PGUP = go to previous placement category
  659. */
  660. case KN_PGUP:
  661. if (PendingObject) {
  662. Place_Prev_Category();
  663. }
  664. input = KN_NONE;
  665. break;
  666. /*
  667. ** PGDN = go to next placement category
  668. */
  669. case KN_PGDN:
  670. if (PendingObject) {
  671. Place_Next_Category();
  672. }
  673. input = KN_NONE;
  674. break;
  675. /*
  676. ** HOME = jump to first placement object, or go to Home Cell
  677. */
  678. case KN_HOME:
  679. if (PendingObject) {
  680. Place_Home();
  681. } else {
  682. /*
  683. ** Set map position
  684. */
  685. ScenarioInit++;
  686. Set_Tactical_Position(Scen.Waypoint[WAYPT_HOME]);
  687. ScenarioInit--;
  688. /*
  689. ** Force map to redraw
  690. */
  691. HidPage.Clear();
  692. Flag_To_Redraw(true);
  693. Render();
  694. }
  695. input = KN_NONE;
  696. break;
  697. /*
  698. ** SHIFT-HOME: set new Home Cell position
  699. */
  700. case ((int)KN_HOME | (int)KN_SHIFT_BIT):
  701. if (CurrentCell != 0) {
  702. /*
  703. ** Unflag the old Home Cell, if there are no other waypoints
  704. ** pointing to it
  705. */
  706. cell = Scen.Waypoint[WAYPT_HOME];
  707. if (cell != -1) {
  708. found = 0;
  709. for (i = 0; i < WAYPT_COUNT; i++) {
  710. if (i != WAYPT_HOME && Scen.Waypoint[i]==cell) {
  711. found = 1;
  712. }
  713. }
  714. if (found==0) {
  715. (*this)[cell].IsWaypoint = 0;
  716. Flag_Cell(cell);
  717. }
  718. }
  719. /*
  720. ** Now set the new Home cell
  721. */
  722. // Scen.Waypoint[WAYPT_HOME] = Coord_Cell(TacticalCoord);
  723. // (*this)[TacticalCoord].IsWaypoint = 1;
  724. // Flag_Cell(Coord_Cell(TacticalCoord));
  725. Scen.Waypoint[WAYPT_HOME] = CurrentCell;
  726. (*this)[CurrentCell].IsWaypoint = 1;
  727. Flag_Cell(CurrentCell);
  728. Changed = 1;
  729. input = KN_NONE;
  730. }
  731. break;
  732. /*
  733. ** SHIFT-R: set new Reinforcement Cell position. Don't allow setting
  734. ** the Reinf. Cell to the same as the Home Cell (for display purposes.)
  735. */
  736. case ((int)KN_R | (int)KN_SHIFT_BIT):
  737. if (CurrentCell==0 || CurrentCell==Scen.Waypoint[WAYPT_HOME]) {
  738. break;
  739. }
  740. /*
  741. ** Unflag the old Reinforcement Cell, if there are no other waypoints
  742. ** pointing to it
  743. */
  744. cell = Scen.Waypoint[WAYPT_REINF];
  745. if (cell != -1) {
  746. found = 0;
  747. for (i = 0; i < WAYPT_COUNT; i++) {
  748. if (i != WAYPT_REINF && Scen.Waypoint[i]==cell) {
  749. found = 1;
  750. }
  751. }
  752. if (found==0) {
  753. (*this)[cell].IsWaypoint = 0;
  754. Flag_Cell(cell);
  755. }
  756. }
  757. /*
  758. ** Now set the new Reinforcement cell
  759. */
  760. Scen.Waypoint[WAYPT_REINF] = CurrentCell;
  761. (*this)[CurrentCell].IsWaypoint = 1;
  762. Flag_Cell(CurrentCell);
  763. Changed = 1;
  764. input = KN_NONE;
  765. break;
  766. /*
  767. ** ALT-Letter: Label a waypoint cell
  768. */
  769. case ((int)KN_A | (int)KN_ALT_BIT):
  770. case ((int)KN_B | (int)KN_ALT_BIT):
  771. case ((int)KN_C | (int)KN_ALT_BIT):
  772. case ((int)KN_D | (int)KN_ALT_BIT):
  773. case ((int)KN_E | (int)KN_ALT_BIT):
  774. case ((int)KN_F | (int)KN_ALT_BIT):
  775. case ((int)KN_G | (int)KN_ALT_BIT):
  776. case ((int)KN_H | (int)KN_ALT_BIT):
  777. case ((int)KN_I | (int)KN_ALT_BIT):
  778. case ((int)KN_J | (int)KN_ALT_BIT):
  779. case ((int)KN_K | (int)KN_ALT_BIT):
  780. case ((int)KN_L | (int)KN_ALT_BIT):
  781. case ((int)KN_M | (int)KN_ALT_BIT):
  782. case ((int)KN_N | (int)KN_ALT_BIT):
  783. case ((int)KN_O | (int)KN_ALT_BIT):
  784. case ((int)KN_P | (int)KN_ALT_BIT):
  785. case ((int)KN_Q | (int)KN_ALT_BIT):
  786. case ((int)KN_R | (int)KN_ALT_BIT):
  787. case ((int)KN_S | (int)KN_ALT_BIT):
  788. case ((int)KN_T | (int)KN_ALT_BIT):
  789. case ((int)KN_U | (int)KN_ALT_BIT):
  790. case ((int)KN_V | (int)KN_ALT_BIT):
  791. case ((int)KN_W | (int)KN_ALT_BIT):
  792. case ((int)KN_X | (int)KN_ALT_BIT):
  793. case ((int)KN_Y | (int)KN_ALT_BIT):
  794. case ((int)KN_Z | (int)KN_ALT_BIT):
  795. if (CurrentCell != 0) {
  796. #ifdef WIN32
  797. waypt_idx = (input & ~KN_ALT_BIT) - KN_A;
  798. #else
  799. waypt_idx = KN_To_KA(input & 0x00ff) - KA_a;
  800. #endif
  801. Update_Waypoint(waypt_idx);
  802. }
  803. input = KN_NONE;
  804. break;
  805. /*
  806. ** ALT-. : Designate an extended (2-letter) waypoint name
  807. */
  808. case KN_PERIOD:
  809. case ((int)KN_PERIOD | (int)KN_ALT_BIT):
  810. if (CurrentCell != 0 && Get_Waypoint_Name(wayname)) {
  811. int waynm = 0;
  812. if (strlen(wayname)) {
  813. wayname[0] = toupper(wayname[0]);
  814. wayname[1] = toupper(wayname[1]);
  815. if (wayname[0] >= 'A' && wayname[0] <= 'Z') {
  816. waynm = wayname[0] - 'A';
  817. if (wayname[1] >= 'A' && wayname[1] <= 'Z') {
  818. waynm = (waynm+1)*26 + (wayname[1] - 'A');
  819. }
  820. if (waynm < WAYPT_HOME) Update_Waypoint(waynm);
  821. }
  822. }
  823. }
  824. input = KN_NONE;
  825. break;
  826. #ifdef OBSOLETE
  827. /*
  828. ** ALT-1-4: Designate a cell as a capture-the-flag cell.
  829. */
  830. case ((int)KN_1 | (int)KN_ALT_BIT):
  831. case ((int)KN_2 | (int)KN_ALT_BIT):
  832. case ((int)KN_3 | (int)KN_ALT_BIT):
  833. case ((int)KN_4 | (int)KN_ALT_BIT):
  834. /*
  835. ** If there's a current cell, place the flag & waypoint there.
  836. */
  837. if (CurrentCell != 0) {
  838. waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & 0xff)) - KA_1);
  839. // waypt_idx = (KN_To_KA(input & 0xff) - KA_1);
  840. house = (HousesType)(HOUSE_MULTI1 + waypt_idx);
  841. if (HouseClass::As_Pointer(house)) {
  842. HouseClass::As_Pointer(house)->Flag_Attach(CurrentCell, true);
  843. }
  844. } else {
  845. /*
  846. ** If there's a current object, attach the flag to it and clear the
  847. ** waypoint.
  848. */
  849. if (CurrentObject[0] != 0) {
  850. waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & 0xff)) - KA_1);
  851. house = (HousesType)(HOUSE_MULTI1 + waypt_idx);
  852. if (HouseClass::As_Pointer(house) && CurrentObject[0]->What_Am_I() == RTTI_UNIT) {
  853. HouseClass::As_Pointer(house)->Flag_Attach((UnitClass *)CurrentObject[0], true);
  854. }
  855. }
  856. }
  857. input = KN_NONE;
  858. break;
  859. #endif
  860. /*
  861. ** ALT-Space: Remove a waypoint designation
  862. */
  863. case ((int)KN_SPACE | (int)KN_ALT_BIT):
  864. if (CurrentCell != 0) {
  865. /*
  866. ** Loop through letter waypoints; if this cell is one of them,
  867. ** clear that waypoint.
  868. */
  869. for (i = 0 ; i < WAYPT_HOME; i++) {
  870. if (Scen.Waypoint[i]==CurrentCell)
  871. Scen.Waypoint[i] = -1;
  872. }
  873. /*
  874. ** Loop through flag home values; if this cell is one of them, clear
  875. ** that waypoint.
  876. */
  877. for (i = 0; i < MAX_PLAYERS; i++) {
  878. house = (HousesType)(HOUSE_MULTI1 + i);
  879. if (HouseClass::As_Pointer(house) &&
  880. CurrentCell == HouseClass::As_Pointer(house)->FlagHome)
  881. HouseClass::As_Pointer(house)->Flag_Remove(As_Target(CurrentCell), true);
  882. }
  883. /*
  884. ** If there are no more waypoints on this cell, clear the cell's
  885. ** waypoint designation.
  886. */
  887. if (Scen.Waypoint[WAYPT_HOME]!=CurrentCell &&
  888. Scen.Waypoint[WAYPT_REINF]!=CurrentCell)
  889. (*this)[CurrentCell].IsWaypoint = 0;
  890. Changed = 1;
  891. Flag_Cell(CurrentCell);
  892. }
  893. input = KN_NONE;
  894. break;
  895. /*
  896. ** 'H' = toggle current placement object's house
  897. */
  898. case KN_H:
  899. case ((int)KN_H | (int)KN_SHIFT_BIT):
  900. if (PendingObject) {
  901. Toggle_House();
  902. }
  903. input = KN_NONE;
  904. break;
  905. /*
  906. ** Left-mouse click:
  907. ** Button DOWN:
  908. ** - Toggle LMouseDown
  909. ** - If we're in placement mode, try to place the current object
  910. ** - If success, re-enter placement mode
  911. ** - Otherwise, try to select an object, and "grab" it if there is one
  912. ** - If no object, then select that cell as the "current" cell
  913. ** Button UP:
  914. ** - Toggle LMouseDown
  915. ** - release any grabbed object
  916. */
  917. case ((int)MAP_AREA | (int)KN_BUTTON):
  918. /*
  919. ** Left Button DOWN
  920. */
  921. if (Keyboard->Down(KN_LMOUSE)) {
  922. LMouseDown = 1;
  923. /*
  924. ** Placement mode: place an object
  925. */
  926. if (PendingObject) {
  927. if (Place_Object()==0) {
  928. Changed = 1;
  929. Start_Placement();
  930. }
  931. } else {
  932. /*
  933. ** Place a trigger
  934. */
  935. if (CurTrigger) {
  936. Place_Trigger();
  937. Changed = 1;
  938. } else {
  939. /*
  940. ** Select an object or a cell
  941. ** Check for double-click
  942. */
  943. if (CurrentObject.Count() &&
  944. ((TickCount - LastClickTime) < 15)) {
  945. ; // stub
  946. } else {
  947. /*
  948. ** Single-click: select object
  949. */
  950. if (Select_Object()==0) {
  951. CurrentCell = 0;
  952. Grab_Object();
  953. } else {
  954. /*
  955. ** No object: select the cell
  956. */
  957. CurrentCell = Click_Cell_Calc(Keyboard->MouseQX, Keyboard->MouseQY);
  958. HidPage.Clear();
  959. Flag_To_Redraw(true);
  960. Render();
  961. }
  962. }
  963. }
  964. }
  965. LastClickTime = TickCount();
  966. input = KN_NONE;
  967. } else {
  968. /*
  969. ** Left Button UP
  970. */
  971. LMouseDown = 0;
  972. GrabbedObject = 0;
  973. input = KN_NONE;
  974. }
  975. break;
  976. /*
  977. ** SHIFT-ALT-Arrow: move the current object
  978. */
  979. case (int)KN_UP | (int)KN_ALT_BIT | (int)KN_SHIFT_BIT:
  980. case (int)KN_DOWN | (int)KN_ALT_BIT | (int)KN_SHIFT_BIT:
  981. case (int)KN_LEFT | (int)KN_ALT_BIT | (int)KN_SHIFT_BIT:
  982. case (int)KN_RIGHT | (int)KN_ALT_BIT | (int)KN_SHIFT_BIT:
  983. if (CurrentObject.Count()) {
  984. CurrentObject[0]->Move(KN_To_Facing(input));
  985. Changed = 1;
  986. }
  987. input = KN_NONE;
  988. break;
  989. /*
  990. ** DELETE: delete currently-selected object
  991. */
  992. case KN_DELETE:
  993. /*
  994. ** Delete currently-selected object's trigger, or the object
  995. */
  996. if (CurrentObject.Count()) {
  997. /*
  998. ** Delete trigger
  999. */
  1000. if (CurrentObject[0]->Trigger.Is_Valid()) {
  1001. CurrentObject[0]->Trigger = NULL;
  1002. } else {
  1003. /*
  1004. ** If the current object is part of the AI's Base, remove it
  1005. ** from the Base's Node list.
  1006. */
  1007. if (CurrentObject[0]->What_Am_I()==RTTI_BUILDING &&
  1008. Base.Is_Node((BuildingClass *)CurrentObject[0])) {
  1009. node = Base.Get_Node((BuildingClass *)CurrentObject[0]);
  1010. Base.Nodes.Delete(*node);
  1011. }
  1012. /*
  1013. ** Delete current object
  1014. */
  1015. delete CurrentObject[0];
  1016. /*
  1017. ** Hide the popup controls
  1018. */
  1019. Popup_Controls();
  1020. }
  1021. /*
  1022. ** Force a redraw
  1023. */
  1024. HidPage.Clear();
  1025. Flag_To_Redraw(true);
  1026. Changed = 1;
  1027. } else {
  1028. /*
  1029. ** Remove trigger from current cell
  1030. */
  1031. if (CurrentCell) {
  1032. if ((*this)[CurrentCell].Trigger.Is_Valid()) {
  1033. (*this)[CurrentCell].Trigger = NULL;
  1034. // CellTriggers[CurrentCell] = NULL;
  1035. /*
  1036. ** Force a redraw
  1037. */
  1038. HidPage.Clear();
  1039. Flag_To_Redraw(true);
  1040. Changed = 1;
  1041. }
  1042. }
  1043. }
  1044. input = KN_NONE;
  1045. break;
  1046. /*
  1047. ** TAB: select next object on the map
  1048. */
  1049. case KN_TAB:
  1050. Select_Next();
  1051. input = KN_NONE;
  1052. break;
  1053. /*
  1054. ** Object-Editing button: House Button
  1055. */
  1056. case POPUP_HOUSELIST|KN_BUTTON:
  1057. /*
  1058. ** Determine the house desired by examining the currently
  1059. ** selected index in the house list gadget.
  1060. */
  1061. house = HousesType(((ListClass *)Buttons->Extract_Gadget(POPUP_HOUSELIST))->Current_Index());
  1062. /*
  1063. ** If that house doesn't own this object, try to transfer it
  1064. */
  1065. if (CurrentObject[0]->Owner() != house) {
  1066. if (Change_House(house)) {
  1067. Changed = 1;
  1068. }
  1069. }
  1070. // Set_House_Buttons(CurrentObject[0]->Owner(), Buttons, POPUP_FIRST);
  1071. HidPage.Clear();
  1072. Buttons->Flag_List_To_Redraw();
  1073. Flag_To_Redraw(true);
  1074. input = KN_NONE;
  1075. break;
  1076. // case (POPUP_GDI | KN_BUTTON):
  1077. // case (POPUP_NOD | KN_BUTTON):
  1078. // case (POPUP_NEUTRAL | KN_BUTTON):
  1079. // case (POPUP_MULTI1 | KN_BUTTON):
  1080. // case (POPUP_MULTI2 | KN_BUTTON):
  1081. // case (POPUP_MULTI3 | KN_BUTTON):
  1082. // case (POPUP_MULTI4 | KN_BUTTON):
  1083. //
  1084. // /*
  1085. // ** Convert input value into a house value; assume HOUSE_GOOD is 0
  1086. // */
  1087. // house = (HousesType)( (input & (~KN_BUTTON)) - POPUP_FIRST);
  1088. //
  1089. // /*
  1090. // ** If that house doesn't own this object, try to transfer it
  1091. // */
  1092. // if (CurrentObject[0]->Owner()!=house) {
  1093. // if (Change_House(house)) {
  1094. // Changed = 1;
  1095. // }
  1096. // }
  1097. // Set_House_Buttons(CurrentObject[0]->Owner(), Buttons, POPUP_FIRST);
  1098. // HidPage.Clear();
  1099. // Flag_To_Redraw(true);
  1100. // input = KN_NONE;
  1101. // break;
  1102. case POPUP_SELLABLE|KN_BUTTON:
  1103. if (CurrentObject[0]->What_Am_I() == RTTI_BUILDING) {
  1104. BuildingClass * building = (BuildingClass *)CurrentObject[0];
  1105. if (building->Class->Level != -1) {
  1106. // if (building->Class->IsBuildable) {
  1107. building->IsAllowedToSell = (building->IsAllowedToSell == false);
  1108. building->Mark(MARK_CHANGE);
  1109. }
  1110. if (building->IsAllowedToSell) {
  1111. Sellable->Turn_On();
  1112. } else {
  1113. Sellable->Turn_Off();
  1114. }
  1115. }
  1116. break;
  1117. case POPUP_REBUILDABLE|KN_BUTTON:
  1118. if (CurrentObject[0]->What_Am_I() == RTTI_BUILDING) {
  1119. BuildingClass * building = (BuildingClass *)CurrentObject[0];
  1120. if (building->Class->Level != -1) {
  1121. // if (building->Class->IsBuildable) {
  1122. building->IsToRebuild = (building->IsToRebuild == false);
  1123. building->Mark(MARK_CHANGE);
  1124. }
  1125. if (building->IsToRebuild) {
  1126. Rebuildable->Turn_On();
  1127. } else {
  1128. Rebuildable->Turn_Off();
  1129. }
  1130. }
  1131. break;
  1132. /*
  1133. ** Object-Editing button: Mission
  1134. */
  1135. case (POPUP_MISSIONLIST | KN_BUTTON):
  1136. if (CurrentObject[0]->Is_Techno()) {
  1137. /*
  1138. ** Set new mission
  1139. */
  1140. mission = MapEditMissions[MissionList->Current_Index()];
  1141. if (CurrentObject[0]->Get_Mission() != mission) {
  1142. ((TechnoClass *)CurrentObject[0])->Set_Mission(mission);
  1143. Changed = 1;
  1144. Buttons->Flag_List_To_Redraw();
  1145. Flag_To_Redraw(true);
  1146. }
  1147. }
  1148. input = KN_NONE;
  1149. break;
  1150. /*
  1151. ** Object-Editing button: Health
  1152. */
  1153. case (POPUP_HEALTHGAUGE | KN_BUTTON):
  1154. if (CurrentObject[0]->Is_Techno()) {
  1155. /*
  1156. ** Derive strength from current gauge reading
  1157. */
  1158. strength = CurrentObject[0]->Class_Of().MaxStrength * fixed(HealthGauge->Get_Value(), 256);
  1159. // strength = Fixed_To_Cardinal((unsigned)CurrentObject[0]->Class_Of().MaxStrength, (unsigned)HealthGauge->Get_Value());
  1160. /*
  1161. ** Clip to 1
  1162. */
  1163. if (strength <= 0) {
  1164. strength = 1;
  1165. }
  1166. /*
  1167. ** Set new strength
  1168. */
  1169. if (strength != CurrentObject[0]->Strength) {
  1170. CurrentObject[0]->Strength = strength;
  1171. HidPage.Clear();
  1172. Flag_To_Redraw(true);
  1173. Changed = 1;
  1174. }
  1175. /*
  1176. ** Update text label
  1177. */
  1178. sprintf(HealthBuf, "%d", strength);
  1179. }
  1180. input = KN_NONE;
  1181. break;
  1182. /*
  1183. ** Object-Editing button: Facing
  1184. */
  1185. case (POPUP_FACINGDIAL | KN_BUTTON):
  1186. if (CurrentObject[0]->Is_Techno()) {
  1187. /*
  1188. ** Set new facing
  1189. */
  1190. if (FacingDial->Get_Direction() !=
  1191. ((TechnoClass *)CurrentObject[0])->PrimaryFacing.Get()) {
  1192. /*
  1193. ** Set body's facing
  1194. */
  1195. ((TechnoClass *)CurrentObject[0])->PrimaryFacing.Set(FacingDial->Get_Direction());
  1196. /*
  1197. ** Set turret facing, if there is one
  1198. */
  1199. if (CurrentObject[0]->What_Am_I()==RTTI_UNIT) {
  1200. ((UnitClass *)CurrentObject[0])->SecondaryFacing.Set(FacingDial->Get_Direction());
  1201. }
  1202. HidPage.Clear();
  1203. Flag_To_Redraw(true);
  1204. Changed = 1;
  1205. }
  1206. }
  1207. input = KN_NONE;
  1208. break;
  1209. /*
  1210. ** Object-Editing button: Facing
  1211. */
  1212. case (POPUP_BASEPERCENT | KN_BUTTON):
  1213. if (BaseGauge->Get_Value() != Scen.Percent) {
  1214. Scen.Percent = BaseGauge->Get_Value();
  1215. Build_Base_To(Scen.Percent);
  1216. HidPage.Clear();
  1217. Flag_To_Redraw(true);
  1218. }
  1219. input = KN_NONE;
  1220. break;
  1221. default:
  1222. break;
  1223. }
  1224. /*
  1225. ** Call parent's AI routine
  1226. */
  1227. MouseClass::AI(input, x, y);
  1228. }
  1229. /***************************************************************************
  1230. * MapEditClass::Draw_It -- overloaded Redraw routine *
  1231. * *
  1232. * INPUT: *
  1233. * *
  1234. * OUTPUT: *
  1235. * *
  1236. * WARNINGS: *
  1237. * *
  1238. * HISTORY: *
  1239. * 11/17/1994 BR : Created. *
  1240. *=========================================================================*/
  1241. void MapEditClass::Draw_It(bool forced)
  1242. {
  1243. char const * label;
  1244. char buf[40];
  1245. char const * tptr;
  1246. MouseClass::Draw_It(forced);
  1247. if (!Debug_Map) {
  1248. return;
  1249. }
  1250. /*
  1251. ** Display the total value of all Tiberium on the map.
  1252. */
  1253. Fancy_Text_Print("Tiberium=%ld ", 0, 0, GadgetClass::Get_Color_Scheme(),
  1254. BLACK, TPF_EFNT | TPF_NOSHADOW, TotalValue);
  1255. /*
  1256. ** If there are no object controls displayed, just invoke parent's Redraw
  1257. ** and return.
  1258. */
  1259. if (!Buttons) {
  1260. return;
  1261. }
  1262. /*
  1263. ** Otherwise, if 'display' is set, invoke the parent's Redraw to refresh
  1264. ** the HIDPAGE; then, update the buttons & text labels onto HIDPAGE;
  1265. ** then invoke the parent's Redraw to blit the HIDPAGE to SEENPAGE.
  1266. */
  1267. if (forced) {
  1268. /*
  1269. ** Update the text labels
  1270. */
  1271. if (CurrentObject.Count()) {
  1272. /*
  1273. ** Display the object's name & ID
  1274. */
  1275. label = Text_String(CurrentObject[0]->Full_Name());
  1276. tptr = label;
  1277. sprintf(buf, "%s (%d)", tptr, CurrentObject[0]->As_Target());
  1278. /*
  1279. ** print the label
  1280. */
  1281. Fancy_Text_Print (buf, 160, 0,
  1282. &ColorRemaps[PCOLOR_BROWN], TBLACK,
  1283. TPF_CENTER | TPF_NOSHADOW | TPF_EFNT);
  1284. }
  1285. }
  1286. }
  1287. /***************************************************************************
  1288. * MapEditClass::Mouse_Moved -- checks for mouse motion *
  1289. * *
  1290. * Reports whether the mouse has moved or not. This varies based on the *
  1291. * type of object currently selected. If there's an infantry object *
  1292. * selected, mouse motion counts even within a cell; for all other types,*
  1293. * mouse motion counts only if the mouse changes cells. *
  1294. * *
  1295. * The reason this routine is needed is to prevent Paint-Mode from putting*
  1296. * gobs of trees and such into the same cell if the mouse moves just *
  1297. * a little bit. *
  1298. * *
  1299. * INPUT: *
  1300. * *
  1301. * OUTPUT: *
  1302. * *
  1303. * WARNINGS: *
  1304. * *
  1305. * HISTORY: *
  1306. * 11/08/1994 BR : Created. *
  1307. *=========================================================================*/
  1308. bool MapEditClass::Mouse_Moved(void)
  1309. {
  1310. static int old_mx = 0;
  1311. static int old_my = 0;
  1312. static CELL old_zonecell = 0;
  1313. const ObjectTypeClass * objtype = NULL;
  1314. bool retcode = false;
  1315. /*
  1316. ** Return if no motion
  1317. */
  1318. if (old_mx == Get_Mouse_X() && old_my == Get_Mouse_Y()) {
  1319. return(false);
  1320. }
  1321. /*
  1322. ** Get a ptr to ObjectTypeClass
  1323. */
  1324. if (PendingObject) {
  1325. objtype = PendingObject;
  1326. } else {
  1327. if (GrabbedObject) {
  1328. objtype = &GrabbedObject->Class_Of();
  1329. } else {
  1330. old_mx = Get_Mouse_X();
  1331. old_my = Get_Mouse_Y();
  1332. old_zonecell = ZoneCell;
  1333. return(false);
  1334. }
  1335. }
  1336. /*
  1337. ** Infantry: mouse moved if any motion at all
  1338. */
  1339. if (objtype->What_Am_I() == RTTI_INFANTRYTYPE) {
  1340. retcode = true;
  1341. } else {
  1342. /*
  1343. ** Others: mouse moved only if cell changed
  1344. */
  1345. if (old_zonecell!=ZoneCell) {
  1346. retcode = true;
  1347. } else {
  1348. retcode = false;
  1349. }
  1350. }
  1351. old_mx = Get_Mouse_X();
  1352. old_my = Get_Mouse_Y();
  1353. old_zonecell = ZoneCell;
  1354. return(retcode);
  1355. }
  1356. /***************************************************************************
  1357. * MapEditClass::Main_Menu -- main menu processor for map editor *
  1358. * *
  1359. * INPUT: *
  1360. * none. *
  1361. * *
  1362. * OUTPUT: *
  1363. * none. *
  1364. * *
  1365. * WARNINGS: *
  1366. * none. *
  1367. * *
  1368. * HISTORY: *
  1369. * 10/20/1994 BR : Created. *
  1370. *=========================================================================*/
  1371. void MapEditClass::Main_Menu(void)
  1372. {
  1373. char const * _menus[MAX_MAIN_MENU_NUM + 1];
  1374. int selection; // option the user picks
  1375. bool process; // menu stays up while true
  1376. int rc;
  1377. /*
  1378. ** Fill in menu items
  1379. */
  1380. _menus[0] = "New Scenario";
  1381. _menus[1] = "Load Scenario";
  1382. _menus[2] = "Save Scenario";
  1383. _menus[3] = "Size Map";
  1384. _menus[4] = "Add Game Object";
  1385. _menus[5] = "Scenario Options";
  1386. _menus[6] = "AI Options";
  1387. _menus[7] = "Play Scenario";
  1388. _menus[8] = NULL;
  1389. /*
  1390. ** Main Menu loop
  1391. */
  1392. Override_Mouse_Shape(MOUSE_NORMAL); // display default mouse cursor
  1393. process = true;
  1394. while (process) {
  1395. /*
  1396. ** Invoke game callback, to update music
  1397. */
  1398. Call_Back();
  1399. /*
  1400. ** Invoke menu
  1401. */
  1402. Hide_Mouse(); // Do_Menu assumes the mouse is already hidden
  1403. selection = Do_Menu(&_menus[0], true);
  1404. Show_Mouse();
  1405. if (UnknownKey==KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) {
  1406. break;
  1407. }
  1408. /*
  1409. ** Process selection
  1410. */
  1411. switch (selection) {
  1412. /*
  1413. ** New scenario
  1414. */
  1415. case 0:
  1416. if (Changed) {
  1417. rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO);
  1418. HidPage.Clear();
  1419. Flag_To_Redraw(true);
  1420. Render();
  1421. if (rc==0) {
  1422. if (Save_Scenario()!=0) {
  1423. break;
  1424. } else {
  1425. Changed = 0;
  1426. }
  1427. }
  1428. }
  1429. if (New_Scenario()==0) {
  1430. Scen.CarryOverMoney = 0;
  1431. Changed = 1;
  1432. }
  1433. process = false;
  1434. break;
  1435. /*
  1436. ** Load scenario
  1437. */
  1438. case 1:
  1439. if (Changed) {
  1440. rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO);
  1441. HidPage.Clear();
  1442. Flag_To_Redraw(true);
  1443. Render();
  1444. if (rc==0) {
  1445. if (Save_Scenario()!=0) {
  1446. break;
  1447. } else {
  1448. Changed = 0;
  1449. }
  1450. }
  1451. }
  1452. if (Load_Scenario()==0) {
  1453. Scen.CarryOverMoney = 0;
  1454. Changed = 0;
  1455. }
  1456. process = false;
  1457. break;
  1458. /*
  1459. ** Save scenario
  1460. */
  1461. case 2:
  1462. if (Save_Scenario() == 0) {
  1463. Changed = 0;
  1464. }
  1465. process = false;
  1466. break;
  1467. /*
  1468. ** Edit map size
  1469. */
  1470. case 3:
  1471. if (Size_Map(MapCellX, MapCellY, MapCellWidth, MapCellHeight)==0) {
  1472. process = false;
  1473. Changed = 1;
  1474. }
  1475. break;
  1476. /*
  1477. ** Add an object
  1478. */
  1479. case 4:
  1480. if (Placement_Dialog() == 0) {
  1481. Start_Placement();
  1482. process = false;
  1483. }
  1484. break;
  1485. /*
  1486. ** Scenario options
  1487. */
  1488. case 5:
  1489. if (Scenario_Dialog() == 0) {
  1490. Changed = 1;
  1491. process = false;
  1492. }
  1493. break;
  1494. /*
  1495. ** Other options
  1496. */
  1497. case 6:
  1498. AI_Menu();
  1499. process = false;
  1500. break;
  1501. /*
  1502. ** Test-drive this scenario
  1503. */
  1504. case 7:
  1505. if (Changed) {
  1506. rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO, TXT_CANCEL);
  1507. HidPage.Clear();
  1508. Flag_To_Redraw(true);
  1509. Render();
  1510. if (rc == 2) return;
  1511. if (rc==0) {
  1512. if (Save_Scenario()!=0) {
  1513. break;
  1514. } else {
  1515. Changed = 0;
  1516. }
  1517. }
  1518. }
  1519. Changed = 0;
  1520. Debug_Map = false;
  1521. Start_Scenario(Scen.ScenarioName);
  1522. return;
  1523. }
  1524. }
  1525. /*
  1526. ** Restore the display:
  1527. ** - Clear HIDPAGE to erase any spurious drawing done by the menu system
  1528. ** - Invoke Flag_To_Redraw to tell DisplayClass to re-render the whole screen
  1529. ** - Invoke Redraw() to update the display
  1530. */
  1531. HidPage.Clear();
  1532. Flag_To_Redraw(true);
  1533. Render();
  1534. }
  1535. /***************************************************************************
  1536. * MapEditClass::AI_Menu -- menu of AI options *
  1537. * *
  1538. * INPUT: *
  1539. * *
  1540. * OUTPUT: *
  1541. * *
  1542. * WARNINGS: *
  1543. * *
  1544. * HISTORY: *
  1545. * 11/29/1994 BR : Created. *
  1546. *=========================================================================*/
  1547. void MapEditClass::AI_Menu(void)
  1548. {
  1549. int selection; // option the user picks
  1550. bool process; // menu stays up while true
  1551. char const * _menus[MAX_AI_MENU_NUM + 1];
  1552. /*
  1553. ** Fill in menu strings
  1554. */
  1555. _menus[0] = "Pre-Build a Base";
  1556. _menus[1] = "Edit Triggers";
  1557. _menus[2] = "Edit Teams";
  1558. _menus[3] = NULL;
  1559. /*
  1560. ** Main Menu loop
  1561. */
  1562. Override_Mouse_Shape(MOUSE_NORMAL); // display default mouse cursor
  1563. process = true;
  1564. while (process) {
  1565. /*
  1566. ** Invoke game callback, to update music
  1567. */
  1568. Call_Back();
  1569. /*
  1570. ** Invoke menu
  1571. */
  1572. Hide_Mouse(); // Do_Menu assumes the mouse is already hidden
  1573. selection = Do_Menu(&_menus[0], true);
  1574. Show_Mouse();
  1575. if (UnknownKey==KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) {
  1576. break;
  1577. }
  1578. /*
  1579. ** Process selection
  1580. */
  1581. switch (selection) {
  1582. /*
  1583. ** Pre-Build a Base
  1584. */
  1585. case 0:
  1586. Start_Base_Building();
  1587. process = false;
  1588. break;
  1589. /*
  1590. ** Trigger Editing
  1591. */
  1592. case 1:
  1593. Handle_Triggers();
  1594. /*
  1595. ** Go into trigger placement mode
  1596. */
  1597. if (CurTrigger) {
  1598. Start_Trigger_Placement();
  1599. }
  1600. process = false;
  1601. break;
  1602. /*
  1603. ** Team Editing
  1604. */
  1605. case 2:
  1606. Handle_Teams("Teams");
  1607. process = false;
  1608. break;
  1609. }
  1610. }
  1611. }
  1612. /***************************************************************************
  1613. * MapEditClass::Verify_House -- is this objtype ownable by this house? *
  1614. * *
  1615. * INPUT: *
  1616. * house house to check *
  1617. * objtype ObjectTypeClass to check *
  1618. * *
  1619. * OUTPUT: *
  1620. * 0 = isn't ownable, 1 = it is *
  1621. * *
  1622. * WARNINGS: *
  1623. * none. *
  1624. * *
  1625. * HISTORY: *
  1626. * 11/16/1994 BR : Created. *
  1627. *=========================================================================*/
  1628. bool MapEditClass::Verify_House(HousesType house, ObjectTypeClass const * objtype)
  1629. {
  1630. /*
  1631. ** Verify that new house can own this object
  1632. */
  1633. return((objtype->Get_Ownable() & (1 << house)) != 0);
  1634. }
  1635. /***************************************************************************
  1636. * MapEditClass::Cycle_House -- finds next valid house for object type *
  1637. * *
  1638. * INPUT: *
  1639. * objtype ObjectTypeClass ptr to get house for *
  1640. * curhouse current house value to start with *
  1641. * *
  1642. * OUTPUT: *
  1643. * HousesType that's valid for this object type *
  1644. * *
  1645. * WARNINGS: *
  1646. * none. *
  1647. * *
  1648. * HISTORY: *
  1649. * 11/23/1994 BR : Created. *
  1650. *=========================================================================*/
  1651. HousesType MapEditClass::Cycle_House(HousesType curhouse, ObjectTypeClass const *)
  1652. {
  1653. HousesType count; // prevents an infinite loop
  1654. /*
  1655. ** Loop through all house types, starting with the one after 'curhouse';
  1656. ** return the first one that's valid
  1657. */
  1658. count = HOUSE_NONE;
  1659. while (1) {
  1660. /*
  1661. ** Go to next house
  1662. */
  1663. curhouse++;
  1664. if (curhouse == HOUSE_COUNT) {
  1665. curhouse = HOUSE_FIRST;
  1666. }
  1667. /*
  1668. ** Count # iterations; don't go forever
  1669. */
  1670. count++;
  1671. if (count == HOUSE_COUNT) {
  1672. curhouse = HOUSE_NONE;
  1673. break;
  1674. }
  1675. /*
  1676. ** Break if this is a valid house
  1677. */
  1678. // if (HouseClass::As_Pointer(curhouse) && Verify_House(curhouse, objtype)) {
  1679. break;
  1680. // }
  1681. }
  1682. return(curhouse);
  1683. }
  1684. /***************************************************************************
  1685. * MapEditClass::Fatal -- exits with error message *
  1686. * *
  1687. * INPUT: *
  1688. * code tells which message to display; this minimizes the *
  1689. * use of character strings in the code. *
  1690. * *
  1691. * OUTPUT: *
  1692. * none. *
  1693. * *
  1694. * WARNINGS: *
  1695. * none. *
  1696. * *
  1697. * HISTORY: *
  1698. * 12/12/1994 BR : Created. *
  1699. *=========================================================================*/
  1700. void MapEditClass::Fatal(int txt)
  1701. {
  1702. //Prog_End();
  1703. printf("%s\n", txt);
  1704. Emergency_Exit(EXIT_FAILURE);
  1705. }
  1706. bool MapEditClass::Scroll_Map(DirType facing, int & distance, bool really)
  1707. {
  1708. if (Debug_Map) {
  1709. /*
  1710. ** The popup gadgets require the entire map to be redrawn if we scroll.
  1711. */
  1712. if (really) {
  1713. Flag_To_Redraw(true);
  1714. }
  1715. }
  1716. return(MouseClass::Scroll_Map(facing, distance, really));
  1717. }
  1718. #ifdef OBSOLETE
  1719. void MapEditClass::Flag_To_Redraw(bool complete)
  1720. {
  1721. MouseClass::Flag_To_Redraw(complete);
  1722. }
  1723. #endif
  1724. void MapEditClass::Detach(ObjectClass * object)
  1725. {
  1726. if (GrabbedObject == object) {
  1727. GrabbedObject = 0;
  1728. }
  1729. }
  1730. bool MapEditClass::Get_Waypoint_Name(char wayptname[])
  1731. {
  1732. /*
  1733. ** Dialog & button dimensions
  1734. */
  1735. enum {
  1736. D_DIALOG_W = 100, // dialog width
  1737. D_DIALOG_H = 56, // dialog height
  1738. D_DIALOG_X = ((320 - D_DIALOG_W) / 2), // centered x-coord
  1739. D_DIALOG_Y = ((200 - D_DIALOG_H) / 2), // centered y-coord
  1740. D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2), // coord of x-center
  1741. D_TXT8_H = 11, // ht of 8-pt text
  1742. D_MARGIN = 7, // margin width/height
  1743. D_EDIT_W = D_DIALOG_W - (D_MARGIN * 2),
  1744. D_EDIT_H = 13,
  1745. D_EDIT_X = D_DIALOG_X + D_MARGIN,
  1746. D_EDIT_Y = D_DIALOG_Y + 20,
  1747. D_BUTTON_X = D_DIALOG_X + D_MARGIN,
  1748. D_BUTTON_Y = D_DIALOG_Y + 40,
  1749. D_BUTTON_W = 40,
  1750. D_BUTTON_H = 13,
  1751. D_CANCEL_X = D_DIALOG_X + 53,
  1752. D_CANCEL_Y = D_DIALOG_Y + 40,
  1753. D_CANCEL_W = 40,
  1754. D_CANCEL_H = 13,
  1755. };
  1756. /*
  1757. ** Button enumerations
  1758. */
  1759. enum {
  1760. BUTTON_OK = 100,
  1761. BUTTON_CANCEL,
  1762. BUTTON_EDIT,
  1763. };
  1764. /*
  1765. ** Dialog variables
  1766. */
  1767. bool cancel = false; // true = user cancels
  1768. wayptname[0] = 0;
  1769. /*
  1770. ** Buttons
  1771. */
  1772. ControlClass * commands = NULL; // the button list
  1773. TextButtonClass button (BUTTON_OK, TXT_OK, TPF_EBUTTON, D_BUTTON_X, D_BUTTON_Y, D_BUTTON_W);
  1774. TextButtonClass cancelbtn (BUTTON_CANCEL, TXT_CANCEL, TPF_EBUTTON, D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W);
  1775. EditClass editbtn (BUTTON_EDIT, wayptname, 3, TPF_EFNT|TPF_NOSHADOW, D_EDIT_X, D_EDIT_Y, D_EDIT_W, -1, EditClass::ALPHANUMERIC);
  1776. /*
  1777. ** Initialize.
  1778. */
  1779. Set_Logic_Page(SeenBuff);
  1780. /*
  1781. ** Create the button list.
  1782. */
  1783. commands = &button;
  1784. cancelbtn.Add_Tail(*commands);
  1785. editbtn.Add_Tail(*commands);
  1786. editbtn.Set_Focus();
  1787. /*
  1788. ** Main Processing Loop.
  1789. */
  1790. bool firsttime = true;
  1791. bool display = true;
  1792. bool process = true;
  1793. while (process) {
  1794. /*
  1795. ** Invoke game callback.
  1796. */
  1797. if (Session.Type == GAME_NORMAL) {
  1798. Call_Back();
  1799. } else if (Main_Loop()) {
  1800. process = false;
  1801. cancel = true;
  1802. }
  1803. /*
  1804. ** Refresh display if needed.
  1805. */
  1806. if (display) {
  1807. /*
  1808. ** Display the dialog box.
  1809. */
  1810. Hide_Mouse();
  1811. if (display) {
  1812. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  1813. // Draw_Caption(caption, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  1814. }
  1815. /*
  1816. ** Redraw the buttons.
  1817. */
  1818. if (display) {
  1819. commands->Flag_List_To_Redraw();
  1820. }
  1821. Show_Mouse();
  1822. display = false;
  1823. }
  1824. /*
  1825. ** Get user input.
  1826. */
  1827. KeyNumType input = commands->Input();
  1828. /*
  1829. ** The first time through the processing loop, set the edit
  1830. ** gadget to have the focus. The
  1831. ** focus must be set here since the gadget list has changed
  1832. ** and this change will cause any previous focus setting to be
  1833. ** cleared by the input processing routine.
  1834. */
  1835. if (firsttime) {
  1836. firsttime = false;
  1837. editbtn.Set_Focus();
  1838. editbtn.Flag_To_Redraw();
  1839. }
  1840. /*
  1841. ** If the <RETURN> key was pressed, then default to the appropriate
  1842. ** action button according to the style of this dialog box.
  1843. */
  1844. if (input == KN_RETURN) {
  1845. input = (KeyNumType)(BUTTON_OK|KN_BUTTON);
  1846. }
  1847. /*
  1848. ** Process input.
  1849. */
  1850. switch (input) {
  1851. /*
  1852. ** Load: if load fails, present a message, and stay in the dialog
  1853. ** to allow the user to try another game
  1854. */
  1855. case (BUTTON_OK | KN_BUTTON):
  1856. Hide_Mouse();
  1857. SeenPage.Clear();
  1858. GamePalette.Set();
  1859. Show_Mouse();
  1860. process = false;
  1861. cancel = false;
  1862. break;
  1863. /*
  1864. ** ESC/Cancel: break
  1865. */
  1866. case (KN_ESC):
  1867. case (BUTTON_CANCEL | KN_BUTTON):
  1868. Hide_Mouse();
  1869. SeenPage.Clear();
  1870. GamePalette.Set();
  1871. Show_Mouse();
  1872. cancel = true;
  1873. process = false;
  1874. break;
  1875. default:
  1876. break;
  1877. }
  1878. }
  1879. Map.Flag_To_Redraw(true);
  1880. if (cancel) return(false);
  1881. return(true);
  1882. }
  1883. void MapEditClass::Update_Waypoint(int waypt_idx)
  1884. {
  1885. CELL cell;
  1886. /*
  1887. ** Unflag cell for this waypoint if there is one
  1888. */
  1889. cell = Scen.Waypoint[waypt_idx];
  1890. if (cell != -1) {
  1891. if (Scen.Waypoint[WAYPT_HOME] != cell && Scen.Waypoint[WAYPT_REINF] != cell) {
  1892. (*this)[cell].IsWaypoint = 0;
  1893. }
  1894. Flag_Cell(cell);
  1895. }
  1896. Scen.Waypoint[waypt_idx] = CurrentCell;
  1897. (*this)[CurrentCell].IsWaypoint = 1;
  1898. Changed = 1;
  1899. Flag_Cell(CurrentCell);
  1900. }
  1901. /***************************************************************************
  1902. * MapEditClass::Read_INI -- overloaded Read_INI function *
  1903. * *
  1904. * Overloading this function gives the map editor a chance to initialize *
  1905. * certain values every time a new INI is read. *
  1906. * *
  1907. * INPUT: *
  1908. * buffer INI staging area *
  1909. * *
  1910. * OUTPUT: *
  1911. * none. *
  1912. * *
  1913. * WARNINGS: *
  1914. * none. *
  1915. * *
  1916. * HISTORY: *
  1917. * 11/16/1994 BR : Created. *
  1918. *=========================================================================*/
  1919. void MapEditClass::Read_INI(CCINIClass & ini)
  1920. {
  1921. /*
  1922. ** Invoke parent's Read_INI
  1923. */
  1924. Mono_Printf("We are in Read_INI\n");
  1925. MouseClass::Read_INI(ini);
  1926. BaseGauge->Set_Value(Scen.Percent);
  1927. Mono_Clear_Screen();
  1928. Mono_Printf("Scen.Percent = %d", Scen.Percent);
  1929. // BaseGauge->Set_Value(Scen.Percent);
  1930. }
  1931. void MapEditClass::Write_INI(CCINIClass & ini)
  1932. {
  1933. MouseClass::Write_INI(ini);
  1934. // ini.Put_Int("Basic", "Percent", Scen.Percent);
  1935. }
  1936. #endif
  1937. #include "mapedsel.cpp"