FinalSun.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. //
  17. // This is the application code. Mainly shows the main dialog and initializes some application global stuff
  18. //
  19. #include "stdafx.h"
  20. #include "FinalSun.h"
  21. #include "FinalSunDlg.h"
  22. #include "structs.h"
  23. #include "mapdata.h"
  24. #include "variables.h"
  25. #include "functions.h"
  26. #include "inlines.h"
  27. #include <ShlObj.h>
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. #define APPID "FinalSun App"
  34. extern char AppPath[];
  35. extern ACTIONDATA AD;
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CFinalSunApp
  38. BEGIN_MESSAGE_MAP(CFinalSunApp, CWinApp)
  39. //{{AFX_MSG_MAP(CFinalSunApp)
  40. //}}AFX_MSG_MAP
  41. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CFinalSunApp construction
  45. void __cdecl term_func()
  46. {
  47. if (MessageBox(0, "Fatal error. Exit FinalSun?", "Fatal error", MB_YESNO) == IDCANCEL) return;
  48. exit(-1);
  49. }
  50. CFinalSunApp::CFinalSunApp()
  51. {
  52. m_cf = RegisterClipboardFormat("FINAL*FORMAT");
  53. if (!m_cf) MessageBox(0, "Failed to register clipboard format, clipboard functions not available", "", 0);
  54. tiledata_count = &t_tiledata_count;
  55. tiledata = &t_tiledata;
  56. // first: set up global variable AppPath
  57. // [02/16/2000] using GetModuleFileName() instead of GetCurrentDirectory(): always the correct path
  58. wchar_t AppPathUtf16[MAX_PATH] = { 0 };
  59. GetModuleFileNameW(NULL, AppPathUtf16, MAX_PATH);
  60. strcpy_s(AppPath, utf16ToUtf8(AppPathUtf16).c_str());
  61. *(strrchr(AppPath, '\\') + 1) = 0;
  62. // Initialize AppData
  63. const std::wstring AppDataPathFolder = utf8ToUtf16(u8AppDataPath.substr(0, u8AppDataPath.size() - 1));
  64. auto create_dir_res = SHCreateDirectoryExW(NULL, AppDataPathFolder.c_str(), nullptr);
  65. if (ERROR_SUCCESS != create_dir_res && ERROR_ALREADY_EXISTS != create_dir_res)
  66. {
  67. wchar_t err_msg[1025] = { 0 };
  68. FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, create_dir_res, 0, err_msg, 1024, NULL);
  69. MessageBoxW(NULL, err_msg, (std::wstring(L"Failed to open ") + AppDataPathFolder).c_str(), 0);
  70. exit(1);
  71. }
  72. if ((GetFileAttributesW(AppDataPathFolder.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
  73. {
  74. MessageBoxW(NULL, (AppDataPathFolder + L" must be a directory, not a file").c_str(), (std::wstring(L"Failed to open ") + AppDataPathFolder).c_str(), 0);
  75. exit(1);
  76. }
  77. /*memset(t_tilepics, 0, sizeof(TILEPICDATA)*10000);
  78. memset(s_tilepics, 0, sizeof(TILEPICDATA)*10000);*/
  79. m_Options.LanguageName = "English";
  80. m_Options.bFlat = FALSE;
  81. m_Options.bEasy = FALSE;
  82. m_Options.bSupportMarbleMadness = FALSE;
  83. m_Options.bMarbleMadness = FALSE;
  84. auto log = u8AppDataPath;
  85. #ifdef TS_MODE
  86. log += "finalsunlog.txt";
  87. #else
  88. log += "finalalert2log.txt";
  89. #endif
  90. m_u8LogFileName = log;
  91. errstream.open(m_u8LogFileName, ios_base::trunc);
  92. errstream << "\uFEFF"; // BOM
  93. #ifdef TS_MODE
  94. errstream << "FinalSun log file" << std::endl << "----------------------" << std::endl << std::endl;
  95. #else
  96. errstream << "FinalAlert 2 log file" << std::endl << "----------------------" << std::endl << std::endl;
  97. #endif
  98. errstream << "CFinalSunApp::CFinalSunApp() called" << std::endl;
  99. errstream << "App Path: " << AppPath << std::endl;
  100. errstream << "AppData Path: " << u8AppDataPath << std::endl;
  101. errstream << "Locale: " << setlocale(LC_ALL, nullptr) << std::endl;
  102. errstream << "Windows ACP: " << GetACP() << std::endl;
  103. INITCOMMONCONTROLSEX ctr;
  104. ctr.dwSize = sizeof(INITCOMMONCONTROLSEX);
  105. ctr.dwICC = ICC_STANDARD_CLASSES;
  106. if (!InitCommonControlsEx(&ctr))
  107. {
  108. errstream << "Error: Common controls could not be initialized" << std::endl;
  109. MessageBox(0, "Common controls could not be initialized.", "Error", 0);
  110. }
  111. errstream << std::endl << std::endl << std::endl;
  112. errstream.flush();
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CFinalSunApp initialization
  116. BOOL CFinalSunApp::InitInstance()
  117. {
  118. m_hAccel = LoadAccelerators(this->m_hInstance, MAKEINTRESOURCE(IDR_MAIN));
  119. #ifndef NOSURFACES
  120. if (GetDeviceCaps(GetDC(GetDesktopWindow()), BITSPIXEL) <= 8)
  121. {
  122. MessageBox(0, "You currently only have 8 bit color mode enabled. This is not recommended. You can continue, but this will cause a significant slowdown while loading graphics, and result in poor graphics quality", "Error", 0);
  123. //exit(0);
  124. }
  125. #else
  126. if (GetDeviceCaps(GetDC(GetDesktopWindow()), BITSPIXEL) <= 8)
  127. {
  128. MessageBox(0, "You currently only have 8 bit color mode enabled. FinalSun/FinalAlert 2 will not work in 8 bit color mode. See readme.txt for further information!", "Error", 0);
  129. exit(0);
  130. }
  131. #endif
  132. ParseCommandLine();
  133. // Load application data
  134. std::string datafile = AppPath;
  135. #ifdef TS_MODE
  136. datafile += "\\FSData.ini";
  137. #else
  138. datafile += "\\FAData.ini";
  139. #endif
  140. g_data.LoadFile(datafile);
  141. // Load language data
  142. std::string languagefile = AppPath;
  143. #ifndef RA2_MODE
  144. languagefile += "\\FSLanguage.ini";
  145. #else
  146. languagefile += "\\FALanguage.ini";
  147. #endif
  148. language.LoadFile(languagefile);
  149. if (language.sections.size() == 0)
  150. {
  151. MessageBox(0, "FALanguage.ini does not exist or is not valid (download corrupt?)", "", 0);
  152. exit(0);
  153. }
  154. #ifndef RA2_MODE
  155. const std::string iniName = "FinalSun.ini";
  156. const std::string defaultIniName = "FinalSunDefaults.ini";
  157. #else
  158. const std::string iniName = "FinalAlert.ini";
  159. const std::string defaultIniName = "FinalAlertDefaults.ini";
  160. #endif
  161. // ok lets get some options
  162. CIniFile optini;
  163. std::string iniFile = u8AppDataPath + iniName;
  164. std::string templateIniFile = std::string(AppPath) + defaultIniName;
  165. bool copiedDefaultFile = false;
  166. if (!DoesFileExist(iniFile.c_str()))
  167. {
  168. if (CopyFileW(utf8ToUtf16(templateIniFile).c_str(), utf8ToUtf16(iniFile).c_str(), TRUE))
  169. copiedDefaultFile = true;
  170. }
  171. optini.LoadFile(iniFile);
  172. #ifdef RA2_MODE
  173. CString game = "RA2";
  174. CString app = "FinalAlert";
  175. #else
  176. CString game = "TS";
  177. CString app = "FinalSun";
  178. #endif
  179. std::wstring key;
  180. #ifdef RA2_MODE
  181. key = L"Software\\Westwood\\Red Alert 2";
  182. #else
  183. key = L"Software\\Westwood\\Tiberian Sun";
  184. #endif
  185. auto& opts = m_Options;
  186. HKEY hKey = 0;
  187. int res;
  188. res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key.c_str(), 0, KEY_EXECUTE/*KEY_ALL_ACCESS*/, &hKey);
  189. if (res != ERROR_SUCCESS)
  190. {
  191. std::wstring s = L"Failed to access registry. Using manual setting. Error was:\n";
  192. wchar_t c[1024] = { 0 };
  193. FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, res, 0, c, 1023, NULL);
  194. MessageBoxW(0, (s + c).c_str(), L"Error", 0);
  195. opts.TSExe = optini.sections[game].values["Exe"];
  196. }
  197. else
  198. {
  199. // key opened
  200. wchar_t path[MAX_PATH + 1] = { 0 };
  201. DWORD pathsize = MAX_PATH;
  202. DWORD type = REG_SZ;
  203. if ((res = RegQueryValueExW(hKey, L"InstallPath", 0, &type, (unsigned char*)path, &pathsize)) != ERROR_SUCCESS)
  204. {
  205. std::wstring s = L"Failed to access registry. Using manual setting. Error was:\n";
  206. wchar_t c[1024] = { 0 };
  207. FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, res, 0, c, 1023, NULL);
  208. MessageBoxW(0, (s + c).c_str(), L"Error", 0);
  209. opts.TSExe = optini.sections[game].values["Exe"];
  210. }
  211. else
  212. opts.TSExe = path;
  213. }
  214. if (copiedDefaultFile ||
  215. optini.sections.size() == 0 ||
  216. opts.TSExe.GetLength() == 0 ||
  217. optini.sections[app].values["Language"].GetLength() == 0 ||
  218. optini.sections[app].values.find("FileSearchLikeGame") == optini.sections[app].values.end() ||
  219. optini.sections[app].values.find("PreferLocalTheaterFiles") == optini.sections[app].values.end())
  220. {
  221. opts.bSearchLikeTS = TRUE;
  222. bOptionsStartup = TRUE;
  223. ShowOptionsDialog();
  224. bOptionsStartup = FALSE;
  225. }
  226. else
  227. {
  228. opts.LanguageName = optini.sections[app].values["Language"];
  229. if (optini.sections[app].values["FileSearchLikeGame"] != "no")
  230. opts.bSearchLikeTS = TRUE;
  231. else opts.bSearchLikeTS = FALSE;
  232. }
  233. opts.bPreferLocalTheaterFiles = optini.sections[app].values.emplace("PreferLocalTheaterFiles", opts.bPreferLocalTheaterFiles ? "1" : "0").first->second == "1";
  234. opts.bDoNotLoadAircraftGraphics = optini.sections["Graphics"].values["NoAircraftGraphics"] == "1";
  235. opts.bDoNotLoadVehicleGraphics = optini.sections["Graphics"].values["NoVehicleGraphics"] == "1";
  236. opts.bDoNotLoadBuildingGraphics = optini.sections["Graphics"].values["NoBuildingGraphics"] == "1";
  237. opts.bDoNotLoadInfantryGraphics = optini.sections["Graphics"].values["NoInfantryGraphics"] == "1";
  238. opts.bDoNotLoadTreeGraphics = optini.sections["Graphics"].values["NoTreeGraphics"] == "1";
  239. opts.bDoNotLoadSnowGraphics = optini.sections["Graphics"].values["NoSnowGraphics"] == "1";
  240. opts.bDoNotLoadTemperateGraphics = optini.sections["Graphics"].values["NoTemperateGraphics"] == "1";
  241. opts.bDoNotLoadBMPs = optini.sections["Graphics"].values["NoBMPs"] == "1";
  242. opts.bDoNotLoadOverlayGraphics = optini.sections["Graphics"].values["NoOverlayGraphics"] == "1";
  243. opts.bVSync = optini.sections["Graphics"].values.emplace("VSync", opts.bVSync ? "1" : "0").first->second == "1";
  244. opts.bDisableAutoShore = optini.sections["UserInterface"].values["DisableAutoShore"] == "1";
  245. opts.bDisableAutoLat = optini.sections["UserInterface"].values["DisableAutoLat"] == "1";
  246. opts.bNoSounds = optini.sections["UserInterface"].values["Sounds"] != "1";
  247. opts.bDisableSlopeCorrection = optini.sections["UserInterface"].values["DisableSlopeCorrection"] == "1";
  248. opts.fLoadScreenDelayInSeconds = static_cast<float>(atof(optini.sections["UserInterface"].values.emplace("LoadScreenDelay", std::to_string(opts.fLoadScreenDelayInSeconds).c_str()).first->second));
  249. opts.bShowStats = optini.sections["UserInterface"].values.emplace("ShowStats", opts.bShowStats ? "1" : "0").first->second == "1";
  250. opts.bHighResUI = optini.sections["UserInterface"].values.emplace("HighRes", opts.bHighResUI ? "1" : "0").first->second == "1";
  251. opts.useDefaultMouseCursor = optini.sections["UserInterface"].values.emplace("UseDefaultMouseCursor", opts.useDefaultMouseCursor ? "1" : "0").first->second == "1";
  252. opts.fMiniMapScale = static_cast<float>(atof(optini.sections["MiniMap"].values.emplace("Scale", std::to_string(opts.fMiniMapScale).c_str()).first->second));
  253. auto defaultViewSteps = CString(Join(",", opts.viewScaleSteps | std::views::transform([](auto v) {return std::to_string(v); })).c_str());
  254. auto viewScaleStepsRange = SplitParams(optini.sections["UserInterface"].values.emplace("ViewScaleSteps", defaultViewSteps).first->second) | std::views::transform([](auto v) { return static_cast<float>(std::atof(v)); });
  255. opts.viewScaleSteps.assign(viewScaleStepsRange.begin(), viewScaleStepsRange.end());
  256. opts.viewScaleUseSteps = optini.sections["UserInterface"].values.emplace("ViewScaleUseSteps", opts.viewScaleUseSteps ? "1" : "0").first->second == "1";
  257. opts.viewScaleSpeed = static_cast<float>(atof(optini.sections["UserInterface"].values.emplace("ViewScaleSpeed", std::to_string(opts.viewScaleSpeed).c_str()).first->second));
  258. // MW 07/19/01
  259. opts.bShowCells = optini.sections["UserInterface"].values["ShowBuildingCells"] == "1";
  260. optini.SaveFile(iniFile);
  261. // MW 07/20/01: Load file list
  262. int i;
  263. for (i = 0;i < 4;i++)
  264. {
  265. char c[50];
  266. itoa(i, c, 10);
  267. opts.prev_maps[i] = optini.sections["Files"].values[c];
  268. }
  269. if (opts.bDoNotLoadTemperateGraphics && opts.bDoNotLoadSnowGraphics)
  270. {
  271. MessageBox(0, "You have turned off loading of both snow and temperate terrain in 'FinalAlert.ini'. At least one of these must be loaded. The application will now quit.", "Error", 0);
  272. exit(-982);
  273. }
  274. int EasyView;
  275. if (optini.sections["UserInterface"].FindName("EasyView") < 0)
  276. {
  277. MessageBox(0, GetLanguageStringACP("ExplainEasyView"), GetLanguageStringACP("ExplainEasyViewCap"), 0);
  278. EasyView = 1;
  279. optini.LoadFile(iniFile);
  280. optini.sections["UserInterface"].values["EasyView"] = "1";
  281. optini.SaveFile(iniFile);
  282. }
  283. else
  284. {
  285. EasyView = atoi(optini.sections["UserInterface"].values["EasyView"]);
  286. }
  287. if (EasyView != 0) theApp.m_Options.bEasy = TRUE;
  288. CString cTSPath = theApp.m_Options.TSExe;
  289. auto lastSlash = cTSPath.ReverseFind('\\');
  290. if (lastSlash >= 0)
  291. cTSPath.SetAt(lastSlash + 1, 0);
  292. strcpy(TSPath, cTSPath);
  293. // MW 01/23/2013: changed the global CMapData Map to a global CMapData* to get rid of static initialization/shutdown problems
  294. {
  295. std::unique_ptr<CMapData> mapData(new CMapData());
  296. Map = mapData.get();
  297. CLoading loading(NULL);
  298. m_loading = &loading;
  299. CFinalSunDlg dlg;
  300. m_pMainWnd = &dlg;
  301. dlg.DoModal();
  302. }
  303. // Map and dialog closed, do further work if required
  304. return FALSE;
  305. }
  306. void CFinalSunApp::ParseCommandLine()
  307. {
  308. #if 0 // Removed as it can conflict with Steam game arguments! -LF 23.02.2024
  309. char data[MAX_PATH + 30];
  310. strcpy(data, theApp.m_lpCmdLine);
  311. if (strlen(data) == 0)
  312. {
  313. strcpy(currentMapFile, "");
  314. return;
  315. }
  316. strcpy(currentMapFile, data);
  317. #endif
  318. }
  319. void CFinalSunApp::ShowTipAtStartup(void)
  320. {
  321. CTipDlg dlg;
  322. if (dlg.m_bStartup)
  323. dlg.DoModal();
  324. }
  325. void CFinalSunApp::ShowTipOfTheDay(void)
  326. {
  327. CTipDlg dlg;
  328. dlg.DoModal();
  329. }
  330. int CFinalSunApp::Run()
  331. {
  332. return CWinApp::Run();
  333. }
  334. BOOL CFinalSunApp::ProcessMessageFilter(int code, LPMSG lpMsg)
  335. {
  336. if (lpMsg->message == WM_KEYDOWN)
  337. {
  338. /*if(lpMsg->wParam==VK_F1)
  339. {
  340. if(ShellExecute(0, NULL, (CString)AppPath+"/help/index.htm", NULL, NULL, SW_NORMAL)==0)
  341. {
  342. MessageBox(0,(CString)"Could not open manual! Try opening "+(CString)AppPath+(CString)"/help/index.htm manually","Error",0);
  343. }
  344. return TRUE;
  345. }*/
  346. // check AD mode
  347. if (lpMsg->wParam == VK_PRIOR || lpMsg->wParam == VK_NEXT)
  348. {
  349. if (lpMsg->wParam == VK_PRIOR)
  350. {
  351. AD.z_data += 1;
  352. }
  353. if (lpMsg->wParam == VK_NEXT)
  354. {
  355. AD.z_data -= 1;
  356. }
  357. if (AD.mode == ACTIONMODE_SETTILE || AD.mode == ACTIONMODE_PASTE)
  358. {
  359. CIsoView* v = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview;
  360. CTerrainDlg& tdlg = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_browser->m_bar;
  361. WORD isox, isoy;
  362. RECT r;
  363. POINT p;
  364. v->GetWindowRect(&r);
  365. GetCursorPos(&p);
  366. isox = p.x - r.left;
  367. isoy = p.y - r.top;
  368. if (isox > r.right - r.left || isoy > r.bottom - r.top)
  369. {
  370. }
  371. else
  372. {
  373. LPARAM lParam;
  374. memcpy(&lParam, &isox, 2);
  375. memcpy((BYTE*)&lParam + 2, &isoy, 2);
  376. v->SendMessage(WM_MOUSEMOVE, 0, lParam);
  377. }
  378. }
  379. }
  380. if (AD.mode == ACTIONMODE_SETTILE)
  381. {
  382. CIsoView* v = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview;
  383. CTerrainDlg& tdlg = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_browser->m_bar;
  384. WORD isox, isoy;
  385. RECT r;
  386. POINT p;
  387. v->GetWindowRect(&r);
  388. GetCursorPos(&p);
  389. isox = p.x - r.left;
  390. isoy = p.y - r.top;
  391. if (isox > r.right - r.left || isoy > r.bottom - r.top)
  392. {
  393. }
  394. else
  395. {
  396. LPARAM lParam;
  397. memcpy(&lParam, &isox, 2);
  398. memcpy((BYTE*)&lParam + 2, &isoy, 2);
  399. int searchedTileSet;
  400. int z;
  401. switch (lpMsg->wParam)
  402. {
  403. case VK_LEFT:
  404. if (AD.type > 0 && (*tiledata)[AD.type].wTileSet == (*tiledata)[AD.type - 1].wTileSet) { AD.type -= 1; AD.z_data = 0; }
  405. v->SendMessage(WM_MOUSEMOVE, 0, lParam);
  406. return 0;
  407. break;
  408. case VK_RIGHT:
  409. if (AD.type < (*tiledata_count) - 1 && (*tiledata)[AD.type].wTileSet == (*tiledata)[AD.type + 1].wTileSet) { AD.type += 1; AD.z_data = 0; }
  410. v->SendMessage(WM_MOUSEMOVE, 0, lParam);
  411. return 0;
  412. break;
  413. case VK_UP:
  414. searchedTileSet = (*tiledata)[AD.type].wTileSet - 1;
  415. case VK_DOWN:
  416. if (lpMsg->wParam == VK_DOWN)
  417. searchedTileSet = (*tiledata)[AD.type].wTileSet + 1;
  418. if (searchedTileSet >= 0 && searchedTileSet < tilesets_start.size())
  419. {
  420. int i;
  421. int s = 1;
  422. int start = 0;
  423. int count = tilesets_start.size() - searchedTileSet;
  424. if (searchedTileSet < (*tiledata)[AD.type].wTileSet)
  425. {
  426. s = -1;
  427. start = 0;
  428. count = searchedTileSet + 1;
  429. }
  430. for (i = start;i < count;i += 1)
  431. {
  432. if (searchedTileSet + i * s < 0 || searchedTileSet + i * s >= tilesets_start.size()) continue;
  433. int pos = tilesets_start[searchedTileSet + i * s];
  434. int e;
  435. CComboBox* cb = ((CComboBox*)tdlg.GetDlgItem(IDC_TILESET));
  436. BOOL bFound = FALSE;
  437. for (e = 0;e < cb->GetCount();e++)
  438. {
  439. if (cb->GetItemData(e) == searchedTileSet + i * s)
  440. {
  441. cb->SendMessage(CB_SETCURSEL, e, 0);
  442. bFound = TRUE;
  443. break;
  444. }
  445. }
  446. if (bFound)
  447. {
  448. AD.type = tilesets_start[searchedTileSet + i * s];
  449. AD.data = 0;
  450. AD.data2 = 0;
  451. AD.data3 = 0;
  452. AD.data_s = "";
  453. v->SendMessage(WM_MOUSEMOVE, 0, lParam);
  454. return 0;
  455. }
  456. }
  457. return 0;
  458. break;
  459. }
  460. return 0;
  461. break;
  462. }
  463. }
  464. }
  465. }
  466. return CWinApp::ProcessMessageFilter(code, lpMsg);
  467. }
  468. LRESULT CFinalSunApp::ProcessWndProcException(CException* e, const MSG* pMsg)
  469. {
  470. // TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen
  471. e->ReportError(MB_YESNO);
  472. return TRUE;
  473. //return CWinApp::ProcessWndProcException(e, pMsg);
  474. }
  475. BOOL CFinalSunApp::PreTranslateMessage(MSG* pMsg)
  476. {
  477. if (!TranslateAccelerator(
  478. *this->m_pMainWnd, // handle to receiving window
  479. m_hAccel, // handle to active accelerator table
  480. pMsg)) // message data
  481. return CWinApp::PreTranslateMessage(pMsg);
  482. return FALSE;
  483. }
  484. BOOL CFinalSunApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  485. {
  486. return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  487. }
  488. BOOL CFinalSunApp::OnIdle(LONG lCount)
  489. {
  490. ((CFinalSunDlg*)m_pMainWnd)->m_view.m_isoview->UpdateWindow();
  491. //MessageBox(0,"Idled","",0);
  492. return CWinApp::OnIdle(lCount);
  493. }