Merge pull request #5352 from OpenRCT2/set-rct1-path

Add menu option to set RCT1 path
This commit is contained in:
Michael Steenbeek 2017-04-10 17:00:47 +02:00 committed by GitHub
commit caa9655617
5 changed files with 95 additions and 9 deletions

View File

@ -2748,7 +2748,7 @@ STR_2739 :None
STR_2740 :RollerCoaster Tycoon 1
STR_2741 :RollerCoaster Tycoon 2
STR_2742 :css50.dat not found
STR_2743 :Copy data\css17.dat from your RCT1 installation to data\css50.dat in your RCT2 installation.
STR_2743 :Copy data\css17.dat from your RCT1 installation to data\css50.dat in your RCT2 installation, or make sure the path to RCT1 in the Miscellaneous tab is correct.
STR_2744 :[
STR_2745 :\
STR_2746 :]
@ -4144,7 +4144,7 @@ STR_5832 :{SMALLFONT}{BLACK}Show height as generic units instead of measureme
STR_5833 :{SMALLFONT}{BLACK}Changes what date format is used
STR_5834 :{SMALLFONT}{BLACK}Select which audio device OpenRCT2 will use
STR_5835 :{SMALLFONT}{BLACK}Mute the game if the window loses focus
STR_5836 :{SMALLFONT}{BLACK}Select music to use on the main menu.{NEWLINE}Selecting RCT1 theme requires that you copy 'data/css17.dat' from your RCT1 game folder to 'data/css50.dat' in your RCT2 folder.
STR_5836 :{SMALLFONT}{BLACK}Select music to use on the main menu.{NEWLINE}Selecting RCT1 theme requires that you copy 'data/css17.dat' from your RCT1 game folder to 'data/css50.dat' in your RCT2 folder, or set the path to RCT1 in the Miscellaneous tab.
STR_5837 :{SMALLFONT}{BLACK}Create and manage custom UI themes
STR_5838 :{SMALLFONT}{BLACK}Show a separate button for the finance window in the toolbar
STR_5839 :{SMALLFONT}{BLACK}Show a separate button for the research and development window in the toolbar
@ -4341,6 +4341,12 @@ STR_6029 :Ride construction - Demolish current
STR_6030 :{SMALLFONT}{BLACK}Scenery picker. Click any scenery on the map to select the same piece for construction.
STR_6031 :Server Description:
STR_6032 :Server Greeting:
STR_6033 :Path to RCT1 installation:
STR_6034 :{SMALLFONT}{BLACK}{STRING}
STR_6035 :Please select your RCT1 directory
STR_6036 :{SMALLFONT}{BLACK}Clear
STR_6037 :Please select a valid RCT1 directory
STR_6038 :{SMALLFONT}{BLACK}If you have RCT1 installed, set this option to its directory to load scenarios, music, etc.
#############
# Scenarios #

View File

@ -629,6 +629,11 @@ extern "C"
{
return &_g2.elements[image_id - SPR_G2_BEGIN];
}
if (_csg.data == nullptr)
{
gfx_load_csg();
}
return &_csg.elements[image_id - SPR_CSG_BEGIN];
}

View File

@ -3687,6 +3687,13 @@ enum {
STR_SERVER_DESCRIPTION = 6031,
STR_SERVER_GREETING = 6032,
STR_PATH_TO_RCT1 = 6033,
STR_STRING_TOOLTIP = 6034,
STR_PATH_TO_RCT1_BROWSER = 6035,
STR_PATH_TO_RCT1_CLEAR_TIP = 6036,
STR_PATH_TO_RCT1_WRONG_ERROR = 6037,
STR_PATH_TO_RCT1_TIP = 6038,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768
};

View File

