MAPEDIT.CPP 62 KB

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