1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

add options for finance and research on toolbar

This commit is contained in:
IntelOrca
2015-03-07 16:38:17 +00:00
parent 7154702ca3
commit de34ab5ed8
10 changed files with 81 additions and 29 deletions

View File

@@ -3451,3 +3451,7 @@ STR_3443 :Page 4
STR_3444 :Page 5 STR_3444 :Page 5
STR_3445 :Set Patrol Area STR_3445 :Set Patrol Area
STR_3446 :Cancel Patrol Area STR_3446 :Cancel Patrol Area
# New strings, cleaner
STR_5120 :Show finances button on toolbar
STR_5121 :Show research button on toolbar

View File

@@ -162,6 +162,11 @@ config_property_definition _generalDefinitions[] = {
{ offsetof(general_configuration, window_width), "window_width", CONFIG_VALUE_TYPE_SINT32, -1, NULL }, { offsetof(general_configuration, window_width), "window_width", CONFIG_VALUE_TYPE_SINT32, -1, NULL },
}; };
config_property_definition _interfaceDefinitions[] = {
{ offsetof(interface_configuration, toolbar_show_finances), "toolbar_show_finances", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
{ offsetof(interface_configuration, toolbar_show_research), "toolbar_show_research", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
};
config_property_definition _soundDefinitions[] = { config_property_definition _soundDefinitions[] = {
{ offsetof(sound_configuration, forced_software_buffering), "forced_software_buffering", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(sound_configuration, forced_software_buffering), "forced_software_buffering", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
{ offsetof(sound_configuration, sound_quality), "sound_quality", CONFIG_VALUE_TYPE_UINT8, 2, NULL }, { offsetof(sound_configuration, sound_quality), "sound_quality", CONFIG_VALUE_TYPE_UINT8, 2, NULL },
@@ -170,12 +175,14 @@ config_property_definition _soundDefinitions[] = {
config_section_definition _sectionDefinitions[] = { config_section_definition _sectionDefinitions[] = {
{ &gConfigGeneral, "general", _generalDefinitions, countof(_generalDefinitions) }, { &gConfigGeneral, "general", _generalDefinitions, countof(_generalDefinitions) },
{ &gConfigInterface, "interface", _interfaceDefinitions, countof(_interfaceDefinitions) },
{ &gConfigSound, "sound", _soundDefinitions, countof(_soundDefinitions) } { &gConfigSound, "sound", _soundDefinitions, countof(_soundDefinitions) }
}; };
#pragma endregion #pragma endregion
general_configuration gConfigGeneral; general_configuration gConfigGeneral;
interface_configuration gConfigInterface;
sound_configuration gConfigSound; sound_configuration gConfigSound;
bool config_open(const utf8string path); bool config_open(const utf8string path);

View File

@@ -105,7 +105,7 @@ enum {
AUTOSAVE_NEVER AUTOSAVE_NEVER
}; };
typedef struct general_configuration { typedef struct {
uint8 play_intro; uint8 play_intro;
uint8 confirmation_prompt; uint8 confirmation_prompt;
uint8 screenshot_format; uint8 screenshot_format;
@@ -131,18 +131,24 @@ typedef struct general_configuration {
uint8 autosave_frequency; uint8 autosave_frequency;
} general_configuration; } general_configuration;
typedef struct sound_configuration { typedef struct {
uint8 toolbar_show_finances;
uint8 toolbar_show_research;
} interface_configuration;
typedef struct {
sint8 forced_software_buffering; sint8 forced_software_buffering;
sint8 sound_quality; sint8 sound_quality;
uint8 title_music; uint8 title_music;
} sound_configuration; } sound_configuration;
typedef struct shortcut_entry { typedef struct {
uint8 key; uint8 key;
uint8 modifier; uint8 modifier;
} shortcut_entry; } shortcut_entry;
extern general_configuration gConfigGeneral; extern general_configuration gConfigGeneral;
extern interface_configuration gConfigInterface;
extern sound_configuration gConfigSound; extern sound_configuration gConfigSound;
extern uint16 gShortcutKeys[SHORTCUT_COUNT]; extern uint16 gShortcutKeys[SHORTCUT_COUNT];

View File

@@ -1113,3 +1113,11 @@ void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int
} }
} }
} }
void widget_set_checkbox_value(rct_window *w, int widgetIndex, int value)
{
if (value)
w->pressed_widgets |= (1ULL << widgetIndex);
else
w->pressed_widgets &= ~(1ULL << widgetIndex);
}

