TRIGTYPE.CPP 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126
  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/TRIGTYPE.CPP 1 3/03/97 10:26a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : TRIGTYPE.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 06/05/96 *
  26. * *
  27. * Last Update : July 9, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * TriggerTypeClass::As_Target -- Convert this trigger type object into a target value. *
  32. * TriggerTypeClass::Attaches_To -- Determines what trigger can attach to. *
  33. * TriggerTypeClass::Build_INI_Entry -- Construct the INI entry into the buffer specified. *
  34. * TriggerTypeClass::Description -- Build a text description of the trigger type. *
  35. * TriggerTypeClass::Detach -- Removes attachments to the target object specified. *
  36. * TriggerTypeClass::Draw_It -- Draws this trigger as if it were a line in a list box. *
  37. * TriggerTypeClass::Edit -- Edit the trigger type through the scenario editor. *
  38. * TriggerTypeClass::Fill_In -- fills in trigger from the given INI entry *
  39. * TriggerTypeClass::From_Name -- Convert an ASCII name into a trigger type pointer. *
  40. * TriggerTypeClass::Init -- Initialize the trigger type object management system. *
  41. * TriggerTypeClass::Read_INI -- reads triggers from the INI file *
  42. * TriggerTypeClass::TriggerTypeClass -- Constructor for trigger class object. *
  43. * TriggerTypeClass::Write_INI -- Stores all trigger types to the INI database specified. *
  44. * TriggerTypeClass::operator delete -- Returns a trigger type class object back to the pool *
  45. * TriggerTypeClass::operator new -- Allocates a trigger type class object. *
  46. * TriggerTypeClass::~TriggerTypeClass -- Deleting a trigger type deletes associated triggers*
  47. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  48. #include "function.h"
  49. #include "trigtype.h"
  50. /***********************************************************************************************
  51. * TriggerTypeClass::TriggerTypeClass -- Constructor for trigger class object. *
  52. * *
  53. * This is the normal constructor for a trigger object. The trigger starts with no team *
  54. * members, no mission, and default values for all settings. *
  55. * *
  56. * INPUT: none *
  57. * *
  58. * OUTPUT: none *
  59. * *
  60. * WARNINGS: none *
  61. * *
  62. * HISTORY: *
  63. * 06/10/1996 JLB : Created. *
  64. *=============================================================================================*/
  65. TriggerTypeClass::TriggerTypeClass(void) :
  66. AbstractTypeClass(RTTI_TRIGGERTYPE, TriggerTypes.ID(this), TXT_NONE, "x"),
  67. IsPersistant(VOLATILE),
  68. EventControl(MULTI_ONLY),
  69. ActionControl(MULTI_ONLY),
  70. House(HOUSE_SPAIN)
  71. {
  72. }
  73. /***********************************************************************************************
  74. * TriggerTypeClass::~TriggerTypeClass -- Deleting a trigger type deletes associated triggers. *
  75. * *
  76. * When a trigger type is deleted, then all triggers that refer to that type must also *
  77. * be deleted as well. There can be no 'orphan' triggers in existence. *
  78. * *
  79. * INPUT: none *
  80. * *
  81. * OUTPUT: none *
  82. * *
  83. * WARNINGS: none *
  84. * *
  85. * HISTORY: *
  86. * 07/09/1996 JLB : Created. *
  87. *=============================================================================================*/
  88. TriggerTypeClass::~TriggerTypeClass(void)
  89. {
  90. }
  91. /***********************************************************************************************
  92. * TriggerTypeClass::operator new -- Allocates a trigger type class object. *
  93. * *
  94. * This routine will allocate a block of memory from the special trigger type object *
  95. * pool. *
  96. * *
  97. * INPUT: none *
  98. * *
  99. * OUTPUT: Returns with a pointer to the allocated trigger type memory block. If there is *
  100. * no more block available in the pool, then NULL is returned. *
  101. * *
  102. * WARNINGS: none *
  103. * *
  104. * HISTORY: *
  105. * 07/09/1996 JLB : Created. *
  106. *=============================================================================================*/
  107. void * TriggerTypeClass::operator new(size_t )
  108. {
  109. void * ptr = TriggerTypes.Allocate();
  110. if (ptr) {
  111. ((TriggerTypeClass *)ptr)->IsActive = true;
  112. }
  113. return(ptr);
  114. }
  115. /***********************************************************************************************
  116. * TriggerTypeClass::operator delete -- Returns a trigger type class object back to the pool *
  117. * *
  118. * This routine will return a previously allocated trigger type object to the private *
  119. * memory pool from which it was allocated. *
  120. * *
  121. * INPUT: ptr -- Pointer to the trigger type class to return to the pool. *
  122. * *
  123. * OUTPUT: none *
  124. * *
  125. * WARNINGS: none *
  126. * *
  127. * HISTORY: *
  128. * 07/09/1996 JLB : Created. *
  129. *=============================================================================================*/
  130. void TriggerTypeClass::operator delete(void * ptr)
  131. {
  132. if (ptr) {
  133. ((TriggerTypeClass *)ptr)->IsActive = false;
  134. }
  135. TriggerTypes.Free((TriggerTypeClass *)ptr);
  136. }
  137. /***********************************************************************************************
  138. * TriggerTypeClass::As_Target -- Convert this trigger type object into a target value. *
  139. * *
  140. * Use this routine to take this trigger type class object and convert it into a *
  141. * target number. *
  142. * *
  143. * INPUT: none *
  144. * *
  145. * OUTPUT: Returns with the target number that represents this trigger type class object. *
  146. * *
  147. * WARNINGS: none *
  148. * *
  149. * HISTORY: *
  150. * 07/09/1996 JLB : Created. *
  151. *=============================================================================================*/
  152. TARGET TriggerTypeClass::As_Target(void) const
  153. {
  154. return(Build_Target(RTTI_TRIGGERTYPE, ID));
  155. }
  156. /***********************************************************************************************
  157. * TriggerTypeClass::Detach -- Removes attachments to the target object specified. *
  158. * *
  159. * When an object disappears from the game, it must be detached from all other objects that *
  160. * may be referring to it. This routine will detach the specified target object from any *
  161. * references to it in this trigger type class. *
  162. * *
  163. * INPUT: target -- The target object to be detached from this trigger type. *
  164. * *
  165. * OUTPUT: none *
  166. * *
  167. * WARNINGS: none *
  168. * *
  169. * HISTORY: *
  170. * 07/09/1996 JLB : Created. *
  171. *=============================================================================================*/
  172. void TriggerTypeClass::Detach(TARGET target, bool)
  173. {
  174. Action1.Detach(target);
  175. Action2.Detach(target);
  176. }
  177. #ifdef SCENARIO_EDITOR
  178. /***********************************************************************************************
  179. * TriggerTypeClass::Edit -- Edit the trigger type through the scenario editor. *
  180. * *
  181. * This is the scenario editor interface to a trigger type class object. It brings up a *
  182. * fancy schmancy dialog to allow full edit control of the trigger type. *
  183. * *
  184. * INPUT: none *
  185. * *
  186. * OUTPUT: bool; Was the "OK" button pressed? A false return value indicates that the edits *
  187. * to this trigger type class object should be rejected. *
  188. * *
  189. * WARNINGS: none *
  190. * *
  191. * HISTORY: *
  192. * 07/09/1996 JLB : Created. *
  193. *=============================================================================================*/
  194. bool TriggerTypeClass::Edit(void)
  195. {
  196. enum {
  197. /*
  198. ** Dialog position and dimensions.
  199. */
  200. D_DIALOG_W = 320 + 100,
  201. D_DIALOG_H = 200 + 20,
  202. D_DIALOG_X = 0,
  203. D_DIALOG_Y = 0,
  204. /*
  205. ** Event entry list box coordinates and dimensions.
  206. */
  207. E1_X=D_DIALOG_X+45,
  208. E1_Y=D_DIALOG_Y+65,
  209. E2_X=E1_X,
  210. E2_Y=E1_Y+22,
  211. E_WIDTH=160,
  212. E_HEIGHT=8*5,
  213. /*
  214. ** Event optional data entry coordinates and dimensions.
  215. */
  216. ED1_X=E1_X+E_WIDTH+20,
  217. ED1_Y=E1_Y,
  218. ED2_X=ED1_X,
  219. ED2_Y=E2_Y,
  220. ED_WIDTH=95,
  221. ED_HEIGHT=8*5,
  222. /*
  223. ** Action entry list box coordinates.
  224. */
  225. A1_X=E1_X,
  226. A1_Y=D_DIALOG_Y+120,
  227. A2_X=E1_X,
  228. A2_Y=A1_Y+22,
  229. /*
  230. ** Action optional data entry coordinates.
  231. */
  232. AD1_X=A1_X+E_WIDTH+20,
  233. AD1_Y=A1_Y,
  234. AD2_X=AD1_X,
  235. AD2_Y=A2_Y,
  236. /*
  237. ** Misc control values.
  238. */
  239. GENERAL_SIZE=10, // Text length for general data entry fields.
  240. ENTRY_SIZE=35, // Maximum size of event or action description text.
  241. WAYPOINT_SIZE=3, // Text length maximum for waypoint entry.
  242. TEAM_SIZE=10, // Team name text entry field length.
  243. DESC_SIZE=35 // Maximum length of object full name description.
  244. };
  245. /*
  246. ** Button enumerations:
  247. */
  248. enum {
  249. EVENT_LIST=100, // Primary event list.
  250. EVENT_LIST2, // Secondary event list.
  251. ACTION_LIST, // Primary action list.
  252. ACTION_LIST2, // Secondary action list.
  253. NAME_EDIT, // Trigger name edit field.
  254. DATA_SPEECH1, // Primary action speech.
  255. DATA_SPEECH2, // Secondary action speech.
  256. DATA_THEME1, // Primary action theme.
  257. DATA_THEME2, // Secondary action theme.
  258. DATA_MOVIE1, // Primary action movie.
  259. DATA_MOVIE2, // Secondary action movie.
  260. DATA_SOUND1, // Primary action sound effect.
  261. DATA_SOUND2, // Secondary action sound effect.
  262. DATA_SPECIAL1, // Primary action special weapon.
  263. DATA_SPECIAL2, // Secondary action special weapon.
  264. DATA_EDIT, // Primary event waypoint data field.
  265. DATA_EDIT2, // Secondary event waypoint data field.
  266. DATA_EDIT3, // Primary action waypoint data field.
  267. DATA_EDIT4, // Secondary action waypoint data field.
  268. DATA_HTYPE1, // Primary event house choice list.
  269. DATA_HTYPE2, // Secondary event house choice list.
  270. DATA_HTYPE3, // Primary action house choice list.
  271. DATA_HTYPE4, // Secondary action house choice list.
  272. DATA_BOOLTYPE1, // Primary action boolean data list.
  273. DATA_BOOLTYPE2, // Secondary action boolean data list.
  274. DATA_GENERAL1, // Primary event general data field.
  275. DATA_GENERAL2, // Secondary event general data field.
  276. DATA_GENERAL3, // Primary action general data field.
  277. DATA_GENERAL4, // Secondary action general data field.
  278. DATA_BTYPE1, // Primary event building type list.
  279. DATA_BTYPE2, // Secondary event building type list.
  280. DATA_ITYPE1, // Primary event infantry type list.
  281. DATA_ITYPE2, // Secondary event infantry type list.
  282. DATA_ATYPE1, // Primary event aircraft type list.
  283. DATA_ATYPE2, // Secondary event aircraft type list.
  284. DATA_UTYPE1, // Primary event unit type list.
  285. DATA_UTYPE2, // Secondary event unit type list.
  286. DATA_TTYPE1, // Primary event team type entry list.
  287. DATA_TTYPE2, // Secondary event team type entry list.
  288. DATA_TTYPE3, // Primary action team type entry list.
  289. DATA_TTYPE4, // Secondary action team type entry list.
  290. DATA_TRTYPE1, // Primary action trigger list.
  291. DATA_TRTYPE2, // Secondary action trigger list.
  292. BUTTON_HOUSE, // House ownership for this trigger.
  293. BUTTON_PERSISTANCE, // Persistence of this trigger.
  294. BUTTON_OK, // Ok button - save and exit.
  295. BUTTON_CANCEL, // Cancel button - just exit.
  296. BUTTON_ACTION, // Multiple action control button.
  297. BUTTON_EVENT, // Multiple event control button.
  298. };
  299. /*
  300. ** Dialog variables:
  301. */
  302. bool cancel = false; // true = user cancels
  303. int i; // loop counter
  304. RemapControlType * scheme = GadgetClass::Get_Color_Scheme();
  305. /*
  306. ** Buttons
  307. */
  308. ControlClass * commands = NULL; // the button list
  309. /*
  310. ** List of events allowed.
  311. */
  312. char eventtext[ENTRY_SIZE] = "";
  313. TDropListClass<EventChoiceClass *> event1list(EVENT_LIST, eventtext, sizeof(eventtext),
  314. TPF_EFNT | TPF_NOSHADOW,
  315. E1_X, E1_Y, E_WIDTH, E_HEIGHT,
  316. MFCD::Retrieve("EBTN-UP.SHP"),
  317. MFCD::Retrieve("EBTN-DN.SHP"));
  318. char event2text[ENTRY_SIZE] = "";
  319. TDropListClass<EventChoiceClass *> event2list(EVENT_LIST2, event2text, sizeof(event2text),
  320. TPF_EFNT | TPF_NOSHADOW,
  321. E2_X, E2_Y, E_WIDTH, E_HEIGHT,
  322. MFCD::Retrieve("EBTN-UP.SHP"),
  323. MFCD::Retrieve("EBTN-DN.SHP"));
  324. for (TEventType event = TEVENT_FIRST; event < TEVENT_COUNT; event++) {
  325. event1list.Add_Item(&EventChoices[event]);
  326. event2list.Add_Item(&EventChoices[event]);
  327. }
  328. PBubble_Sort(&event1list[0], event1list.Count());
  329. PBubble_Sort(&event2list[0], event2list.Count());
  330. if (Event1.Event == TEVENT_NONE) Event1.Event = TEVENT_FIRST;
  331. event1list.Set_Selected_Index(&EventChoices[Event1.Event]);
  332. if (Event2.Event == TEVENT_NONE) Event2.Event = TEVENT_FIRST;
  333. event2list.Set_Selected_Index(&EventChoices[Event2.Event]);
  334. /*
  335. ** List of actions allowed.
  336. */
  337. char actiontext[ENTRY_SIZE] = "";
  338. TDropListClass<ActionChoiceClass *> action1list(ACTION_LIST, actiontext, sizeof(actiontext),
  339. TPF_EFNT | TPF_NOSHADOW,
  340. A1_X, A1_Y, E_WIDTH, E_HEIGHT,
  341. MFCD::Retrieve("EBTN-UP.SHP"),
  342. MFCD::Retrieve("EBTN-DN.SHP"));
  343. char action2text[ENTRY_SIZE] = "";
  344. TDropListClass<ActionChoiceClass *> action2list(ACTION_LIST2, action2text, sizeof(action2text),
  345. TPF_EFNT | TPF_NOSHADOW,
  346. A2_X, A2_Y, E_WIDTH, E_HEIGHT,
  347. MFCD::Retrieve("EBTN-UP.SHP"),
  348. MFCD::Retrieve("EBTN-DN.SHP"));
  349. for (TActionType action = TACTION_FIRST; action < TACTION_COUNT; action++) {
  350. action1list.Add_Item(&ActionChoices[action]);
  351. action2list.Add_Item(&ActionChoices[action]);
  352. }
  353. PBubble_Sort(&action1list[0], action1list.Count());
  354. PBubble_Sort(&action2list[0], action2list.Count());
  355. if (Action1.Action == ACTION_NONE) Action1.Action = TACTION_FIRST;
  356. action1list.Set_Selected_Index(&ActionChoices[Action1.Action]);
  357. if (Action2.Action == ACTION_NONE) Action2.Action = TACTION_FIRST;
  358. action2list.Set_Selected_Index(&ActionChoices[Action2.Action]);
  359. /*
  360. ** Optional waypoint entry field.
  361. */
  362. char way1[WAYPOINT_SIZE] = "A";
  363. EditClass way1data(DATA_EDIT, way1, sizeof(way1), TPF_EFNT | TPF_NOSHADOW,
  364. ED1_X, ED1_Y, ED_WIDTH, 9, EditClass::ALPHA);
  365. if (Event_Needs(Event1.Event) == NEED_WAYPOINT) {
  366. if (Event1.Data.Value < 26) {
  367. sprintf(way1data.Get_Text(), "%c", Event1.Data.Value + 'A');
  368. } else {
  369. sprintf(way1data.Get_Text(), "%c%c", (Event1.Data.Value / 26) + 'A'-1, (Event1.Data.Value % 26) + 'A');
  370. }
  371. }
  372. char way2[WAYPOINT_SIZE] = "A";
  373. EditClass way2data(DATA_EDIT2, way2, sizeof(way2), TPF_EFNT | TPF_NOSHADOW,
  374. ED2_X, ED2_Y, ED_WIDTH, 9, EditClass::ALPHA);
  375. if (Event_Needs(Event2.Event) == NEED_WAYPOINT) {
  376. if (Event2.Data.Value < 26) {
  377. sprintf(way2data.Get_Text(), "%c", Event2.Data.Value + 'A');
  378. } else {
  379. sprintf(way2data.Get_Text(), "%c%c", (Event2.Data.Value / 26) + 'A'-1, (Event2.Data.Value % 26) + 'A');
  380. }
  381. }
  382. char way3[WAYPOINT_SIZE] = "A";
  383. EditClass way3data(DATA_EDIT3, way3, sizeof(way3), TPF_EFNT | TPF_NOSHADOW,
  384. AD1_X, AD1_Y, ED_WIDTH, 9, EditClass::ALPHA);
  385. if (Action_Needs(Action1.Action) == NEED_WAYPOINT) {
  386. if (Action1.Data.Value < 26) {
  387. sprintf(way3data.Get_Text(), "%c", Action1.Data.Value + 'A');
  388. } else {
  389. sprintf(way3data.Get_Text(), "%c%c", (Action1.Data.Value / 26) + 'A'-1, (Action1.Data.Value % 26) + 'A');
  390. }
  391. }
  392. char way4[WAYPOINT_SIZE] = "A";
  393. EditClass way4data(DATA_EDIT4, way4, sizeof(way4), TPF_EFNT | TPF_NOSHADOW,
  394. AD2_X, AD2_Y, ED_WIDTH, 9, EditClass::ALPHA);
  395. if (Action_Needs(Action2.Action) == NEED_WAYPOINT) {
  396. if (Action2.Data.Value < 26) {
  397. sprintf(way4data.Get_Text(), "%c", Action2.Data.Value + 'A');
  398. } else {
  399. sprintf(way4data.Get_Text(), "%c%c", (Action2.Data.Value / 26) + 'A'-1, (Action2.Data.Value % 26) + 'A');
  400. }
  401. }
  402. /*
  403. ** Optional event data entry field.
  404. */
  405. char databuf1[GENERAL_SIZE] = "";
  406. EditClass event1data(DATA_GENERAL1, databuf1, sizeof(databuf1),
  407. TPF_EFNT | TPF_NOSHADOW,
  408. ED1_X, ED1_Y, ED_WIDTH, 9, EditClass::NUMERIC);
  409. switch (Event_Needs(Event1.Event)) {
  410. case NEED_TIME:
  411. case NEED_NUMBER:
  412. sprintf(event1data.Get_Text(), "%d", Event1.Data.Value);
  413. break;
  414. }
  415. char databuf2[GENERAL_SIZE] = "";
  416. EditClass event2data(DATA_GENERAL2, databuf2, sizeof(databuf2),
  417. TPF_EFNT | TPF_NOSHADOW,
  418. ED2_X, ED2_Y, ED_WIDTH, 9, EditClass::NUMERIC);
  419. switch (Event_Needs(Event2.Event)) {
  420. case NEED_TIME:
  421. case NEED_NUMBER:
  422. sprintf(event2data.Get_Text(), "%d", Event2.Data.Value);
  423. break;
  424. }
  425. char actionbuf1[GENERAL_SIZE] = "";
  426. EditClass action1data(DATA_GENERAL3, actionbuf1, sizeof(actionbuf1),
  427. TPF_EFNT | TPF_NOSHADOW,
  428. AD1_X, AD1_Y, ED_WIDTH, 9, EditClass::NUMERIC);
  429. switch (Action_Needs(Action1.Action)) {
  430. case NEED_NUMBER:
  431. sprintf(action1data.Get_Text(), "%d", Action1.Data.Value);
  432. break;
  433. }
  434. char actionbuf2[GENERAL_SIZE] = "";
  435. EditClass action2data(DATA_GENERAL4, actionbuf2, sizeof(actionbuf2),
  436. TPF_EFNT | TPF_NOSHADOW,
  437. AD2_X, AD2_Y, ED_WIDTH, 9, EditClass::NUMERIC);
  438. switch (Action_Needs(Action2.Action)) {
  439. case NEED_NUMBER:
  440. sprintf(action2data.Get_Text(), "%d", Action2.Data.Value);
  441. break;
  442. }
  443. /*
  444. ** Optional team entry list.
  445. */
  446. char tbuf1[TEAM_SIZE] = "";
  447. DropListClass ttype1list(DATA_TTYPE1, tbuf1, sizeof(tbuf1),
  448. TPF_EFNT | TPF_NOSHADOW,
  449. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  450. MFCD::Retrieve("EBTN-UP.SHP"),
  451. MFCD::Retrieve("EBTN-DN.SHP"));
  452. char tbuf2[TEAM_SIZE] = "";
  453. DropListClass ttype2list(DATA_TTYPE2, tbuf2, sizeof(tbuf2),
  454. TPF_EFNT | TPF_NOSHADOW,
  455. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  456. MFCD::Retrieve("EBTN-UP.SHP"),
  457. MFCD::Retrieve("EBTN-DN.SHP"));
  458. char tbuf3[TEAM_SIZE] = "";
  459. DropListClass ttype3list(DATA_TTYPE3, tbuf3, sizeof(tbuf3),
  460. TPF_EFNT | TPF_NOSHADOW,
  461. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  462. MFCD::Retrieve("EBTN-UP.SHP"),
  463. MFCD::Retrieve("EBTN-DN.SHP"));
  464. char tbuf4[TEAM_SIZE] = "";
  465. DropListClass ttype4list(DATA_TTYPE4, tbuf4, sizeof(tbuf4),
  466. TPF_EFNT | TPF_NOSHADOW,
  467. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  468. MFCD::Retrieve("EBTN-UP.SHP"),
  469. MFCD::Retrieve("EBTN-DN.SHP"));
  470. for (int index = 0; index < TeamTypes.Count(); index++) {
  471. ttype1list.Add_Item(TeamTypes.Ptr(index)->IniName);
  472. ttype2list.Add_Item(TeamTypes.Ptr(index)->IniName);
  473. ttype3list.Add_Item(TeamTypes.Ptr(index)->IniName);
  474. ttype4list.Add_Item(TeamTypes.Ptr(index)->IniName);
  475. }
  476. if (Event1.Team.Is_Valid()) {
  477. ttype1list.Set_Selected_Index(Event1.Team->IniName);
  478. } else {
  479. ttype1list.Set_Selected_Index(0);
  480. }
  481. if (Event2.Team.Is_Valid()) {
  482. ttype2list.Set_Selected_Index(Event2.Team->IniName);
  483. } else {
  484. ttype2list.Set_Selected_Index(0);
  485. }
  486. if (Action1.Team.Is_Valid()) {
  487. ttype3list.Set_Selected_Index(Action1.Team->IniName);
  488. } else {
  489. ttype3list.Set_Selected_Index(0);
  490. }
  491. if (Action2.Team.Is_Valid()) {
  492. ttype4list.Set_Selected_Index(Action2.Team->IniName);
  493. } else {
  494. ttype4list.Set_Selected_Index(0);
  495. }
  496. /*
  497. ** Optional trigger entry list.
  498. */
  499. char trbuf1[TEAM_SIZE] = "";
  500. DropListClass trtype1list(DATA_TRTYPE1, trbuf1, sizeof(trbuf1),
  501. TPF_EFNT | TPF_NOSHADOW,
  502. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  503. MFCD::Retrieve("EBTN-UP.SHP"),
  504. MFCD::Retrieve("EBTN-DN.SHP"));
  505. char trbuf2[TEAM_SIZE] = "";
  506. DropListClass trtype2list(DATA_TRTYPE2, trbuf2, sizeof(trbuf2),
  507. TPF_EFNT | TPF_NOSHADOW,
  508. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  509. MFCD::Retrieve("EBTN-UP.SHP"),
  510. MFCD::Retrieve("EBTN-DN.SHP"));
  511. for (index = 0; index < TriggerTypes.Count(); index++) {
  512. trtype1list.Add_Item(TriggerTypes.Ptr(index)->IniName);
  513. trtype2list.Add_Item(TriggerTypes.Ptr(index)->IniName);
  514. }
  515. if (Action1.Trigger.Is_Valid()) {
  516. trtype1list.Set_Selected_Index(Action1.Trigger->IniName);
  517. } else {
  518. trtype1list.Set_Selected_Index(0);
  519. }
  520. if (Action2.Trigger.Is_Valid()) {
  521. trtype2list.Set_Selected_Index(Action2.Trigger->IniName);
  522. } else {
  523. trtype2list.Set_Selected_Index(0);
  524. }
  525. /*
  526. ** Optional boolean value list.
  527. */
  528. char boolbuf1[TEAM_SIZE] = "";
  529. DropListClass booltype1list(DATA_BOOLTYPE1, boolbuf1, sizeof(boolbuf1),
  530. TPF_EFNT | TPF_NOSHADOW,
  531. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  532. MFCD::Retrieve("EBTN-UP.SHP"),
  533. MFCD::Retrieve("EBTN-DN.SHP"));
  534. char boolbuf2[TEAM_SIZE] = "";
  535. DropListClass booltype2list(DATA_BOOLTYPE2, boolbuf2, sizeof(boolbuf2),
  536. TPF_EFNT | TPF_NOSHADOW,
  537. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  538. MFCD::Retrieve("EBTN-UP.SHP"),
  539. MFCD::Retrieve("EBTN-DN.SHP"));
  540. booltype1list.Add_Item("OFF");
  541. booltype1list.Add_Item("ON");
  542. booltype2list.Add_Item("OFF");
  543. booltype2list.Add_Item("ON");
  544. booltype1list.Set_Selected_Index(Action1.Data.Bool);
  545. booltype2list.Set_Selected_Index(Action2.Data.Bool);
  546. /*
  547. ** Optional musical theme choice list.
  548. */
  549. char themebuf1[DESC_SIZE] = "";
  550. DropListClass themetype1list(DATA_THEME1, themebuf1, sizeof(themebuf1),
  551. TPF_EFNT | TPF_NOSHADOW,
  552. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  553. MFCD::Retrieve("EBTN-UP.SHP"),
  554. MFCD::Retrieve("EBTN-DN.SHP"));
  555. char themebuf2[DESC_SIZE] = "";
  556. DropListClass themetype2list(DATA_THEME2, themebuf2, sizeof(themebuf2),
  557. TPF_EFNT | TPF_NOSHADOW,
  558. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  559. MFCD::Retrieve("EBTN-UP.SHP"),
  560. MFCD::Retrieve("EBTN-DN.SHP"));
  561. for (ThemeType theme = THEME_FIRST; theme < THEME_COUNT; theme++) {
  562. themetype1list.Add_Item(Theme.Full_Name(theme));
  563. themetype2list.Add_Item(Theme.Full_Name(theme));
  564. }
  565. if (Action_Needs(Action1.Action) == NEED_THEME) {
  566. themetype1list.Set_Selected_Index(Action1.Data.Theme);
  567. } else {
  568. themetype1list.Set_Selected_Index(0);
  569. }
  570. if (Action_Needs(Action2.Action) == NEED_THEME) {
  571. themetype2list.Set_Selected_Index(Action2.Data.Theme);
  572. } else {
  573. themetype2list.Set_Selected_Index(0);
  574. }
  575. /*
  576. ** Optional movie list.
  577. */
  578. char moviebuf1[DESC_SIZE] = "";
  579. DropListClass movietype1list(DATA_MOVIE1, moviebuf1, sizeof(moviebuf1),
  580. TPF_EFNT | TPF_NOSHADOW,
  581. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  582. MFCD::Retrieve("EBTN-UP.SHP"),
  583. MFCD::Retrieve("EBTN-DN.SHP"));
  584. char moviebuf2[DESC_SIZE] = "";
  585. DropListClass movietype2list(DATA_MOVIE2, moviebuf2, sizeof(moviebuf2),
  586. TPF_EFNT | TPF_NOSHADOW,
  587. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  588. MFCD::Retrieve("EBTN-UP.SHP"),
  589. MFCD::Retrieve("EBTN-DN.SHP"));
  590. for (VQType movie = VQ_FIRST; movie < VQ_COUNT; movie++) {
  591. movietype1list.Add_Item(VQName[movie]);
  592. movietype2list.Add_Item(VQName[movie]);
  593. }
  594. if (Action_Needs(Action1.Action) == NEED_MOVIE) {
  595. movietype1list.Set_Selected_Index(Action1.Data.Movie);
  596. } else {
  597. movietype1list.Set_Selected_Index(0);
  598. }
  599. if (Action_Needs(Action2.Action) == NEED_MOVIE) {
  600. movietype2list.Set_Selected_Index(Action2.Data.Movie);
  601. } else {
  602. movietype2list.Set_Selected_Index(0);
  603. }
  604. /*
  605. ** Optional sound effect list.
  606. */
  607. char soundbuf1[DESC_SIZE] = "";
  608. DropListClass soundtype1list(DATA_SOUND1, soundbuf1, sizeof(soundbuf1),
  609. TPF_EFNT | TPF_NOSHADOW,
  610. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  611. MFCD::Retrieve("EBTN-UP.SHP"),
  612. MFCD::Retrieve("EBTN-DN.SHP"));
  613. char soundbuf2[DESC_SIZE] = "";
  614. DropListClass soundtype2list(DATA_SOUND2, soundbuf2, sizeof(soundbuf2),
  615. TPF_EFNT | TPF_NOSHADOW,
  616. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  617. MFCD::Retrieve("EBTN-UP.SHP"),
  618. MFCD::Retrieve("EBTN-DN.SHP"));
  619. for (VocType sound = VOC_FIRST; sound < VOC_COUNT; sound++) {
  620. soundtype1list.Add_Item(Voc_Name(sound));
  621. soundtype2list.Add_Item(Voc_Name(sound));
  622. }
  623. if (Action_Needs(Action1.Action) == NEED_SOUND) {
  624. soundtype1list.Set_Selected_Index(Action1.Data.Sound);
  625. } else {
  626. soundtype1list.Set_Selected_Index(0);
  627. }
  628. if (Action_Needs(Action2.Action) == NEED_SOUND) {
  629. soundtype2list.Set_Selected_Index(Action2.Data.Sound);
  630. } else {
  631. soundtype2list.Set_Selected_Index(0);
  632. }
  633. /*
  634. ** Optional speech effect list.
  635. */
  636. char speechbuf1[DESC_SIZE] = "";
  637. DropListClass speechtype1list(DATA_SPEECH1, speechbuf1, sizeof(speechbuf1),
  638. TPF_EFNT | TPF_NOSHADOW,
  639. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  640. MFCD::Retrieve("EBTN-UP.SHP"),
  641. MFCD::Retrieve("EBTN-DN.SHP"));
  642. char speechbuf2[DESC_SIZE] = "";
  643. DropListClass speechtype2list(DATA_SPEECH2, speechbuf2, sizeof(speechbuf2),
  644. TPF_EFNT | TPF_NOSHADOW,
  645. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  646. MFCD::Retrieve("EBTN-UP.SHP"),
  647. MFCD::Retrieve("EBTN-DN.SHP"));
  648. for (VoxType speech = VOX_FIRST; speech < VOX_COUNT; speech++) {
  649. speechtype1list.Add_Item(Speech_Name(speech));
  650. speechtype2list.Add_Item(Speech_Name(speech));
  651. }
  652. if (Action_Needs(Action1.Action) == NEED_SPEECH) {
  653. speechtype1list.Set_Selected_Index(Action1.Data.Speech);
  654. } else {
  655. speechtype1list.Set_Selected_Index(0);
  656. }
  657. if (Action_Needs(Action2.Action) == NEED_SPEECH) {
  658. speechtype2list.Set_Selected_Index(Action2.Data.Speech);
  659. } else {
  660. speechtype2list.Set_Selected_Index(0);
  661. }
  662. /*
  663. ** Optional building type entry list.
  664. */
  665. char bbuf1[DESC_SIZE] = "";
  666. DropListClass btype1list(DATA_BTYPE1, bbuf1, sizeof(bbuf1),
  667. TPF_EFNT | TPF_NOSHADOW,
  668. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  669. MFCD::Retrieve("EBTN-UP.SHP"),
  670. MFCD::Retrieve("EBTN-DN.SHP"));
  671. char bbuf2[DESC_SIZE] = "";
  672. DropListClass btype2list(DATA_BTYPE2, bbuf2, sizeof(bbuf2),
  673. TPF_EFNT | TPF_NOSHADOW,
  674. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  675. MFCD::Retrieve("EBTN-UP.SHP"),
  676. MFCD::Retrieve("EBTN-DN.SHP"));
  677. for (StructType ss = STRUCT_FIRST; ss < STRUCT_COUNT; ss++) {
  678. btype1list.Add_Item(Text_String(BuildingTypeClass::As_Reference(ss).Full_Name()));
  679. btype2list.Add_Item(Text_String(BuildingTypeClass::As_Reference(ss).Full_Name()));
  680. }
  681. if (Event_Needs(Event1.Event) == NEED_STRUCTURE) {
  682. btype1list.Set_Selected_Index(Event1.Data.Structure);
  683. } else {
  684. btype1list.Set_Selected_Index(0);
  685. }
  686. if (Event_Needs(Event2.Event) == NEED_STRUCTURE) {
  687. btype2list.Set_Selected_Index(Event2.Data.Structure);
  688. } else {
  689. btype2list.Set_Selected_Index(0);
  690. }
  691. /*
  692. ** Optional infantry type entry list.
  693. */
  694. char ibuf1[DESC_SIZE] = "";
  695. DropListClass itype1list(DATA_ITYPE1, ibuf1, sizeof(ibuf1),
  696. TPF_EFNT | TPF_NOSHADOW,
  697. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  698. MFCD::Retrieve("EBTN-UP.SHP"),
  699. MFCD::Retrieve("EBTN-DN.SHP"));
  700. char ibuf2[DESC_SIZE] = "";
  701. DropListClass itype2list(DATA_ITYPE2, ibuf2, sizeof(ibuf2),
  702. TPF_EFNT | TPF_NOSHADOW,
  703. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  704. MFCD::Retrieve("EBTN-UP.SHP"),
  705. MFCD::Retrieve("EBTN-DN.SHP"));
  706. for (InfantryType ii = INFANTRY_FIRST; ii < INFANTRY_COUNT; ii++) {
  707. itype1list.Add_Item(Text_String(InfantryTypeClass::As_Reference(ii).Full_Name()));
  708. itype2list.Add_Item(Text_String(InfantryTypeClass::As_Reference(ii).Full_Name()));
  709. }
  710. if (Event_Needs(Event1.Event) == NEED_INFANTRY) {
  711. itype1list.Set_Selected_Index(Event1.Data.Infantry);
  712. } else {
  713. itype1list.Set_Selected_Index(0);
  714. }
  715. if (Event_Needs(Event2.Event) == NEED_INFANTRY) {
  716. itype2list.Set_Selected_Index(Event2.Data.Infantry);
  717. } else {
  718. itype2list.Set_Selected_Index(0);
  719. }
  720. /*
  721. ** Optional aircraft type entry list.
  722. */
  723. char abuf1[DESC_SIZE] = "";
  724. DropListClass atype1list(DATA_ATYPE1, abuf1, sizeof(abuf1),
  725. TPF_EFNT | TPF_NOSHADOW,
  726. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  727. MFCD::Retrieve("EBTN-UP.SHP"),
  728. MFCD::Retrieve("EBTN-DN.SHP"));
  729. char abuf2[DESC_SIZE] = "";
  730. DropListClass atype2list(DATA_ATYPE2, abuf2, sizeof(abuf2),
  731. TPF_EFNT | TPF_NOSHADOW,
  732. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  733. MFCD::Retrieve("EBTN-UP.SHP"),
  734. MFCD::Retrieve("EBTN-DN.SHP"));
  735. for (AircraftType aa = AIRCRAFT_FIRST; aa < AIRCRAFT_COUNT; aa++) {
  736. atype1list.Add_Item(Text_String(AircraftTypeClass::As_Reference(aa).Full_Name()));
  737. atype2list.Add_Item(Text_String(AircraftTypeClass::As_Reference(aa).Full_Name()));
  738. }
  739. if (Event_Needs(Event1.Event) == NEED_AIRCRAFT) {
  740. atype1list.Set_Selected_Index(Event1.Data.Aircraft);
  741. } else {
  742. atype1list.Set_Selected_Index(0);
  743. }
  744. if (Event_Needs(Event2.Event) == NEED_AIRCRAFT) {
  745. atype2list.Set_Selected_Index(Event2.Data.Aircraft);
  746. } else {
  747. atype2list.Set_Selected_Index(0);
  748. }
  749. /*
  750. ** Optional unit type entry list.
  751. */
  752. char ubuf1[DESC_SIZE] = "";
  753. DropListClass utype1list(DATA_UTYPE1, ubuf1, sizeof(ubuf1),
  754. TPF_EFNT | TPF_NOSHADOW,
  755. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  756. MFCD::Retrieve("EBTN-UP.SHP"),
  757. MFCD::Retrieve("EBTN-DN.SHP"));
  758. char ubuf2[DESC_SIZE] = "";
  759. DropListClass utype2list(DATA_UTYPE2, ubuf2, sizeof(ubuf2),
  760. TPF_EFNT | TPF_NOSHADOW,
  761. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  762. MFCD::Retrieve("EBTN-UP.SHP"),
  763. MFCD::Retrieve("EBTN-DN.SHP"));
  764. for (UnitType uu = UNIT_FIRST; uu < UNIT_COUNT; uu++) {
  765. utype1list.Add_Item(Text_String(UnitTypeClass::As_Reference(uu).Full_Name()));
  766. utype2list.Add_Item(Text_String(UnitTypeClass::As_Reference(uu).Full_Name()));
  767. }
  768. if (Event_Needs(Event1.Event) == NEED_UNIT) {
  769. utype1list.Set_Selected_Index(Event1.Data.Unit);
  770. } else {
  771. utype1list.Set_Selected_Index(0);
  772. }
  773. if (Event_Needs(Event2.Event) == NEED_UNIT) {
  774. utype2list.Set_Selected_Index(Event2.Data.Unit);
  775. } else {
  776. utype2list.Set_Selected_Index(0);
  777. }
  778. /*
  779. ** Optional house type entry list.
  780. */
  781. char housebuf1[DESC_SIZE] = "";
  782. DropListClass htype1list(DATA_HTYPE1, housebuf1, sizeof(housebuf1),
  783. TPF_EFNT | TPF_NOSHADOW,
  784. ED1_X, ED1_Y, ED_WIDTH, ED_HEIGHT,
  785. MFCD::Retrieve("EBTN-UP.SHP"),
  786. MFCD::Retrieve("EBTN-DN.SHP"));
  787. char housebuf2[DESC_SIZE] = "";
  788. DropListClass htype2list(DATA_HTYPE2, housebuf2, sizeof(housebuf2),
  789. TPF_EFNT | TPF_NOSHADOW,
  790. ED2_X, ED2_Y, ED_WIDTH, ED_HEIGHT,
  791. MFCD::Retrieve("EBTN-UP.SHP"),
  792. MFCD::Retrieve("EBTN-DN.SHP"));
  793. char housebuf3[DESC_SIZE] = "";
  794. DropListClass htype3list(DATA_HTYPE3, housebuf3, sizeof(housebuf3),
  795. TPF_EFNT | TPF_NOSHADOW,
  796. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  797. MFCD::Retrieve("EBTN-UP.SHP"),
  798. MFCD::Retrieve("EBTN-DN.SHP"));
  799. char housebuf4[DESC_SIZE] = "";
  800. DropListClass htype4list(DATA_HTYPE4, housebuf4, sizeof(housebuf4),
  801. TPF_EFNT | TPF_NOSHADOW,
  802. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  803. MFCD::Retrieve("EBTN-UP.SHP"),
  804. MFCD::Retrieve("EBTN-DN.SHP"));
  805. for (HousesType hh = HOUSE_FIRST; hh < HOUSE_COUNT; hh++) {
  806. htype1list.Add_Item(HouseTypeClass::As_Reference(hh).IniName);
  807. htype2list.Add_Item(HouseTypeClass::As_Reference(hh).IniName);
  808. htype3list.Add_Item(HouseTypeClass::As_Reference(hh).IniName);
  809. htype4list.Add_Item(HouseTypeClass::As_Reference(hh).IniName);
  810. }
  811. if (Event_Needs(Event1.Event) == NEED_HOUSE) {
  812. htype1list.Set_Selected_Index(Event1.Data.House);
  813. } else {
  814. htype1list.Set_Selected_Index(0);
  815. }
  816. if (Event_Needs(Event2.Event) == NEED_HOUSE) {
  817. htype2list.Set_Selected_Index(Event2.Data.House);
  818. } else {
  819. htype2list.Set_Selected_Index(0);
  820. }
  821. if (Action_Needs(Action1.Action) == NEED_HOUSE) {
  822. htype3list.Set_Selected_Index(Action1.Data.House);
  823. } else {
  824. htype3list.Set_Selected_Index(0);
  825. }
  826. if (Action_Needs(Action2.Action) == NEED_HOUSE) {
  827. htype4list.Set_Selected_Index(Action2.Data.House);
  828. } else {
  829. htype4list.Set_Selected_Index(0);
  830. }
  831. /*
  832. ** Optional special weapon list.
  833. */
  834. char special1[DESC_SIZE] = "";
  835. DropListClass spc1(DATA_SPECIAL1, special1, sizeof(special1),
  836. TPF_EFNT | TPF_NOSHADOW,
  837. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  838. MFCD::Retrieve("EBTN-UP.SHP"),
  839. MFCD::Retrieve("EBTN-DN.SHP"));
  840. char special2[DESC_SIZE] = "";
  841. DropListClass spc2(DATA_SPECIAL2, special2, sizeof(special2),
  842. TPF_EFNT | TPF_NOSHADOW,
  843. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  844. MFCD::Retrieve("EBTN-UP.SHP"),
  845. MFCD::Retrieve("EBTN-DN.SHP"));
  846. for (SpecialWeaponType spec = SPC_FIRST; spec < SPC_COUNT; spec++) {
  847. spc1.Add_Item(SpecialWeaponName[spec]);
  848. spc2.Add_Item(SpecialWeaponName[spec]);
  849. }
  850. if ((unsigned)Action1.Data.Special < SPC_COUNT) {
  851. spc1.Set_Selected_Index(Action1.Data.Special);
  852. } else {
  853. spc1.Set_Selected_Index(0);
  854. }
  855. if ((unsigned)Action2.Data.Special < SPC_COUNT) {
  856. spc2.Set_Selected_Index(Action2.Data.Special);
  857. } else {
  858. spc2.Set_Selected_Index(0);
  859. }
  860. /*
  861. ** Optional quarry type.
  862. */
  863. char quarry1[DESC_SIZE] = "";
  864. DropListClass qlist1(DATA_SPECIAL1, quarry1, sizeof(quarry1),
  865. TPF_EFNT | TPF_NOSHADOW,
  866. AD1_X, AD1_Y, ED_WIDTH, ED_HEIGHT,
  867. MFCD::Retrieve("EBTN-UP.SHP"),
  868. MFCD::Retrieve("EBTN-DN.SHP"));
  869. char quarry2[DESC_SIZE] = "";
  870. DropListClass qlist2(DATA_SPECIAL2, quarry2, sizeof(quarry2),
  871. TPF_EFNT | TPF_NOSHADOW,
  872. AD2_X, AD2_Y, ED_WIDTH, ED_HEIGHT,
  873. MFCD::Retrieve("EBTN-UP.SHP"),
  874. MFCD::Retrieve("EBTN-DN.SHP"));
  875. for (QuarryType q = QUARRY_FIRST; q < QUARRY_COUNT; q++) {
  876. qlist1.Add_Item(QuarryName[q]);
  877. qlist2.Add_Item(QuarryName[q]);
  878. }
  879. if ((unsigned)Action1.Data.Quarry < QUARRY_COUNT) {
  880. qlist1.Set_Selected_Index(Action1.Data.Quarry);
  881. } else {
  882. qlist1.Set_Selected_Index(0);
  883. }
  884. if ((unsigned)Action2.Data.Quarry < QUARRY_COUNT) {
  885. qlist2.Set_Selected_Index(Action2.Data.Quarry);
  886. } else {
  887. qlist2.Set_Selected_Index(0);
  888. }
  889. /*
  890. ** Name of this trigger text edit field.
  891. */
  892. char namebuf[5] = "";
  893. EditClass name_edt(NAME_EDIT, namebuf, sizeof(namebuf), TPF_EFNT | TPF_NOSHADOW, D_DIALOG_X+40, D_DIALOG_Y+30, 40, 9, EditClass::ALPHANUMERIC);
  894. strcpy(namebuf, IniName); // Name
  895. /*
  896. ** Create the list of house's allowed for trigger.
  897. */
  898. char housetext[DESC_SIZE] = "";
  899. DropListClass housebtn(BUTTON_HOUSE, housetext, sizeof(housetext),
  900. TPF_EFNT | TPF_NOSHADOW,
  901. name_edt.X+name_edt.Width+20, name_edt.Y, 95, 8*5,
  902. MFCD::Retrieve("EBTN-UP.SHP"),
  903. MFCD::Retrieve("EBTN-DN.SHP"));
  904. for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
  905. housebtn.Add_Item(HouseTypeClass::As_Reference(house).IniName);
  906. }
  907. if (House == HOUSE_NONE) House = HOUSE_GOOD;
  908. housebtn.Set_Selected_Index(House);
  909. /*
  910. ** Must match order and number of PersistantType specified in
  911. ** TriggerTypeClass definition.
  912. */
  913. char perstext[DESC_SIZE] = "";
  914. static char * _perstext[3] = {
  915. "Volatile",
  916. "Semi-persistent",
  917. "Persistent"
  918. };
  919. DropListClass persbtn(BUTTON_PERSISTANCE, perstext, sizeof(perstext),
  920. TPF_EFNT | TPF_NOSHADOW,
  921. housebtn.X+housebtn.Width+20, housebtn.Y, 105, 8*5,
  922. MFCD::Retrieve("EBTN-UP.SHP"),
  923. MFCD::Retrieve("EBTN-DN.SHP"));
  924. for (i = 0; i < sizeof(_perstext)/sizeof(_perstext[0]); i++) {
  925. persbtn.Add_Item(_perstext[i]);
  926. }
  927. persbtn.Set_Selected_Index(IsPersistant);
  928. /*
  929. ** This button controls the existence and relationship of a second trigger
  930. ** event.
  931. */
  932. int eventflag = EventControl;
  933. TextButtonClass eventbtn(BUTTON_EVENT, TXT_TRIGGER_JUST_EVENT, TPF_EBUTTON, event1list.X, event1list.Y+11, 100, 9);
  934. /*
  935. ** This button controls the existence of a secondary action.
  936. */
  937. bool actionflag = ActionControl;
  938. TextButtonClass actionbtn(BUTTON_ACTION, TXT_TRIGGER_JUST_ACTION, TPF_EBUTTON, action1list.X, action1list.Y+11, 100, 9);
  939. /*
  940. ** Create the ubiquitous OK and Cancel buttons.
  941. */
  942. TextButtonClass okbtn(BUTTON_OK, TXT_OK, TPF_EBUTTON, D_DIALOG_X+35, D_DIALOG_Y+D_DIALOG_H-30, 45, 9);
  943. TextButtonClass cancelbtn(BUTTON_CANCEL, TXT_CANCEL, TPF_EBUTTON, D_DIALOG_X+D_DIALOG_W-80, D_DIALOG_Y+D_DIALOG_H-30, 45, 9);
  944. /*
  945. ** Initialize
  946. */
  947. Set_Logic_Page(SeenBuff);
  948. /*
  949. ** Build the button list
  950. */
  951. commands = &okbtn;
  952. cancelbtn.Add_Tail(*commands);
  953. event1list.Add_Tail(*commands);
  954. action1list.Add_Tail(*commands);
  955. eventbtn.Add_Tail(*commands);
  956. actionbtn.Add_Tail(*commands);
  957. name_edt.Add_Tail(*commands);
  958. persbtn.Add_Tail(*commands);
  959. housebtn.Add_Tail(*commands);
  960. /*
  961. ** Main Processing Loop
  962. */
  963. bool display = true;
  964. bool process = true;
  965. while (process) {
  966. /*
  967. ** Invoke game callback
  968. */
  969. Call_Back();
  970. /*
  971. ** Refresh display if needed
  972. */
  973. if (display /*&& LogicPage->Lock()*/) {
  974. /*
  975. ** Display the dialog box
  976. */
  977. Hide_Mouse();
  978. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  979. Draw_Caption(TXT_TRIGGER_EDITOR, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  980. /*
  981. ** Draw the captions
  982. */
  983. Fancy_Text_Print("Trigger Event:", event1list.X, event1list.Y - 7, scheme, TBLACK, TPF_EFNT | TPF_NOSHADOW);
  984. Fancy_Text_Print("Action to Perform:", action1list.X, action1list.Y - 7, scheme, TBLACK, TPF_EFNT | TPF_NOSHADOW);
  985. Fancy_Text_Print("House:", housebtn.X, housebtn.Y - 7, scheme, TBLACK, TPF_EFNT | TPF_NOSHADOW);
  986. Fancy_Text_Print("Name:", name_edt.X, name_edt.Y - 7, scheme, TBLACK, TPF_EFNT | TPF_NOSHADOW);
  987. Fancy_Text_Print("Persistence:", persbtn.X, persbtn.Y - 7, scheme, TBLACK, TPF_EFNT | TPF_NOSHADOW);
  988. if (eventflag == 3) {
  989. LogicPage->Draw_Line(event1list.X-1, event1list.Y+3, event1list.X-2*RESFACTOR, event1list.Y+3, WHITE);
  990. LogicPage->Draw_Line(event1list.X-2*RESFACTOR, event1list.Y+3, action1list.X-2*RESFACTOR, action1list.Y+3, WHITE);
  991. LogicPage->Draw_Line(action1list.X-1, action1list.Y+3, action1list.X-2*RESFACTOR, action1list.Y+3, WHITE);
  992. LogicPage->Draw_Line(event2list.X-1, event2list.Y+3, event2list.X-5*RESFACTOR, event2list.Y+3, WHITE);
  993. LogicPage->Draw_Line(event2list.X-5*RESFACTOR, event2list.Y+3, action2list.X-5*RESFACTOR, action2list.Y+3, WHITE);
  994. LogicPage->Draw_Line(action2list.X-1, action2list.Y+3, action2list.X-5*RESFACTOR, action2list.Y+3, WHITE);
  995. }
  996. /*
  997. ** Adjust the button list to match current control settings.
  998. */
  999. event2list.Remove();
  1000. switch (eventflag) {
  1001. case 0:
  1002. eventbtn.Set_Text(TXT_TRIGGER_JUST_EVENT);
  1003. break;
  1004. case 1:
  1005. eventbtn.Set_Text(TXT_TRIGGER_AND);
  1006. event2list.Add(*commands);
  1007. break;
  1008. case 2:
  1009. eventbtn.Set_Text(TXT_TRIGGER_OR);
  1010. event2list.Add(*commands);
  1011. break;
  1012. case 3:
  1013. eventbtn.Set_Text(TXT_TRIGGER_LINKED);
  1014. event2list.Add(*commands);
  1015. break;
  1016. }
  1017. /*
  1018. ** Prepare the primary event data field.
  1019. */
  1020. htype1list.Remove();
  1021. way1data.Remove();
  1022. event1data.Remove();
  1023. btype1list.Remove();
  1024. itype1list.Remove();
  1025. atype1list.Remove();
  1026. utype1list.Remove();
  1027. ttype1list.Remove();
  1028. switch (Event_Needs(*event1list.Current_Item())) {
  1029. case NEED_HOUSE:
  1030. htype1list.Add(*commands);
  1031. break;
  1032. case NEED_TEAM:
  1033. ttype1list.Add(*commands);
  1034. break;
  1035. case NEED_WAYPOINT:
  1036. way1data.Add(*commands);
  1037. break;
  1038. case NEED_TIME:
  1039. case NEED_NUMBER:
  1040. event1data.Add(*commands);
  1041. break;
  1042. case NEED_STRUCTURE:
  1043. btype1list.Add(*commands);
  1044. break;
  1045. case NEED_INFANTRY:
  1046. itype1list.Add(*commands);
  1047. break;
  1048. case NEED_AIRCRAFT:
  1049. atype1list.Add(*commands);
  1050. break;
  1051. case NEED_UNIT:
  1052. utype1list.Add(*commands);
  1053. break;
  1054. default:
  1055. break;
  1056. }
  1057. /*
  1058. ** Prepare the secondary event data field.
  1059. */
  1060. htype2list.Remove();
  1061. way2data.Remove();
  1062. event2data.Remove();
  1063. btype2list.Remove();
  1064. itype2list.Remove();
  1065. atype2list.Remove();
  1066. utype2list.Remove();
  1067. ttype2list.Remove();
  1068. if (commands->Extract_Gadget(EVENT_LIST2)) {
  1069. switch (Event_Needs(*event2list.Current_Item())) {
  1070. case NEED_HOUSE:
  1071. htype2list.Add(*commands);
  1072. break;
  1073. case NEED_TEAM:
  1074. ttype2list.Add(*commands);
  1075. break;
  1076. case NEED_WAYPOINT:
  1077. way2data.Add(*commands);
  1078. break;
  1079. case NEED_TIME:
  1080. case NEED_NUMBER:
  1081. event2data.Add(*commands);
  1082. break;
  1083. case NEED_STRUCTURE:
  1084. btype2list.Add(*commands);
  1085. break;
  1086. case NEED_INFANTRY:
  1087. itype2list.Add(*commands);
  1088. break;
  1089. case NEED_AIRCRAFT:
  1090. atype2list.Add(*commands);
  1091. break;
  1092. case NEED_UNIT:
  1093. utype2list.Add(*commands);
  1094. break;
  1095. default:
  1096. break;
  1097. }
  1098. }
  1099. /*
  1100. ** Setup the action buttons and associated data entry fields.
  1101. */
  1102. actionbtn.Remove();
  1103. action2list.Remove();
  1104. if (eventflag == 3) {
  1105. action2list.Add(*commands);
  1106. } else {
  1107. actionbtn.Add(*commands);
  1108. if (actionflag) {
  1109. actionbtn.Set_Text(TXT_TRIGGER_AND);
  1110. action2list.Add(*commands);
  1111. } else {
  1112. actionbtn.Set_Text(TXT_TRIGGER_JUST_ACTION);
  1113. }
  1114. }
  1115. qlist1.Remove();
  1116. spc1.Remove();
  1117. htype3list.Remove();
  1118. booltype1list.Remove();
  1119. trtype1list.Remove();
  1120. way3data.Remove();
  1121. action1data.Remove();
  1122. ttype3list.Remove();
  1123. themetype1list.Remove();
  1124. soundtype1list.Remove();
  1125. movietype1list.Remove();
  1126. speechtype1list.Remove();
  1127. switch (Action_Needs(*action1list.Current_Item())) {
  1128. case NEED_MOVIE:
  1129. movietype1list.Add(*commands);
  1130. break;
  1131. case NEED_SPECIAL:
  1132. spc1.Add(*commands);
  1133. break;
  1134. case NEED_HOUSE:
  1135. htype3list.Add(*commands);
  1136. break;
  1137. case NEED_BOOL:
  1138. booltype1list.Add(*commands);
  1139. break;
  1140. case NEED_TRIGGER:
  1141. trtype1list.Add(*commands);
  1142. break;
  1143. case NEED_TEAM:
  1144. ttype3list.Add(*commands);
  1145. break;
  1146. case NEED_NUMBER:
  1147. action1data.Add(*commands);
  1148. break;
  1149. case NEED_WAYPOINT:
  1150. way3data.Add(*commands);
  1151. break;
  1152. case NEED_THEME:
  1153. themetype1list.Add(*commands);
  1154. break;
  1155. case NEED_SOUND:
  1156. soundtype1list.Add(*commands);
  1157. break;
  1158. case NEED_SPEECH:
  1159. speechtype1list.Add(*commands);
  1160. break;
  1161. case NEED_QUARRY:
  1162. qlist1.Add(*commands);
  1163. break;
  1164. }
  1165. qlist2.Remove();
  1166. spc2.Remove();
  1167. htype4list.Remove();
  1168. booltype2list.Remove();
  1169. trtype2list.Remove();
  1170. way4data.Remove();
  1171. action2data.Remove();
  1172. ttype4list.Remove();
  1173. themetype2list.Remove();
  1174. soundtype2list.Remove();
  1175. movietype2list.Remove();
  1176. speechtype2list.Remove();
  1177. if (commands->Extract_Gadget(ACTION_LIST2)) {
  1178. switch (Action_Needs(*action2list.Current_Item())) {
  1179. case NEED_MOVIE:
  1180. movietype2list.Add(*commands);
  1181. break;
  1182. case NEED_SPECIAL:
  1183. spc2.Add(*commands);
  1184. break;
  1185. case NEED_HOUSE:
  1186. htype4list.Add(*commands);
  1187. break;
  1188. case NEED_BOOL:
  1189. booltype2list.Add(*commands);
  1190. break;
  1191. case NEED_TRIGGER:
  1192. trtype2list.Add(*commands);
  1193. break;
  1194. case NEED_TEAM:
  1195. ttype4list.Add(*commands);
  1196. break;
  1197. case NEED_NUMBER:
  1198. action2data.Add(*commands);
  1199. break;
  1200. case NEED_WAYPOINT:
  1201. way4data.Add(*commands);
  1202. break;
  1203. case NEED_THEME:
  1204. themetype2list.Add(*commands);
  1205. break;
  1206. case NEED_SOUND:
  1207. soundtype2list.Add(*commands);
  1208. break;
  1209. case NEED_SPEECH:
  1210. speechtype2list.Add(*commands);
  1211. break;
  1212. case NEED_QUARRY:
  1213. qlist2.Add(*commands);
  1214. break;
  1215. }
  1216. }
  1217. /*
  1218. ** Collapse any dropped down list boxes.
  1219. */
  1220. spc1.Collapse();
  1221. spc2.Collapse();
  1222. qlist1.Collapse();
  1223. qlist2.Collapse();
  1224. htype1list.Collapse();
  1225. htype2list.Collapse();
  1226. htype3list.Collapse();
  1227. htype4list.Collapse();
  1228. ttype1list.Collapse();
  1229. ttype2list.Collapse();
  1230. ttype3list.Collapse();
  1231. ttype4list.Collapse();
  1232. btype1list.Collapse();
  1233. btype2list.Collapse();
  1234. utype1list.Collapse();
  1235. utype2list.Collapse();
  1236. itype1list.Collapse();
  1237. itype2list.Collapse();
  1238. atype1list.Collapse();
  1239. atype2list.Collapse();
  1240. trtype1list.Collapse();
  1241. trtype2list.Collapse();
  1242. action1list.Collapse();
  1243. action2list.Collapse();
  1244. event1list.Collapse();
  1245. event2list.Collapse();
  1246. housebtn.Collapse();
  1247. persbtn.Collapse();
  1248. booltype1list.Collapse();
  1249. booltype2list.Collapse();
  1250. themetype1list.Collapse();
  1251. themetype2list.Collapse();
  1252. soundtype1list.Collapse();
  1253. soundtype2list.Collapse();
  1254. movietype1list.Collapse();
  1255. movietype2list.Collapse();
  1256. speechtype1list.Collapse();
  1257. speechtype2list.Collapse();
  1258. commands->Flag_List_To_Redraw();
  1259. Show_Mouse();
  1260. display = false;
  1261. // LogicPage->Unlock();
  1262. }
  1263. /*
  1264. ** Get user input
  1265. */
  1266. KeyNumType input = commands->Input();
  1267. /*
  1268. ** Process input
  1269. */
  1270. switch (input) {
  1271. case BUTTON_EVENT | KN_BUTTON:
  1272. eventflag = (eventflag+1) % 4;
  1273. display = true;
  1274. break;
  1275. case BUTTON_ACTION | KN_BUTTON:
  1276. actionflag = (actionflag == false);
  1277. display = true;
  1278. break;
  1279. case DATA_SPEECH1 | KN_BUTTON:
  1280. Speak(VoxType(speechtype1list.Current_Index()));
  1281. display = true;
  1282. break;
  1283. case DATA_SPEECH2 | KN_BUTTON:
  1284. Speak(VoxType(speechtype2list.Current_Index()));
  1285. display = true;
  1286. break;
  1287. case DATA_SOUND1 | KN_BUTTON:
  1288. Sound_Effect(VocType(soundtype1list.Current_Index()));
  1289. display = true;
  1290. break;
  1291. case DATA_SOUND2 | KN_BUTTON:
  1292. Sound_Effect(VocType(soundtype2list.Current_Index()));
  1293. display = true;
  1294. break;
  1295. /*
  1296. ** Transfer all the necessary values from the edit fields into their
  1297. ** respective positions within the trigger object.
  1298. */
  1299. case KN_RETURN:
  1300. case BUTTON_OK | KN_BUTTON:
  1301. House = HousesType(housebtn.Current_Index());
  1302. IsPersistant = PersistantType(persbtn.Current_Index());
  1303. if (strlen(namebuf)==0) {
  1304. Set_Name("____");
  1305. } else {
  1306. Set_Name(namebuf);
  1307. }
  1308. /*
  1309. ** Primary event specific data retrieval.
  1310. */
  1311. EventControl = MultiStyleType(eventflag);
  1312. Event1.Event = *event1list.Current_Item();
  1313. switch (Event_Needs(Event1.Event)) {
  1314. case NEED_HOUSE:
  1315. Event1.Data.House = HousesType(htype1list.Current_Index());
  1316. break;
  1317. case NEED_TIME:
  1318. Event1.Data.Value = atoi(event1data.Get_Text());
  1319. break;
  1320. case NEED_NUMBER:
  1321. Event1.Data.Value = atoi(event1data.Get_Text());
  1322. break;
  1323. case NEED_STRUCTURE:
  1324. Event1.Data.Structure = StructType(btype1list.Current_Index());
  1325. break;
  1326. case NEED_UNIT:
  1327. Event1.Data.Unit = UnitType(utype1list.Current_Index());
  1328. break;
  1329. case NEED_INFANTRY:
  1330. Event1.Data.Infantry = InfantryType(itype1list.Current_Index());
  1331. break;
  1332. case NEED_AIRCRAFT:
  1333. Event1.Data.Aircraft = AircraftType(atype1list.Current_Index());
  1334. break;
  1335. case NEED_WAYPOINT:
  1336. Event1.Data.Value = toupper(way1[0]) - 'A';
  1337. if (way1[1] != '\0') {
  1338. Event1.Data.Value = (Event1.Data.Value+1)*26;
  1339. Event1.Data.Value += toupper(way1[1]) - 'A';
  1340. }
  1341. break;
  1342. case NEED_TEAM:
  1343. Event1.Team = TeamTypeClass::From_Name(ttype1list.Current_Item());
  1344. break;
  1345. }
  1346. /*
  1347. ** Secondary event specific data retrieval.
  1348. */
  1349. Event2.Event = *event2list.Current_Item();
  1350. switch (Event_Needs(Event2.Event)) {
  1351. case NEED_HOUSE:
  1352. Event2.Data.House = HousesType(htype2list.Current_Index());
  1353. break;
  1354. case NEED_TIME:
  1355. Event2.Data.Value = atoi(event2data.Get_Text());
  1356. break;
  1357. case NEED_NUMBER:
  1358. Event2.Data.Value = atoi(event2data.Get_Text());
  1359. break;
  1360. case NEED_STRUCTURE:
  1361. Event2.Data.Structure = StructType(btype2list.Current_Index());
  1362. break;
  1363. case NEED_UNIT:
  1364. Event2.Data.Unit = UnitType(utype2list.Current_Index());
  1365. break;
  1366. case NEED_INFANTRY:
  1367. Event2.Data.Infantry = InfantryType(itype2list.Current_Index());
  1368. break;
  1369. case NEED_AIRCRAFT:
  1370. Event2.Data.Aircraft = AircraftType(atype2list.Current_Index());
  1371. break;
  1372. case NEED_WAYPOINT:
  1373. Event2.Data.Value = toupper(way2[0]) - 'A';
  1374. if (way2[1] != '\0') {
  1375. Event2.Data.Value = (Event2.Data.Value+1)*26;
  1376. Event2.Data.Value += toupper(way2[1]) - 'A';
  1377. }
  1378. break;
  1379. case NEED_TEAM:
  1380. Event2.Team = TeamTypeClass::As_Pointer(ttype2list.Current_Item());
  1381. break;
  1382. }
  1383. /*
  1384. ** Primary action data retrieval.
  1385. */
  1386. ActionControl = MultiStyleType(actionflag);
  1387. Action1.Action = *action1list.Current_Item();
  1388. switch (Action_Needs(Action1.Action)) {
  1389. case NEED_SPECIAL:
  1390. Action1.Data.Special = SpecialWeaponType(spc1.Current_Index());
  1391. break;
  1392. case NEED_HOUSE:
  1393. Action1.Data.House = HousesType(htype3list.Current_Index());
  1394. break;
  1395. case NEED_TRIGGER:
  1396. Action1.Trigger = TriggerTypeClass::From_Name(trtype1list.Current_Item());
  1397. break;
  1398. case NEED_TEAM:
  1399. Action1.Team = TeamTypeClass::From_Name(ttype3list.Current_Item());
  1400. break;
  1401. case NEED_NUMBER:
  1402. Action1.Data.Value = atoi(action1data.Get_Text());
  1403. break;
  1404. case NEED_WAYPOINT:
  1405. Action1.Data.Value = toupper(way3[0]) - 'A';
  1406. if (way3[1] != '\0') {
  1407. Action1.Data.Value = (Action1.Data.Value+1)*26;
  1408. Action1.Data.Value += toupper(way3[1]) - 'A';
  1409. }
  1410. break;
  1411. case NEED_BOOL:
  1412. Action1.Data.Bool = booltype1list.Current_Index();
  1413. break;
  1414. case NEED_THEME:
  1415. Action1.Data.Theme = ThemeType(themetype1list.Current_Index());
  1416. break;
  1417. case NEED_SOUND:
  1418. Action1.Data.Sound = VocType(soundtype1list.Current_Index());
  1419. break;
  1420. case NEED_MOVIE:
  1421. Action1.Data.Movie = VQType(movietype1list.Current_Index());
  1422. break;
  1423. case NEED_SPEECH:
  1424. Action1.Data.Speech = VoxType(speechtype1list.Current_Index());
  1425. break;
  1426. case NEED_QUARRY:
  1427. Action1.Data.Quarry = QuarryType(qlist1.Current_Index());
  1428. break;
  1429. }
  1430. /*
  1431. ** Secondary action data retrieval.
  1432. */
  1433. Action2.Action = *action2list.Current_Item();
  1434. switch (Action_Needs(Action2.Action)) {
  1435. case NEED_SPECIAL:
  1436. Action2.Data.Special = SpecialWeaponType(spc2.Current_Index());
  1437. break;
  1438. case NEED_HOUSE:
  1439. Action2.Data.House = HousesType(htype4list.Current_Index());
  1440. break;
  1441. case NEED_TRIGGER:
  1442. Action2.Trigger = TriggerTypeClass::From_Name(trtype2list.Current_Item());
  1443. break;
  1444. case NEED_TEAM:
  1445. Action2.Team = TeamTypeClass::From_Name(ttype4list.Current_Item());
  1446. break;
  1447. case NEED_NUMBER:
  1448. Action2.Data.Value = atoi(action2data.Get_Text());
  1449. break;
  1450. case NEED_WAYPOINT:
  1451. Action2.Data.Value = toupper(way4[0]) - 'A';
  1452. if (way4[1] != '\0') {
  1453. Action2.Data.Value = (Action2.Data.Value+1)*26;
  1454. Action2.Data.Value += toupper(way4[1]) - 'A';
  1455. }
  1456. break;
  1457. case NEED_BOOL:
  1458. Action2.Data.Bool = booltype2list.Current_Index();
  1459. break;
  1460. case NEED_THEME:
  1461. Action2.Data.Theme = ThemeType(themetype2list.Current_Index());
  1462. break;
  1463. case NEED_MOVIE:
  1464. Action2.Data.Movie = VQType(movietype2list.Current_Index());
  1465. break;
  1466. case NEED_SOUND:
  1467. Action2.Data.Sound = VocType(soundtype2list.Current_Index());
  1468. break;
  1469. case NEED_SPEECH:
  1470. Action2.Data.Speech = VoxType(speechtype2list.Current_Index());
  1471. break;
  1472. case NEED_QUARRY:
  1473. Action2.Data.Quarry = QuarryType(qlist1.Current_Index());
  1474. break;
  1475. }
  1476. return(true);
  1477. case KN_ESC:
  1478. case BUTTON_CANCEL | KN_BUTTON:
  1479. process = false;
  1480. /*
  1481. ** Always signal a redraw if any of the buttons were touched. This
  1482. ** can be determined by examining the button bit flag in the input
  1483. ** return value.
  1484. */
  1485. default:
  1486. if (input & KN_BUTTON) {
  1487. display = true;
  1488. }
  1489. break;
  1490. }
  1491. }
  1492. return(false);
  1493. }
  1494. #endif
  1495. #if defined(CHEAT_KEYS) || defined(SCENARIO_EDITOR)
  1496. /***********************************************************************************************
  1497. * TriggerTypeClass::Description -- Build a text description of the trigger type. *
  1498. * *
  1499. * This will build a (static) text description of the trigger type. Use this description *
  1500. * when displaying this trigger in a list box. *
  1501. * *
  1502. * INPUT: none *
  1503. * *
  1504. * OUTPUT: Returns with a pointer to a one line text description of this trigger. *
  1505. * *
  1506. * WARNINGS: The pointer returned actually points to a static buffer. The pointer is only *
  1507. * valid until this routine is called again. *
  1508. * *
  1509. * HISTORY: *
  1510. * 07/09/1996 JLB : Created. *
  1511. *=============================================================================================*/
  1512. char const * TriggerTypeClass::Description(void) const
  1513. {
  1514. static char _buffer[128];
  1515. char special;
  1516. switch (EventControl) {
  1517. case MULTI_AND:
  1518. special = '&';
  1519. break;
  1520. case MULTI_OR:
  1521. special = '|';
  1522. break;
  1523. case MULTI_LINKED:
  1524. special = '=';
  1525. break;
  1526. default:
  1527. special = '.';
  1528. break;
  1529. }
  1530. char special2 = '.';
  1531. if (ActionControl == MULTI_AND) {
  1532. special2 = '&';
  1533. }
  1534. char tbuf[32];
  1535. char const * added = "";
  1536. switch (Event_Needs(Event1.Event)) {
  1537. case NEED_NUMBER:
  1538. sprintf(tbuf, "%d", Event1.Data.Value);
  1539. added = tbuf;
  1540. break;
  1541. case NEED_UNIT:
  1542. added = Text_String(UnitTypeClass::As_Reference(Event1.Data.Unit).Full_Name());;
  1543. break;
  1544. case NEED_AIRCRAFT:
  1545. added = Text_String(AircraftTypeClass::As_Reference(Event1.Data.Aircraft).Full_Name());;
  1546. break;
  1547. case NEED_STRUCTURE:
  1548. added = Text_String(BuildingTypeClass::As_Reference(Event1.Data.Structure).Full_Name());
  1549. break;
  1550. case NEED_INFANTRY:
  1551. added = Text_String(InfantryTypeClass::As_Reference(Event1.Data.Infantry).Full_Name());
  1552. break;
  1553. case NEED_WAYPOINT:
  1554. if (Event1.Data.Value < 26) {
  1555. sprintf(tbuf, "'%c'", Event1.Data.Value + 'A');
  1556. } else {
  1557. sprintf(tbuf, "'%c%c'", (Event1.Data.Value / 26) + 'A'-1, (Event1.Data.Value % 26) + 'A');
  1558. }
  1559. added = tbuf;
  1560. break;
  1561. default:
  1562. break;
  1563. }
  1564. /*
  1565. ** Persistence indicator value.
  1566. */
  1567. char pers = 'V';
  1568. if (IsPersistant == SEMIPERSISTANT) pers = 'S';
  1569. if (IsPersistant == PERSISTANT) pers = 'P';
  1570. sprintf(_buffer, "%4.4s\t %s %c%c%c %s%s",
  1571. IniName,
  1572. HouseTypeClass::As_Reference(House).Suffix,
  1573. pers,
  1574. special,
  1575. special2,
  1576. Name_From_Event(Event1.Event),
  1577. added);
  1578. return(_buffer);
  1579. }
  1580. #endif
  1581. /***********************************************************************************************
  1582. * TriggerTypeClass::Attaches_To -- Determines what trigger can attach to. *
  1583. * *
  1584. * This routine will examine the trigger events and return with a composit bitfield that *
  1585. * indicates what this trigger can be attached to. This is used for trigger placement *
  1586. * and logic processing. *
  1587. * *
  1588. * INPUT: none *
  1589. * *
  1590. * OUTPUT: Returns with AttachType bitfield representing what this trigger can be attached *
  1591. * to. *
  1592. * *
  1593. * WARNINGS: none *
  1594. * *
  1595. * HISTORY: *
  1596. * 11/30/1995 JLB : Created. *
  1597. *=============================================================================================*/
  1598. AttachType TriggerTypeClass::Attaches_To(void) const
  1599. {
  1600. AttachType attach = ::Attaches_To(Event1.Event);
  1601. if (EventControl != MULTI_ONLY) {
  1602. attach = attach | ::Attaches_To(Event2.Event);
  1603. }
  1604. return(attach);
  1605. }
  1606. /***********************************************************************************************
  1607. * TriggerTypeClass::Read_INI -- reads triggers from the INI file *
  1608. * *
  1609. * INI entry format: *
  1610. * Triggername = Eventname, Actionname, Data, Housename, TeamName, IsPersistant *
  1611. * *
  1612. * This routine reads in the triggers & creates them. Then, other classes can *
  1613. * get pointers to the triggers they're linked to. *
  1614. * *
  1615. * The routine relies on the TeamTypeClasses already being loaded so it can resolve *
  1616. * references to teams in this function. *
  1617. * *
  1618. * Cell Trigger pointers & IsTrigger flags are set in DisplayClass::Read_INI(), *
  1619. * and cleared in the Map::Init() routine (which clears all cell objects to 0's). *
  1620. * *
  1621. * Object's pointers are set in: *
  1622. * InfantryClass::Read_INI() *
  1623. * BuildingClass::Read_INI() *
  1624. * UnitClass::Read_INI() *
  1625. * TerrainClass::Read_INI() *
  1626. * The object trigger pointers are cleared in the ObjectClass constructor. *
  1627. * *
  1628. * The House's EMSListOf triggers is set in this routine, and cleared in the *
  1629. * HouseClass::Init() routine. *
  1630. * *
  1631. * INPUT: *
  1632. * buffer buffer to hold the INI data *
  1633. * *
  1634. * OUTPUT: *
  1635. * none. *
  1636. * *
  1637. * WARNINGS: *
  1638. * This function must be called before any other class's Read_INI. *
  1639. * *
  1640. * HISTORY: *
  1641. * 11/28/1994 BR : Created. *
  1642. *=============================================================================================*/
  1643. void TriggerTypeClass::Read_INI(CCINIClass & ini)
  1644. {
  1645. TriggerTypeClass *trigger; // Working trigger pointer.
  1646. char buf[128];
  1647. int len = ini.Entry_Count(INI_Name());
  1648. for (int index = 0; index < len; index++) {
  1649. char const * entry = ini.Get_Entry(INI_Name(), index);
  1650. /*
  1651. ** Create a new trigger.
  1652. */
  1653. trigger = new TriggerTypeClass();
  1654. /*
  1655. ** Get the trigger entry.
  1656. */
  1657. ini.Get_String(INI_Name(), entry, NULL, buf, sizeof(buf));
  1658. /*
  1659. ** Fill in the trigger.
  1660. */
  1661. trigger->Fill_In((char *)entry, buf);
  1662. }
  1663. if (NewINIFormat < 2) {
  1664. /*
  1665. ** Fix up the self-referential trigger pointers.
  1666. */
  1667. for (int trig_index = 0; trig_index < TriggerTypes.Count(); trig_index++) {
  1668. TriggerTypeClass * trigger = TriggerTypes.Ptr(trig_index);
  1669. char * ptr = (char *)trigger->Action1.Trigger.Raw();
  1670. if (ptr /*&& trigger->Action1.Trigger.Raw() != -1*/) {
  1671. trigger->Action1.Trigger = TriggerTypeClass::From_Name(ptr);
  1672. free(ptr);
  1673. }
  1674. ptr = (char *)trigger->Action2.Trigger.Raw();
  1675. if (ptr /*&& trigger->Action2.Trigger.Raw() != -1*/) {
  1676. trigger->Action2.Trigger = TriggerTypeClass::From_Name(ptr);
  1677. free(ptr);
  1678. }
  1679. }
  1680. }
  1681. }
  1682. /***********************************************************************************************
  1683. * TriggerTypeClass::Fill_In -- fills in trigger from the given INI entry *
  1684. * *
  1685. * This routine fills in the given trigger with the given name, and values from *
  1686. * the given INI entry. *
  1687. * *
  1688. * (This routine is used by the scenario editor, to import teams from the MASTER.INI file.) *
  1689. * *
  1690. * INI entry format: *
  1691. * Triggername = Eventname, Actionname, Data, Housename, TeamName, IsPersistant *
  1692. * *
  1693. * INPUT: *
  1694. * name mnemonic for the desired trigger *
  1695. * entry INI entry to parse *
  1696. * *
  1697. * OUTPUT: *
  1698. * none. *
  1699. * *
  1700. * WARNINGS: *
  1701. * none. *
  1702. * *
  1703. * HISTORY: *
  1704. * 11/28/1994 BR : Created. *
  1705. *=============================================================================================*/
  1706. void TriggerTypeClass::Fill_In(char * name, char * entry)
  1707. {
  1708. assert(TriggerTypes.ID(this) == ID);
  1709. /*
  1710. ** Set its name.
  1711. */
  1712. Set_Name(name);
  1713. IsPersistant = PersistantType(atoi(strtok(entry, ",")));
  1714. House = HousesType(atoi(strtok(NULL, ",")));
  1715. EventControl = MultiStyleType(atoi(strtok(NULL, ",")));
  1716. ActionControl = MultiStyleType(atoi(strtok(NULL, ",")));
  1717. Event1.Read_INI();
  1718. Event2.Read_INI();
  1719. Action1.Read_INI();
  1720. Action2.Read_INI();
  1721. }
  1722. /***********************************************************************************************
  1723. * TriggerTypeClass::Write_INI -- Stores all trigger types to the INI database specified. *
  1724. * *
  1725. * This routine will write out all trigger type objects to the INI database. Any existing *
  1726. * trigger types in the database will be cleared out. *
  1727. * *
  1728. * INPUT: ini -- Reference to the INI database to have the trigger types added. *
  1729. * *
  1730. * OUTPUT: none *
  1731. * *
  1732. * WARNINGS: none *
  1733. * *
  1734. * HISTORY: *
  1735. * 07/09/1996 JLB : Created. *
  1736. *=============================================================================================*/
  1737. void TriggerTypeClass::Write_INI(CCINIClass & ini)
  1738. {
  1739. ini.Clear("Triggers");
  1740. ini.Clear(INI_Name());
  1741. /*
  1742. ** Now write all the trigger data out
  1743. */
  1744. for (int index = 0; index < TriggerTypes.Count(); index++) {
  1745. // for (int index = TriggerTypes.Count()-1; index >= 0; index--) {
  1746. char buf[256];
  1747. TriggerTypeClass * trigger = TriggerTypes.Ptr(index);
  1748. trigger->Build_INI_Entry(buf);
  1749. ini.Put_String(INI_Name(), trigger->IniName, buf);
  1750. }
  1751. }
  1752. /***********************************************************************************************
  1753. * TriggerTypeClass::Build_INI_Entry -- Construct the INI entry into the buffer specified. *
  1754. * *
  1755. * This low level routine will take the information in this trigger type and store it *
  1756. * into a buffer such that the resultant string can be stored into an INI database for *
  1757. * later retrieval. *
  1758. * *
  1759. * INPUT: buffer -- Pointer to the buffer to store the INI entry string. *
  1760. * *
  1761. * OUTPUT: none *
  1762. * *
  1763. * WARNINGS: Be sure the buffer is big enough. Usually 128 bytes is more than sufficient. *
  1764. * *
  1765. * HISTORY: *
  1766. * 07/09/1996 JLB : Created. *
  1767. *=============================================================================================*/
  1768. void TriggerTypeClass::Build_INI_Entry(char * buffer) const
  1769. {
  1770. /*
  1771. ** Build the root portion of the trigger event.
  1772. */
  1773. sprintf(buffer, "%d,%d,%d,%d,", IsPersistant, House, EventControl, ActionControl);
  1774. /*
  1775. ** Append the event and action values.
  1776. */
  1777. buffer += strlen(buffer);
  1778. Event1.Build_INI_Entry(buffer);
  1779. strcat(buffer, ",");
  1780. buffer += strlen(buffer);
  1781. Event2.Build_INI_Entry(buffer);
  1782. strcat(buffer, ",");
  1783. buffer += strlen(buffer);
  1784. Action1.Build_INI_Entry(buffer);
  1785. strcat(buffer, ",");
  1786. buffer += strlen(buffer);
  1787. Action2.Build_INI_Entry(buffer);
  1788. }
  1789. #if defined(CHEAT_KEYS) || defined(SCENARIO_EDITOR)
  1790. /***********************************************************************************************
  1791. * TriggerTypeClass::Draw_It -- Draws this trigger as if it were a line in a list box. *
  1792. * *
  1793. * This routine is called when triggers are assigned to a list box and then must be drawn. *
  1794. * It will display an identifying text string with as much information as is useful. *
  1795. * *
  1796. * INPUT: index -- The index number of this line in the list box. *
  1797. * *
  1798. * x,y -- The pixel coordinate of the upper left corner of the text box. *
  1799. * *
  1800. * width,height -- The dimensions of the text box to display the description in. *
  1801. * *
  1802. * selected -- Is this a selected line? If so, then it should be highlighted. *
  1803. * *
  1804. * flags -- The text print flags to use to display this text string. *
  1805. * *
  1806. * OUTPUT: none *
  1807. * *
  1808. * WARNINGS: none *
  1809. * *
  1810. * HISTORY: *
  1811. * 07/09/1996 JLB : Created. *
  1812. *=============================================================================================*/
  1813. void TriggerTypeClass::Draw_It(int , int x, int y, int width, int height, bool selected, TextPrintType flags) const
  1814. {
  1815. RemapControlType * scheme = GadgetClass::Get_Color_Scheme();
  1816. static int _tabs[] = {13,40};
  1817. if ((flags & 0x0F) == TPF_6PT_GRAD || (flags & 0x0F) == TPF_EFNT) {
  1818. if (selected) {
  1819. flags = flags | TPF_BRIGHT_COLOR;
  1820. LogicPage->Fill_Rect(x, y, x + width - 1, y + height - 1, scheme->Shadow);
  1821. } else {
  1822. if (!(flags & TPF_USE_GRAD_PAL)) {
  1823. flags = flags | TPF_MEDIUM_COLOR;
  1824. }
  1825. }
  1826. Conquer_Clip_Text_Print(Description(), x, y, scheme, TBLACK, flags, width, _tabs);
  1827. } else {
  1828. Conquer_Clip_Text_Print(Description(), x, y, (selected ? &ColorRemaps[PCOLOR_DIALOG_BLUE] : &ColorRemaps[PCOLOR_GREY]), TBLACK, flags, width, _tabs);
  1829. }
  1830. }
  1831. #endif
  1832. /***********************************************************************************************
  1833. * TriggerTypeClass::Init -- Initialize the trigger type object management system. *
  1834. * *
  1835. * This routine should be called to initialize the trigger type object system. It should *
  1836. * be called when clearing out a scenario. *
  1837. * *
  1838. * INPUT: none *
  1839. * *
  1840. * OUTPUT: none *
  1841. * *
  1842. * WARNINGS: All trigger types will be destroyed by this routine. *
  1843. * *
  1844. * HISTORY: *
  1845. * 07/09/1996 JLB : Created. *
  1846. *=============================================================================================*/
  1847. void TriggerTypeClass::Init(void)
  1848. {
  1849. TriggerTypes.Free_All();
  1850. }
  1851. /***********************************************************************************************
  1852. * TriggerTypeClass::From_Name -- Convert an ASCII name into a trigger type pointer. *
  1853. * *
  1854. * Given just an ASCII representation of the trigger type, this routine will return with *
  1855. * a pointer to the trigger type it refers to. Typical use of this is when parsing *
  1856. * scenario INI files. *
  1857. * *
  1858. * INPUT: name -- Pointer to the name to use to identify the trigger type class object to *
  1859. * be looked up. *
  1860. * *
  1861. * OUTPUT: Returns with a pointer to the trigger type class object that matches the name *
  1862. * specified. If no match could be found, then NULL is returned. *
  1863. * *
  1864. * WARNINGS: none *
  1865. * *
  1866. * HISTORY: *
  1867. * 07/09/1996 JLB : Created. *
  1868. *=============================================================================================*/
  1869. TriggerTypeClass * TriggerTypeClass::From_Name(char const * name)
  1870. {
  1871. if (name != NULL) {
  1872. for (int index = 0; index < TriggerTypes.Count(); index++) {
  1873. if (stricmp(TriggerTypes.Ptr(index)->Name(), name) == 0) {
  1874. return(TriggerTypes.Ptr(index));
  1875. }
  1876. }
  1877. }
  1878. return(NULL);
  1879. }