diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 3c13ff3f2b..8438e163f6 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -93,9 +93,12 @@ + + + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 00a17f947b..c11377bf77 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,6 +281,15 @@ Source Files + + Windows + + + Windows + + + Windows + diff --git a/src/addresses.h b/src/addresses.h index 2ec02b5edd..0917bbfe59 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -228,6 +228,8 @@ #define RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB 0x00F4390A +#define RCT2_ADDRESS_WINDOW_MAP_SELECTED_TAB 0x014209E4 + #define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654 #define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656 #define RCT2_ADDRESS_OS_TIME_DAY 0x01424304 diff --git a/src/config.c b/src/config.c index af8ac6ca44..f1b2ddd385 100644 --- a/src/config.c +++ b/src/config.c @@ -27,6 +27,8 @@ #include "rct2.h" #include +#include "osinterface.h" + // Current keyboard shortcuts uint16 gShortcutKeys[SHORTCUT_COUNT]; @@ -230,8 +232,8 @@ static void config_create_default(char *path) FILE* fp; if (!config_find_rct2_path(gConfig.game_path)) { - MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK); - char *res = config_show_directory_browser(); + osinterface_show_messagebox("Unable to find RCT2 installation directory. Please select the directory where you installed RCT2!"); + char *res = osinterface_open_directory_browser("Please select your RCT2 directory"); strcpy(gConfig.game_path, res); } @@ -243,50 +245,6 @@ static void config_create_default(char *path) fclose(fp); } -/** - * A directory browser allowing for semi-automatic config.ini for non standard installs. - */ -static char *config_show_directory_browser() -{ - BROWSEINFO bi; - char pszBuffer[MAX_PATH]; - LPITEMIDLIST pidl; - LPMALLOC lpMalloc; - - // Initialize COM - if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { - MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); - CoUninitialize(); - return 0; - } - - // Get a pointer to the shell memory allocator - if (SHGetMalloc(&lpMalloc) != S_OK) { - MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); - CoUninitialize(); - return 0; - } - - bi.hwndOwner = NULL; - bi.pidlRoot = NULL; - bi.pszDisplayName = pszBuffer; - bi.lpszTitle = _T("Select your RCT2 installation directory"); - bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - bi.lpfn = NULL; - bi.lParam = 0; - - char *outPath = "C:\\"; - - if (pidl = SHBrowseForFolder(&bi)) { - // Copy the path directory to the buffer - if (SHGetPathFromIDList(pidl, pszBuffer)) { - // Store pszBuffer (and the path) in the outPath - outPath = strcat("", pszBuffer); - } - } - CoUninitialize(); - return outPath; -} /** * Parse settings and set the game veriables @@ -505,7 +463,7 @@ static int config_parse_section(FILE *fp, char *setting, char *value){ * @param msg Message to print in message box */ static void config_error(char *msg){ - MessageBox(NULL, msg, "OpenRCT2", MB_OK); + osinterface_show_messagebox(msg); //TODO:SHUT DOWN EVERYTHING! } diff --git a/src/editor.c b/src/editor.c index 9f07f326af..57ec041be7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -58,11 +58,11 @@ void editor_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); @@ -107,10 +107,10 @@ void trackdesigner_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create @@ -145,10 +145,10 @@ void trackmanager_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create diff --git a/src/game.c b/src/game.c index c734617582..9d7611bbc3 100644 --- a/src/game.c +++ b/src/game.c @@ -1298,7 +1298,7 @@ int game_load_save() RCT2_CALLPROC_EBPSAFE(0x0069E9A7); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play RCT2_CALLPROC_EBPSAFE(0x0069E869); diff --git a/src/osinterface.c b/src/osinterface.c index 3e97491e5b..760f73bf63 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -19,6 +19,8 @@ *****************************************************************************/ #include +#include +#include #include #include #include @@ -348,4 +350,49 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c RCT2_GLOBAL(0x009E2C74, uint32) = tmp; return result; -} \ No newline at end of file +} + +void osinterface_show_messagebox(char* message){ + MessageBox(NULL, message, "OpenRCT2", MB_OK); +} + +char* osinterface_open_directory_browser(char *title) { + BROWSEINFO bi; + char pszBuffer[MAX_PATH]; + LPITEMIDLIST pidl; + LPMALLOC lpMalloc; + + // Initialize COM + if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + // Get a pointer to the shell memory allocator + if (SHGetMalloc(&lpMalloc) != S_OK) { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + bi.hwndOwner = NULL; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszBuffer; + bi.lpszTitle = _T(title); + bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + bi.lpfn = NULL; + bi.lParam = 0; + + char *outPath = "C:\\"; + + if (pidl = SHBrowseForFolder(&bi)) { + // Copy the path directory to the buffer + if (SHGetPathFromIDList(pidl, pszBuffer)) { + // Store pszBuffer (and the path) in the outPath + outPath = strcat("", pszBuffer); + } + } + CoUninitialize(); + return outPath; +} diff --git a/src/osinterface.h b/src/osinterface.h index 9ec682fea2..a42da3c6d3 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -47,5 +47,7 @@ void osinterface_draw(); void osinterface_free(); int osinterface_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName); +void osinterface_show_messagebox(char* message); +char* osinterface_open_directory_browser(char *title); #endif diff --git a/src/rct2.c b/src/rct2.c index be54cd7306..f586b16230 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -135,9 +135,9 @@ void rct2_init() date_reset(); climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); title_load(); @@ -151,7 +151,7 @@ void rct2_init_directories() // check install directory DWORD dwAttrib = GetFileAttributes(gConfig.game_path); if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { - MessageBox(NULL, "Invalid RCT2 installation path. Please correct in config.ini.", "OpenRCT2", MB_OK); + osinterface_show_messagebox("Invalid RCT2 installation path. Please correct in config.ini."); exit(-1); } diff --git a/src/scenario.c b/src/scenario.c index 4d2b409bdb..0752ea39df 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -450,7 +450,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) window_invalidate(mainWindow); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); RCT2_GLOBAL(0x00F663B0, sint32) = RCT2_GLOBAL(0x009AA0F0, sint32); RCT2_GLOBAL(0x00F663B4, sint32) = RCT2_GLOBAL(0x009AA0F4, sint32); diff --git a/src/title.c b/src/title.c index fc6ef67aa5..e32641a20b 100644 --- a/src/title.c +++ b/src/title.c @@ -103,9 +103,9 @@ void title_load() date_reset(); RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_CALLPROC_EBPSAFE(0x0068AFFD); RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); @@ -191,7 +191,7 @@ static void title_update_showcase() window_invalidate(w); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); diff --git a/src/window.c b/src/window.c index a35da16b81..0a7f726040 100644 --- a/src/window.c +++ b/src/window.c @@ -1203,28 +1203,4 @@ void window_guest_list_init_vars_b() { RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; RCT2_GLOBAL(0x00F1AF20, uint16) = 0; -} - -/** -* -* rct2: 0x006ACA58 -*/ -void window_ride_list_init_vars() { - // If we are in the track designer, default to the Roller Coaster tab - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) { - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_LIST_TAB_ROLLER_COASTER; - } - else { - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_LIST_TAB_TRANSPORT; - } - - for (short i = 0; i < 6; i++) { - /* - Reset what is highlighted in each tab. - Each 16bit number represents the item in its respective tab. - */ - RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, uint16)[i] = 0xFFFF; - } - - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_INFORMATION_TYPE, uint8) = 0; } \ No newline at end of file diff --git a/src/window.h b/src/window.h index 3b80f58142..956507fa1e 100644 --- a/src/window.h +++ b/src/window.h @@ -284,22 +284,6 @@ enum { WC_CHEATS = 110, } WINDOW_CLASS; -enum { - WINDOW_RIDE_LIST_TAB_TRANSPORT, - WINDOW_RIDE_LIST_TAB_GENTLE, - WINDOW_RIDE_LIST_TAB_ROLLER_COASTER, - WINDOW_RIDE_LIST_TAB_THRILL, - WINDOW_RIDE_LIST_TAB_WATER, - WINDOW_RIDE_LIST_TAB_SHOP, - WINDOW_RIDE_LIST_TAB_RESEARCH -} WINDOW_RIDE_LIST_TAB; - -enum { - WINDOW_STAFF_LIST_TAB_HANDYMEN, - WINDOW_STAFF_LIST_TAB_MECHANICS, - WINDOW_STAFF_LIST_TAB_SECURITY, - WINDOW_STAFF_LIST_TAB_ENTERTAINERS -} WINDOW_STAFF_LIST_TAB; void window_dispatch_update_all(); void window_update_all(); @@ -369,6 +353,9 @@ void window_cheats_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); -void window_ride_list_init_vars(); + +void window_ride_construction_init_vars(); + +void window_staff_init_vars(); #endif diff --git a/src/window_finances.c b/src/window_finances.c new file mode 100644 index 0000000000..a2244518dd --- /dev/null +++ b/src/window_finances.c @@ -0,0 +1,33 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include "addresses.h" +#include "game.h" +#include "window.h" + +enum { + WINDOW_FINANCES_TAB_SUMMARY, + WINDOW_FINANCES_TAB_FINANCIAL_GRAPH, + WINDOW_FINANCES_TAB_VALUE_GRAPH, + WINDOW_FINANCES_TAB_PROFIT_GRAPH, + WINDOW_FINANCES_TAB_MARKETING, + WINDOW_FINANCES_TAB_RESEARCH +} WINDOW_FINANCIAL_TAB; \ No newline at end of file diff --git a/src/window_ride_construction.c b/src/window_ride_construction.c new file mode 100644 index 0000000000..35b813ac78 --- /dev/null +++ b/src/window_ride_construction.c @@ -0,0 +1,58 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include "addresses.h" +#include "game.h" +#include "window.h" + +enum { + WINDOW_RIDE_CONSTRUCTION_TAB_TRANSPORT, + WINDOW_RIDE_CONSTRUCTION_TAB_GENTLE, + WINDOW_RIDE_CONSTRUCTION_TAB_ROLLER_COASTER, + WINDOW_RIDE_CONSTRUCTION_TAB_THRILL, + WINDOW_RIDE_CONSTRUCTION_TAB_WATER, + WINDOW_RIDE_CONSTRUCTION_TAB_SHOP, + WINDOW_RIDE_CONSTRUCTION_TAB_RESEARCH +} WINDOW_RIDE_CONSTRUCTION_TAB; + +/** +* +* rct2: 0x006ACA58 +*/ +void window_ride_construction_init_vars() { + // If we are in the track designer, default to the Roller Coaster tab + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_CONSTRUCTION_TAB_ROLLER_COASTER; + } + else { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_CONSTRUCTION_TAB_TRANSPORT; + } + + for (short i = 0; i < 6; i++) { + /* + Reset what is highlighted in each tab. + Each 16bit number represents the item in its respective tab. + */ + RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, uint16)[i] = 0xFFFF; + } + + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_INFORMATION_TYPE, uint8) = 0; +} \ No newline at end of file diff --git a/src/window_staff.c b/src/window_staff.c new file mode 100644 index 0000000000..3652084e9d --- /dev/null +++ b/src/window_staff.c @@ -0,0 +1,39 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include "addresses.h" +#include "game.h" +#include "window.h" + +enum { + WINDOW_STAFF_LIST_TAB_HANDYMEN, + WINDOW_STAFF_LIST_TAB_MECHANICS, + WINDOW_STAFF_LIST_TAB_SECURITY, + WINDOW_STAFF_LIST_TAB_ENTERTAINERS +} WINDOW_STAFF_LIST_TAB; + + +/* +* rct2: 0x006BD39C +**/ +void window_staff_init_vars() { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; +} \ No newline at end of file