View File

@@ -63,4 +63,7 @@ int widget_is_pressed(rct_window *w, int widgetIndex);
int widget_is_highlighted(rct_window *w, int widgetIndex); int widget_is_highlighted(rct_window *w, int widgetIndex);
int widget_is_active_tool(rct_window *w, int widgetIndex); int widget_is_active_tool(rct_window *w, int widgetIndex);
void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int *output_x, int *output_y, int *output_scroll_area, int *scroll_id); void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int *output_x, int *output_y, int *output_scroll_area, int *scroll_id);
void widget_set_checkbox_value(rct_window *w, int widgetIndex, int value);
#endif #endif

View File

@@ -82,10 +82,19 @@ static int utf8_get_next(char *char_ptr, char **nextchar_ptr)
const char *language_get_string(rct_string_id id) const char *language_get_string(rct_string_id id)
{ {
const char *rct = RCT2_ADDRESS(0x009BF2D4, const char*)[id]; if (id >= STR_OPENRCT2_BEGIN_STRING_ID) {
const char *openrct = language_strings == NULL ? NULL : language_strings[id]; const char *openrct = language_strings == NULL ? NULL : language_strings[id];
const char *str = (openrct == NULL || strlen(openrct) == 0 ? rct : openrct); if (openrct != NULL)
return str == NULL ? "" : str; return openrct;
// TODO Fall back to another language or otherwise English (UK)
return "(undefined string)";
} else {
const char *rct = RCT2_ADDRESS(0x009BF2D4, const char*)[id];
const char *openrct = language_strings == NULL ? NULL : language_strings[id];
const char *str = (openrct == NULL || strlen(openrct) == 0 ? rct : openrct);
return str == NULL ? "" : str;
}
} }
int language_open(int id) int language_open(int id)
@@ -128,7 +137,7 @@ static int language_open_file(const char *filename)
return 0; return 0;
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
language_buffer_size = ftell(f); language_buffer_size = ftell(f) + 1;
language_buffer = calloc(1, language_buffer_size); language_buffer = calloc(1, language_buffer_size);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
fread(language_buffer, language_buffer_size, 1, f); fread(language_buffer, language_buffer_size, 1, f);

View File

@@ -1394,6 +1394,8 @@ enum {
STR_SET_PATROL_AREA = 3445, STR_SET_PATROL_AREA = 3445,
STR_CLEAR_PATROL_AREA = 3446, STR_CLEAR_PATROL_AREA = 3446,
STR_OPENRCT2_BEGIN_STRING_ID = 5120,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768 STR_COUNT = 32768
}; };

View File

@@ -571,12 +571,12 @@ static void window_cheats_paint()
window_cheats_draw_tab_images(dpi, w); window_cheats_draw_tab_images(dpi, w);
if (w->page == WINDOW_CHEATS_PAGE_MONEY){ if (w->page == WINDOW_CHEATS_PAGE_MONEY){
gfx_draw_string(dpi, language_get_string(2681), 0, w->x + XPL(0) + TXTO, w->y + YPL(0) + TXTO); gfx_draw_string(dpi, (char*)language_get_string(2681), 0, w->x + XPL(0) + TXTO, w->y + YPL(0) + TXTO);
gfx_draw_string(dpi, language_get_string(2682), 0, w->x + XPL(0) + TXTO, w->y + YPL(2) + TXTO); gfx_draw_string(dpi, (char*)language_get_string(2682), 0, w->x + XPL(0) + TXTO, w->y + YPL(2) + TXTO);
} }
else if (w->page == WINDOW_CHEATS_PAGE_GUESTS){ else if (w->page == WINDOW_CHEATS_PAGE_GUESTS){
gfx_draw_string(dpi, language_get_string(2683), 0, w->x + XPL(0) + TXTO, w->y + YPL(0) + TXTO); gfx_draw_string(dpi, (char*)language_get_string(2683), 0, w->x + XPL(0) + TXTO, w->y + YPL(0) + TXTO);
gfx_draw_string(dpi, language_get_string(2684), 0, w->x + XPL(0) + TXTO, w->y + YPL(2) + TXTO); gfx_draw_string(dpi, (char*)language_get_string(2684), 0, w->x + XPL(0) + TXTO, w->y + YPL(2) + TXTO);
} }
} }