@ -163,7 +163,6 @@ bool rct2_init()
if (!gfx_load_g2()) {
return false;
}
gfx_load_csg();
font_sprite_initialise_characters();
if (!gOpenRCT2Headless) {
@ -417,8 +416,13 @@ void rct2_update()
const utf8 *get_file_path(sint32 pathId)
{
static utf8 path[MAX_PATH];
safe_strcpy(path, gRCT2AddressAppPath, sizeof(path));
safe_strcat_path(path, RCT2FilePaths[pathId], sizeof(path));
if (pathId == PATH_ID_CSS50 && !str_is_null_or_empty(gConfigGeneral.rct1_path)) {
safe_strcpy(path, gConfigGeneral.rct1_path, sizeof(path));
safe_strcat_path(path, RCT2FilePaths[PATH_ID_CSS17], sizeof(path));
} else {
safe_strcpy(path, gRCT2AddressAppPath, sizeof(path));
safe_strcat_path(path, RCT2FilePaths[pathId], sizeof(path));
}
return path;
}

View File

@ -33,6 +33,7 @@
#include "../interface/window.h"
#include "../localisation/currency.h"
#include "../localisation/date.h"
#include "../localisation/language.h"
#include "../localisation/localisation.h"
#include "../platform/platform.h"
#include "../rct2.h"
@ -169,6 +170,9 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
WIDX_WINDOW_LIMIT,
WIDX_WINDOW_LIMIT_UP,
WIDX_WINDOW_LIMIT_DOWN,
WIDX_PATH_TO_RCT1_TEXT,
WIDX_PATH_TO_RCT1_BUTTON,
WIDX_PATH_TO_RCT1_CLEAR,
// Twitch
WIDX_CHANNEL_BUTTON = WIDX_PAGE_START,
@ -327,9 +331,12 @@ static rct_widget window_options_misc_widgets[] = {
{ WWT_CHECKBOX, 2, 10, 299, 219, 230, STR_AUTO_OPEN_SHOPS, STR_AUTO_OPEN_SHOPS_TIP }, // Automatically open shops & stalls
{ WWT_DROPDOWN, 1, 155, 299, 234, 245, STR_NONE, STR_NONE }, // Default inspection time dropdown
{ WWT_DROPDOWN_BUTTON, 1, 288, 298, 235, 244, STR_DROPDOWN_GLYPH, STR_DEFAULT_INSPECTION_INTERVAL_TIP }, // Default inspection time dropdown button
{ WWT_SPINNER, 1, 155, 299, 249, 260, STR_NONE, STR_NONE }, // Window limit
{ WWT_SPINNER, 1, 155, 299, 249, 260, STR_NONE, STR_NONE }, // Window limit
{ WWT_DROPDOWN_BUTTON, 1, 288, 298, 250, 254, STR_NUMERIC_UP, STR_NONE }, // Window limit up
{ WWT_DROPDOWN_BUTTON, 1, 288, 298, 255, 259, STR_NUMERIC_DOWN, STR_NONE }, // Window limit down
{ WWT_12, 1, 10, 142, 264, 275, STR_PATH_TO_RCT1, STR_PATH_TO_RCT1_TIP }, // RCT 1 path text
{ WWT_DROPDOWN_BUTTON, 1, 10, 289, 278, 289, STR_NONE, STR_STRING_TOOLTIP }, // RCT 1 path button
{ WWT_DROPDOWN_BUTTON, 1, 289, 299, 278, 289, STR_CLOSE_X, STR_PATH_TO_RCT1_CLEAR_TIP }, // RCT 1 path clear button
{ WIDGETS_END },
};
@ -404,6 +411,7 @@ static void window_options_invalidate(rct_window *w);
static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_options_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
static void window_options_text_input(rct_window *w, sint32 widgetIndex, char *text);
static void window_options_tooltip(rct_window *w, sint32 widgetIndex, rct_string_id *stringid);
static rct_window_event_list window_options_events = {
NULL,
@ -428,7 +436,7 @@ static rct_window_event_list window_options_events = {
window_options_text_input,
NULL,
NULL,
NULL,
window_options_tooltip,
NULL,
NULL,
window_options_invalidate,
@ -450,7 +458,7 @@ static rct_window_event_list window_options_events = {
(1 << WIDX_TAB_6) | \
(1 << WIDX_TAB_7)
static uint32 window_options_page_enabled_widgets[] = {
static uint64 window_options_page_enabled_widgets[] = {
MAIN_OPTIONS_ENABLED_WIDGETS |
(1 << WIDX_RESOLUTION) |
(1 << WIDX_RESOLUTION_DROPDOWN) |
@ -542,7 +550,9 @@ static uint32 window_options_page_enabled_widgets[] = {
(1 << WIDX_DEFAULT_INSPECTION_INTERVAL_DROPDOWN) |
(1 << WIDX_WINDOW_LIMIT) |
(1 << WIDX_WINDOW_LIMIT_UP) |
(1 << WIDX_WINDOW_LIMIT_DOWN),
(1 << WIDX_WINDOW_LIMIT_DOWN) |
(1 << WIDX_PATH_TO_RCT1_BUTTON) |
(1ULL << WIDX_PATH_TO_RCT1_CLEAR),
MAIN_OPTIONS_ENABLED_WIDGETS |
(1 << WIDX_CHANNEL_BUTTON) |
@ -828,6 +838,36 @@ static void window_options_mouseup(rct_window *w, sint32 widgetIndex)
config_save_default();
window_invalidate(w);
break;
case WIDX_PATH_TO_RCT1_BUTTON:
{
utf8string rct1path = platform_open_directory_browser(language_get_string(STR_PATH_TO_RCT1_BROWSER));
if (rct1path) {
// Check if this directory actually contains RCT1
utf8 checkpath[MAX_PATH];
safe_strcpy(checkpath, rct1path, MAX_PATH);
safe_strcat_path(checkpath, "Data", MAX_PATH);
safe_strcat_path(checkpath, "csg1.1", MAX_PATH);
if (platform_file_exists(checkpath))
{
SafeFree(gConfigGeneral.rct1_path);
gConfigGeneral.rct1_path = rct1path;
config_save_default();
window_error_open(STR_RESTART_REQUIRED, STR_NONE);
} else {
SafeFree(rct1path);
window_error_open(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE);
}
}
window_invalidate(w);
break;
}
case WIDX_PATH_TO_RCT1_CLEAR:
if (!str_is_null_or_empty(gConfigGeneral.rct1_path)) {
SafeFree(gConfigGeneral.rct1_path);
config_save_default();
}
window_invalidate(w);
break;
}
break;
@ -1674,6 +1714,8 @@ static void window_options_invalidate(rct_window *w)
window_options_misc_widgets[WIDX_WINDOW_LIMIT].type = WWT_SPINNER;
window_options_misc_widgets[WIDX_WINDOW_LIMIT_UP].type = WWT_DROPDOWN_BUTTON;
window_options_misc_widgets[WIDX_WINDOW_LIMIT_DOWN].type = WWT_DROPDOWN_BUTTON;
window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].type = WWT_DROPDOWN_BUTTON;
window_options_misc_widgets[WIDX_PATH_TO_RCT1_CLEAR].type = WWT_DROPDOWN_BUTTON;
break;
case WINDOW_OPTIONS_PAGE_TWITCH:
@ -1909,6 +1951,16 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
w->x + window_options_misc_widgets[WIDX_WINDOW_LIMIT].left + 1,
w->y + window_options_misc_widgets[WIDX_WINDOW_LIMIT].top
);
set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path);
gfx_draw_string_left_clipped(
dpi,
STR_STRING,
gCommonFormatArgs,
w->colours[1],
w->x + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].left + 1,
w->y + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].top,
277
);
break;
}
}
@ -1954,6 +2006,18 @@ static void window_options_text_input(rct_window *w, sint32 widgetIndex, char *t
}
}
static void window_options_tooltip(rct_window *w, sint32 widgetIndex, rct_string_id *stringid)
{
if (widgetIndex == WIDX_PATH_TO_RCT1_BUTTON && w->page == WINDOW_OPTIONS_PAGE_MISC) {
if (str_is_null_or_empty(gConfigGeneral.rct1_path)) {
// No tooltip if the path is empty
*stringid = STR_NONE;
} else {
set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path);
}
}
}
#pragma region Common
static void window_options_set_page(rct_window *w, sint32 page)