Houses.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  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. // Houses.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "Houses.h"
  21. #include "resource.h"
  22. #include "finalsundlg.h"
  23. #include "mapdata.h"
  24. #include "variables.h"
  25. #include "functions.h"
  26. #include "newra2housedlg.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Eigenschaftenseite CHouses
  34. IMPLEMENT_DYNCREATE(CHouses, CDialog)
  35. CHouses::CHouses() : CDialog(CHouses::IDD)
  36. {
  37. //{{AFX_DATA_INIT(CHouses)
  38. // HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein
  39. //}}AFX_DATA_INIT
  40. }
  41. CHouses::~CHouses()
  42. {
  43. }
  44. void CHouses::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CHouses)
  48. DDX_Control(pDX, IDC_HUMANPLAYER, m_HumanPlayer);
  49. DDX_Control(pDX, IDC_TECHLEVEL, m_TechLevel);
  50. DDX_Control(pDX, IDC_SIDE, m_Side);
  51. DDX_Control(pDX, IDC_PLAYERCONTROL, m_PlayerControl);
  52. DDX_Control(pDX, IDC_PERCENTBUILT, m_PercentBuilt);
  53. DDX_Control(pDX, IDC_NODECOUNT, m_Nodecount);
  54. DDX_Control(pDX, IDC_IQ, m_IQ);
  55. DDX_Control(pDX, IDC_EDGE, m_Edge);
  56. DDX_Control(pDX, IDC_CREDITS, m_Credits);
  57. DDX_Control(pDX, IDC_COLOR, m_Color);
  58. DDX_Control(pDX, IDC_ALLIES, m_Allies);
  59. DDX_Control(pDX, IDC_ACTSLIKE, m_ActsLike);
  60. DDX_Control(pDX, IDC_HOUSES, m_houses);
  61. //}}AFX_DATA_MAP
  62. }
  63. BEGIN_MESSAGE_MAP(CHouses, CDialog)
  64. //{{AFX_MSG_MAP(CHouses)
  65. ON_CBN_SELCHANGE(IDC_HOUSES, OnSelchangeHouses)
  66. ON_BN_CLICKED(IDC_PREPAREHOUSES, OnPreparehouses)
  67. ON_WM_SHOWWINDOW()
  68. ON_BN_CLICKED(IDC_ADDHOUSE, OnAddhouse)
  69. ON_BN_CLICKED(IDC_DELETEHOUSE, OnDeletehouse)
  70. ON_CBN_KILLFOCUS(IDC_IQ, OnKillfocusIq)
  71. ON_CBN_KILLFOCUS(IDC_EDGE, OnKillfocusEdge)
  72. ON_CBN_KILLFOCUS(IDC_SIDE, OnKillfocusSide)
  73. ON_CBN_KILLFOCUS(IDC_COLOR, OnKillfocusColor)
  74. ON_EN_KILLFOCUS(IDC_ALLIES, OnKillfocusAllies)
  75. ON_EN_KILLFOCUS(IDC_CREDITS, OnKillfocusCredits)
  76. ON_CBN_EDITCHANGE(IDC_ACTSLIKE, OnEditchangeActslike)
  77. ON_CBN_KILLFOCUS(IDC_NODECOUNT, OnKillfocusNodecount)
  78. ON_CBN_KILLFOCUS(IDC_TECHLEVEL, OnKillfocusTechlevel)
  79. ON_CBN_KILLFOCUS(IDC_PERCENTBUILT, OnKillfocusPercentbuilt)
  80. ON_CBN_KILLFOCUS(IDC_PLAYERCONTROL, OnKillfocusPlayercontrol)
  81. ON_CBN_SELCHANGE(IDC_HUMANPLAYER, OnSelchangeHumanplayer)
  82. ON_CBN_SELCHANGE(IDC_ACTSLIKE, OnSelchangeActslike)
  83. ON_EN_SETFOCUS(IDC_ALLIES, OnSetfocusAllies)
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // Behandlungsroutinen für Nachrichten CHouses
  88. void CHouses::UpdateDialog()
  89. {
  90. while(this->m_houses.DeleteString(0)!=CB_ERR);
  91. while(this->m_HumanPlayer.DeleteString(0)!=CB_ERR);
  92. while(this->m_Color.DeleteString(0)!=CB_ERR);
  93. while(this->m_ActsLike.DeleteString(0)!=CB_ERR);
  94. ListHouses(m_Side, FALSE, TRUE);
  95. int i;
  96. for(i=0;i<rules.sections[HOUSES].values.size();i++)
  97. {
  98. #ifdef RA2_MODE
  99. CString j=*rules.sections[HOUSES].GetValue(i);
  100. j.MakeLower();
  101. if(j=="nod" || j=="gdi") continue;
  102. #endif
  103. char house_id[5];
  104. CString houseCString;
  105. itoa(i,house_id,10);
  106. houseCString=house_id;
  107. houseCString+=" ";
  108. houseCString+=TranslateHouse(*rules.sections[HOUSES].GetValue(i), TRUE);
  109. m_ActsLike.AddString(houseCString);
  110. }
  111. CIniFile& ini=Map->GetIniFile();
  112. if(ini.sections.find(MAPHOUSES)==ini.sections.end() && ini.sections.size()>0)
  113. {
  114. // MessageBox("No houses do exist, if you want to use houses, you should use ""Prepare houses"" before doing anything else.");
  115. }
  116. else
  117. {
  118. m_HumanPlayer.AddString("None");
  119. m_HumanPlayer.SetCurSel(0);
  120. for(i=0;i<ini.sections[MAPHOUSES].values.size();i++)
  121. {
  122. #ifdef RA2_MODE
  123. CString j=*ini.sections[MAPHOUSES].GetValue(i);
  124. j.MakeLower();
  125. if(j=="nod" || j=="gdi") continue;
  126. #endif
  127. m_houses.AddString(TranslateHouse(*ini.sections[MAPHOUSES].GetValue(i), TRUE));
  128. m_HumanPlayer.AddString(TranslateHouse(*ini.sections[MAPHOUSES].GetValue(i), TRUE));
  129. }
  130. if(ini.sections["Basic"].values.find("Player")!=ini.sections["Basic"].values.end())
  131. {
  132. m_HumanPlayer.SetCurSel(m_HumanPlayer.FindStringExact(0, TranslateHouse(ini.sections["Basic"].values["Player"], TRUE)));
  133. }
  134. m_houses.SetCurSel(0);
  135. m_ActsLike.SetWindowText("");
  136. m_Allies.SetWindowText("");
  137. m_Color.SetWindowText("");
  138. m_Credits.SetWindowText("");
  139. m_Edge.SetWindowText("");
  140. m_IQ.SetWindowText("");
  141. m_Nodecount.SetWindowText("");
  142. m_PercentBuilt.SetWindowText("");
  143. m_PlayerControl.SetWindowText("");
  144. m_Side.SetWindowText("");
  145. m_TechLevel.SetWindowText("");
  146. OnSelchangeHouses();
  147. }
  148. // houses list done
  149. // ok now color list
  150. const auto& rulesColors = rules.sections["Colors"];
  151. for(i=0;i< rulesColors.values.size();i++)
  152. {
  153. m_Color.AddString(*rulesColors.GetValueName(i));
  154. }
  155. for (i = 0;i < ini.sections["Colors"].values.size();i++)
  156. {
  157. auto col = *ini.sections["Colors"].GetValueName(i);
  158. if(rulesColors.values.find(col) == rulesColors.values.end())
  159. m_Color.AddString(*ini.sections["Colors"].GetValueName(i));
  160. }
  161. }
  162. BOOL CHouses::OnInitDialog()
  163. {
  164. CDialog::OnInitDialog();
  165. UpdateStrings();
  166. UpdateDialog();
  167. #ifdef RA2_MODE
  168. m_ActsLike.ShowWindow(SW_HIDE);
  169. //m_Edge.ShowWindow(SW_HIDE);
  170. #endif
  171. return TRUE; // return TRUE unless you set the focus to a control
  172. // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
  173. }
  174. void CHouses::OnSelchangeHouses()
  175. {
  176. CIniFile& ini=Map->GetIniFile();
  177. int cusel;
  178. cusel=m_houses.GetCurSel();
  179. if(cusel==-1) return;
  180. CString name;
  181. m_houses.GetLBText(cusel, name);
  182. name=TranslateHouse(name);
  183. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  184. // ListHouses(m_ActsLike, TRUE);
  185. #ifndef RA2_MODE
  186. m_ActsLike.SetWindowText(s.values["ActsLike"]);
  187. #endif
  188. m_Allies.SetWindowText(TranslateHouse(s.values["Allies"], TRUE));
  189. m_Color.SetWindowText(s.values["Color"]);
  190. m_Credits.SetWindowText(s.values["Credits"]);
  191. m_Edge.SetWindowText(s.values["Edge"]);
  192. m_IQ.SetWindowText(s.values["IQ"]);
  193. m_Nodecount.SetWindowText(s.values["NodeCount"]);
  194. m_PercentBuilt.SetWindowText(s.values["PercentBuilt"]);
  195. m_PlayerControl.SetWindowText(s.values["PlayerControl"]);
  196. #ifndef RA2_MODE
  197. m_Side.SetWindowText(s.values["Side"]);
  198. #else
  199. m_Side.SetWindowText(TranslateHouse(s.values["Country"], TRUE));
  200. #endif
  201. m_TechLevel.SetWindowText(s.values["TechLevel"]);
  202. }
  203. void CHouses::OnPreparehouses()
  204. {
  205. CIniFile& ini=Map->GetIniFile();
  206. #ifdef RA2_MODE
  207. if(Map->IsMultiplayer())
  208. {
  209. ini.sections["Basic"].values["MultiplayerOnly"]="1";
  210. int i;
  211. for (i=0;i<rules.sections[HOUSES].values.size();i++)
  212. {
  213. char c[50];
  214. int k=i;
  215. itoa(k,c,10);
  216. CString country=*rules.sections[HOUSES].GetValue(i);
  217. // we now create a MAPHOUSE with the same name as the current rules house
  218. ini.sections[MAPHOUSES].values[c]=country;
  219. ini.sections[country].values["IQ"]="0";
  220. ini.sections[country].values["Edge"]="North";
  221. ini.sections[country].values["Color"]=rules.sections[country].values["Color"];
  222. ini.sections[country].values["Allies"]=country;
  223. ini.sections[country].values["Country"]=country;
  224. ini.sections[country].values["Credits"]="0";
  225. ini.sections[country].values["NodeCount"]="0";
  226. ini.sections[country].values["TechLevel"]="1";
  227. ini.sections[country].values["PercentBuilt"]="0";
  228. ini.sections[country].values["PlayerControl"]="no";
  229. }
  230. UpdateDialog();
  231. return;
  232. }
  233. #endif
  234. // import the rules.ini houses
  235. if(ini.sections.find(MAPHOUSES)!=ini.sections.end())
  236. {
  237. if(ini.sections[MAPHOUSES].values.size()>0)
  238. {
  239. MessageBox("There are already houses in your map. You need to delete these first.");
  240. return;
  241. }
  242. }
  243. int i;
  244. for(i=0;i<rules.sections[HOUSES].values.size();i++)
  245. {
  246. AddHouse(GetHouseSectionName(*rules.sections[HOUSES].GetValue(i)));
  247. }
  248. }
  249. void CHouses::AddHouse(const char *name)
  250. {
  251. CIniFile& ini=Map->GetIniFile();
  252. if(ini.sections.find(name)!=ini.sections.end())
  253. {
  254. MessageBox(((CString)"Sorry this name is not available. " + name + (CString)" is already used in the map file. You need to use another name."));
  255. return;
  256. }
  257. if(ini.sections.find(TranslateHouse(name))!=ini.sections.end())
  258. {
  259. MessageBox(((CString)"Sorry this name is not available. " + name + (CString)" is already used in the map file. You need to use another name."));
  260. return;
  261. }
  262. #ifdef RA2_MODE
  263. CNewRA2HouseDlg dlg;
  264. if(dlg.DoModal()==IDCANCEL) return;
  265. #endif
  266. int c;
  267. //okay, get a free slot
  268. int pos=-1;
  269. #ifdef RA2_MODE
  270. int pos2=-1;
  271. #endif
  272. for(c=0;c>-1;c++)
  273. {
  274. char k[50];
  275. itoa(c,k,10);
  276. if(ini.sections[MAPHOUSES].values.find(k)==ini.sections[MAPHOUSES].values.end())
  277. pos=c;
  278. if(pos!=-1) break;
  279. }
  280. #ifdef RA2_MODE
  281. for(c=0;c>-1;c++)
  282. {
  283. char k[50];
  284. itoa(c,k,10);
  285. if(ini.sections[HOUSES].values.find(k)==ini.sections[HOUSES].values.end())
  286. pos2=c;
  287. if(pos2!=-1) break;
  288. }
  289. #endif
  290. char k[50];
  291. itoa(pos,k,10);
  292. ini.sections[MAPHOUSES].values[k]=TranslateHouse(name);
  293. CString country;
  294. country=name;
  295. country.Replace(" House", "");
  296. country.Replace("House","");
  297. if(country.Find(" ")>=0) country.Replace(" ", "_"); //=country.Left(country.Find(" "));
  298. #ifdef RA2_MODE
  299. itoa(pos2, k, 10);
  300. ini.sections[HOUSES].values[k]=country;
  301. #endif
  302. ini.sections[TranslateHouse(name)].values["IQ"]="0";
  303. ini.sections[TranslateHouse(name)].values["Edge"]="West";
  304. ini.sections[TranslateHouse(name)].values["Allies"]=TranslateHouse(name);
  305. CString side=name;
  306. #ifdef RA2_MODE
  307. side=rules.sections[TranslateHouse(dlg.m_Country)].values["Side"];
  308. #endif
  309. if(strstr(name, "Nod")!=NULL)
  310. {
  311. #ifndef RA2_MODE
  312. ini.sections[TranslateHouse(name)].values["Side"]="Nod";
  313. #endif
  314. ini.sections[TranslateHouse(name)].values["Color"]="DarkRed";
  315. if(name!="Nod") ini.sections[name].values["Allies"]+=",Nod";
  316. }
  317. else
  318. {
  319. #ifndef RA2_MODE
  320. ini.sections[TranslateHouse(name)].values["Side"]="GDI";
  321. #endif
  322. ini.sections[TranslateHouse(name)].values["Color"]="Gold";
  323. if(name!="GDI") ini.sections[TranslateHouse(name)].values["Allies"]+=",GDI";
  324. }
  325. ini.sections[TranslateHouse(name)].values["Credits"]="0";
  326. #ifndef RA2_MODE
  327. ini.sections[TranslateHouse(name)].values["ActsLike"]="0";
  328. #else
  329. ini.sections[TranslateHouse(name)].values["Country"]=TranslateHouse(country);
  330. #endif
  331. ini.sections[TranslateHouse(name)].values["NodeCount"]="0";
  332. ini.sections[TranslateHouse(name)].values["TechLevel"]="10";
  333. ini.sections[TranslateHouse(name)].values["PercentBuilt"]="100";
  334. ini.sections[TranslateHouse(name)].values["PlayerControl"]="no";
  335. #ifdef RA2_MODE
  336. dlg.m_Country=TranslateHouse(dlg.m_Country); // just to make sure...
  337. country=TranslateHouse(country);
  338. ini.sections[country].values["ParentCountry"]=dlg.m_Country;
  339. ini.sections[country].values["Name"]=country;
  340. ini.sections[country].values["Suffix"]=rules.sections[dlg.m_Country].values["Suffix"];
  341. ini.sections[country].values["Prefix"]=rules.sections[dlg.m_Country].values["Prefix"];
  342. ini.sections[country].values["Color"]=rules.sections[dlg.m_Country].values["Color"];
  343. ini.sections[country].values["Side"]=rules.sections[dlg.m_Country].values["Side"];
  344. ini.sections[country].values["SmartAI"]=rules.sections[dlg.m_Country].values["SmartAI"];
  345. ini.sections[country].values["CostUnitsMult"]="1";
  346. #endif
  347. int cusel=m_houses.GetCurSel();
  348. UpdateDialog();
  349. ((CFinalSunDlg*)theApp.m_pMainWnd)->UpdateDialogs();
  350. if(cusel!=-1)m_houses.SetCurSel(cusel);
  351. }
  352. void CHouses::OnShowWindow(BOOL bShow, UINT nStatus)
  353. {
  354. CDialog::OnShowWindow(bShow, nStatus);
  355. CIniFile& ini=Map->GetIniFile();
  356. if(bShow)
  357. {
  358. if(ini.sections.find(MAPHOUSES)==ini.sections.end() && ini.sections.size()>0)
  359. {
  360. #ifndef RA2_MODE
  361. MessageBox("No houses do exist, if you want to use houses, you should use ""Prepare houses"" before doing anything else. Note that in a multiplayer map independent computer players cannot be created by using the names GDI and Nod for the house. Just use something like GDI_AI.");
  362. #else
  363. MessageBox("No houses do exist, if you want to use houses, you should use ""Prepare houses"" before doing anything else.");
  364. #endif
  365. }
  366. }
  367. else
  368. {
  369. // call all KillFocus !
  370. OnKillfocusIq();
  371. OnEditchangeActslike();
  372. OnKillfocusAllies();
  373. OnKillfocusColor();
  374. OnKillfocusCredits();
  375. OnKillfocusEdge();
  376. OnKillfocusNodecount();
  377. OnKillfocusPercentbuilt();
  378. OnKillfocusPlayercontrol();
  379. OnKillfocusSide();
  380. OnKillfocusTechlevel();
  381. }
  382. }
  383. void CHouses::OnAddhouse()
  384. {
  385. CString name=InputBox(GetLanguageStringACP("AddHouse"),GetLanguageStringACP("AddHouseCap"));
  386. if(name.GetLength()==0) return;
  387. name=GetHouseSectionName(name);
  388. //name=TranslateHouse(name);
  389. AddHouse(name);
  390. }
  391. void CHouses::OnDeletehouse()
  392. {
  393. CIniFile& ini=Map->GetIniFile();
  394. int cusel;
  395. cusel=m_houses.GetCurSel();
  396. if(cusel==-1) return;
  397. CString name;
  398. CString uiname;
  399. m_houses.GetLBText(cusel, name);
  400. uiname=name;
  401. name=TranslateHouse(name);
  402. CString str=GetLanguageStringACP("DeleteHouse");
  403. str=TranslateStringVariables(1, str, uiname);
  404. if(MessageBox(str,GetLanguageStringACP("DeleteHouseCap"),MB_YESNO)==IDNO) return;
  405. ini.sections.erase((LPCTSTR)name);
  406. int i;
  407. for(i=0;i<ini.sections[MAPHOUSES].values.size();i++)
  408. {
  409. if(*ini.sections[MAPHOUSES].GetValue(i)==name)
  410. {
  411. ini.sections[MAPHOUSES].values.erase(*ini.sections[MAPHOUSES].GetValueName(i));
  412. }
  413. }
  414. if(ini.sections[MAPHOUSES].values.size()==0)
  415. ini.sections.erase(MAPHOUSES);
  416. ((CFinalSunDlg*)theApp.m_pMainWnd)->UpdateDialogs();
  417. UpdateDialog();
  418. }
  419. void CHouses::OnKillfocusIq()
  420. {
  421. CIniFile& ini=Map->GetIniFile();
  422. SetMainStatusBarReady();
  423. int cusel;
  424. cusel=m_houses.GetCurSel();
  425. if(cusel==-1) return;
  426. CString name;
  427. m_houses.GetLBText(cusel, name);
  428. name=TranslateHouse(name);
  429. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  430. CString t;
  431. m_IQ.GetWindowText(t);
  432. s.values["IQ"]=t;
  433. }
  434. void CHouses::OnKillfocusEdge()
  435. {
  436. CIniFile& ini=Map->GetIniFile();
  437. SetMainStatusBarReady();
  438. int cusel;
  439. cusel=m_houses.GetCurSel();
  440. if(cusel==-1) return;
  441. CString name;
  442. m_houses.GetLBText(cusel, name);
  443. name=TranslateHouse(name);
  444. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  445. CString t;
  446. m_Edge.GetWindowText(t);
  447. s.values["Edge"]=t;
  448. }
  449. void CHouses::OnKillfocusSide()
  450. {
  451. CIniFile& ini=Map->GetIniFile();
  452. SetMainStatusBarReady();
  453. int cusel;
  454. cusel=m_houses.GetCurSel();
  455. if(cusel==-1) return;
  456. CString name;
  457. m_houses.GetLBText(cusel, name);
  458. name=TranslateHouse(name);
  459. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  460. CString t;
  461. m_Side.GetWindowText(t);
  462. t=TranslateHouse(t);
  463. #ifndef RA2_MODE
  464. s.values["Side"]=t;
  465. #else
  466. s.values["Country"]=t;
  467. #endif
  468. }
  469. void CHouses::OnKillfocusColor()
  470. {
  471. CIniFile& ini=Map->GetIniFile();
  472. SetMainStatusBarReady();
  473. int cusel;
  474. cusel=m_houses.GetCurSel();
  475. if(cusel==-1) return;
  476. CString name;
  477. m_houses.GetLBText(cusel, name);
  478. name=TranslateHouse(name);
  479. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  480. CString t;
  481. m_Color.GetWindowText(t);
  482. s.values["Color"]=t;
  483. //Map->UpdateIniFile(MAPDATA_UPDATE_FROM_INI);
  484. // MW fix: Only update structures
  485. // this recalculates the colors
  486. Map->UpdateStructures(FALSE);
  487. // and minimap
  488. Map->RedrawMinimap();
  489. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->RedrawWindow();
  490. ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_minimap.RedrawWindow();
  491. }
  492. void CHouses::OnKillfocusAllies()
  493. {
  494. CIniFile& ini=Map->GetIniFile();
  495. SetMainStatusBarReady();
  496. int cusel;
  497. cusel=m_houses.GetCurSel();
  498. if(cusel==-1) return;
  499. CString name;
  500. m_houses.GetLBText(cusel, name);
  501. name=TranslateHouse(name);
  502. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  503. CString t;
  504. m_Allies.GetWindowText(t);
  505. t=TranslateHouse(t);
  506. s.values["Allies"]=t;
  507. }
  508. void CHouses::OnKillfocusCredits()
  509. {
  510. CIniFile& ini=Map->GetIniFile();
  511. SetMainStatusBarReady();
  512. int cusel;
  513. cusel=m_houses.GetCurSel();
  514. if(cusel==-1) return;
  515. CString name;
  516. m_houses.GetLBText(cusel, name);
  517. name=TranslateHouse(name);
  518. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  519. CString t;
  520. m_Credits.GetWindowText(t);
  521. s.values["Credits"]=t;
  522. }
  523. void CHouses::OnEditchangeActslike()
  524. {
  525. CIniFile& ini=Map->GetIniFile();
  526. SetMainStatusBarReady();
  527. int cusel;
  528. cusel=m_houses.GetCurSel();
  529. if(cusel==-1) return;
  530. CString name;
  531. m_houses.GetLBText(cusel, name);
  532. name=TranslateHouse(name);
  533. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  534. CString t;
  535. m_ActsLike.GetWindowText(t);
  536. TruncSpace(t);
  537. t=TranslateHouse(t);
  538. s.values["ActsLike"]=t;
  539. }
  540. void CHouses::OnKillfocusNodecount()
  541. {
  542. CIniFile& ini=Map->GetIniFile();
  543. SetMainStatusBarReady();
  544. int cusel;
  545. cusel=m_houses.GetCurSel();
  546. if(cusel==-1) return;
  547. CString name;
  548. m_houses.GetLBText(cusel, name);
  549. name=TranslateHouse(name);
  550. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  551. CString t;
  552. m_Nodecount.GetWindowText(t);
  553. s.values["NodeCount"]=t;
  554. }
  555. void CHouses::OnKillfocusTechlevel()
  556. {
  557. CIniFile& ini=Map->GetIniFile();
  558. SetMainStatusBarReady();
  559. int cusel;
  560. cusel=m_houses.GetCurSel();
  561. if(cusel==-1) return;
  562. CString name;
  563. m_houses.GetLBText(cusel, name);
  564. name=TranslateHouse(name);
  565. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  566. CString t;
  567. m_TechLevel.GetWindowText(t);
  568. s.values["TechLevel"]=t;
  569. }
  570. void CHouses::OnKillfocusPercentbuilt()
  571. {
  572. CIniFile& ini=Map->GetIniFile();
  573. SetMainStatusBarReady();
  574. int cusel;
  575. cusel=m_houses.GetCurSel();
  576. if(cusel==-1) return;
  577. CString name;
  578. m_houses.GetLBText(cusel, name);
  579. name=TranslateHouse(name);
  580. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  581. CString t;
  582. m_PercentBuilt.GetWindowText(t);
  583. s.values["PercentBuilt"]=t;
  584. }
  585. void CHouses::OnKillfocusPlayercontrol()
  586. {
  587. CIniFile& ini=Map->GetIniFile();
  588. SetMainStatusBarReady();
  589. int cusel;
  590. cusel=m_houses.GetCurSel();
  591. if(cusel==-1) return;
  592. CString name;
  593. m_houses.GetLBText(cusel, name);
  594. name=TranslateHouse(name);
  595. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  596. CString t;
  597. m_PlayerControl.GetWindowText(t);
  598. s.values["PlayerControl"]=t;
  599. }
  600. void CHouses::OnSelchangeHumanplayer()
  601. {
  602. CIniFile& ini=Map->GetIniFile();
  603. CString pl;
  604. m_HumanPlayer.GetLBText(m_HumanPlayer.GetCurSel(),pl);
  605. pl=TranslateHouse(pl);
  606. if(pl.GetLength()==0 || pl=="None")
  607. {
  608. ini.sections["Basic"].values.erase("Player");
  609. }
  610. else
  611. {
  612. ini.sections["Basic"].values["Player"]=(LPCTSTR)pl;
  613. }
  614. }
  615. void CHouses::OnSelchangeActslike()
  616. {
  617. CIniFile& ini=Map->GetIniFile();
  618. int cusel;
  619. cusel=m_houses.GetCurSel();
  620. if(cusel==-1) return;
  621. CString name;
  622. m_houses.GetLBText(cusel, name);
  623. name=TranslateHouse(name);
  624. CIniFileSection& s=ini.sections[(LPCTSTR)name];
  625. CString t;
  626. m_ActsLike.GetLBText(m_ActsLike.GetCurSel(),t);
  627. TruncSpace(t);
  628. t=TranslateHouse(t);
  629. s.values["ActsLike"]=t;
  630. }
  631. void CHouses::UpdateStrings()
  632. {
  633. SetDlgItemText(IDC_DESC, GetLanguageStringACP("HousesDesc"));
  634. SetDlgItemText(IDC_LPLAYER, GetLanguageStringACP("HousesPlayerHouse"));
  635. SetDlgItemText(IDC_LHOUSE, GetLanguageStringACP("HousesHouse"));
  636. SetDlgItemText(IDC_LIQ, GetLanguageStringACP("HousesIQ"));
  637. SetDlgItemText(IDC_LEDGE, GetLanguageStringACP("HousesEdge"));
  638. SetDlgItemText(IDC_LSIDE, GetLanguageStringACP("HousesSide"));
  639. SetDlgItemText(IDC_LCOLOR, GetLanguageStringACP("HousesColor"));
  640. SetDlgItemText(IDC_LALLIES, GetLanguageStringACP("HousesAllies"));
  641. SetDlgItemText(IDC_LCREDITS, GetLanguageStringACP("HousesCredits"));
  642. SetDlgItemText(IDC_LACTSLIKE, GetLanguageStringACP("HousesActsLike"));
  643. SetDlgItemText(IDC_LNODECOUNT, GetLanguageStringACP("HousesNodeCount"));
  644. SetDlgItemText(IDC_LTECHLEVEL, GetLanguageStringACP("HousesTechlevel"));
  645. SetDlgItemText(IDC_LBUILDACTIVITY, GetLanguageStringACP("HousesBuildActivity"));
  646. SetDlgItemText(IDC_LPLAYERCONTROL, GetLanguageStringACP("HousesPlayerControl"));
  647. SetDlgItemText(IDC_PREPAREHOUSES, GetLanguageStringACP("HousesPrepareHouses"));
  648. SetDlgItemText(IDC_ADDHOUSE, GetLanguageStringACP("HousesAddHouse"));
  649. SetDlgItemText(IDC_DELETEHOUSE, GetLanguageStringACP("HousesDeleteHouse"));
  650. SetWindowText(TranslateStringACP(HOUSES));
  651. }
  652. void CHouses::OnSetfocusAllies()
  653. {
  654. SetMainStatusBar(GetLanguageStringACP("HousesAlliesHelp"));
  655. }
  656. void CHouses::PostNcDestroy()
  657. {
  658. CDialog::PostNcDestroy();
  659. }