TRIGTYPE.CPP 79 KB

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