MAPEDTM.CPP 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074
  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: F:\projects\c&c\vcs\code\mapedtm.cpv 2.18 16 Oct 1995 16:52:16 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 : MAPEDTM.CPP *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : December 7, 1994 *
  26. * *
  27. * Last Update : April 9, 1996 [BRR] *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * Functions: *
  31. * MapEditClass::Handle_Teams -- main team-dialog-handling function *
  32. * MapEditClass::Select_Team -- user selects a team from a list *
  33. * MapEditClass::Edit_Team -- user edits a team's options *
  34. * MapEditClass::Team_Members -- user picks makeup of a team *
  35. * MapEditClass::Build_Mission_list -- fills in mission list box *
  36. * MapEditClass::Draw_Member -- Draws a member of the team dialog box. *
  37. * MapEditClass::Team_Members -- Team members dialog *
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #include "function.h"
  40. #ifdef SCENARIO_EDITOR
  41. /***************************************************************************
  42. * MapEditClass::Handle_Teams -- main team-dialog-handling function *
  43. * *
  44. * INPUT: *
  45. * none. *
  46. * *
  47. * OUTPUT: *
  48. * none. *
  49. * *
  50. * WARNINGS: *
  51. * none. *
  52. * *
  53. * HISTORY: *
  54. * 12/08/1994 BR : Created. *
  55. *=========================================================================*/
  56. void MapEditClass::Handle_Teams(char const * caption)
  57. {
  58. int rc;
  59. /*------------------------------------------------------------------------
  60. Team dialog processing loop:
  61. - Invoke the team selection dialog. If a team's selected, break
  62. & return
  63. - If user wants to edit the current team, do so
  64. - If user wants to create new team, new a TeamTypeClass & edit it
  65. - If user wants to delete team, delete the current team
  66. - Keep looping until 'OK'
  67. ------------------------------------------------------------------------*/
  68. for (;;) {
  69. /*
  70. ............................. Select team .............................
  71. */
  72. rc = Select_Team(caption);
  73. /*
  74. ............................. 'OK'; break .............................
  75. */
  76. if (rc == 0) {
  77. break;
  78. } else {
  79. /*
  80. ............................... 'Edit' ................................
  81. */
  82. if (rc == 1 && CurTeam) {
  83. if (Edit_Team()==0) {
  84. Changed = 1;
  85. }
  86. } else {
  87. /*
  88. ................................ 'New' ................................
  89. */
  90. if (rc == 2) {
  91. /*
  92. ........................ Create a new team .........................
  93. */
  94. CurTeam = new TeamTypeClass();
  95. if (CurTeam) {
  96. /*
  97. ................... delete it if user cancels ...................
  98. */
  99. if (Edit_Team()==-1) {
  100. delete CurTeam;
  101. CurTeam = NULL;
  102. } else {
  103. Changed = 1;
  104. }
  105. } else {
  106. /*
  107. ................. Unable to create; issue warning ..................
  108. */
  109. CCMessageBox().Process("No more teams available.");
  110. HiddenPage.Clear();
  111. Flag_To_Redraw(true);
  112. Render();
  113. }
  114. } else {
  115. /*
  116. .............................. 'Delete' ...............................
  117. */
  118. if (rc==3) {
  119. if (CurTeam) {
  120. CurTeam->Remove();
  121. CurTeam = NULL;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. /***************************************************************************
  130. * MapEditClass::Select_Team -- user selects a team from a list *
  131. * *
  132. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  133. * ³ Teams ³ *
  134. * ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ³ *
  135. * ³ ³ Name House Class:Count,Class:Count ³³ ³ *
  136. * ³ ³ Name House Class:Count,Class:Count ÃÄ´ ³ *
  137. * ³ ³ Name House Class:Count,Class:Count ³ ³ ³ *
  138. * ³ ³ Name House Class:Count,Class:Count ³ ³ ³ *
  139. * ³ ³ ³ ³ ³ *
  140. * ³ ³ ³ ³ ³ *
  141. * ³ ³ ÃÄ´ ³ *
  142. * ³ ³ ³³ ³ *
  143. * ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ³ *
  144. * ³ ³ *
  145. * ³ [Edit] [New] [Delete] [OK] ³ *
  146. * ³ ³ *
  147. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  148. * *
  149. * INPUT: *
  150. * none. *
  151. * *
  152. * OUTPUT: *
  153. * 0 = OK, 1 = Edit, 2 = New, 3 = Delete *
  154. * *
  155. * WARNINGS: *
  156. * Uses HIDBUFF. *
  157. * *
  158. * HISTORY: *
  159. * 12/08/1994 BR : Created. *
  160. *=========================================================================*/
  161. int MapEditClass::Select_Team(char const * caption)
  162. {
  163. /*........................................................................
  164. Dialog & button dimensions
  165. ........................................................................*/
  166. enum {
  167. D_DIALOG_W = 528, // dialog width
  168. D_DIALOG_H = 290, // dialog height
  169. D_DIALOG_X = ((640 - D_DIALOG_W) / 2), // centered x-coord
  170. D_DIALOG_Y = ((400 - D_DIALOG_H) / 2), // centered y-coord
  171. D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2), // coord of x-center
  172. D_TXT8_H = 22, // ht of 8-pt text
  173. D_MARGIN = 14, // margin width/height
  174. D_LIST_W = 500,
  175. D_LIST_H = 208,
  176. D_LIST_X = D_DIALOG_X + D_MARGIN,
  177. D_LIST_Y = D_DIALOG_Y + D_MARGIN + D_TXT8_H,
  178. D_EDIT_W = 90,
  179. D_EDIT_H = 18,
  180. D_EDIT_X = D_DIALOG_X + (D_DIALOG_W / 8) - (D_EDIT_W / 2),
  181. D_EDIT_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_EDIT_H,
  182. D_NEW_W = 90,
  183. D_NEW_H = 18,
  184. D_NEW_X = D_DIALOG_X + (D_DIALOG_W / 8) * 3 - (D_NEW_W / 2),
  185. D_NEW_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_NEW_H,
  186. D_DELETE_W = 90,
  187. D_DELETE_H = 18,
  188. D_DELETE_X = D_DIALOG_X + (D_DIALOG_W / 8) * 5 - (D_DELETE_W / 2),
  189. D_DELETE_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_DELETE_H,
  190. D_OK_W = 90,
  191. D_OK_H = 18,
  192. D_OK_X = D_DIALOG_X + (D_DIALOG_W / 8) * 7 - (D_OK_W / 2),
  193. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_OK_H,
  194. TEAMTXT_LEN = 43, // max length of a team entry
  195. };
  196. /*........................................................................
  197. Button enumerations:
  198. ........................................................................*/
  199. enum {
  200. TEAM_LIST=100,
  201. BUTTON_EDIT,
  202. BUTTON_NEW,
  203. BUTTON_DELETE,
  204. BUTTON_OK,
  205. };
  206. /*........................................................................
  207. Redraw values: in order from "top" to "bottom" layer of the dialog
  208. ........................................................................*/
  209. typedef enum {
  210. REDRAW_NONE = 0,
  211. REDRAW_BUTTONS,
  212. REDRAW_BACKGROUND,
  213. REDRAW_ALL = REDRAW_BACKGROUND
  214. } RedrawType;
  215. /*........................................................................
  216. Dialog variables
  217. ........................................................................*/
  218. RedrawType display; // requested redraw level
  219. bool process; // loop while true
  220. char *teamtext[TEAMTYPE_MAX + 1]; // text for defined teams
  221. KeyNumType input; // user input
  222. bool edit_team = false; // true = user wants to edit
  223. bool new_team = false; // true = user wants to new
  224. bool del_team = false; // true = user wants to new
  225. int i; // loop counters
  226. int j;
  227. int def_idx; // default list index
  228. static int tabs[] = {120, 180}; // list box tab stops
  229. char txt[10];
  230. // int housetxt;
  231. /*........................................................................
  232. Buttons
  233. ........................................................................*/
  234. GadgetClass *commands = NULL; // the button list
  235. ListClass teamlist (TEAM_LIST,
  236. D_LIST_X, D_LIST_Y, D_LIST_W, D_LIST_H,
  237. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  238. Hires_Retrieve("BTN-UP.SHP"),
  239. Hires_Retrieve("BTN-DN.SHP"));
  240. TextButtonClass editbtn (BUTTON_EDIT, "Edit",
  241. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  242. D_EDIT_X, D_EDIT_Y, D_EDIT_W, D_EDIT_H);
  243. TextButtonClass newbtn (BUTTON_NEW, "New",
  244. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  245. D_NEW_X, D_NEW_Y, D_NEW_W, D_NEW_H);
  246. TextButtonClass deletebtn (BUTTON_DELETE, "Delete",
  247. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  248. D_DELETE_X, D_DELETE_Y, D_DELETE_W, D_DELETE_H);
  249. TextButtonClass okbtn (BUTTON_OK, TXT_OK,
  250. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  251. D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  252. /*
  253. ------------------------------- Initialize -------------------------------
  254. */
  255. Set_Logic_Page(SeenBuff);
  256. /*
  257. ........................... Fill in team names ...........................
  258. */
  259. def_idx = 0;
  260. for (i = 0; i < TeamTypes.Count(); i++) {
  261. /*
  262. ................... Generate string for this team .....................
  263. */
  264. //teamtext[i] = (char *)HidPage.Get_Graphic_Buffer()->Get_Buffer() + TEAMTXT_LEN * i;
  265. teamtext[i] = new char[255];
  266. /*
  267. ........................ Fill in name & house .........................
  268. */
  269. strcpy(teamtext[i],TeamTypes.Ptr(i)->IniName);
  270. strcat(teamtext[i],"\t");
  271. strcat(teamtext[i], HouseTypeClass::As_Reference(TeamTypes.Ptr(i)->House).Suffix);
  272. strcat(teamtext[i],"\t");
  273. /*
  274. ................ Fill in class & count for all classes ................
  275. */
  276. for (j = 0; j < TeamTypes.Ptr(i)->ClassCount; j++) {
  277. sprintf (txt,"%s:%d", TeamTypes.Ptr(i)->Class[j]->IniName, TeamTypes.Ptr(i)->DesiredNum[j]);
  278. /*..................................................................
  279. Add entry if there's room; break otherwise
  280. (+ 3 for the ", " and the NULL; +3 again for the "..." for the next
  281. entry)
  282. ..................................................................*/
  283. if (strlen(txt) + strlen(teamtext[i]) + 6 < TEAMTXT_LEN) {
  284. if (j > 0) {
  285. strcat(teamtext[i],", ");
  286. }
  287. strcat(teamtext[i],txt);
  288. } else {
  289. strcat(teamtext[i], "...");
  290. break;
  291. }
  292. }
  293. /*
  294. .................. Set def_idx if this is CurTeam .....................
  295. */
  296. if (TeamTypes.Ptr(i)==CurTeam) {
  297. def_idx = i;
  298. }
  299. /*
  300. ........................... Add to list box ...........................
  301. */
  302. teamlist.Add_Item(teamtext[i]);
  303. }
  304. /*
  305. ....................... Set CurTeam if it isn't ..........................
  306. */
  307. if (TeamTypes.Count()==0) {
  308. CurTeam = NULL;
  309. } else {
  310. if (!CurTeam) {
  311. CurTeam = TeamTypes.Ptr(def_idx);
  312. }
  313. }
  314. /*
  315. ............................ Create the list .............................
  316. */
  317. commands = &teamlist;
  318. editbtn.Add_Tail(*commands);
  319. newbtn.Add_Tail(*commands);
  320. deletebtn.Add_Tail(*commands);
  321. okbtn.Add_Tail(*commands);
  322. /*
  323. ------------------------ Init tab stops for list -------------------------
  324. */
  325. teamlist.Set_Tabs(tabs);
  326. /*
  327. -------------------------- Main Processing Loop --------------------------
  328. */
  329. display = REDRAW_ALL;
  330. process = true;
  331. while (process) {
  332. /*
  333. ** If we have just received input focus again after running in the background then
  334. ** we need to redraw.
  335. */
  336. if (AllSurfaces.SurfacesRestored){
  337. AllSurfaces.SurfacesRestored=FALSE;
  338. display=REDRAW_ALL;
  339. }
  340. /*
  341. ........................ Invoke game callback .........................
  342. */
  343. Call_Back();
  344. /*
  345. ...................... Refresh display if needed ......................
  346. */
  347. if (display) {
  348. /*
  349. ...................... Display the dialog box ......................
  350. */
  351. Hide_Mouse();
  352. if (display >= REDRAW_BACKGROUND) {
  353. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  354. Draw_Caption(TXT_NONE, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  355. /*
  356. ....................... Draw the captions .......................
  357. */
  358. Fancy_Text_Print(caption, D_DIALOG_CX, D_DIALOG_Y + D_MARGIN,
  359. CC_GREEN, TBLACK,
  360. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  361. }
  362. /*
  363. ........................ Redraw the buttons ........................
  364. */
  365. if (display >= REDRAW_BUTTONS) {
  366. commands->Draw_All();
  367. }
  368. Show_Mouse();
  369. display = REDRAW_NONE;
  370. }
  371. /*
  372. ........................... Get user input ............................
  373. */
  374. input = commands->Input();
  375. /*
  376. ............................ Process input ............................
  377. */
  378. switch (input) {
  379. case (TEAM_LIST | KN_BUTTON):
  380. def_idx = teamlist.Current_Index();
  381. if (def_idx < TeamTypes.Count())
  382. CurTeam = TeamTypes.Ptr(def_idx);
  383. break;
  384. case (BUTTON_EDIT | KN_BUTTON):
  385. if (CurTeam) { // only allow if there's one selected
  386. process = false;
  387. edit_team = true;
  388. }
  389. break;
  390. case (BUTTON_NEW | KN_BUTTON):
  391. process = false;
  392. new_team = true;
  393. break;
  394. case (BUTTON_DELETE | KN_BUTTON):
  395. process = false;
  396. del_team = true;
  397. break;
  398. case (KN_RETURN):
  399. case (BUTTON_OK | KN_BUTTON):
  400. process = false;
  401. break;
  402. }
  403. }
  404. /*
  405. --------------------------- Redraw the display ---------------------------
  406. */
  407. HiddenPage.Clear();
  408. Flag_To_Redraw(true);
  409. Render();
  410. for (i = 0; i < TeamTypes.Count(); i++) {
  411. delete [] teamtext[i];
  412. }
  413. if (edit_team) return(1);
  414. if (new_team) return(2);
  415. if (del_team) return(3);
  416. return(0);
  417. }
  418. /***************************************************************************
  419. * MapEditClass::Edit_Team -- user edits a team's options *
  420. * *
  421. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  422. * ³ Team Editor ³ *
  423. * ³ ³ *
  424. * ³ Name ______ [Roundabout] ³ *
  425. * ³ Priority ______ [ GDI ] [Learning ] ³ *
  426. * ³ Max Num ______ [ NOD ] [Suicide ] ³ *
  427. * ³ Init Num ______ [Autocreate] ³ *
  428. * ³ Fear ______ [Mercenary ] ³ *
  429. * ³ [Prebuild ] ³ *
  430. * ³ [Reinforce ] ³ *
  431. * ³ ³ *
  432. * ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ³ *
  433. * ³ ³ ³^³ ³ ³^³ ³ *
  434. * ³ ³ ÃÄ´ [Add >>] ³ ÃÄ´ ³ *
  435. * ³ ³ ³ ³ [Insert] ³ ³ ³ ³ *
  436. * ³ ³ ³ ³ [Delete] ³ ³ ³ ³ *
  437. * ³ ³ ÃÄ´ ____ ³ ÃÄ´ ³ *
  438. * ³ ³ ³v³ ³ ³v³ ³ *
  439. * ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ³ *
  440. * ³ ³ *
  441. * ³ [Members] [Cancel] [OK] ³ *
  442. * ³ ³ *
  443. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  444. * *
  445. * INPUT: *
  446. * none. *
  447. * *
  448. * OUTPUT: *
  449. * 0 = OK, -1 = cancel *
  450. * *
  451. * WARNINGS: *
  452. * CurTeam must NOT be NULL when this function is called. *
  453. * This routine invokes the Members dialog, which uses HIDBUFF. *
  454. * *
  455. * HISTORY: *
  456. * 12/08/1994 BR : Created. *
  457. *=========================================================================*/
  458. int MapEditClass::Edit_Team(void)
  459. {
  460. /*........................................................................
  461. Dialog & button dimensions
  462. ........................................................................*/
  463. enum {
  464. D_DIALOG_W = 516,
  465. D_DIALOG_H = 376,
  466. D_DIALOG_X = ((640 - D_DIALOG_W) / 2),
  467. D_DIALOG_Y = ((400 - D_DIALOG_H) / 2),
  468. D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2),
  469. D_TXT8_H = 22,
  470. D_MARGIN = 14,
  471. D_NAME_W = 120,
  472. D_NAME_H = 18,
  473. D_NAME_X = D_DIALOG_X + D_MARGIN + 100,
  474. D_NAME_Y = D_DIALOG_Y + D_MARGIN + D_TXT8_H,
  475. D_PRIORITY_W = 120,
  476. D_PRIORITY_H = 18,
  477. D_PRIORITY_X = D_DIALOG_X + D_MARGIN + 100,
  478. D_PRIORITY_Y = D_NAME_Y + D_NAME_H,
  479. D_MAXNUM_W = 120,
  480. D_MAXNUM_H = 18,
  481. D_MAXNUM_X = D_DIALOG_X + D_MARGIN + 100,
  482. D_MAXNUM_Y = D_PRIORITY_Y + D_PRIORITY_H,
  483. D_INITNUM_W = 120,
  484. D_INITNUM_H = 18,
  485. D_INITNUM_X = D_DIALOG_X + D_MARGIN + 100,
  486. D_INITNUM_Y = D_MAXNUM_Y + D_MAXNUM_H,
  487. D_FEAR_W = 120,
  488. D_FEAR_H = 18,
  489. D_FEAR_X = D_DIALOG_X + D_MARGIN + 100,
  490. D_FEAR_Y = D_INITNUM_Y + D_INITNUM_H,
  491. D_GDI_W = 100,
  492. D_GDI_H = 18,
  493. D_GDI_X = D_NAME_X + D_NAME_W + D_MARGIN,
  494. D_GDI_Y = D_NAME_Y + D_NAME_H + D_NAME_H / 2,
  495. D_NOD_W = 100,
  496. D_NOD_H = 18,
  497. D_NOD_X = D_NAME_X + D_NAME_W + D_MARGIN,
  498. D_NOD_Y = D_GDI_Y + D_GDI_H,
  499. D_NEU_W = 100,
  500. D_NEU_H = 18,
  501. D_NEU_X = D_NAME_X + D_NAME_W + D_MARGIN,
  502. D_NEU_Y = D_NOD_Y + D_NOD_H,
  503. D_MULTI1_W = 50,
  504. D_MULTI1_H = 18,
  505. D_MULTI1_X = D_GDI_X,
  506. D_MULTI1_Y = D_GDI_Y,
  507. D_MULTI2_W = 50,
  508. D_MULTI2_H = 18,
  509. D_MULTI2_X = D_GDI_X + D_MULTI2_W,
  510. D_MULTI2_Y = D_GDI_Y,
  511. D_MULTI3_W = 50,
  512. D_MULTI3_H = 18,
  513. D_MULTI3_X = D_NOD_X,
  514. D_MULTI3_Y = D_NOD_Y,
  515. D_MULTI4_W = 50,
  516. D_MULTI4_H = 18,
  517. D_MULTI4_X = D_NOD_X + D_MULTI4_W,
  518. D_MULTI4_Y = D_NOD_Y,
  519. D_ROUNDABOUT_W = 130,
  520. D_ROUNDABOUT_H = 18,
  521. D_ROUNDABOUT_X = D_DIALOG_X + D_DIALOG_W - D_MARGIN - D_ROUNDABOUT_W,
  522. D_ROUNDABOUT_Y = D_DIALOG_Y + D_MARGIN + D_TXT8_H - 10,
  523. D_LEARNING_W = D_ROUNDABOUT_W,
  524. D_LEARNING_H = 18,
  525. D_LEARNING_X = D_ROUNDABOUT_X,
  526. D_LEARNING_Y = D_ROUNDABOUT_Y + D_ROUNDABOUT_H,
  527. D_SUICIDE_W = D_ROUNDABOUT_W,
  528. D_SUICIDE_H = 18,
  529. D_SUICIDE_X = D_ROUNDABOUT_X,
  530. D_SUICIDE_Y = D_LEARNING_Y + D_LEARNING_H,
  531. D_AUTOCREATE_W = D_ROUNDABOUT_W,
  532. D_AUTOCREATE_H = 18,
  533. D_AUTOCREATE_X = D_ROUNDABOUT_X,
  534. D_AUTOCREATE_Y = D_SUICIDE_Y + D_SUICIDE_H,
  535. D_MERCENARY_W = D_ROUNDABOUT_W,
  536. D_MERCENARY_H = 18,
  537. D_MERCENARY_X = D_ROUNDABOUT_X,
  538. D_MERCENARY_Y = D_AUTOCREATE_Y + D_AUTOCREATE_H,
  539. D_PREBUILT_W = D_ROUNDABOUT_W,
  540. D_PREBUILT_H = 18,
  541. D_PREBUILT_X = D_ROUNDABOUT_X,
  542. D_PREBUILT_Y = D_MERCENARY_Y + D_MERCENARY_H,
  543. D_REINFORCE_W = D_ROUNDABOUT_W,
  544. D_REINFORCE_H = 18,
  545. D_REINFORCE_X = D_ROUNDABOUT_X,
  546. D_REINFORCE_Y = D_PREBUILT_Y + D_PREBUILT_H,
  547. D_MISSION1_W = 180,
  548. D_MISSION1_H = 128,
  549. D_MISSION1_X = D_DIALOG_X + D_MARGIN,
  550. D_MISSION1_Y = D_REINFORCE_Y + D_REINFORCE_H + D_MARGIN,
  551. D_MISSION2_W = 180,
  552. D_MISSION2_H = 128,
  553. D_MISSION2_X = D_DIALOG_X + D_DIALOG_W - D_MARGIN - D_MISSION2_W,
  554. D_MISSION2_Y = D_MISSION1_Y,
  555. D_ADD_W = 100,
  556. D_ADD_H = 18,
  557. D_ADD_X = D_MISSION1_X + D_MISSION1_W + D_MARGIN,
  558. D_ADD_Y = D_MISSION1_Y + D_ADD_H,
  559. D_INSERT_W = 100,
  560. D_INSERT_H = 18,
  561. D_INSERT_X = D_MISSION1_X + D_MISSION1_W + D_MARGIN,
  562. D_INSERT_Y = D_ADD_Y + D_ADD_H,
  563. D_DEL_W = 100,
  564. D_DEL_H = 18,
  565. D_DEL_X = D_MISSION1_X + D_MISSION1_W + D_MARGIN,
  566. D_DEL_Y = D_INSERT_Y + D_INSERT_H,
  567. D_ARG_W = 100,
  568. D_ARG_H = 18,
  569. D_ARG_X = D_MISSION1_X + D_MISSION1_W + D_MARGIN,
  570. D_ARG_Y = D_DEL_Y + D_DEL_H,
  571. D_MEMBERS_W = 100,
  572. D_MEMBERS_H = 18,
  573. D_MEMBERS_X = D_DIALOG_X + (D_DIALOG_W / 6) - D_MEMBERS_W / 2,
  574. D_MEMBERS_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_MEMBERS_H,
  575. D_CANCEL_W = 100,
  576. D_CANCEL_H = 18,
  577. D_CANCEL_X = D_DIALOG_X + (D_DIALOG_W / 6) * 3 - D_CANCEL_W / 2,
  578. D_CANCEL_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_CANCEL_H,
  579. D_OK_W = 100,
  580. D_OK_H = 18,
  581. D_OK_X = D_DIALOG_X + (D_DIALOG_W / 6) * 5 - D_OK_W / 2,
  582. D_OK_Y = D_DIALOG_Y + D_DIALOG_H - D_MARGIN - D_OK_H,
  583. };
  584. /*........................................................................
  585. Button enumerations:
  586. ........................................................................*/
  587. enum {
  588. BUTTON_NAME=100,
  589. BUTTON_RECRUIT,
  590. BUTTON_MAXNUM,
  591. BUTTON_INITNUM,
  592. BUTTON_FEAR,
  593. BUTTON_GDI,
  594. BUTTON_NOD,
  595. BUTTON_NEU,
  596. BUTTON_JP, // placeholder
  597. BUTTON_MULTI1,
  598. BUTTON_MULTI2,
  599. BUTTON_MULTI3,
  600. BUTTON_MULTI4,
  601. BUTTON_MULTI5,
  602. BUTTON_MULTI6,
  603. BUTTON_ROUNDABOUT,
  604. BUTTON_LEARNING,
  605. BUTTON_SUICIDE,
  606. BUTTON_AUTO,
  607. BUTTON_MERCENARY,
  608. BUTTON_PREBUILT,
  609. BUTTON_REINFORCE,
  610. BUTTON_MISSION1,
  611. BUTTON_MISSION2,
  612. BUTTON_ADD,
  613. BUTTON_INSERT,
  614. BUTTON_DEL,
  615. BUTTON_ARG,
  616. BUTTON_MEMBERS,
  617. BUTTON_OK,
  618. BUTTON_CANCEL,
  619. };
  620. /*........................................................................
  621. Redraw values: in order from "top" to "bottom" layer of the dialog
  622. ........................................................................*/
  623. typedef enum {
  624. REDRAW_NONE = 0,
  625. REDRAW_BUTTONS,
  626. REDRAW_BACKGROUND,
  627. REDRAW_ALL = REDRAW_BACKGROUND
  628. } RedrawType;
  629. /*........................................................................
  630. Dialog variables:
  631. ........................................................................*/
  632. RedrawType display; // requested redraw level
  633. bool process; // loop while true
  634. KeyNumType input;
  635. bool cancel = false; // true = user cancels
  636. char name_buf[12];
  637. char recr_buf[4];
  638. char maxnum_buf[4];
  639. char initnum_buf[4];
  640. char fear_buf[4];
  641. HousesType house;
  642. int roundabout;
  643. int learning;
  644. int suicide;
  645. int autocreate;
  646. int mercenary;
  647. int prebuilt;
  648. int reinforce;
  649. int missioncount;
  650. TeamMissionStruct missions[TeamTypeClass::MAX_TEAM_MISSIONS];
  651. char missionbuf[TeamTypeClass::MAX_TEAM_MISSIONS][20];
  652. int curmission; // currently-selected mission index
  653. char arg_buf[4] = {0};
  654. static int tabs[] = {130, 180}; // list box tab stops
  655. int i,j;
  656. /*........................................................................
  657. Buttons:
  658. ........................................................................*/
  659. ControlClass *commands;
  660. EditClass name_edt (BUTTON_NAME,
  661. name_buf, 8,
  662. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  663. D_NAME_X, D_NAME_Y, D_NAME_W, D_NAME_H, EditClass::ALPHANUMERIC);
  664. EditClass recr_edt (BUTTON_RECRUIT,
  665. recr_buf, 3,
  666. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  667. D_PRIORITY_X, D_PRIORITY_Y, D_PRIORITY_W, D_PRIORITY_H, EditClass::NUMERIC);
  668. EditClass maxnum_edt (BUTTON_MAXNUM,
  669. maxnum_buf, 3,
  670. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  671. D_MAXNUM_X, D_MAXNUM_Y, D_MAXNUM_W, D_MAXNUM_H, EditClass::NUMERIC);
  672. EditClass initnum_edt (BUTTON_INITNUM,
  673. initnum_buf, 3,
  674. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  675. D_INITNUM_X, D_INITNUM_Y, D_INITNUM_W, D_INITNUM_H, EditClass::NUMERIC);
  676. EditClass fear_edt (BUTTON_FEAR,
  677. fear_buf, 3,
  678. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  679. D_FEAR_X, D_FEAR_Y, D_FEAR_W, D_FEAR_H, EditClass::NUMERIC);
  680. TextButtonClass gdibtn (BUTTON_GDI, "GDI",
  681. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  682. D_GDI_X, D_GDI_Y, D_GDI_W, D_GDI_H);
  683. TextButtonClass nodbtn (BUTTON_NOD, "NOD",
  684. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  685. D_NOD_X, D_NOD_Y, D_NOD_W, D_NOD_H);
  686. TextButtonClass neubtn (BUTTON_NEU, "NEUTRAL",
  687. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  688. D_NEU_X, D_NEU_Y, D_NEU_W, D_NEU_H);
  689. TextButtonClass multi1btn (BUTTON_MULTI1, "M1",
  690. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  691. D_MULTI1_X, D_MULTI1_Y, D_MULTI1_W, D_MULTI1_H);
  692. TextButtonClass multi2btn (BUTTON_MULTI2, "M2",
  693. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  694. D_MULTI2_X, D_MULTI2_Y, D_MULTI2_W, D_MULTI2_H);
  695. TextButtonClass multi3btn (BUTTON_MULTI3, "M3",
  696. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  697. D_MULTI3_X, D_MULTI3_Y, D_MULTI3_W, D_MULTI3_H);
  698. TextButtonClass multi4btn (BUTTON_MULTI4, "M4",
  699. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  700. D_MULTI4_X, D_MULTI4_Y, D_MULTI4_W, D_MULTI4_H);
  701. TextButtonClass roundbtn (BUTTON_ROUNDABOUT, "Roundabout",
  702. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  703. D_ROUNDABOUT_X, D_ROUNDABOUT_Y, D_ROUNDABOUT_W, D_ROUNDABOUT_H);
  704. TextButtonClass learnbtn (BUTTON_LEARNING, "Learning",
  705. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  706. D_LEARNING_X, D_LEARNING_Y, D_LEARNING_W, D_LEARNING_H);
  707. TextButtonClass suicidebtn (BUTTON_SUICIDE, "Suicide",
  708. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  709. D_SUICIDE_X, D_SUICIDE_Y, D_SUICIDE_W, D_SUICIDE_H);
  710. TextButtonClass autocreatebtn (BUTTON_AUTO, "Autocreate",
  711. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  712. D_AUTOCREATE_X, D_AUTOCREATE_Y, D_AUTOCREATE_W, D_AUTOCREATE_H);
  713. TextButtonClass mercbtn (BUTTON_MERCENARY, "Mercenary",
  714. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  715. D_MERCENARY_X, D_MERCENARY_Y, D_MERCENARY_W, D_MERCENARY_H);
  716. TextButtonClass prebuiltbtn (BUTTON_PREBUILT, "Prebuild",
  717. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  718. D_PREBUILT_X, D_PREBUILT_Y, D_PREBUILT_W, D_PREBUILT_H);
  719. TextButtonClass reinforcebtn (BUTTON_REINFORCE, "Reinforce",
  720. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  721. D_REINFORCE_X, D_REINFORCE_Y, D_REINFORCE_W, D_REINFORCE_H);
  722. ListClass missionlist1 (BUTTON_MISSION1,
  723. D_MISSION1_X, D_MISSION1_Y, D_MISSION1_W, D_MISSION1_H,
  724. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  725. Hires_Retrieve("BTN-UP.SHP"),
  726. Hires_Retrieve("BTN-DN.SHP"));
  727. ListClass missionlist2 (BUTTON_MISSION2,
  728. D_MISSION2_X, D_MISSION2_Y, D_MISSION2_W, D_MISSION2_H,
  729. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  730. Hires_Retrieve("BTN-UP.SHP"),
  731. Hires_Retrieve("BTN-DN.SHP"));
  732. TextButtonClass addbtn (BUTTON_ADD, "Add >>",
  733. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  734. D_ADD_X, D_ADD_Y, D_ADD_W, D_ADD_H);
  735. TextButtonClass insertbtn (BUTTON_INSERT, "Insert",
  736. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  737. D_INSERT_X, D_INSERT_Y, D_INSERT_W, D_INSERT_H);
  738. TextButtonClass delbtn (BUTTON_DEL, "Delete",
  739. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  740. D_DEL_X, D_DEL_Y, D_DEL_W, D_DEL_H);
  741. EditClass arg_edt (BUTTON_ARG, arg_buf, 4,
  742. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  743. D_ARG_X, D_ARG_Y, D_ARG_W, D_ARG_H, EditClass::ALPHANUMERIC);
  744. TextButtonClass membersbtn (BUTTON_MEMBERS, "Members",
  745. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  746. D_MEMBERS_X, D_MEMBERS_Y, D_MEMBERS_W, D_MEMBERS_H);
  747. TextButtonClass okbtn (BUTTON_OK, TXT_OK,
  748. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  749. D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  750. TextButtonClass cancelbtn (BUTTON_CANCEL, TXT_CANCEL,
  751. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  752. D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W, D_CANCEL_H);
  753. /*
  754. ------------------------------- Initialize -------------------------------
  755. */
  756. Set_Logic_Page(SeenBuff);
  757. /*
  758. ........................... Copy team's state ............................
  759. */
  760. strcpy(name_buf,CurTeam->IniName);
  761. sprintf(recr_buf,"%d",CurTeam->RecruitPriority);
  762. sprintf(maxnum_buf,"%d",CurTeam->MaxAllowed);
  763. sprintf(initnum_buf,"%d",CurTeam->InitNum);
  764. sprintf(fear_buf,"%d",CurTeam->Fear);
  765. roundabout = CurTeam->IsRoundAbout;
  766. learning = CurTeam->IsLearning;
  767. suicide = CurTeam->IsSuicide;
  768. house = CurTeam->House;
  769. autocreate = CurTeam->IsAutocreate;
  770. mercenary = CurTeam->IsMercenary;
  771. prebuilt = CurTeam->IsPrebuilt;
  772. reinforce = CurTeam->IsReinforcable;
  773. /*
  774. ......................... Fill in mission lists ..........................
  775. */
  776. for (i = 0; i < TMISSION_COUNT; i++) {
  777. missionlist1.Add_Item(TeamTypeClass::Name_From_Mission((TeamMissionType)i));
  778. }
  779. missioncount = CurTeam->MissionCount;
  780. for (i = 0; i < missioncount; i++) {
  781. missions[i] = CurTeam->MissionList[i];
  782. }
  783. Build_Mission_List(missioncount, missions, missionbuf, &missionlist2);
  784. curmission = 0;
  785. if (missioncount) {
  786. if (missions[curmission].Mission == TMISSION_MOVE || missions[curmission].Mission == TMISSION_UNLOAD) {
  787. sprintf(arg_buf,"%c",missions[curmission].Argument + 'A');
  788. } else {
  789. sprintf(arg_buf,"%d",missions[curmission].Argument);
  790. }
  791. }
  792. missionlist2.Set_Tabs(tabs);
  793. /*
  794. ......................... Init the button states .........................
  795. */
  796. name_edt.Set_Text(name_buf,8);
  797. recr_edt.Set_Text(recr_buf,3);
  798. maxnum_edt.Set_Text(maxnum_buf,3);
  799. initnum_edt.Set_Text(initnum_buf,3);
  800. fear_edt.Set_Text(fear_buf,3);
  801. arg_edt.Set_Text(arg_buf,3);
  802. if (roundabout) {
  803. roundbtn.Turn_On();
  804. }
  805. if (learning) {
  806. learnbtn.Turn_On();
  807. }
  808. if (suicide) {
  809. suicidebtn.Turn_On();
  810. }
  811. if (autocreate) {
  812. autocreatebtn.Turn_On();
  813. }
  814. if (mercenary) {
  815. mercbtn.Turn_On();
  816. }
  817. if (reinforce) {
  818. reinforcebtn.Turn_On();
  819. }
  820. if (prebuilt) {
  821. prebuiltbtn.Turn_On();
  822. }
  823. /*
  824. ............................ Create the list .............................
  825. */
  826. commands = &okbtn;
  827. cancelbtn.Add_Tail(*commands);
  828. membersbtn.Add_Tail(*commands);
  829. name_edt.Add_Tail(*commands);
  830. recr_edt.Add_Tail(*commands);
  831. maxnum_edt.Add_Tail(*commands);
  832. initnum_edt.Add_Tail(*commands);
  833. fear_edt.Add_Tail(*commands);
  834. gdibtn.Add_Tail(*commands);
  835. nodbtn.Add_Tail(*commands);
  836. neubtn.Add_Tail(*commands);
  837. roundbtn.Add_Tail(*commands);
  838. learnbtn.Add_Tail(*commands);
  839. suicidebtn.Add_Tail(*commands);
  840. autocreatebtn.Add_Tail(*commands);
  841. mercbtn.Add_Tail(*commands);
  842. prebuiltbtn.Add_Tail(*commands);
  843. reinforcebtn.Add_Tail(*commands);
  844. missionlist1.Add_Tail(*commands);
  845. missionlist2.Add_Tail(*commands);
  846. addbtn.Add_Tail(*commands);
  847. insertbtn.Add_Tail(*commands);
  848. delbtn.Add_Tail(*commands);
  849. arg_edt.Add_Tail(*commands);
  850. Set_House_Buttons (house, commands, BUTTON_GDI);
  851. /*
  852. -------------------------- Main Processing Loop --------------------------
  853. */
  854. display = REDRAW_ALL;
  855. process = true;
  856. while (process) {
  857. /*
  858. ** If we have just received input focus again after running in the background then
  859. ** we need to redraw.
  860. */
  861. if (AllSurfaces.SurfacesRestored){
  862. AllSurfaces.SurfacesRestored=FALSE;
  863. display=REDRAW_ALL;
  864. }
  865. /*
  866. ........................ Invoke game callback .........................
  867. */
  868. Call_Back();
  869. /*
  870. ...................... Refresh display if needed ......................
  871. */
  872. if (display) {
  873. /*
  874. ...................... Display the dialog box ......................
  875. */
  876. Hide_Mouse();
  877. if (display >= REDRAW_BACKGROUND) {
  878. Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
  879. Draw_Caption(TXT_NONE, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
  880. /*
  881. ....................... Draw the captions .......................
  882. */
  883. Fancy_Text_Print("Team Edit", D_DIALOG_CX, D_DIALOG_Y + D_MARGIN,
  884. CC_GREEN, TBLACK,
  885. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  886. Fancy_Text_Print("Name", D_NAME_X - 5, D_NAME_Y,
  887. CC_GREEN, TBLACK,
  888. TPF_RIGHT | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  889. Fancy_Text_Print("Priority", D_PRIORITY_X - 5, D_PRIORITY_Y,
  890. CC_GREEN, TBLACK,
  891. TPF_RIGHT | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  892. Fancy_Text_Print("Max Num", D_MAXNUM_X - 5, D_MAXNUM_Y,
  893. CC_GREEN, TBLACK,
  894. TPF_RIGHT | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  895. Fancy_Text_Print("Init Num", D_INITNUM_X - 5, D_INITNUM_Y,
  896. CC_GREEN, TBLACK,
  897. TPF_RIGHT | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  898. Fancy_Text_Print("Fear", D_FEAR_X - 5, D_FEAR_Y,
  899. CC_GREEN, TBLACK,
  900. TPF_RIGHT | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  901. }
  902. /*
  903. ........................ Redraw the buttons ........................
  904. */
  905. if (display >= REDRAW_BUTTONS) {
  906. commands->Draw_All();
  907. }
  908. Show_Mouse();
  909. display = REDRAW_NONE;
  910. }
  911. /*
  912. ........................... Get user input ............................
  913. */
  914. input = commands->Input();
  915. /*
  916. ............................ Process input ............................
  917. */
  918. switch (input) {
  919. case (BUTTON_NAME | KN_BUTTON):
  920. break;
  921. case (BUTTON_RECRUIT | KN_BUTTON):
  922. break;
  923. case (BUTTON_MAXNUM | KN_BUTTON):
  924. break;
  925. case (BUTTON_INITNUM | KN_BUTTON):
  926. break;
  927. case (BUTTON_FEAR | KN_BUTTON):
  928. break;
  929. /*..................................................................
  930. Toggle RoundAbout
  931. ..................................................................*/
  932. case (BUTTON_ROUNDABOUT | KN_BUTTON):
  933. if (roundabout) {
  934. roundabout = 0;
  935. roundbtn.Turn_Off();
  936. } else {
  937. roundabout = 1;
  938. roundbtn.Turn_On();
  939. }
  940. break;
  941. /*..................................................................
  942. Toggle Learning
  943. ..................................................................*/
  944. case (BUTTON_LEARNING | KN_BUTTON):
  945. if (learning) {
  946. learning = 0;
  947. learnbtn.Turn_Off();
  948. } else {
  949. learning = 1;
  950. learnbtn.Turn_On();
  951. }
  952. break;
  953. /*..................................................................
  954. Toggle Suicide
  955. ..................................................................*/
  956. case (BUTTON_SUICIDE | KN_BUTTON):
  957. if (suicide) {
  958. suicide = 0;
  959. suicidebtn.Turn_Off();
  960. } else {
  961. suicide = 1;
  962. suicidebtn.Turn_On();
  963. }
  964. break;
  965. /*..................................................................
  966. Toggle Spy
  967. ..................................................................*/
  968. case (BUTTON_AUTO | KN_BUTTON):
  969. if (autocreate) {
  970. autocreate = 0;
  971. autocreatebtn.Turn_Off();
  972. } else {
  973. autocreate = 1;
  974. autocreatebtn.Turn_On();
  975. }
  976. break;
  977. /*..................................................................
  978. Toggle Mercenary
  979. ..................................................................*/
  980. case (BUTTON_MERCENARY | KN_BUTTON):
  981. if (mercenary) {
  982. mercenary = 0;
  983. mercbtn.Turn_Off();
  984. } else {
  985. mercenary = 1;
  986. mercbtn.Turn_On();
  987. }
  988. break;
  989. case (BUTTON_PREBUILT | KN_BUTTON):
  990. if (prebuilt) {
  991. prebuilt = 0;
  992. prebuiltbtn.Turn_Off();
  993. } else {
  994. prebuilt = 1;
  995. prebuiltbtn.Turn_On();
  996. }
  997. break;
  998. case (BUTTON_REINFORCE | KN_BUTTON):
  999. if (reinforce) {
  1000. reinforce = 0;
  1001. reinforcebtn.Turn_Off();
  1002. } else {
  1003. reinforce = 1;
  1004. reinforcebtn.Turn_On();
  1005. }
  1006. break;
  1007. /*..................................................................
  1008. Select a Mission on the left-hand mission list
  1009. ..................................................................*/
  1010. case (BUTTON_MISSION1 | KN_BUTTON):
  1011. break;
  1012. /*..................................................................
  1013. Select a Mission on the right-hand mission list; update the Argument
  1014. field to reflect the current value
  1015. ..................................................................*/
  1016. case (BUTTON_MISSION2 | KN_BUTTON):
  1017. if (missionlist2.Count() > 0 &&
  1018. missionlist2.Current_Index() != curmission) {
  1019. curmission = missionlist2.Current_Index();
  1020. if (missions[curmission].Mission==TMISSION_MOVE || missions[curmission].Mission == TMISSION_UNLOAD) {
  1021. sprintf(arg_buf,"%c",missions[curmission].Argument + 'A');
  1022. } else {
  1023. sprintf(arg_buf,"%d",missions[curmission].Argument);
  1024. }
  1025. arg_edt.Set_Text(arg_buf,3);
  1026. }
  1027. break;
  1028. /*..................................................................
  1029. Copy mission from left list box to right list box
  1030. ..................................................................*/
  1031. case (BUTTON_ADD | KN_BUTTON):
  1032. case (BUTTON_INSERT | KN_BUTTON):
  1033. if (missioncount < TeamTypeClass::MAX_TEAM_MISSIONS) {
  1034. /*
  1035. ** Set 'i' to the position we're going to add into; this will
  1036. ** be just AFTER the current item if we're adding, and it will
  1037. ** be the current item if we're inserting.
  1038. */
  1039. if (input == (BUTTON_ADD | KN_BUTTON)) {
  1040. i = missionlist2.Current_Index() + 1;
  1041. if (i < 0) {
  1042. i = 0;
  1043. }
  1044. if (i > missioncount) {
  1045. i = missioncount;
  1046. }
  1047. } else {
  1048. i = missionlist2.Current_Index();
  1049. if (i < 0) {
  1050. i = 0;
  1051. }
  1052. if (i >= missioncount && missioncount > 0) {
  1053. i = missioncount - 1;
  1054. }
  1055. }
  1056. /*
  1057. ** Move all other missions forward in the array
  1058. */
  1059. for (j = missioncount; j > i; j--) {
  1060. missions[j] = missions[j - 1];
  1061. }
  1062. /*
  1063. ** Set the Mission value based on 1st list box's index
  1064. */
  1065. missions[i].Mission = (TeamMissionType)(TMISSION_FIRST + missionlist1.Current_Index());
  1066. /*
  1067. ** Set the missions argument field
  1068. */
  1069. if (missions[i].Mission == TMISSION_MOVE || missions[i].Mission == TMISSION_UNLOAD) {
  1070. missions[i].Argument = toupper(arg_buf[0]) - 'A';
  1071. } else {
  1072. missions[i].Argument = atoi(arg_buf);
  1073. }
  1074. missioncount++;
  1075. /*
  1076. ** Rebuild the list box from scratch
  1077. */
  1078. Build_Mission_List(missioncount, missions, missionbuf, &missionlist2);
  1079. /*
  1080. ** Update the list's current item index
  1081. */
  1082. missionlist2.Set_Selected_Index(i);
  1083. }
  1084. break;
  1085. /*..................................................................
  1086. Delete mission from right-hand list box
  1087. ..................................................................*/
  1088. case (BUTTON_DEL | KN_BUTTON):
  1089. if (missioncount > 0) {
  1090. i = missionlist2.Current_Index();
  1091. if (i < 0 || i >= missioncount) {
  1092. break;
  1093. }
  1094. /*
  1095. ** Move all missions back in the array
  1096. */
  1097. for (j = i; j < missioncount - 1; j++) {
  1098. missions[j] = missions[j + 1];
  1099. }
  1100. missioncount--;
  1101. /*
  1102. ** Rebuild the list box from scratch
  1103. */
  1104. Build_Mission_List(missioncount, missions, missionbuf, &missionlist2);
  1105. /*
  1106. ** Update the list's current item index
  1107. */
  1108. if (i >= missioncount) {
  1109. i--;
  1110. if (i < 0) {
  1111. i = 0;
  1112. }
  1113. missionlist2.Set_Selected_Index(i);
  1114. }
  1115. }
  1116. break;
  1117. /*..................................................................
  1118. Set house
  1119. ..................................................................*/
  1120. case (BUTTON_GDI | KN_BUTTON):
  1121. case (BUTTON_NOD | KN_BUTTON):
  1122. case (BUTTON_NEU | KN_BUTTON):
  1123. case (BUTTON_MULTI1 | KN_BUTTON):
  1124. case (BUTTON_MULTI2 | KN_BUTTON):
  1125. case (BUTTON_MULTI3 | KN_BUTTON):
  1126. case (BUTTON_MULTI4 | KN_BUTTON):
  1127. house = (HousesType)( (input & (~KN_BUTTON)) - BUTTON_GDI);
  1128. Set_House_Buttons(house, commands, BUTTON_GDI);
  1129. break;
  1130. /*..................................................................
  1131. Invoke the members dialog
  1132. ..................................................................*/
  1133. case (BUTTON_MEMBERS | KN_BUTTON):
  1134. /*
  1135. .................... Take editor focus away .....................
  1136. */
  1137. membersbtn.Turn_Off();
  1138. /*
  1139. ....................... Invoke the dialog .......................
  1140. */
  1141. Team_Members(house);
  1142. /*
  1143. ............................ Redraw .............................
  1144. */
  1145. display = REDRAW_ALL;
  1146. break;
  1147. /*..................................................................
  1148. OK: return
  1149. ..................................................................*/
  1150. case (BUTTON_OK | KN_BUTTON):
  1151. cancel = false;
  1152. process = false;
  1153. break;
  1154. /*..................................................................
  1155. Cancel: return
  1156. ..................................................................*/
  1157. case (BUTTON_CANCEL | KN_BUTTON):
  1158. cancel = true;
  1159. process = false;
  1160. break;
  1161. /*..................................................................
  1162. Pass all other events to the currently-active text editor
  1163. ..................................................................*/
  1164. default:
  1165. break;
  1166. }
  1167. }
  1168. /*
  1169. --------------------------- Redraw the display ---------------------------
  1170. */
  1171. HiddenPage.Clear();
  1172. Flag_To_Redraw(true);
  1173. Render();
  1174. /*
  1175. ------------------------- If cancel, just return -------------------------
  1176. */
  1177. if (cancel) {
  1178. return(-1);
  1179. }
  1180. /*
  1181. ------------------------ Save selections & return ------------------------
  1182. */
  1183. CurTeam->Set_Name(name_buf);
  1184. CurTeam->RecruitPriority = atoi(recr_buf);
  1185. CurTeam->MaxAllowed = atoi(maxnum_buf);
  1186. CurTeam->InitNum = atoi(initnum_buf);
  1187. CurTeam->IsRoundAbout = roundabout;
  1188. CurTeam->IsLearning = learning;
  1189. CurTeam->IsSuicide = suicide;
  1190. CurTeam->IsAutocreate = autocreate;
  1191. CurTeam->IsPrebuilt = prebuilt;
  1192. CurTeam->IsReinforcable = reinforce;
  1193. CurTeam->IsMercenary = mercenary;
  1194. CurTeam->House = house;
  1195. CurTeam->MissionCount = missioncount;
  1196. for (i = 0 ; i < missioncount; i++) {
  1197. CurTeam->MissionList[i] = missions[i];
  1198. }
  1199. return(0);
  1200. }
  1201. /***************************************************************************
  1202. * MapEditClass::Team_Members -- user picks makeup of a team *
  1203. * *
  1204. * Team members are rendered in a 24 x 24 area; the Window coordinates *
  1205. * have to be set to this area when the object's 'Display()' routine is *
  1206. * called. Thus, the dialog's window coords have to be divisible by *
  1207. * 24. The height of the dialog is computed based on how many objects *
  1208. * there are in it. *
  1209. * *
  1210. * 10 pixels are left between rows of objects, so the # of that type of *
  1211. * object can be displayed underneath the object. *
  1212. * *
  1213. * ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ *
  1214. * ³ Team Members ³ *
  1215. * ³ ³ *
  1216. * ³ ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿ ³ *
  1217. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1218. * ³ ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´ ³ *
  1219. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1220. * ³ ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´ ³ *
  1221. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1222. * ³ ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´ ³ *
  1223. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1224. * ³ ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´ ³ *
  1225. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1226. * ³ ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´ ³ *
  1227. * ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ *
  1228. * ³ ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ ³ *
  1229. * ³ [OK] [Cancel] ³ *
  1230. * ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ *
  1231. * *
  1232. * INPUT: *
  1233. * house house to display objects for *
  1234. * *
  1235. * OUTPUT: *
  1236. * 0 = OK, -1 = cancel *
  1237. * *
  1238. * WARNINGS: *
  1239. * CurTeam must NOT be NULL when this function is called. *
  1240. * This routine uses HIDBUFF for data storage. *
  1241. * *
  1242. * HISTORY: *
  1243. * 12/07/1994 BR : Created. *
  1244. *=========================================================================*/
  1245. #define TEENSY_WEENSY
  1246. /*
  1247. ** Dialog & button dimensions
  1248. */
  1249. enum {
  1250. D_DIALOG_W = 608,
  1251. D_DIALOG_X = ((640 - D_DIALOG_W) / 2),
  1252. D_DIALOG_CX = D_DIALOG_X + (D_DIALOG_W / 2),
  1253. D_TXT6_H = 14,
  1254. D_MARGIN = 14,
  1255. #ifdef TEENSY_WEENSY
  1256. //D_PICTURE_W = 32,
  1257. //D_PICTURE_H = 24,
  1258. D_PICTURE_W = 64, // 9 pictures / row, 16 pixel margin on each side
  1259. D_PICTURE_H = 48,
  1260. #else
  1261. //D_PICTURE_W = 32,
  1262. //D_PICTURE_H = 30,
  1263. D_PICTURE_W = 64,
  1264. D_PICTURE_H = 60,
  1265. #endif
  1266. D_ROW_H = (D_PICTURE_H + 6),
  1267. D_OK_W = 100,
  1268. D_OK_H = 18,
  1269. D_OK_X = D_DIALOG_CX - 10 - D_OK_W,
  1270. D_OK_Y = 0,
  1271. D_CANCEL_W = 100,
  1272. D_CANCEL_H = 18,
  1273. D_CANCEL_X = D_DIALOG_CX + 10,
  1274. D_CANCEL_Y = 0,
  1275. };
  1276. /***************************************************************************
  1277. * MapEditClass::Team_Members -- Team members dialog *
  1278. * *
  1279. * INPUT: *
  1280. * house house to show members for *
  1281. * *
  1282. * OUTPUT: *
  1283. * 0 = OK, -1 = cancel *
  1284. * *
  1285. * WARNINGS: *
  1286. * none. *
  1287. * *
  1288. * HISTORY: *
  1289. * 04/09/1996 BRR : Created. *
  1290. *=========================================================================*/
  1291. int MapEditClass::Team_Members(HousesType house)
  1292. {
  1293. /*
  1294. ** Button enumerations:
  1295. */
  1296. enum {
  1297. BUTTON_OK = 100,
  1298. BUTTON_CANCEL,
  1299. };
  1300. /*
  1301. ** Redraw values: in order from "top" to "bottom" layer of the dialog
  1302. ** (highest enum is the lowest layer). Each section of the map checks
  1303. ** the requested redraw level to see if it's supposed to draw; if it's
  1304. ** >= its level, it redraws.
  1305. */
  1306. typedef enum {
  1307. REDRAW_NONE = 0,
  1308. REDRAW_BUTTONS,
  1309. REDRAW_BACKGROUND,
  1310. REDRAW_ALL = REDRAW_BACKGROUND
  1311. } RedrawType;
  1312. RedrawType display; // requested redraw level
  1313. bool process; // loop while true
  1314. /*
  1315. ............................ Dialog variables ............................
  1316. */
  1317. KeyNumType input; // user input
  1318. bool cancel = false; // true = user cancels
  1319. /*
  1320. ......................... Team display variables .........................
  1321. */
  1322. const TechnoTypeClass **teamclass; // array of team classes
  1323. int *teamcount; // array of class counts
  1324. int numcols; // # units displayed horizontally
  1325. int numrows; // # units displayed vertically
  1326. // int col; // horizontal picture index
  1327. // int row; // vertical picture index
  1328. // int x,y;
  1329. /*
  1330. ** Dialog dimensions.
  1331. */
  1332. int dlg_y;
  1333. int dlg_h; // dialog height
  1334. int dlg_picture_top; // coord of top of pictures
  1335. int msg_y; // y-coord for object names
  1336. /*
  1337. ** Values for parsing the classes.
  1338. */
  1339. InfantryType i_id;
  1340. AircraftType a_id;
  1341. UnitType u_id;
  1342. int curclass = -1; // current index into 'teamclass'; can be invalid!
  1343. // (is based on current mouse position)
  1344. int numclasses; // current # classes in the team (limited to <=5)
  1345. int maxclasses; // max # classes available
  1346. int i,j;
  1347. /*
  1348. ** Values for timing when mouse held down.
  1349. */
  1350. int lheld = 0;
  1351. int rheld = 0;
  1352. long tdelay[3] = {5, 20, 0};
  1353. int tindex = 0;
  1354. long heldtime;
  1355. /*
  1356. ** Buttons.
  1357. */
  1358. ControlClass *commands;
  1359. TextButtonClass okbtn (BUTTON_OK, TXT_OK,
  1360. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  1361. D_OK_X, D_OK_Y, D_OK_W, D_OK_H);
  1362. TextButtonClass cancelbtn (BUTTON_CANCEL, TXT_CANCEL,
  1363. TPF_CENTER | TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  1364. D_CANCEL_X, D_CANCEL_Y, D_CANCEL_W, D_CANCEL_H);
  1365. /*
  1366. ** Set up the team data arrays (ObjectTypeClass pointers & count)
  1367. */
  1368. teamclass = (const TechnoTypeClass **)(new TechnoTypeClass *[MAX_TEAM_CLASSES]);
  1369. teamcount = new int[MAX_TEAM_CLASSES];
  1370. /*
  1371. ** Fill in the ObjectTypeClass array with all available object type ptrs,
  1372. ** checking to be sure this house can own the object
  1373. */
  1374. i = 0;
  1375. for (i_id = INFANTRY_FIRST; i_id < INFANTRY_COUNT; i_id++) {
  1376. if (Verify_House(house,&InfantryTypeClass::As_Reference(i_id))) {
  1377. teamclass[i] = &InfantryTypeClass::As_Reference(i_id);
  1378. i++;
  1379. }
  1380. }
  1381. for (a_id = AIRCRAFT_FIRST; a_id < AIRCRAFT_COUNT; a_id++) {
  1382. if (Verify_House(house,&AircraftTypeClass::As_Reference(a_id))) {
  1383. teamclass[i] = &AircraftTypeClass::As_Reference(a_id);
  1384. i++;
  1385. }
  1386. }
  1387. for (u_id = UNIT_FIRST; u_id < UNIT_COUNT; u_id++) {
  1388. if (Verify_House(house,&UnitTypeClass::As_Reference(u_id))) {
  1389. teamclass[i] = &UnitTypeClass::As_Reference(u_id);
  1390. i++;
  1391. }
  1392. }
  1393. /*
  1394. ** Save max # classes.
  1395. */
  1396. maxclasses = i;
  1397. /*
  1398. ** Fill in the 'count' array with data from the current team:
  1399. ** - For every class in the current team, find that class type in the
  1400. ** 'teamclass' array & set its count value
  1401. */
  1402. for (j = 0; j < maxclasses; j++) {
  1403. teamcount[j] = 0;
  1404. }
  1405. /*
  1406. ** Loop through all classes in the team.
  1407. */
  1408. for (i = 0; i < CurTeam->ClassCount; i++) {
  1409. /*
  1410. ** Find this class in our array.
  1411. */
  1412. for (j = 0; j < maxclasses; j++) {
  1413. /*
  1414. ** Set the count; detect a match between the team's class & the
  1415. ** 'teamclass' array entry by comparing the actual pointers; typeid
  1416. ** won't work because E1 & E2 are the same type class.
  1417. */
  1418. if (CurTeam->Class[i] == teamclass[j]) {
  1419. teamcount[j] = CurTeam->DesiredNum[i];
  1420. break;
  1421. }
  1422. }
  1423. }
  1424. numclasses = CurTeam->ClassCount;
  1425. /*
  1426. ** Set up the dialog dimensions based on number of classes we have to draw
  1427. **
  1428. ** Compute picture rows & cols.
  1429. */
  1430. numcols = (D_DIALOG_W - 16) / D_PICTURE_W;
  1431. numrows = (maxclasses + numcols - 1) / numcols;
  1432. //
  1433. // Dialog's height = top margin + label + picture rows +
  1434. // margin + label + margin + btn
  1435. //
  1436. dlg_h = (D_MARGIN + D_TXT6_H + D_MARGIN + (numrows * D_ROW_H) +
  1437. D_MARGIN + D_TXT6_H + D_MARGIN + D_OK_H + D_MARGIN);
  1438. if (dlg_h > 400) {
  1439. dlg_h = 400;
  1440. }
  1441. dlg_y = (400 - dlg_h) / 2;
  1442. dlg_picture_top = dlg_y + D_MARGIN + D_TXT6_H + D_MARGIN;
  1443. msg_y = dlg_y + D_MARGIN + D_TXT6_H + D_MARGIN + (numrows * D_ROW_H) + D_MARGIN;
  1444. okbtn.Y = dlg_y + dlg_h - D_MARGIN - D_OK_H;
  1445. cancelbtn.Y = dlg_y + dlg_h - D_MARGIN - D_CANCEL_H;
  1446. /*
  1447. ** Draw to SeenBuff.
  1448. */
  1449. Set_Logic_Page(SeenBuff);
  1450. /*
  1451. ** Make sure 'house' is valid.
  1452. */
  1453. if (house!=HOUSE_GOOD && house!=HOUSE_BAD && house != HOUSE_MULTI1 &&
  1454. house != HOUSE_MULTI2 && house != HOUSE_MULTI3 && house != HOUSE_MULTI4 ) {
  1455. if (ScenPlayer == SCEN_PLAYER_MPLAYER) {
  1456. house = HOUSE_MULTI1;
  1457. } else {
  1458. house = HOUSE_GOOD;
  1459. }
  1460. }
  1461. /*
  1462. ** Create the list.
  1463. */
  1464. commands = &okbtn;
  1465. cancelbtn.Add_Tail(*commands);
  1466. /*
  1467. ** Main Processing Loop.
  1468. */
  1469. display = REDRAW_ALL;
  1470. process = true;
  1471. while (process) {
  1472. /*
  1473. ** If we have just received input focus again after running in the background then
  1474. ** we need to redraw.
  1475. */
  1476. if (AllSurfaces.SurfacesRestored){
  1477. AllSurfaces.SurfacesRestored=FALSE;
  1478. display=REDRAW_ALL;
  1479. }
  1480. /*
  1481. ** Invoke game callback.
  1482. */
  1483. Call_Back();
  1484. /*
  1485. ** Refresh display if needed.
  1486. */
  1487. if (display) {
  1488. /*
  1489. ** Display the dialog box.
  1490. */
  1491. Hide_Mouse();
  1492. if (display >= REDRAW_BACKGROUND) {
  1493. /*
  1494. ** Display the constant background of this dialog.
  1495. */
  1496. Dialog_Box(D_DIALOG_X, dlg_y, D_DIALOG_W, dlg_h);
  1497. Draw_Caption(TXT_NONE, D_DIALOG_X, dlg_y, D_DIALOG_W);
  1498. Fancy_Text_Print("Team Members", D_DIALOG_CX, dlg_y + D_MARGIN, CC_GREEN, TBLACK,
  1499. TPF_CENTER|TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  1500. //
  1501. // Draw the objects.
  1502. //
  1503. for (i = 0; i < maxclasses; i++) {
  1504. //
  1505. // Display the object along with any count value for it.
  1506. //
  1507. Draw_Member(teamclass[i], i, teamcount[i], house,
  1508. D_DIALOG_X + 16, dlg_picture_top);
  1509. }
  1510. if ((unsigned)curclass < maxclasses) {
  1511. Fancy_Text_Print(teamclass[curclass]->Full_Name(),
  1512. D_DIALOG_X + D_DIALOG_W / 2, msg_y, CC_TAN, TBLACK,
  1513. TPF_CENTER|TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  1514. }
  1515. }
  1516. /*
  1517. ** Redraw the buttons.
  1518. */
  1519. if (display >= REDRAW_BUTTONS) {
  1520. commands->Draw_All();
  1521. }
  1522. Show_Mouse();
  1523. display = REDRAW_NONE;
  1524. }
  1525. /*
  1526. ** Get user input.
  1527. */
  1528. input = commands->Input();
  1529. /*
  1530. ** Process input.
  1531. */
  1532. switch (input) {
  1533. /*
  1534. ** Mouse buttons set or clear 'held' values
  1535. */
  1536. case (KN_LMOUSE):
  1537. if (curclass >= 0 && curclass < maxclasses) {
  1538. lheld = 1;
  1539. tindex = 2;
  1540. heldtime = 0;
  1541. }
  1542. break;
  1543. case (KN_RMOUSE):
  1544. if (curclass >= 0 && curclass < maxclasses) {
  1545. rheld = 1;
  1546. tindex = 2;
  1547. heldtime = 0;
  1548. }
  1549. break;
  1550. case ((int)KN_LMOUSE | (int)KN_RLSE_BIT):
  1551. lheld = 0;
  1552. break;
  1553. case ((int)KN_RMOUSE | (int)KN_RLSE_BIT):
  1554. rheld = 0;
  1555. break;
  1556. /*
  1557. ** OK: save values & return.
  1558. */
  1559. case (BUTTON_OK | KN_BUTTON):
  1560. process = false;
  1561. break;
  1562. /*
  1563. ** Cancel: abort & return.
  1564. */
  1565. case (BUTTON_CANCEL | KN_BUTTON):
  1566. cancel = true;
  1567. process = false;
  1568. break;
  1569. default:
  1570. /*
  1571. ** Compute new 'curclass' based on mouse position.
  1572. */
  1573. i = (Get_Mouse_X() - 16 - D_DIALOG_X) / D_PICTURE_W +
  1574. ((Get_Mouse_Y() - dlg_picture_top) / D_ROW_H) * numcols;
  1575. /*
  1576. ** If it's changed, update class label.
  1577. */
  1578. if (i != curclass) {
  1579. curclass = i;
  1580. /*
  1581. ** Clear out the previously printed name of the item.
  1582. */
  1583. Hide_Mouse();
  1584. LogicPage->Fill_Rect(D_DIALOG_X + 8, msg_y, D_DIALOG_X + D_DIALOG_W - 9, msg_y + D_TXT6_H, BLACK);
  1585. if ((unsigned)curclass < maxclasses) {
  1586. Fancy_Text_Print(teamclass[curclass]->Full_Name(),
  1587. D_DIALOG_X + D_DIALOG_W / 2, msg_y,
  1588. CC_GREEN, TBLACK,
  1589. TPF_CENTER|TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  1590. }
  1591. /*
  1592. ** Force buttons to not be held.
  1593. */
  1594. lheld = 0;
  1595. rheld = 0;
  1596. Show_Mouse();
  1597. }
  1598. break;
  1599. }
  1600. /*
  1601. ** Check for a 'held' mouse button; if it's down, and the correct
  1602. ** amount of time has gone by, increment/decrement the count for the
  1603. ** current class.
  1604. */
  1605. if (lheld) {
  1606. /*
  1607. ** The first time in, TickCount - heldtime will be larger than
  1608. ** tdelay[2], so we increment the count immediately; then, we decrement
  1609. ** tindex to go to the next time delay, which is longer; then, decr.
  1610. ** again to go to the 1st time delay which is the shortest.
  1611. */
  1612. if (TickCount.Time() - heldtime > tdelay[tindex]) {
  1613. heldtime = TickCount.Time();
  1614. if (tindex) {
  1615. tindex--;
  1616. }
  1617. /*
  1618. ** Detect addition of a new class.
  1619. */
  1620. if (teamcount[curclass]==0) {
  1621. /*
  1622. ** Don't allow more classes than we can handle.
  1623. */
  1624. if (numclasses == TeamTypeClass::MAX_TEAM_CLASSCOUNT) {
  1625. continue;
  1626. }
  1627. numclasses++;
  1628. }
  1629. teamcount[curclass]++;
  1630. /*
  1631. ** Update number label.
  1632. */
  1633. Draw_Member(teamclass[curclass], curclass, teamcount[curclass],
  1634. house, D_DIALOG_X + 16, dlg_picture_top);
  1635. }
  1636. } else {
  1637. if (rheld) {
  1638. /*
  1639. ** The first time in, TickCount - heldtime will be larger than
  1640. ** tdelay[2], so we increment the count immediately; then, we decrement
  1641. ** tindex to go to the next time delay, which is longer; then, decr.
  1642. ** again to go to the 1st time delay which is the shortest.
  1643. */
  1644. if (TickCount.Time() - heldtime > tdelay[tindex]) {
  1645. if (tindex) {
  1646. tindex--;
  1647. }
  1648. heldtime = TickCount.Time();
  1649. if (teamcount[curclass] > 0) {
  1650. teamcount[curclass]--;
  1651. /*
  1652. ** Detect removal of a class.
  1653. */
  1654. if (teamcount[curclass] == 0) {
  1655. numclasses--;
  1656. }
  1657. }
  1658. /*
  1659. ** Update number label.
  1660. */
  1661. Draw_Member(teamclass[curclass], curclass, teamcount[curclass],
  1662. house, D_DIALOG_X + 16, dlg_picture_top);
  1663. }
  1664. }
  1665. }
  1666. }
  1667. /*
  1668. ** Copy data into team.
  1669. */
  1670. if (!cancel) {
  1671. CurTeam->ClassCount = numclasses;
  1672. i = 0; // current team class index
  1673. for (j = 0; j < maxclasses; j++) {
  1674. if (teamcount[j] > 0) {
  1675. CurTeam->DesiredNum[i] = teamcount[j];
  1676. CurTeam->Class[i] = teamclass[j];
  1677. i++;
  1678. }
  1679. }
  1680. }
  1681. /*
  1682. ** Redraw the display.
  1683. */
  1684. HiddenPage.Clear();
  1685. Flag_To_Redraw(true);
  1686. Render();
  1687. delete [] teamclass;
  1688. delete [] teamcount;
  1689. if (cancel) return(-1);
  1690. return(0);
  1691. }
  1692. /***********************************************************************************************
  1693. * MapEditClass::Draw_Member -- Draws a member of the team dialog box. *
  1694. * *
  1695. * This routine will display the cameo image of the potential team member. In the corner, *
  1696. * it will show the current quantity of this member for the current team being edited. *
  1697. * *
  1698. * INPUT: ptr -- Pointer to the member object type. *
  1699. * *
  1700. * index -- The index into the team dialog box array of selectable objects. This is *
  1701. * used to determine the correct X and Y offsets to draw. *
  1702. * *
  1703. * quant -- The quantity number to display in the corner of the image. *
  1704. * *
  1705. * house -- The owner of this object. *
  1706. * pic_x, pic_y -- x,y coords of upper-left corner to start drawing at
  1707. * *
  1708. * OUTPUT: none *
  1709. * *
  1710. * WARNINGS: none *
  1711. * *
  1712. * HISTORY: *
  1713. * 07/02/1995 JLB : Created. *
  1714. *=============================================================================================*/
  1715. void MapEditClass::Draw_Member(TechnoTypeClass const * ptr, int index,
  1716. int quant, HousesType house, int pic_x, int pic_y)
  1717. {
  1718. int numcols = (D_DIALOG_W - 32) / D_PICTURE_W;
  1719. int col = index % numcols;
  1720. int row = index / numcols;
  1721. int x = pic_x + col * D_PICTURE_W;
  1722. int y = pic_y + row * D_ROW_H;
  1723. WindowList[WINDOW_EDITOR][WINDOWX] = 0;
  1724. WindowList[WINDOW_EDITOR][WINDOWY] = 0;
  1725. WindowList[WINDOW_EDITOR][WINDOWWIDTH] = 640 / 8;
  1726. WindowList[WINDOW_EDITOR][WINDOWHEIGHT] = 400;
  1727. Change_Window((int)WINDOW_EDITOR);
  1728. Hide_Mouse();
  1729. Draw_Box(x, y, D_PICTURE_W, D_PICTURE_H, BOXSTYLE_GREEN_DOWN, true);
  1730. ptr->Display(x + D_PICTURE_W / 2, y + D_PICTURE_H / 2, WINDOW_EDITOR, house);
  1731. if (quant > 0) {
  1732. Fancy_Text_Print("%d", x + 1, y + D_PICTURE_H - 16,
  1733. CC_GREEN, TBLACK,
  1734. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_DROPSHADOW, quant);
  1735. }
  1736. Show_Mouse();
  1737. #if 0
  1738. int numcols = (D_DIALOG_W - 16) / D_PICTURE_W;
  1739. int col = index % numcols;
  1740. int row = index / numcols;
  1741. int dlg_y = 0;
  1742. int x = D_DIALOG_X + 8 + col * D_PICTURE_W;
  1743. int y = dlg_y + 8 + 13 + row * D_ROW_H;
  1744. /*
  1745. ** Change the window to this box.
  1746. */
  1747. WindowList[WINDOW_EDITOR][WINDOWX] = x >> 3;
  1748. WindowList[WINDOW_EDITOR][WINDOWY] = y;
  1749. WindowList[WINDOW_EDITOR][WINDOWWIDTH] = D_PICTURE_W >> 3;
  1750. WindowList[WINDOW_EDITOR][WINDOWHEIGHT] = D_PICTURE_H;
  1751. Change_Window((int)WINDOW_EDITOR);
  1752. Hide_Mouse();
  1753. Draw_Box(x, y, D_PICTURE_W, D_PICTURE_H, BOXSTYLE_GREEN_DOWN, true);
  1754. ptr->Display(WinW<<2, WinH>>1, WINDOW_EDITOR, house);
  1755. if (quant > 0) {
  1756. Fancy_Text_Print("%d", x+1, y+D_PICTURE_H-8, CC_GREEN, TBLACK, TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_DROPSHADOW, quant);
  1757. }
  1758. Show_Mouse();
  1759. #endif
  1760. }
  1761. /***************************************************************************
  1762. * MapEditClass::Build_Mission_list -- fills in mission list box *
  1763. * *
  1764. * INPUT: *
  1765. * missioncount # of missions to add to the list *
  1766. * missions array of TeamMissionStruct's *
  1767. * missionbuf character arrays to store strings in *
  1768. * list list box to add strings to *
  1769. * *
  1770. * OUTPUT: *
  1771. * 0 = OK, -1 = cancel *
  1772. * *
  1773. * WARNINGS: *
  1774. * none. *
  1775. * *
  1776. * HISTORY: *
  1777. * 12/07/1994 BR : Created. *
  1778. *=========================================================================*/
  1779. void MapEditClass::Build_Mission_List(int missioncount, TeamMissionStruct *missions,
  1780. char missionbuf[TeamTypeClass::MAX_TEAM_MISSIONS][20], ListClass *list)
  1781. {
  1782. /*
  1783. ** Start with an empty list
  1784. */
  1785. while (list->Count()) {
  1786. list->Remove_Item(list->Get_Item(0));
  1787. }
  1788. for (int i = 0; i < missioncount; i++) {
  1789. /*
  1790. ** generate the string for a MOVE mission; the argument is the
  1791. ** letter-designation of the cell to move to.
  1792. */
  1793. if (missions[i].Mission == TMISSION_MOVE || missions[i].Mission == TMISSION_UNLOAD) {
  1794. sprintf(missionbuf[i],"%s\t%c",
  1795. TeamTypeClass::Name_From_Mission(missions[i].Mission),
  1796. missions[i].Argument + 'A');
  1797. } else {
  1798. /*
  1799. ** All other missions take a numeric argument.
  1800. */
  1801. sprintf(missionbuf[i],"%s\t%d",
  1802. TeamTypeClass::Name_From_Mission(missions[i].Mission),
  1803. missions[i].Argument);
  1804. }
  1805. /*
  1806. ** Add the string to the list box
  1807. */
  1808. list->Add_Item(missionbuf[i]);
  1809. }
  1810. }
  1811. #endif