This commit is contained in:
Duncan Frost 2014-05-09 19:47:54 +01:00
commit 0ea838358b
16 changed files with 217 additions and 103 deletions

View File

@ -93,9 +93,12 @@
<ClCompile Include="..\src\window_land.c" />
<ClCompile Include="..\src\window_news.c" />
<ClCompile Include="..\src\window_park.c" />
<ClCompile Include="..\src\window_finances.c" />
<ClCompile Include="..\src\window_footpath.c" />
<ClCompile Include="..\src\window_ride_construction.c" />
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_staff.c" />
<ClCompile Include="..\src\window_title_exit.c" />
<ClCompile Include="..\src\window_title_logo.c" />
<ClCompile Include="..\src\window_main.c" />

View File

@ -281,6 +281,15 @@
<ClCompile Include="..\src\finance.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\window_ride_construction.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_finances.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_staff.c">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@ -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

View File

@ -27,6 +27,8 @@
#include "rct2.h"
#include <tchar.h>
#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!
}

View File

@ -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

View File

@ -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);

View File

@ -19,6 +19,8 @@
*****************************************************************************/
#include <stdio.h>
#include <shlobj.h>
#include <tchar.h>
#include <windows.h>
#include <SDL.h>
#include <SDL_syswm.h>
@ -348,4 +350,49 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
RCT2_GLOBAL(0x009E2C74, uint32) = tmp;
return result;
}
}
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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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();

View File

@ -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;
}

View File

@ -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

33
src/window_finances.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <string.h>
#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;

View File

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <string.h>
#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;
}

39
src/window_staff.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <string.h>
#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;
}