mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 15:54:31 +01:00
Merge branch 'anyc-testing'
This commit is contained in:
48
src/config.c
48
src/config.c
@@ -72,6 +72,32 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = {
|
||||
0x0200 | SDL_SCANCODE_S // SHORTCUT_SCREENSHOT
|
||||
};
|
||||
|
||||
general_configuration_t gGeneral_config;
|
||||
general_configuration_t gGeneral_config_default = {
|
||||
1,
|
||||
1,
|
||||
SCREENSHOT_FORMAT_PNG,
|
||||
"",
|
||||
MEASUREMENT_FORMAT_IMPERIAL,
|
||||
TEMPERATURE_FORMAT_F,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
sound_configuration_t gSound_config;
|
||||
|
||||
static char *config_show_directory_browser();
|
||||
static void config_parse_settings(FILE *fp);
|
||||
static void config_general(char *setting, char *value);
|
||||
static void config_sound(char *setting, char *value);
|
||||
static int config_get_line(FILE *fp, char *setting, char *value);
|
||||
static int config_parse_setting(FILE *fp, char *setting);
|
||||
static int config_parse_value(FILE *fp, char *value);
|
||||
static int config_parse_section(FILE *fp, char *setting, char *value);
|
||||
static void config_create_default(char *path);
|
||||
static int config_parse_currency(char* currency);
|
||||
static void config_error(char *msg);
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3604
|
||||
@@ -178,22 +204,6 @@ void config_save()
|
||||
}
|
||||
}
|
||||
|
||||
// New config format
|
||||
|
||||
general_configuration_t gGeneral_config;
|
||||
sound_configuration_t gSound_config;
|
||||
|
||||
static char *config_show_directory_browser();
|
||||
static void config_parse_settings(FILE *fp);
|
||||
static void config_general(char *setting, char *value);
|
||||
static void config_sound(char *setting, char *value);
|
||||
static int config_get_line(FILE *fp, char *setting, char *value);
|
||||
static int config_parse_setting(FILE *fp, char *setting);
|
||||
static int config_parse_value(FILE *fp, char *value);
|
||||
static int config_parse_section(FILE *fp, char *setting, char *value);
|
||||
static void config_create_default(char *path);
|
||||
static int config_parse_currency(char* currency);
|
||||
static void config_error(char *msg);
|
||||
|
||||
/**
|
||||
* Initilise the settings.
|
||||
@@ -205,6 +215,8 @@ void config_init()
|
||||
TCHAR path[MAX_PATH];
|
||||
FILE* fp;
|
||||
|
||||
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
||||
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
|
||||
strcat(path, "\\OpenRCT2");
|
||||
DWORD dwAttrib = GetFileAttributes(path);
|
||||
@@ -280,6 +292,7 @@ static void config_create_default(char *path)
|
||||
fprintf(fp, "game_path = %s\n", gGeneral_config.game_path);
|
||||
fprintf(fp, "screenshot_format = PNG\n");
|
||||
fprintf(fp, "play_intro = false\n");
|
||||
fprintf(fp, "confirmation_prompt = true\n");
|
||||
fprintf(fp, "edge_scrolling = true\n");
|
||||
fprintf(fp, "currency = GBP\n");
|
||||
fprintf(fp, "measurement_format = imperial\n");
|
||||
@@ -372,6 +385,9 @@ static void config_general(char *setting, char *value){
|
||||
else if (strcmp(setting, "play_intro") == 0) {
|
||||
gGeneral_config.play_intro = (strcmp(value, "true") == 0);
|
||||
}
|
||||
else if (strcmp(setting, "confirmation_prompt") == 0) {
|
||||
gGeneral_config.confirmation_prompt = (strcmp(value, "true") == 0);
|
||||
}
|
||||
else if (strcmp(setting, "edge_scrolling") == 0){
|
||||
if (strcmp(value, "true") == 0){
|
||||
gGeneral_config.edge_scrolling = 1;
|
||||
|
||||
@@ -123,12 +123,13 @@ typedef struct sound_configuration {
|
||||
|
||||
typedef struct general_configuration {
|
||||
uint8 play_intro;
|
||||
uint8 confirmation_prompt;
|
||||
uint8 screenshot_format;
|
||||
char game_path[MAX_PATH];
|
||||
sint8 measurement_format;
|
||||
sint8 temperature_format;
|
||||
sint8 currency_format;
|
||||
sint8 consturction_marker_colour;
|
||||
sint8 construction_marker_colour;
|
||||
sint8 edge_scrolling;
|
||||
|
||||
} general_configuration_t;
|
||||
|
||||
@@ -746,8 +746,9 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!widget_is_enabled(w, widgetIndex))
|
||||
break;
|
||||
// comment check as it disables the rotate station/building button in construction window
|
||||
// if (!widget_is_enabled(w, widgetIndex))
|
||||
// break;
|
||||
if (widget_is_disabled(w, widgetIndex))
|
||||
break;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ int gfx_load_g1()
|
||||
}
|
||||
|
||||
// Unsuccessful
|
||||
RCT2_ERROR("Unable to load g1.dat");
|
||||
RCT2_ERR("Unable to load g1.dat");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
int object_load(int groupIndex, rct_object_entry *entry)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006A985D, 0, 0, groupIndex, 0, 0, 0, (int)entry);
|
||||
#ifdef _MSC_VER
|
||||
__asm jb fail
|
||||
#else
|
||||
__asm__ goto ( "jb %l0" : : : : fail );
|
||||
#endif
|
||||
return 1;
|
||||
fail:
|
||||
return 0;
|
||||
|
||||
@@ -234,7 +234,8 @@ void osinterface_process_messages()
|
||||
while (SDL_PollEvent(&e)) {
|
||||
switch (e.type) {
|
||||
case SDL_QUIT:
|
||||
rct2_finish();
|
||||
// rct2_finish();
|
||||
rct2_quit();
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
|
||||
@@ -132,6 +132,14 @@ void rct2_finish()
|
||||
_finished = 1;
|
||||
}
|
||||
|
||||
void rct2_quit() {
|
||||
if (gGeneral_config.confirmation_prompt) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) = PM_QUIT;
|
||||
window_save_prompt_open();
|
||||
} else
|
||||
rct2_finish();
|
||||
}
|
||||
|
||||
void rct2_init()
|
||||
{
|
||||
RCT2_GLOBAL(0x00F663AC, int) = 0;
|
||||
|
||||
@@ -170,5 +170,6 @@ void get_local_time();
|
||||
void *rct2_malloc(size_t numBytes);
|
||||
void *rct2_realloc(void *block, size_t numBytes);
|
||||
void rct2_free(void *block);
|
||||
void rct2_quit();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -411,7 +411,9 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge
|
||||
widget = &w->widgets[widgetIndex];
|
||||
|
||||
// Get the colour
|
||||
colour = w->colours[widget->colour];
|
||||
// colour = w->colours[widget->colour];
|
||||
// do not use widget color as this is already used as background for the text_button
|
||||
colour = 2;
|
||||
|
||||
// Resolve the absolute ltrb
|
||||
l = w->x + widget->left;
|
||||
|
||||
@@ -285,6 +285,12 @@ enum {
|
||||
WC_CHEATS = 110,
|
||||
} WINDOW_CLASS;
|
||||
|
||||
enum PROMPT_MODE {
|
||||
PM_SAVE_BEFORE_LOAD,
|
||||
PM_SAVE_BEFORE_QUIT,
|
||||
PM_SAVE_BEFORE_QUIT2,
|
||||
PM_QUIT
|
||||
};
|
||||
|
||||
void window_dispatch_update_all();
|
||||
void window_update_all();
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "audio.h"
|
||||
#include "config.h"
|
||||
|
||||
enum WINDOW_SAVE_PROMPT_WIDGET_IDX {
|
||||
WIDX_BACKGROUND,
|
||||
@@ -39,13 +40,30 @@ enum WINDOW_SAVE_PROMPT_WIDGET_IDX {
|
||||
};
|
||||
|
||||
static rct_widget window_save_prompt_widgets[] = {
|
||||
{ WWT_FRAME, 0, 0, 259, 0, 49, -1, STR_NONE }, // panel / background
|
||||
{ WWT_FRAME, 0, 0, 259, 0, 49, STR_NONE, STR_NONE }, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, 258, 1, 14, 0, STR_WINDOW_TITLE_TIP }, // title bar
|
||||
{ WWT_CLOSEBOX, 0, 247, 257, 2, 13, 824, STR_CLOSE_WINDOW_TIP }, // close x button
|
||||
{ WWT_CLOSEBOX, 0, 247, 257, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
||||
{ WWT_12, 0, 2, 257, 19, 30, 0, STR_NONE }, // question/label
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 8, 85, 35, 46, 0, STR_SAVE_PROMPT_SAVE }, // save
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 91, 168, 35, 46, 0, STR_SAVE_PROMPT_DONT_SAVE },// don't save
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 174, 251, 35, 46, 0, STR_SAVE_PROMPT_CANCEL }, // cancel
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 8, 85, 35, 46, STR_SAVE_PROMPT_SAVE, STR_NONE }, // save
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 91, 168, 35, 46, STR_SAVE_PROMPT_DONT_SAVE, STR_NONE }, // don't save
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 174, 251, 35, 46, STR_SAVE_PROMPT_CANCEL, STR_NONE }, // cancel
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
enum WINDOW_QUIT_PROMPT_WIDGET_IDX {
|
||||
WQIDX_BACKGROUND,
|
||||
WQIDX_TITLE,
|
||||
WQIDX_CLOSE,
|
||||
WQIDX_OK,
|
||||
WQIDX_CANCEL
|
||||
};
|
||||
|
||||
static rct_widget window_quit_prompt_widgets[] = {
|
||||
{ WWT_FRAME, 0, 0, 176, 0, 33, STR_NONE, STR_NONE }, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, 175, 1, 14, STR_QUIT_GAME, STR_WINDOW_TITLE_TIP }, // title bar
|
||||
{ WWT_CLOSEBOX, 0, 164, 174, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 8, 85, 19, 30, STR_OK, STR_NONE }, // ok
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 91, 168, 19, 30, STR_CANCEL, STR_NONE }, // cancel
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
@@ -91,28 +109,48 @@ static void* window_save_prompt_events[] = {
|
||||
*/
|
||||
void window_save_prompt_open()
|
||||
{
|
||||
int stringId;
|
||||
int stringId, x, y;
|
||||
rct_window* window;
|
||||
unsigned short prompt_mode;
|
||||
rct_widget *widgets;
|
||||
uint64 enabled_widgets;
|
||||
|
||||
prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);
|
||||
|
||||
// Check if window is already open
|
||||
window = window_bring_to_front_by_id(WC_SAVE_PROMPT, 0);
|
||||
if (window == NULL) {
|
||||
if (prompt_mode == PM_QUIT) {
|
||||
widgets = window_quit_prompt_widgets;
|
||||
enabled_widgets =
|
||||
(1 << WQIDX_CLOSE) |
|
||||
(1 << WQIDX_OK) |
|
||||
(1 << WQIDX_CANCEL);
|
||||
x = 177;
|
||||
y = 34;
|
||||
} else {
|
||||
widgets = window_save_prompt_widgets;
|
||||
enabled_widgets =
|
||||
(1 << WIDX_CLOSE) |
|
||||
(1 << WIDX_SAVE) |
|
||||
(1 << WIDX_DONT_SAVE) |
|
||||
(1 << WIDX_CANCEL);
|
||||
x = 260;
|
||||
y = 50;
|
||||
}
|
||||
|
||||
window = window_create(
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - 130,
|
||||
max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 25),
|
||||
260,
|
||||
50,
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x/2,
|
||||
max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y/2),
|
||||
x,
|
||||
y,
|
||||
(uint32*)window_save_prompt_events,
|
||||
WC_SAVE_PROMPT,
|
||||
0
|
||||
);
|
||||
|
||||
window->widgets = window_save_prompt_widgets;
|
||||
window->enabled_widgets =
|
||||
(1 << WIDX_CLOSE) |
|
||||
(1 << WIDX_SAVE) |
|
||||
(1 << WIDX_DONT_SAVE) |
|
||||
(1 << WIDX_CANCEL);
|
||||
window->widgets = widgets;
|
||||
window->enabled_widgets = enabled_widgets;
|
||||
window_init_scroll_widgets(window);
|
||||
window->colours[0] = 154;
|
||||
window->flags |= WF_TRANSPARENT;
|
||||
@@ -123,14 +161,107 @@ void window_save_prompt_open()
|
||||
window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
|
||||
}
|
||||
|
||||
stringId = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) + STR_LOAD_GAME;
|
||||
stringId = prompt_mode + STR_LOAD_GAME;
|
||||
if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
|
||||
stringId = STR_LOAD_LANDSCAPE;
|
||||
if (stringId == STR_QUIT_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
|
||||
stringId = STR_QUIT_SCENARIO_EDITOR;
|
||||
window_save_prompt_widgets[WIDX_TITLE].image = stringId;
|
||||
window_save_prompt_widgets[WIDX_LABEL].image =
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) + STR_SAVE_BEFORE_LOADING;
|
||||
window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING;
|
||||
|
||||
if (!gGeneral_config.confirmation_prompt) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) {
|
||||
game_load_or_quit_no_save_prompt();
|
||||
return;
|
||||
}
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) {
|
||||
RCT2_CALLPROC_EBPSAFE(0x0066EE54);
|
||||
game_load_or_quit_no_save_prompt();
|
||||
return;
|
||||
} else {
|
||||
tutorial_stop();
|
||||
game_load_or_quit_no_save_prompt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) {
|
||||
game_load_or_quit_no_save_prompt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066DF17
|
||||
*/
|
||||
static void window_save_prompt_close()
|
||||
{
|
||||
// Unpause the game
|
||||
RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2;
|
||||
unpause_sounds();
|
||||
window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066DDF2
|
||||
*/
|
||||
static void window_save_prompt_mouseup()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
short prompt_mode;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov widgetIndex, dx
|
||||
#else
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
|
||||
prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);
|
||||
|
||||
if (prompt_mode == PM_QUIT) {
|
||||
switch (widgetIndex) {
|
||||
case WQIDX_OK:
|
||||
rct2_finish();
|
||||
break;
|
||||
case WQIDX_CLOSE:
|
||||
case WQIDX_CANCEL:
|
||||
window_close(w);
|
||||
window_save_prompt_close();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
switch (widgetIndex) {
|
||||
case WIDX_SAVE:
|
||||
// TODO to avoid data loss, treat SAVE as CANCEL
|
||||
RCT2_ERROR("%s", "TODO\n");
|
||||
window_close(w);
|
||||
window_save_prompt_close();
|
||||
return;
|
||||
break;
|
||||
case WIDX_DONT_SAVE:
|
||||
break;
|
||||
case WIDX_CLOSE:
|
||||
case WIDX_CANCEL:
|
||||
window_close(w);
|
||||
window_save_prompt_close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) {
|
||||
game_load_or_quit_no_save_prompt();
|
||||
@@ -155,57 +286,6 @@ void window_save_prompt_open()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066DF17
|
||||
*/
|
||||
static void window_save_prompt_close()
|
||||
{
|
||||
// Unpause the game
|
||||
RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2;
|
||||
unpause_sounds();
|
||||
window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066DDF2
|
||||
*/
|
||||
static void window_save_prompt_mouseup()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov widgetIndex, dx
|
||||
#else
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
|
||||
|
||||
// TODO
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
window_save_prompt_close();
|
||||
break;
|
||||
case WIDX_SAVE:
|
||||
break;
|
||||
case WIDX_DONT_SAVE:
|
||||
break;
|
||||
case WIDX_CANCEL:
|
||||
window_close(w);
|
||||
window_save_prompt_close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_save_prompt_paint()
|
||||
{
|
||||
rct_window *w;
|
||||
@@ -225,18 +305,4 @@ static void window_save_prompt_paint()
|
||||
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
|
||||
gfx_draw_string_centred(dpi, window_save_prompt_widgets[WIDX_LABEL].image,
|
||||
w->x + window_save_prompt_widgets[WIDX_LABEL].left + 125,
|
||||
w->y + window_save_prompt_widgets[WIDX_LABEL].top + 1, 2, w);
|
||||
|
||||
gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_SAVE,
|
||||
w->x + window_save_prompt_widgets[WIDX_SAVE].left + 38,
|
||||
w->y + window_save_prompt_widgets[WIDX_SAVE].top + 1, 2, w);
|
||||
gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_DONT_SAVE,
|
||||
w->x + window_save_prompt_widgets[WIDX_DONT_SAVE].left + 38,
|
||||
w->y + window_save_prompt_widgets[WIDX_DONT_SAVE].top + 1, 2, w);
|
||||
gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_CANCEL,
|
||||
w->x + window_save_prompt_widgets[WIDX_CANCEL].left + 38,
|
||||
w->y + window_save_prompt_widgets[WIDX_CANCEL].top + 1, 2, w);
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "string_ids.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "rct2.h"
|
||||
|
||||
static rct_widget window_title_exit_widgets[] = {
|
||||
{ WWT_IMGBTN, 2, 0, 39, 0, 63, SPR_MENU_EXIT, STR_EXIT },
|
||||
@@ -114,7 +115,8 @@ static void window_title_exit_mouseup()
|
||||
return;
|
||||
|
||||
if (widgetIndex == 0)
|
||||
game_do_command(0, 1, 0, 0, 5, 2, 0);
|
||||
rct2_quit();
|
||||
// game_do_command(0, 1, 0, 0, 5, 3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user