View File

@@ -93,6 +93,8 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
WIDX_SCREEN_EDGE_SCROLLING, WIDX_SCREEN_EDGE_SCROLLING,
WIDX_HOTKEY_DROPDOWN, WIDX_HOTKEY_DROPDOWN,
WIDX_TOOLBAR_SHOW_FINANCES,
WIDX_TOOLBAR_SHOW_RESEARCH,
WIDX_REAL_NAME_CHECKBOX, WIDX_REAL_NAME_CHECKBOX,
WIDX_SAVE_PLUGIN_DATA_CHECKBOX, WIDX_SAVE_PLUGIN_DATA_CHECKBOX,
@@ -151,6 +153,8 @@ static rct_widget window_options_widgets[] = {
// Controls tab // Controls tab
{ WWT_CHECKBOX, 2, 10, 299, 53, 64, STR_SCREEN_EDGE_SCROLLING, STR_SCREEN_EDGE_SCROLLING_TIP }, { WWT_CHECKBOX, 2, 10, 299, 53, 64, STR_SCREEN_EDGE_SCROLLING, STR_SCREEN_EDGE_SCROLLING_TIP },
{ WWT_DROPDOWN_BUTTON, 0, 26, 185, 68, 78, STR_HOTKEY, STR_HOTKEY_TIP }, { WWT_DROPDOWN_BUTTON, 0, 26, 185, 68, 78, STR_HOTKEY, STR_HOTKEY_TIP },
{ WWT_CHECKBOX, 2, 10, 299, 82, 93, 5120, STR_NONE },
{ WWT_CHECKBOX, 2, 10, 299, 97, 108, 5121, STR_NONE },
// Misc // Misc
{ WWT_CHECKBOX, 2, 10, 299, 53, 64, STR_REAL_NAME, STR_REAL_NAME_TIP }, { WWT_CHECKBOX, 2, 10, 299, 53, 64, STR_REAL_NAME, STR_REAL_NAME_TIP },
@@ -253,6 +257,8 @@ void window_options_open()
(1ULL << WIDX_TEMPERATURE_DROPDOWN) | (1ULL << WIDX_TEMPERATURE_DROPDOWN) |
(1ULL << WIDX_HOTKEY_DROPDOWN) | (1ULL << WIDX_HOTKEY_DROPDOWN) |
(1ULL << WIDX_SCREEN_EDGE_SCROLLING) | (1ULL << WIDX_SCREEN_EDGE_SCROLLING) |
(1ULL << WIDX_TOOLBAR_SHOW_FINANCES) |
(1ULL << WIDX_TOOLBAR_SHOW_RESEARCH) |
(1ULL << WIDX_REAL_NAME_CHECKBOX) | (1ULL << WIDX_REAL_NAME_CHECKBOX) |
(1ULL << WIDX_CONSTRUCTION_MARKER) | (1ULL << WIDX_CONSTRUCTION_MARKER) |
(1ULL << WIDX_CONSTRUCTION_MARKER_DROPDOWN) | (1ULL << WIDX_CONSTRUCTION_MARKER_DROPDOWN) |
@@ -303,6 +309,18 @@ static void window_options_mouseup()
config_save_default(); config_save_default();
window_invalidate(w); window_invalidate(w);
break; break;
case WIDX_TOOLBAR_SHOW_FINANCES:
gConfigInterface.toolbar_show_finances ^= 1;
config_save_default();
window_invalidate(w);
window_invalidate_by_class(WC_TOP_TOOLBAR);
break;
case WIDX_TOOLBAR_SHOW_RESEARCH:
gConfigInterface.toolbar_show_research ^= 1;
config_save_default();
window_invalidate(w);
window_invalidate_by_class(WC_TOP_TOOLBAR);
break;
case WIDX_REAL_NAME_CHECKBOX: case WIDX_REAL_NAME_CHECKBOX:
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) ^= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) ^= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
RCT2_CALLPROC_X(0x0069C52F, RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES ? 0 : 1, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_X(0x0069C52F, RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES ? 0 : 1, 0, 0, 0, 0, 0, 0);
@@ -752,17 +770,8 @@ static void window_options_invalidate()
// sound quality: low/medium/high // sound quality: low/medium/high
RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gConfigSound.sound_quality; RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gConfigSound.sound_quality;
//Sound pause checkbox widget_set_checkbox_value(w, WIDX_SOUND_PAUSED_CHECKBOX, !g_sounds_disabled);
if (!g_sounds_disabled) widget_set_checkbox_value(w, WIDX_SOUND_SW_BUFFER_CHECKBOX, gConfigSound.forced_software_buffering);
w->pressed_widgets |= (1ULL << WIDX_SOUND_PAUSED_CHECKBOX);
else
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_PAUSED_CHECKBOX);
// sound software mixing buffer checkbox
if (gConfigSound.forced_software_buffering)
w->pressed_widgets |= (1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
else
w->pressed_widgets &= ~(1ULL << WIDX_SOUND_SW_BUFFER_CHECKBOX);
window_options_widgets[WIDX_SOUND].type = WWT_DROPDOWN; window_options_widgets[WIDX_SOUND].type = WWT_DROPDOWN;
window_options_widgets[WIDX_SOUND_DROPDOWN].type = WWT_DROPDOWN_BUTTON; window_options_widgets[WIDX_SOUND_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
@@ -776,14 +785,14 @@ static void window_options_invalidate()
window_options_widgets[WIDX_TITLE_MUSIC_DROPDOWN].type = WWT_DROPDOWN_BUTTON; window_options_widgets[WIDX_TITLE_MUSIC_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
break; break;
case WINDOW_OPTIONS_PAGE_INPUT: case WINDOW_OPTIONS_PAGE_INPUT:
// screen edge scrolling checkbox widget_set_checkbox_value(w, WIDX_SCREEN_EDGE_SCROLLING, gConfigGeneral.edge_scrolling);
if (gConfigGeneral.edge_scrolling) widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_FINANCES, gConfigInterface.toolbar_show_finances);
w->pressed_widgets |= (1ULL << WIDX_SCREEN_EDGE_SCROLLING); widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_RESEARCH, gConfigInterface.toolbar_show_research);
else
w->pressed_widgets &= ~(1ULL << WIDX_SCREEN_EDGE_SCROLLING);
window_options_widgets[WIDX_SCREEN_EDGE_SCROLLING].type = WWT_CHECKBOX; window_options_widgets[WIDX_SCREEN_EDGE_SCROLLING].type = WWT_CHECKBOX;
window_options_widgets[WIDX_HOTKEY_DROPDOWN].type = WWT_DROPDOWN_BUTTON; window_options_widgets[WIDX_HOTKEY_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
window_options_widgets[WIDX_TOOLBAR_SHOW_FINANCES].type = WWT_CHECKBOX;
window_options_widgets[WIDX_TOOLBAR_SHOW_RESEARCH].type = WWT_CHECKBOX;
break; break;
case WINDOW_OPTIONS_PAGE_MISC: case WINDOW_OPTIONS_PAGE_MISC:
// real name checkbox // real name checkbox

View File

@@ -19,6 +19,7 @@
*****************************************************************************/ *****************************************************************************/
#include "../addresses.h" #include "../addresses.h"
#include "../config.h"
#include "../editor.h" #include "../editor.h"
#include "../game.h" #include "../game.h"
#include "../input.h" #include "../input.h"
@@ -503,8 +504,11 @@ static void window_top_toolbar_invalidate()
window_top_toolbar_widgets[WIDX_VIEW_MENU].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_VIEW_MENU].type = WWT_EMPTY;
} }
} else { } else {
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) || !gConfigInterface.toolbar_show_finances)
window_top_toolbar_widgets[WIDX_FINANCES].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_FINANCES].type = WWT_EMPTY;
if (!gConfigInterface.toolbar_show_research)
window_top_toolbar_widgets[WIDX_RESEARCH].type = WWT_EMPTY;
} }
enabledWidgets = 0; enabledWidgets = 0;