ScriptTypes.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  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. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // ScriptTypes.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "ScriptTypes.h"
  21. #include "FinalSunDlg.h"
  22. #include "mapdata.h"
  23. #include "variables.h"
  24. #include "functions.h"
  25. #include "inlines.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. #define TMISSION_COUNT 59
  32. #define TPROPERTY_COUNT 4
  33. #define UNLOAD_COUNT 4
  34. // The various missions that a team can have.
  35. enum TeamMissionType {
  36. TMISSION_ATTACK,
  37. TMISSION_ATT_WAYPT,
  38. TMISSION_BERZERK,
  39. TMISSION_MOVE,
  40. TMISSION_MOVECELL,
  41. TMISSION_GUARD,
  42. TMISSION_LOOP,
  43. TMISSION_WIN,
  44. TMISSION_UNLOAD,
  45. TMISSION_DEPLOY,
  46. TMISSION_HOUND_DOG,
  47. TMISSION_DO,
  48. TMISSION_SET_GLOBAL,
  49. TMISSION_IDLE_ANIM,
  50. TMISSION_LOAD,
  51. TMISSION_SPY,
  52. TMISSION_PATROL,
  53. TMISSION_SCRIPT,
  54. TMISSION_TEAMCHANGE,
  55. TMISSION_PANIC,
  56. TMISSION_CHANGE_HOUSE,
  57. TMISSION_SCATTER,
  58. TMISSION_GOTO_SHROUD,
  59. TMISSION_LOSE,
  60. TMISSION_PLAY_SPEECH,
  61. TMISSION_PLAY_SOUND,
  62. TMISSION_PLAY_MOVIE,
  63. TMISSION_PLAY_MUSIC,
  64. TMISSION_REDUCE_TIBERIUM,
  65. TMISSION_BEGIN_PRODUCTION,
  66. TMISSION_FIRE_SALE,
  67. TMISSION_SELF_DESTRUCT,
  68. TMISSION_ION_STORM_START,
  69. TMISSION_ION_STORM_END,
  70. TMISSION_CENTER_VIEWPOINT,
  71. TMISSION_RESHROUD,
  72. TMISSION_REVEAL,
  73. TMISSION_DESTROY_MEMBERS,
  74. TMISSION_CLEAR_GLOBAL,
  75. TMISSION_SET_LOCAL,
  76. TMISSION_CLEAR_LOCAL,
  77. TMISSION_UNPANIC,
  78. TMISSION_FORCE_FACING,
  79. TMISSION_FULLY_LOADED,
  80. TMISSION_UNLOAD_TRUCK,
  81. TMISSION_LOAD_TRUCK,
  82. TMISSION_ATTACK_BUILDING_WITH_PROPERTY,
  83. TMISSION_MOVETO_BUILDING_WITH_PROPERTY,
  84. TMISSION_SCOUT,
  85. TMISSION_SUCCESS,
  86. TMISSION_FLASH,
  87. TMISSION_PLAY_ANIM,
  88. TMISSION_TALK_BUBBLE,
  89. TMISSION_GATHER_FAR,
  90. TMISSION_GATHER_NEAR,
  91. TMISSION_ACTIVATE_CURTAIN,
  92. TMISSION_CHRONO_ATTACK_BUILDING_WITH_PROPERTY,
  93. TMISSION_CHRONO_ATTACK,
  94. TMISSION_MOVETO_OWN_BUILDING_WITH_PROPERTY,
  95. };
  96. char const * TMissions[TMISSION_COUNT] = {
  97. "Attack...",
  98. "Attack Waypoint...",
  99. "Go Berzerk",
  100. "Move to waypoint...",
  101. "Move to Cell...",
  102. "Guard area (timer ticks)...",
  103. "Jump to line #...",
  104. "Player wins",
  105. "Unload...",
  106. "Deploy",
  107. "Follow friendlies",
  108. "Do this...",
  109. "Set global...",
  110. "Idle Anim...",
  111. "Load onto Transport",
  112. "Spy on bldg @ waypt...",
  113. "Patrol to waypoint...",
  114. "Change script...",
  115. "Change team...",
  116. "Panic",
  117. "Change house...",
  118. "Scatter",
  119. "Goto nearby shroud",
  120. "Player loses",
  121. "Play speech...",
  122. "Play sound...",
  123. "Play movie...",
  124. "Play music...",
  125. "Reduce tiberium",
  126. "Begin production",
  127. "Fire sale",
  128. "Self destruct",
  129. "Ion storm start in...",
  130. "Ion storn end",
  131. "Center view on team (speed)...",
  132. "Reshroud map",
  133. "Reveal map",
  134. "Delete team members",
  135. "Clear global...",
  136. "Set local...",
  137. "Clear local...",
  138. "Unpanic",
  139. "Force facing...",
  140. "Wait till fully loaded",
  141. "Truck unload",
  142. "Truck load",
  143. "Attack enemy building",
  144. "Moveto enemy building",
  145. "Scout",
  146. "Success",
  147. "Flash",
  148. "Play Anim",
  149. "Talk Bubble",
  150. "Gather at Enemy",
  151. "Gather at Base",
  152. "Iron Curtain Me",
  153. "Chrono Prep for ABwP",
  154. "Chrono Prep for AQ",
  155. "Move to own building",
  156. };
  157. char const * TMissionsHelp[TMISSION_COUNT] = {
  158. "Attack some general target",
  159. "Attack anything nearby the specified waypoint",
  160. "Cyborg members of the team will go berzerk.",
  161. "Orders the team to move to a waypoint on the map",
  162. "Orders the team to move to a specific cell on the map",
  163. "Guard an area for a specified amount of time",
  164. "Move to a new line number in the script. Used for loops.",
  165. "Duh",
  166. "Unloads all loaded units. The command parameter specifies which units should stay a part of the team, and which should be severed from the team.",
  167. "Causes all deployable units in the team to deploy",
  168. "Causes the team to follow the nearest friendly unit",
  169. "Give all team members the specified mission",
  170. "Sets a global variable",
  171. "Causes team members to enter their idle animation",
  172. "Causes all units to load into transports, if able",
  173. "**OBSOLETE**",
  174. "Move to a waypoint while scanning for enemies",
  175. "Causes the team to start using a new script",
  176. "Causes the team to switch team types",
  177. "Causes all units in the team to panic",
  178. "All units in the team switch houses",
  179. "Tells all units to scatter",
  180. "Causes units to flee to a shrouded cell",
  181. "Causes the player to lose",
  182. "Plays the specified voice file",
  183. "Plays the specified sound file",
  184. "Plays the specified movie file",
  185. "Plays the specified theme",
  186. "Reduces the amount of tiberium around team members",
  187. "Signals the owning house to begin production",
  188. "Causes an AI house to sell all of its buildings and do a Braveheart",
  189. "Causes all team members to self destruct",
  190. "Causes an ion storm to begin at the specified time",
  191. "Causes an ion storm to end",
  192. "Center view on team (speed)...",
  193. "Reshrouds the map",
  194. "Reveals the map",
  195. "Delete all members from the team",
  196. "Clears the specified global variable",
  197. "Sets the specified local variable",
  198. "Clears the specified local variable",
  199. "Causes all team members to stop panicking",
  200. "Forces team members to face a certain direction",
  201. "Waits until all transports are full",
  202. "Causes all trucks to unload their crates (ie, change imagery)",
  203. "Causes all trucks to load crates (ie, change imagery)",
  204. "Attack a specific type of building with the specified property",
  205. "Move to a specific type of building with the specified property",
  206. "The team will scout the bases of the players that have not been scouted",
  207. "Record a team as having successfully accomplished its mission. Used for AI trigger weighting. Put this at the end of every AITrigger script.",
  208. "Flashes a team for a period of team.",
  209. "Plays an anim over every unit in the team.",
  210. "Displays talk bubble over first unit in the team.",
  211. "Uses AISafeDistance to find a spot close to enemy's base to gather close.",
  212. "Gathers outside own base perimeter.",
  213. "Calls (and waits if nearly ready) for House to deliver Iron Curtain to Team.",
  214. "Teleports team to Building With Property, but needs similar attack order as next mission.",
  215. "Teleports team to Attack Quarry, but needs similar attack order as next mission.",
  216. "A BwP move that will only search through buildings owned by this house.",
  217. };
  218. char const *TargetProperties[TPROPERTY_COUNT] = {
  219. "Least Threat",
  220. "Greatest Threat",
  221. "Nearest",
  222. "Farthest",
  223. };
  224. char const *UnloadTypeNames[UNLOAD_COUNT] = {
  225. "Keep Transports, Keep Units",
  226. "Keep Transports, Lose Units",
  227. "Lose Transports, Keep Units",
  228. "Lose Transports, Lose Units",
  229. };
  230. /////////////////////////////////////////////////////////////////////////////
  231. // Eigenschaftenseite CScriptTypes
  232. IMPLEMENT_DYNCREATE(CScriptTypes, CDialog)
  233. CScriptTypes::CScriptTypes() : CDialog(CScriptTypes::IDD)
  234. {
  235. //{{AFX_DATA_INIT(CScriptTypes)
  236. m_Name = _T("");
  237. //}}AFX_DATA_INIT
  238. }
  239. CScriptTypes::~CScriptTypes()
  240. {
  241. }
  242. void CScriptTypes::DoDataExchange(CDataExchange* pDX)
  243. {
  244. CDialog::DoDataExchange(pDX);
  245. //{{AFX_DATA_MAP(CScriptTypes)
  246. DDX_Control(pDX, IDC_DESCRIPTION, m_DescriptionEx);
  247. DDX_Control(pDX, IDC_PDESC, m_Desc);
  248. DDX_Control(pDX, IDC_TYPE, m_Type);
  249. DDX_Control(pDX, IDC_SCRIPTTYPE, m_ScriptType);
  250. DDX_Control(pDX, IDC_PARAM, m_Param);
  251. DDX_Control(pDX, IDC_ACTION, m_Action);
  252. DDX_Text(pDX, IDC_NAME, m_Name);
  253. //}}AFX_DATA_MAP
  254. }
  255. BEGIN_MESSAGE_MAP(CScriptTypes, CDialog)
  256. //{{AFX_MSG_MAP(CScriptTypes)
  257. ON_CBN_EDITCHANGE(IDC_SCRIPTTYPE, OnEditchangeScripttype)
  258. ON_CBN_SELCHANGE(IDC_SCRIPTTYPE, OnSelchangeScripttype)
  259. ON_LBN_SELCHANGE(IDC_ACTION, OnSelchangeAction)
  260. ON_EN_CHANGE(IDC_NAME, OnChangeName)
  261. ON_CBN_EDITCHANGE(IDC_TYPE, OnEditchangeType)
  262. ON_CBN_SELCHANGE(IDC_TYPE, OnSelchangeType)
  263. ON_CBN_EDITCHANGE(IDC_PARAM, OnEditchangeParam)
  264. ON_CBN_SELCHANGE(IDC_PARAM, OnSelchangeParam)
  265. ON_BN_CLICKED(IDC_ADDACTION, OnAddaction)
  266. ON_BN_CLICKED(IDC_DELETEACTION, OnDeleteaction)
  267. ON_BN_CLICKED(IDC_ADD, OnAdd)
  268. ON_BN_CLICKED(IDC_DELETE, OnDelete)
  269. //}}AFX_MSG_MAP
  270. END_MESSAGE_MAP()
  271. /////////////////////////////////////////////////////////////////////////////
  272. // Behandlungsroutinen für Nachrichten CScriptTypes
  273. void CScriptTypes::UpdateDialog()
  274. {
  275. CIniFile& ini=Map->GetIniFile();
  276. int sel=m_ScriptType.GetCurSel();
  277. while(m_ScriptType.DeleteString(0)!=CB_ERR);
  278. // MW 07/24/01: clear dialog
  279. m_DescriptionEx.SetWindowText("");
  280. m_Name="";
  281. m_Param.SetWindowText("");
  282. m_Action.SetWindowText("");
  283. m_Type.SetCurSel(-1);
  284. UpdateData(FALSE);
  285. int i;
  286. for(i=0;i<ini.sections["ScriptTypes"].values.size();i++)
  287. {
  288. CString type,s;
  289. type=*ini.sections["ScriptTypes"].GetValue(i);
  290. s=type;
  291. s+=" (";
  292. s+=ini.sections[(LPCTSTR)type].values["Name"];
  293. s+=")";
  294. m_ScriptType.AddString(s);
  295. }
  296. m_ScriptType.SetCurSel(0);
  297. if(sel>=0) m_ScriptType.SetCurSel(sel);
  298. OnSelchangeScripttype();
  299. }
  300. void CScriptTypes::OnEditchangeScripttype()
  301. {
  302. }
  303. void CScriptTypes::OnSelchangeScripttype()
  304. {
  305. CIniFile& ini=Map->GetIniFile();
  306. int sel=m_Action.GetCurSel();
  307. while(m_Action.DeleteString(0)!=CB_ERR);
  308. CString Scripttype;
  309. if(m_ScriptType.GetCurSel()<0) return;
  310. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  311. TruncSpace(Scripttype);
  312. m_Name=ini.sections[(LPCTSTR)Scripttype].values["Name"];
  313. int count=ini.sections[(LPCTSTR)Scripttype].values.size()-1;
  314. int i;
  315. for(i=0;i<count;i++)
  316. {
  317. char c[50];
  318. itoa(i,c,10);
  319. m_Action.AddString(c);
  320. }
  321. m_Action.SetCurSel(0);
  322. if(sel>=0) m_Action.SetCurSel(sel);
  323. OnSelchangeAction();
  324. UpdateData(FALSE);
  325. }
  326. void CScriptTypes::OnSelchangeAction()
  327. {
  328. CIniFile& ini=Map->GetIniFile();
  329. CString Scripttype;
  330. char action[50];
  331. if(m_ScriptType.GetCurSel()<0) return;
  332. if(m_Action.GetCurSel()<0) return;
  333. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  334. TruncSpace(Scripttype);
  335. itoa(m_Action.GetCurSel(), action, 10);
  336. //m_Type.SetWindowText(GetParam(ini.sections[(LPCTSTR)Scripttype].values[action],0));
  337. m_Type.SetCurSel(atoi(GetParam(ini.sections[(LPCTSTR)Scripttype].values[action], 0)));
  338. OnSelchangeType();
  339. m_Param.SetWindowText(GetParam(ini.sections[(LPCTSTR)Scripttype].values[action],1));
  340. }
  341. void CScriptTypes::OnChangeName()
  342. {
  343. CIniFile& ini=Map->GetIniFile();
  344. UpdateData();
  345. CEdit* n=(CEdit*)GetDlgItem(IDC_NAME);
  346. DWORD pos=n->GetSel();
  347. CString Scripttype;
  348. if(m_ScriptType.GetCurSel()<0) return;
  349. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  350. TruncSpace(Scripttype);
  351. ini.sections[(LPCTSTR)Scripttype].values["Name"]=m_Name;
  352. UpdateDialog();
  353. n->SetSel(pos);
  354. }
  355. void CScriptTypes::OnEditchangeType()
  356. {
  357. CIniFile& ini=Map->GetIniFile();
  358. while(m_Param.DeleteString(0)!=CB_ERR);
  359. CString Scripttype;
  360. char action[50];
  361. if(m_Action.GetCurSel()<0) return;
  362. if(m_ScriptType.GetCurSel()<0) return;
  363. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  364. TruncSpace(Scripttype);
  365. //CString type;
  366. //m_Type.GetWindowText(type);
  367. //TruncSpace(type);
  368. //MessageBox("beep");
  369. int type=m_Type.GetCurSel();
  370. int i;
  371. char tmp[50];
  372. switch(type)
  373. {
  374. case 0:
  375. ListTargets(m_Param);
  376. m_Desc.SetWindowText("Target:");
  377. break;
  378. case 39:
  379. case 40:
  380. ListGlobals(m_Param);
  381. break;
  382. case 11:
  383. ListBehaviours(m_Param);
  384. break;
  385. case 1:
  386. case 3:
  387. case 16:
  388. ListWaypoints(m_Param);
  389. m_Desc.SetWindowText("Waypoint:");
  390. break;
  391. case 4:
  392. m_Desc.SetWindowText("Cell:");
  393. break;
  394. case 5:
  395. m_Desc.SetWindowText("Time units to guard:");
  396. break;
  397. case 6:
  398. m_Desc.SetWindowText("Script action #:");
  399. while(m_Param.DeleteString(0)!=CB_ERR);
  400. for(i=1;i<=ini.sections[(LPCTSTR)Scripttype].values.size()-1;i++)
  401. m_Param.AddString(itoa(i,tmp,10));
  402. break;
  403. case 8:
  404. m_Desc.SetWindowText("Split groups:");
  405. while(m_Param.DeleteString(0)!=CB_ERR);
  406. int i;
  407. for(i=0;i<UNLOAD_COUNT;i++)
  408. {
  409. CString p;
  410. char c[50];
  411. itoa(i,c,10);
  412. p=c;
  413. p+=" - ";
  414. p+=UnloadTypeNames[i];
  415. m_Param.AddString(p);
  416. }
  417. break;
  418. case 9:
  419. case 14:
  420. case 37:
  421. m_Desc.SetWindowText("Use 0:");
  422. break;
  423. case 12:
  424. m_Desc.SetWindowText("Global:");
  425. break;
  426. case 20:
  427. ListHouses(m_Param, TRUE);
  428. m_Desc.SetWindowText("House:");
  429. break;
  430. case 46:
  431. case 47:
  432. {
  433. m_Desc.SetWindowText("Type to move/attack:");
  434. for(i=0;i<rules.sections["BuildingTypes"].values.size();i++)
  435. {
  436. char c[50];
  437. itoa(i,c,10);
  438. CString s=c;
  439. s+=" ";
  440. //s+=rules.sections[*rules.sections["BuildingTypes"].GetValue(i)].values["Name"];
  441. s+=Map->GetUnitName(*rules.sections["BuildingTypes"].GetValue(i));
  442. m_Param.AddString(s);
  443. }
  444. break;
  445. }
  446. default:
  447. m_Desc.SetWindowText("Parameter of action:");
  448. }
  449. itoa(m_Action.GetCurSel(), action, 10);
  450. char types[50];
  451. itoa(type, types, 10);
  452. ini.sections[(LPCTSTR)Scripttype].values[action]=SetParam(ini.sections[(LPCTSTR)Scripttype].values[action], 0, (LPCTSTR)types);
  453. }
  454. void CScriptTypes::OnSelchangeType()
  455. {
  456. CString str;
  457. if(m_Type.GetCurSel()>-1)
  458. {
  459. //m_Type.GetLBText(m_Type.GetCurSel(), str);
  460. //m_Type.SetWindowText(str);
  461. m_DescriptionEx.SetWindowText(TMissionsHelp[m_Type.GetCurSel()]);
  462. }
  463. OnEditchangeType();
  464. }
  465. void CScriptTypes::OnEditchangeParam()
  466. {
  467. CIniFile& ini=Map->GetIniFile();
  468. CString Scripttype;
  469. char action[50];
  470. if(m_Action.GetCurSel()<0) return;
  471. if(m_ScriptType.GetCurSel()<0) return;
  472. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  473. TruncSpace(Scripttype);
  474. CString param;
  475. m_Param.GetWindowText(param);
  476. TruncSpace(param);
  477. param=TranslateHouse(param);
  478. itoa(m_Action.GetCurSel(), action, 10);
  479. ini.sections[(LPCTSTR)Scripttype].values[action]=SetParam(ini.sections[(LPCTSTR)Scripttype].values[action], 1, (LPCTSTR)param);
  480. }
  481. void CScriptTypes::OnSelchangeParam()
  482. {
  483. m_Param.SetWindowText(GetText(&m_Param));
  484. OnEditchangeParam();
  485. }
  486. void CScriptTypes::OnAddaction()
  487. {
  488. CIniFile& ini=Map->GetIniFile();
  489. CString Scripttype;
  490. if(m_ScriptType.GetCurSel()<0) return;
  491. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  492. TruncSpace(Scripttype);
  493. char action[20];
  494. int count=ini.sections[(LPCTSTR)Scripttype].values.size()-1;
  495. itoa(count,action,10);
  496. ini.sections[(LPCTSTR)Scripttype].values[action]="0,0";
  497. UpdateDialog();
  498. }
  499. void CScriptTypes::OnDeleteaction()
  500. {
  501. CIniFile& ini=Map->GetIniFile();
  502. CString Scripttype;
  503. if(m_Action.GetCurSel()<0) return;
  504. if(m_ScriptType.GetCurSel()<0) return;
  505. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  506. TruncSpace(Scripttype);
  507. // okay, action is now the deleted one...
  508. int i;
  509. for(i=m_Action.GetCurSel(); i<m_Action.GetCount()-1;i++)
  510. {
  511. // okay, now move every action one number up.
  512. char current[50];
  513. char next[50];
  514. itoa(i, current, 10);
  515. itoa(i+1, next, 10);
  516. ini.sections[(LPCTSTR)Scripttype].values[current]=ini.sections[(LPCTSTR)Scripttype].values[next];
  517. }
  518. char last[50];
  519. itoa(m_Action.GetCount()-1, last, 10);
  520. ini.sections[(LPCTSTR)Scripttype].values.erase(last);
  521. UpdateDialog();
  522. }
  523. CString GetFree(const char* section);
  524. void CScriptTypes::OnAdd()
  525. {
  526. CIniFile& ini=Map->GetIniFile();
  527. CString ID=GetFreeID();
  528. CString p=GetFree("ScriptTypes");
  529. ini.sections["ScriptTypes"].values[p]=ID;
  530. ini.sections[ID].values["Name"]="New script";
  531. int i;
  532. for(i=0;i<m_ScriptType.GetCount();i++)
  533. {
  534. CString data;
  535. m_ScriptType.GetLBText(i, data);
  536. TruncSpace(data);
  537. if(data==ID)
  538. {
  539. m_ScriptType.SetCurSel(i);
  540. OnSelchangeScripttype(); // MW bugfix
  541. break;
  542. }
  543. }
  544. ((CFinalSunDlg*)theApp.m_pMainWnd)->UpdateDialogs(TRUE);
  545. //UpdateDialog();
  546. }
  547. void CScriptTypes::OnDelete()
  548. {
  549. CIniFile& ini=Map->GetIniFile();
  550. CString Scripttype;
  551. if(m_ScriptType.GetCurSel()<0) return;
  552. m_ScriptType.GetLBText(m_ScriptType.GetCurSel(), Scripttype);
  553. TruncSpace(Scripttype);
  554. int res=MessageBox("Are you sure to delete this ScriptType? Don´t forget to delete any references to this ScriptType","Delete ScriptType", MB_YESNO | MB_ICONQUESTION);
  555. if(res!=IDYES) return;
  556. ini.sections.erase((LPCTSTR)Scripttype);
  557. ini.sections["ScriptTypes"].values.erase(*ini.sections["ScriptTypes"].GetValueName(ini.sections["ScriptTypes"].FindValue((LPCTSTR)Scripttype)));
  558. //UpdateDialog();
  559. ((CFinalSunDlg*)theApp.m_pMainWnd)->UpdateDialogs(TRUE);
  560. }
  561. void CScriptTypes::ListBehaviours(CComboBox &cb)
  562. {
  563. while(cb.DeleteString(0)!=CB_ERR);
  564. cb.AddString("0 - Sleep");
  565. cb.AddString("1 - Attack nearest enemy");
  566. cb.AddString("2 - Move");
  567. cb.AddString("3 - QMove");
  568. cb.AddString("4 - Retreat home for R&R");
  569. cb.AddString("5 - Guard");
  570. cb.AddString("6 - Sticky (never recruit)");
  571. cb.AddString("7 - Enter object");
  572. cb.AddString("8 - Capture object");
  573. cb.AddString("9 - Move into & get eaten");
  574. cb.AddString("10 - Harvest");
  575. cb.AddString("11 - Area Guard");
  576. cb.AddString("12 - Return (to refinery)");
  577. cb.AddString("13 - Stop");
  578. cb.AddString("14 - Ambush (wait until discovered)");
  579. cb.AddString("15 - Hunt");
  580. cb.AddString("16 - Unload");
  581. cb.AddString("17 - Sabotage (move in & destroy)");
  582. cb.AddString("18 - Construction");
  583. cb.AddString("19 - Deconstruction");
  584. cb.AddString("20 - Repair");
  585. cb.AddString("21 - Rescue");
  586. cb.AddString("22 - Missile");
  587. cb.AddString("23 - Harmless");
  588. cb.AddString("24 - Open");
  589. cb.AddString("25 - Patrol");
  590. cb.AddString("26 - Paradrop approach drop zone");
  591. cb.AddString("27 - Paradrop overlay drop zone");
  592. cb.AddString("28 - Wait");
  593. cb.AddString("29 - Attack move");
  594. if(yuri_mode)
  595. {
  596. // cb.AddString("30 - Spyplane approach");
  597. // cb.AddString("31 - Spyplane retreat");
  598. }
  599. }
  600. BOOL CScriptTypes::OnInitDialog()
  601. {
  602. CDialog::OnInitDialog();
  603. while(m_Type.DeleteString(0)!=CB_ERR);
  604. int i;
  605. for(i=0;i<TMISSION_COUNT;i++)
  606. {
  607. CString p;
  608. char c[50];
  609. itoa(i,c,10);
  610. //p=c;
  611. //p+=" - ";
  612. p+=TMissions[i];
  613. if(strlen(TMissions[i])>0)
  614. {
  615. m_Type.AddString(p);
  616. }
  617. }
  618. return TRUE; // return TRUE unless you set the focus to a control
  619. // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
  620. }