From 6bc081edca13d212805f552cfaacec9b6b759135 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Sun, 24 May 2015 12:38:07 -0400 Subject: [PATCH] Added date format to culture options menu --- data/language/english_uk.txt | 4 ++++ src/config.c | 7 +++++++ src/config.h | 6 ++++++ src/windows/game_bottom_toolbar.c | 14 +++++++++---- src/windows/options.c | 34 ++++++++++++++++++++++++++++++- 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index e0360a898c..aee4cf57eb 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3493,3 +3493,7 @@ STR_5156 :{SMALLFONT}{BLACK}Allows testing of most ride types even when the t STR_5157 :Unlock all prices STR_5158 :Quit to menu STR_5159 :Exit OpenRCT2 +STR_5160 :{MONTH} {STRINGID}, Year {COMMA16} +STR_5161 :{WHITE}Date Format: +STR_5162 :Day/Month/Year +STR_5163 :Month/Day/Year diff --git a/src/config.c b/src/config.c index 7a6727e7c1..ab3a29f8c4 100644 --- a/src/config.c +++ b/src/config.c @@ -134,6 +134,12 @@ config_enum_definition _languageEnum[] = { END_OF_ENUM }; +config_enum_definition _dateFormatEnum[] = { + { "DD/MM/YY", DATE_FORMAT_DMY }, + { "MM/DD/YY", DATE_FORMAT_MDY }, + END_OF_ENUM +}; + #pragma endregion #pragma region Section / property definitions @@ -164,6 +170,7 @@ config_property_definition _generalDefinitions[] = { { offsetof(general_configuration, hardware_display), "hardware_display", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(general_configuration, test_unfinished_tracks), "test_unfinished_tracks", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(general_configuration, no_test_crashes), "no_test_crashes", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, + { offsetof(general_configuration, date_format), "date_format", CONFIG_VALUE_TYPE_UINT8, DATE_FORMAT_DMY, _dateFormatEnum }, }; config_property_definition _interfaceDefinitions[] = { diff --git a/src/config.h b/src/config.h index 29b3d5bf4a..104e6a9b34 100644 --- a/src/config.h +++ b/src/config.h @@ -105,6 +105,11 @@ enum { AUTOSAVE_NEVER }; +enum { + DATE_FORMAT_DMY, + DATE_FORMAT_MDY +}; + typedef struct { uint8 play_intro; uint8 confirmation_prompt; @@ -133,6 +138,7 @@ typedef struct { uint8 hardware_display; uint8 test_unfinished_tracks; uint8 no_test_crashes; + uint8 date_format; } general_configuration; typedef struct { diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 175c5ccac4..c4f781b8fb 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -498,13 +498,19 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, int year = date_get_year(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)) + 1; int month = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7); int day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) * days_in_month[month]) >> 16) & 0xFF; - - RCT2_GLOBAL(0x013CE952, short) = STR_DATE_DAY_1 + day; - RCT2_GLOBAL(0x013CE954, short) = month; + if (gConfigGeneral.date_format) { + RCT2_GLOBAL(0x013CE952, short) = month; + RCT2_GLOBAL(0x013CE954, short) = STR_DATE_DAY_1 + day; + } + else { + RCT2_GLOBAL(0x013CE952, short) = STR_DATE_DAY_1 + day; + RCT2_GLOBAL(0x013CE954, short) = month; + } + RCT2_GLOBAL(0x013CE956, short) = year; gfx_draw_string_centred( dpi, - 2737, + (gConfigGeneral.date_format ? 5160 : 2737), x, y, (RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_DATE ? 2 : w->colours[0] & 0x7F), diff --git a/src/windows/options.c b/src/windows/options.c index dcb971320d..1d3e4fe88a 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -80,6 +80,8 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_TEMPERATURE_DROPDOWN, WIDX_HEIGHT_LABELS, WIDX_HEIGHT_LABELS_DROPDOWN, + WIDX_DATE_FORMAT, + WIDX_DATE_FORMAT_DROPDOWN, WIDX_SOUND, WIDX_SOUND_DROPDOWN, @@ -141,6 +143,8 @@ static rct_widget window_options_widgets[] = { { WWT_DROPDOWN_BUTTON, 0, 288, 298, 99, 108, 876, STR_NONE }, //jjj { WWT_DROPDOWN, 0, 155, 299, 113, 124, 868, STR_NONE }, // height labels { WWT_DROPDOWN_BUTTON, 0, 288, 298, 114, 123, 876, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 128, 139, STR_NONE, STR_NONE }, // date format + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 129, 138, 876, STR_NONE }, // Audio tab { WWT_DROPDOWN, 0, 10, 299, 53, 64, 865, STR_NONE }, // sound @@ -277,7 +281,9 @@ void window_options_open() (1ULL << WIDX_ALLOW_SUBTYPE_SWITCHING) | (1ULL << WIDX_DEBUGGING_TOOLS) | (1ULL << WIDX_TEST_UNFINISHED_TRACKS) | - (1ULL << WIDX_RCT1_COLOUR_SCHEME); + (1ULL << WIDX_RCT1_COLOUR_SCHEME) | + (1ULL << WIDX_DATE_FORMAT) | + (1ULL << WIDX_DATE_FORMAT_DROPDOWN); w->page = WINDOW_OPTIONS_PAGE_DISPLAY; window_init_scroll_widgets(w); @@ -548,6 +554,14 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget* window_options_show_dropdown(w, widget, AUTOSAVE_NEVER + 1); gDropdownItemsChecked = 1 << gConfigGeneral.autosave_frequency; break; + case WIDX_DATE_FORMAT_DROPDOWN: + for (i = 0; i < 2; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = 5162 + i; + } + window_options_show_dropdown(w, widget, 2); + gDropdownItemsChecked = 1 << (gConfigGeneral.date_format); + break; } } @@ -676,6 +690,13 @@ static void window_options_dropdown() window_invalidate(w); } break; + case WIDX_DATE_FORMAT_DROPDOWN: + if (dropdownIndex != gConfigGeneral.date_format) { + gConfigGeneral.date_format = (uint8)dropdownIndex; + config_save_default(); + gfx_invalidate_screen(); + } + break; } } @@ -767,6 +788,8 @@ static void window_options_invalidate() window_options_widgets[WIDX_TEMPERATURE_DROPDOWN].type = WWT_DROPDOWN_BUTTON; window_options_widgets[WIDX_HEIGHT_LABELS].type = WWT_DROPDOWN; window_options_widgets[WIDX_HEIGHT_LABELS_DROPDOWN].type = WWT_DROPDOWN_BUTTON; + window_options_widgets[WIDX_DATE_FORMAT].type = WWT_DROPDOWN; + window_options_widgets[WIDX_DATE_FORMAT_DROPDOWN].type = WWT_DROPDOWN_BUTTON; break; case WINDOW_OPTIONS_PAGE_AUDIO: currentSoundDevice = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32); @@ -893,6 +916,15 @@ static void window_options_paint() gfx_draw_string_left(dpi, STR_DISTANCE_AND_SPEED, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_DISTANCE].top + 1); gfx_draw_string_left(dpi, STR_TEMPERATURE, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_TEMPERATURE].top + 1); gfx_draw_string_left(dpi, STR_HEIGHT_LABELS, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_HEIGHT_LABELS].top + 1); + gfx_draw_string_left(dpi, 5161, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_DATE_FORMAT].top + 1); + gfx_draw_string_left( + dpi, + 5162 + gConfigGeneral.date_format, + NULL, + 12, + w->x + window_options_widgets[WIDX_DATE_FORMAT].left + 1, + w->y + window_options_widgets[WIDX_DATE_FORMAT].top + ); break; case WINDOW_OPTIONS_PAGE_AUDIO: gfx_draw_string_left(dpi, 2738, w, 12, w->x + 10, w->y + window_options_widgets[WIDX_TITLE_MUSIC].top + 1);