diff --git a/src/openrct2-ui/input/KeyboardShortcut.cpp b/src/openrct2-ui/input/KeyboardShortcut.cpp index cd2452a16a..92c3558ba0 100644 --- a/src/openrct2-ui/input/KeyboardShortcut.cpp +++ b/src/openrct2-ui/input/KeyboardShortcut.cpp @@ -98,7 +98,7 @@ static void ShortcutCloseAllFloatingWindow() { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)) window_close_all(); - else if (gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + else if (gS6Info.editor_step == EditorStep::LandscapeEditor) window_close_top(); } @@ -362,7 +362,7 @@ static void ShortcutAdjustLand() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -381,7 +381,7 @@ static void ShortcutAdjustWater() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -400,7 +400,7 @@ static void ShortcutBuildScenery() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -419,7 +419,7 @@ static void ShortcutBuildPaths() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -526,7 +526,7 @@ static void ShortcutShowMap() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) context_open_window(WC_MAP); } @@ -574,7 +574,7 @@ static void ShortcutClearScenery() if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { @@ -787,7 +787,7 @@ static void ShortcutAdvanceToNextTick() static void ShortcutOpenSceneryPicker() { if ((gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) - || (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gS6Info.editor_step != EDITOR_STEP_LANDSCAPE_EDITOR)) + || (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gS6Info.editor_step != EditorStep::LandscapeEditor)) return; rct_window* window_scenery = window_find_by_class(WC_SCENERY); diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index ad638f49f0..c499a9b887 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -60,7 +60,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord return info; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) return info; info = get_map_coordinates_from_pos( @@ -250,7 +250,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor return info; // - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) return info; info = get_map_coordinates_from_pos(screenCoords, ~(VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER)); diff --git a/src/openrct2-ui/scripting/CustomMenu.cpp b/src/openrct2-ui/scripting/CustomMenu.cpp index a43b2498a6..a475fc3797 100644 --- a/src/openrct2-ui/scripting/CustomMenu.cpp +++ b/src/openrct2-ui/scripting/CustomMenu.cpp @@ -186,7 +186,7 @@ namespace OpenRCT2::Scripting // prevents abort from being called. rct_widgetindex widgetIndex = -2; tool_cancel(); - tool_set(toolbarWindow, widgetIndex, static_cast(customTool.Cursor)); + tool_set(toolbarWindow, widgetIndex, static_cast(customTool.Cursor)); ActiveCustomTool = std::move(customTool); ActiveCustomTool->Start(); } diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index c41675dbd6..8795aa6ca3 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -126,7 +126,7 @@ rct_window* window_editor_bottom_toolbar_open() void window_editor_bottom_toolbar_jump_back_to_object_selection() { window_close_all(); - gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info.editor_step = EditorStep::ObjectSelection; gfx_invalidate_screen(); } @@ -139,7 +139,7 @@ void window_editor_bottom_toolbar_jump_back_to_landscape_editor() window_close_all(); set_all_scenery_items_invented(); scenery_set_default_placement_configuration(); - gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info.editor_step = EditorStep::LandscapeEditor; context_open_window(WC_MAP); gfx_invalidate_screen(); } @@ -152,7 +152,7 @@ static void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() { window_close_all(); context_open_window(WC_EDITOR_INVENTION_LIST); - gS6Info.editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; + gS6Info.editor_step = EditorStep::InventionsListSetUp; gfx_invalidate_screen(); } @@ -164,7 +164,7 @@ void window_editor_bottom_toolbar_jump_back_to_options_selection() { window_close_all(); context_open_window(WC_EDITOR_SCENARIO_OPTIONS); - gS6Info.editor_step = EDITOR_STEP_OPTIONS_SELECTION; + gS6Info.editor_step = EditorStep::OptionsSelection; gfx_invalidate_screen(); } @@ -223,7 +223,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() { window_close_all(); context_open_window(WC_EDITOR_INVENTION_LIST); - gS6Info.editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; + gS6Info.editor_step = EditorStep::InventionsListSetUp; } else { @@ -241,7 +241,7 @@ void window_editor_bottom_toolbar_jump_forward_to_options_selection() { window_close_all(); context_open_window(WC_EDITOR_SCENARIO_OPTIONS); - gS6Info.editor_step = EDITOR_STEP_OPTIONS_SELECTION; + gS6Info.editor_step = EditorStep::OptionsSelection; gfx_invalidate_screen(); } @@ -253,7 +253,7 @@ void window_editor_bottom_toolbar_jump_forward_to_objective_selection() { window_close_all(); context_open_window(WC_EDITOR_OBJECTIVE_OPTIONS); - gS6Info.editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; + gS6Info.editor_step = EditorStep::ObjectiveSelection; gfx_invalidate_screen(); } @@ -288,12 +288,12 @@ static void window_editor_bottom_toolbar_mouseup([[maybe_unused]] rct_window* w, if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) || (GetEntityListCount(EntityListId::Free) == MAX_SPRITES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED))) { - previous_button_mouseup_events[gS6Info.editor_step](); + previous_button_mouseup_events[EnumValue(gS6Info.editor_step)](); } } else if (widgetIndex == WIDX_NEXT_STEP_BUTTON) { - next_button_mouseup_events[gS6Info.editor_step](); + next_button_mouseup_events[EnumValue(gS6Info.editor_step)](); } } @@ -336,11 +336,11 @@ void window_editor_bottom_toolbar_invalidate(rct_window* w) } else { - if (gS6Info.editor_step == EDITOR_STEP_OBJECT_SELECTION) + if (gS6Info.editor_step == EditorStep::ObjectSelection) { hide_previous_step_button(); } - else if (gS6Info.editor_step == EDITOR_STEP_ROLLERCOASTER_DESIGNER) + else if (gS6Info.editor_step == EditorStep::RollercoasterDesigner) { hide_next_step_button(); } @@ -363,7 +363,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) bool drawPreviousButton = false; bool drawNextButton = false; - if (gS6Info.editor_step == EDITOR_STEP_OBJECT_SELECTION) + if (gS6Info.editor_step == EditorStep::ObjectSelection) { drawNextButton = true; } @@ -395,7 +395,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].bottom + w->windowPos.y, FilterPaletteID::Palette51); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) { gfx_filter_rect( dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + w->windowPos.x, @@ -419,7 +419,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) INSET_RECT_F_30); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) { gfx_fill_rect_inset( dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + 1 + w->windowPos.x, @@ -435,8 +435,8 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t stateY = w->height - 0x0C + w->windowPos.y; gfx_draw_string_centred( - dpi, EditorStepNames[gS6Info.editor_step], { stateX, stateY }, NOT_TRANSLUCENT(w->colours[2]) | COLOUR_FLAG_OUTLINE, - nullptr); + dpi, EditorStepNames[EnumValue(gS6Info.editor_step)], { stateX, stateY }, + NOT_TRANSLUCENT(w->colours[2]) | COLOUR_FLAG_OUTLINE, nullptr); if (drawPreviousButton) { @@ -460,7 +460,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t textY = window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].top + 6 + w->windowPos.y; - rct_string_id stringId = EditorStepNames[gS6Info.editor_step - 1]; + rct_string_id stringId = EditorStepNames[EnumValue(gS6Info.editor_step) - 1]; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_EDITOR_STEP_OBJECT_SELECTION; @@ -468,7 +468,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_draw_string_centred(dpi, stringId, { textX, textY + 10 }, textColour, nullptr); } - if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((drawPreviousButton || drawNextButton) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) { gfx_draw_sprite( dpi, SPR_NEXT, @@ -490,7 +490,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) + w->windowPos.x; int16_t textY = window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + 6 + w->windowPos.y; - rct_string_id stringId = EditorStepNames[gS6Info.editor_step + 1]; + rct_string_id stringId = EditorStepNames[EnumValue(gS6Info.editor_step) + 1]; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER; diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 60476832bf..814a95d0eb 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1271,7 +1271,7 @@ static void window_editor_object_selection_manage_tracks() set_every_ride_type_invented(); set_every_ride_entry_invented(); - gS6Info.editor_step = EDITOR_STEP_TRACK_DESIGNS_MANAGER; + gS6Info.editor_step = EditorStep::DesignsManager; int32_t entry_index = 0; for (; object_entry_get_chunk(ObjectType::Ride, entry_index) == nullptr; entry_index++) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 865fdc43e9..69d51ff840 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -218,7 +218,7 @@ rct_window* window_footpath_open() tool_cancel(); gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND; - tool_set(window, WIDX_CONSTRUCT_ON_LAND, TOOL_PATH_DOWN); + tool_set(window, WIDX_CONSTRUCT_ON_LAND, Tool::PathDown); input_set_flag(INPUT_FLAG_6, true); _footpathErrorOccured = false; window_footpath_set_enabled_and_pressed_widgets(); @@ -269,7 +269,7 @@ static void window_footpath_mouseup(rct_window* w, rct_widgetindex widgetIndex) map_invalidate_map_selection_tiles(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND; - tool_set(w, WIDX_CONSTRUCT_ON_LAND, TOOL_PATH_DOWN); + tool_set(w, WIDX_CONSTRUCT_ON_LAND, Tool::PathDown); input_set_flag(INPUT_FLAG_6, true); _footpathErrorOccured = false; window_footpath_set_enabled_and_pressed_widgets(); @@ -286,7 +286,7 @@ static void window_footpath_mouseup(rct_window* w, rct_widgetindex widgetIndex) map_invalidate_map_selection_tiles(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL; - tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, TOOL_CROSSHAIR); + tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::Crosshair); input_set_flag(INPUT_FLAG_6, true); _footpathErrorOccured = false; window_footpath_set_enabled_and_pressed_widgets(); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index c5c0f46d4a..9b169402f4 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -593,7 +593,7 @@ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex) rct_window* wind = window_find_by_number(WC_PEEP, peepnum); if (wind) { - tool_set(wind, WC_PEEP__WIDX_PICKUP, TOOL_PICKER); + tool_set(wind, WC_PEEP__WIDX_PICKUP, Tool::Picker); } }); GameActions::Execute(&pickupAction); diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index 60de6b797c..3686e059d0 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -106,7 +106,7 @@ rct_window* window_land_rights_open() gLandToolSize = 1; show_gridlines(); - tool_set(window, WIDX_BUY_LAND_RIGHTS, TOOL_UP_ARROW); + tool_set(window, WIDX_BUY_LAND_RIGHTS, Tool::UpArrow); input_set_flag(INPUT_FLAG_6, true); show_land_rights(); @@ -144,7 +144,7 @@ static void window_land_rights_mouseup(rct_window* w, rct_widgetindex widgetInde case WIDX_BUY_LAND_RIGHTS: if (_landRightsMode != LAND_RIGHTS_MODE_BUY_LAND) { - tool_set(w, WIDX_BUY_LAND_RIGHTS, TOOL_UP_ARROW); + tool_set(w, WIDX_BUY_LAND_RIGHTS, Tool::UpArrow); _landRightsMode = LAND_RIGHTS_MODE_BUY_LAND; show_land_rights(); w->Invalidate(); @@ -153,7 +153,7 @@ static void window_land_rights_mouseup(rct_window* w, rct_widgetindex widgetInde case WIDX_BUY_CONSTRUCTION_RIGHTS: if (_landRightsMode != LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS) { - tool_set(w, WIDX_BUY_CONSTRUCTION_RIGHTS, TOOL_UP_ARROW); + tool_set(w, WIDX_BUY_CONSTRUCTION_RIGHTS, Tool::UpArrow); _landRightsMode = LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS; show_construction_rights(); w->Invalidate(); diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 4bd6619e1a..e764c72dee 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -477,13 +477,13 @@ static void window_loadsave_mouseup(rct_window* w, rct_widgetindex widgetIndex) break; case WIDX_SORT_NAME: - if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING) + if (gConfigGeneral.load_save_sort == Sort::NameAscending) { - gConfigGeneral.load_save_sort = SORT_NAME_DESCENDING; + gConfigGeneral.load_save_sort = Sort::NameDescending; } else { - gConfigGeneral.load_save_sort = SORT_NAME_ASCENDING; + gConfigGeneral.load_save_sort = Sort::NameAscending; } config_save_default(); window_loadsave_sort_list(); @@ -491,13 +491,13 @@ static void window_loadsave_mouseup(rct_window* w, rct_widgetindex widgetIndex) break; case WIDX_SORT_DATE: - if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING) + if (gConfigGeneral.load_save_sort == Sort::DateDescending) { - gConfigGeneral.load_save_sort = SORT_DATE_ASCENDING; + gConfigGeneral.load_save_sort = Sort::DateAscending; } else { - gConfigGeneral.load_save_sort = SORT_DATE_DESCENDING; + gConfigGeneral.load_save_sort = Sort::DateDescending; } config_save_default(); window_loadsave_sort_list(); @@ -710,9 +710,9 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi) // Name button text rct_string_id id = STR_NONE; - if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING) + if (gConfigGeneral.load_save_sort == Sort::NameAscending) id = STR_UP; - else if (gConfigGeneral.load_save_sort == SORT_NAME_DESCENDING) + else if (gConfigGeneral.load_save_sort == Sort::NameDescending) id = STR_DOWN; // Draw name button indicator. @@ -721,9 +721,9 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi) dpi, STR_NAME, &id, COLOUR_GREY, w->windowPos + ScreenCoordsXY{ sort_name_widget.left + 11, sort_name_widget.top + 1 }); // Date button text - if (gConfigGeneral.load_save_sort == SORT_DATE_ASCENDING) + if (gConfigGeneral.load_save_sort == Sort::DateAscending) id = STR_UP; - else if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING) + else if (gConfigGeneral.load_save_sort == Sort::DateDescending) id = STR_DOWN; else id = STR_NONE; @@ -797,17 +797,16 @@ static bool list_item_sort(LoadSaveListItem& a, LoadSaveListItem& b) switch (gConfigGeneral.load_save_sort) { - case SORT_NAME_ASCENDING: + case Sort::NameAscending: return strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; - case SORT_NAME_DESCENDING: + case Sort::NameDescending: return -strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; - case SORT_DATE_DESCENDING: + case Sort::DateDescending: return -difftime(a.date_modified, b.date_modified) < 0; - case SORT_DATE_ASCENDING: + case Sort::DateAscending: return difftime(a.date_modified, b.date_modified) < 0; - default: - return strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; } + return strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; } static void window_loadsave_sort_list() @@ -1060,7 +1059,7 @@ static void window_loadsave_select(rct_window* w, const char* path) save_path(&gConfigGeneral.last_save_scenario_directory, pathBuffer); int32_t parkFlagsBackup = gParkFlags; gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED; - gS6Info.editor_step = 255; + gS6Info.editor_step = EditorStep::Invalid; safe_strcpy(gScenarioFileName, pathBuffer, sizeof(gScenarioFileName)); int32_t success = scenario_save(pathBuffer, gConfigGeneral.save_plugin_data ? 3 : 2); gParkFlags = parkFlagsBackup; @@ -1074,7 +1073,7 @@ static void window_loadsave_select(rct_window* w, const char* path) else { context_show_error(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED, {}); - gS6Info.editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; + gS6Info.editor_step = EditorStep::ObjectiveSelection; window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } break; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 1539ee2e32..ff0ae0c191 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -287,7 +287,7 @@ static void window_map_mouseup(rct_window* w, rct_widgetindex widgetIndex) break; case WIDX_SET_LAND_RIGHTS: w->Invalidate(); - if (tool_set(w, widgetIndex, TOOL_UP_ARROW)) + if (tool_set(w, widgetIndex, Tool::UpArrow)) break; _activeTool = 2; // Prevent mountain tool size. @@ -330,7 +330,7 @@ static void window_map_mouseup(rct_window* w, rct_widgetindex widgetIndex) break; case WIDX_BUILD_PARK_ENTRANCE: w->Invalidate(); - if (tool_set(w, widgetIndex, TOOL_UP_ARROW)) + if (tool_set(w, widgetIndex, Tool::UpArrow)) break; gParkEntranceGhostExists = false; @@ -344,7 +344,7 @@ static void window_map_mouseup(rct_window* w, rct_widgetindex widgetIndex) gWindowSceneryRotation = (gWindowSceneryRotation + 1) & 3; break; case WIDX_PEOPLE_STARTING_POSITION: - if (tool_set(w, widgetIndex, TOOL_UP_ARROW)) + if (tool_set(w, widgetIndex, Tool::UpArrow)) break; show_gridlines(); diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 32b22622fe..38bc9eb022 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -177,7 +177,7 @@ static void window_maze_construction_close(rct_window* w) static void window_maze_construction_entrance_mouseup(rct_window* w, rct_widgetindex widgetIndex) { - if (tool_set(w, widgetIndex, TOOL_CROSSHAIR)) + if (tool_set(w, widgetIndex, Tool::Crosshair)) return; gRideEntranceExitPlaceType = widgetIndex == WIDX_MAZE_ENTRANCE ? ENTRANCE_TYPE_RIDE_ENTRANCE : ENTRANCE_TYPE_RIDE_EXIT; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 47a3478737..1acba0179b 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -4268,7 +4268,7 @@ static void window_ride_colour_mouseup(rct_window* w, rct_widgetindex widgetInde window_ride_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_PAINT_INDIVIDUAL_AREA: - tool_set(w, WIDX_PAINT_INDIVIDUAL_AREA, TOOL_PAINT_DOWN); + tool_set(w, WIDX_PAINT_INDIVIDUAL_AREA, Tool::PaintDown); break; } } @@ -5174,7 +5174,7 @@ static void setup_scenery_selection(rct_window* w) cancel_scenery_selection(); } - while (tool_set(w, WIDX_BACKGROUND, TOOL_CROSSHAIR)) + while (tool_set(w, WIDX_BACKGROUND, Tool::Crosshair)) ; gTrackDesignSaveRideIndex = w->number; diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index fd6efd47db..85d13430ed 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -1971,7 +1971,7 @@ static void window_ride_construction_rotate(rct_window* w) */ static void window_ride_construction_entrance_click(rct_window* w) { - if (tool_set(w, WIDX_ENTRANCE, TOOL_CROSSHAIR)) + if (tool_set(w, WIDX_ENTRANCE, Tool::Crosshair)) { auto ride = get_ride(_currentRideIndex); if (ride != nullptr && !ride_try_get_origin_element(ride, nullptr)) @@ -2001,7 +2001,7 @@ static void window_ride_construction_entrance_click(rct_window* w) */ static void window_ride_construction_exit_click(rct_window* w) { - if (tool_set(w, WIDX_EXIT, TOOL_CROSSHAIR)) + if (tool_set(w, WIDX_EXIT, Tool::Crosshair)) { auto ride = get_ride(_currentRideIndex); if (!ride_try_get_origin_element(ride, nullptr)) @@ -3794,7 +3794,7 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords) w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != nullptr) { - tool_set(w, WIDX_CONSTRUCT, TOOL_CROSSHAIR); + tool_set(w, WIDX_CONSTRUCT, Tool::Crosshair); input_set_flag(INPUT_FLAG_6, true); _trackPlaceCtrlState = false; _trackPlaceShiftState = false; diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index f7e0f62a8c..36432e00c5 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -801,11 +801,11 @@ static void window_scenery_update(rct_window* w) if (gWindowSceneryEyedropperEnabled) { - gCurrentToolId = TOOL_CROSSHAIR; + gCurrentToolId = Tool::Crosshair; } else if (gWindowSceneryPaintEnabled == 1) { - gCurrentToolId = TOOL_PAINT_DOWN; + gCurrentToolId = Tool::PaintDown; } else { @@ -816,25 +816,24 @@ static void window_scenery_update(rct_window* w) { if (tabSelectedScenery.SceneryType == SCENERY_TYPE_BANNER) { - gCurrentToolId = TOOL_ENTRANCE_DOWN; + gCurrentToolId = Tool::EntranceDown; } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_LARGE) { - gCurrentToolId = static_cast( + gCurrentToolId = static_cast( get_large_scenery_entry(tabSelectedScenery.EntryIndex)->large_scenery.tool_id); } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_WALL) { - gCurrentToolId = static_cast(get_wall_entry(tabSelectedScenery.EntryIndex)->wall.tool_id); + gCurrentToolId = static_cast(get_wall_entry(tabSelectedScenery.EntryIndex)->wall.tool_id); } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_PATH_ITEM) { // path bit - gCurrentToolId = static_cast( - get_footpath_item_entry(tabSelectedScenery.EntryIndex)->path_bit.tool_id); + gCurrentToolId = static_cast(get_footpath_item_entry(tabSelectedScenery.EntryIndex)->path_bit.tool_id); } else { // small scenery - gCurrentToolId = static_cast( + gCurrentToolId = static_cast( get_small_scenery_entry(tabSelectedScenery.EntryIndex)->small_scenery.tool_id); } } diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 617d502f67..a629a4165e 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -423,7 +423,7 @@ void window_staff_overview_mouseup(rct_window* w, rct_widgetindex widgetIndex) rct_window* wind = window_find_by_number(WC_PEEP, peepnum); if (wind) { - tool_set(wind, WC_STAFF__WIDX_PICKUP, TOOL_PICKER); + tool_set(wind, WC_STAFF__WIDX_PICKUP, Tool::Picker); } }); GameActions::Execute(&pickupAction); @@ -567,7 +567,7 @@ void window_staff_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, } else { - if (!tool_set(w, widgetIndex, TOOL_WALK_DOWN)) + if (!tool_set(w, widgetIndex, Tool::WalkDown)) { show_gridlines(); gStaffDrawPatrolAreas = w->number; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 213f6f67e8..9ad8d3b213 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -227,7 +227,7 @@ static void window_staff_list_mouseup(rct_window* w, rct_widgetindex widgetIndex break; } case WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON: - if (!tool_set(w, WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON, TOOL_CROSSHAIR)) + if (!tool_set(w, WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON, Tool::Crosshair)) { show_gridlines(); gStaffDrawPatrolAreas = _windowStaffListSelectedTab | 0x8000; diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 64edb468a6..35e3299524 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -518,7 +518,7 @@ rct_window* window_tile_inspector_open() windowTileInspectorTileSelected = false; - tool_set(window, WIDX_BACKGROUND, TOOL_CROSSHAIR); + tool_set(window, WIDX_BACKGROUND, Tool::Crosshair); return window; } diff --git a/src/openrct2-ui/windows/TitleCommandEditor.cpp b/src/openrct2-ui/windows/TitleCommandEditor.cpp index 3cb2aa14c7..d6b8027cef 100644 --- a/src/openrct2-ui/windows/TitleCommandEditor.cpp +++ b/src/openrct2-ui/windows/TitleCommandEditor.cpp @@ -331,7 +331,7 @@ static void window_title_command_editor_mouseup(rct_window* w, rct_widgetindex w case WIDX_SELECT_SPRITE: if (!sprite_selector_tool_is_active()) { - tool_set(w, WIDX_BACKGROUND, TOOL_CROSSHAIR); + tool_set(w, WIDX_BACKGROUND, Tool::Crosshair); } else { diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index af006e5949..586d2a1346 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -366,7 +366,7 @@ static void window_top_toolbar_mouseup(rct_window* w, rct_widgetindex widgetInde toggle_water_window(w, WIDX_WATER); break; case WIDX_SCENERY: - if (!tool_set(w, WIDX_SCENERY, TOOL_ARROW)) + if (!tool_set(w, WIDX_SCENERY, Tool::Arrow)) { input_set_flag(INPUT_FLAG_6, true); context_open_window(WC_SCENERY); @@ -683,20 +683,20 @@ static void window_top_toolbar_invalidate(rct_window* w) window_top_toolbar_widgets[WIDX_NEWS].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_NETWORK].type = WindowWidgetType::Empty; - if (gS6Info.editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) + if (gS6Info.editor_step != EditorStep::LandscapeEditor) { window_top_toolbar_widgets[WIDX_LAND].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_WATER].type = WindowWidgetType::Empty; } - if (gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if (gS6Info.editor_step != EditorStep::RollercoasterDesigner) { window_top_toolbar_widgets[WIDX_RIDES].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty; } - if (gS6Info.editor_step != EDITOR_STEP_LANDSCAPE_EDITOR && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if (gS6Info.editor_step != EditorStep::LandscapeEditor && gS6Info.editor_step != EditorStep::RollercoasterDesigner) { window_top_toolbar_widgets[WIDX_MAP].type = WindowWidgetType::Empty; window_top_toolbar_widgets[WIDX_SCENERY].type = WindowWidgetType::Empty; @@ -2092,7 +2092,7 @@ static void top_toolbar_tool_update_land(const ScreenCoordsXY& screenPos) map_invalidate_selection_rect(); - if (gCurrentToolId == TOOL_UP_DOWN_ARROW) + if (gCurrentToolId == Tool::UpDownArrow) { if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) return; @@ -2328,7 +2328,7 @@ static void top_toolbar_tool_update_water(const ScreenCoordsXY& screenPos) { map_invalidate_selection_rect(); - if (gCurrentToolId == TOOL_UP_DOWN_ARROW) + if (gCurrentToolId == Tool::UpDownArrow) { if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) return; @@ -2947,7 +2947,7 @@ static void window_top_toolbar_tool_down(rct_window* w, rct_widgetindex widgetIn { auto action = GetClearAction(); GameActions::Execute(&action); - gCurrentToolId = TOOL_CROSSHAIR; + gCurrentToolId = Tool::Crosshair; } break; case WIDX_LAND: @@ -2959,7 +2959,7 @@ static void window_top_toolbar_tool_down(rct_window* w, rct_widgetindex widgetIn GameActions::Execute(&surfaceSetStyleAction); - gCurrentToolId = TOOL_UP_DOWN_ARROW; + gCurrentToolId = Tool::UpDownArrow; } else { @@ -2969,7 +2969,7 @@ static void window_top_toolbar_tool_down(rct_window* w, rct_widgetindex widgetIn case WIDX_WATER: if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { - gCurrentToolId = TOOL_UP_DOWN_ARROW; + gCurrentToolId = Tool::UpDownArrow; } else { @@ -3166,7 +3166,7 @@ static void window_top_toolbar_tool_drag(rct_window* w, rct_widgetindex widgetIn { auto action = GetClearAction(); GameActions::Execute(&action); - gCurrentToolId = TOOL_CROSSHAIR; + gCurrentToolId = Tool::Crosshair; } break; case WIDX_LAND: @@ -3183,7 +3183,7 @@ static void window_top_toolbar_tool_drag(rct_window* w, rct_widgetindex widgetIn // The tool is set to 12 here instead of 3 so that the dragging cursor is not the elevation change // cursor - gCurrentToolId = TOOL_CROSSHAIR; + gCurrentToolId = Tool::Crosshair; } } else @@ -3230,17 +3230,17 @@ static void window_top_toolbar_tool_up(rct_window* w, rct_widgetindex widgetInde case WIDX_LAND: map_invalidate_selection_rect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gCurrentToolId = TOOL_DIG_DOWN; + gCurrentToolId = Tool::DigDown; break; case WIDX_WATER: map_invalidate_selection_rect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gCurrentToolId = TOOL_WATER_DOWN; + gCurrentToolId = Tool::WaterDown; break; case WIDX_CLEAR_SCENERY: map_invalidate_selection_rect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gCurrentToolId = TOOL_CROSSHAIR; + gCurrentToolId = Tool::Crosshair; break; #ifdef ENABLE_SCRIPTING default: @@ -3285,7 +3285,7 @@ static void top_toolbar_init_map_menu(rct_window* w, rct_widget* widget) auto i = 0; gDropdownItemsFormat[i++] = STR_SHORTCUT_SHOW_MAP; gDropdownItemsFormat[i++] = STR_EXTRA_VIEWPORT; - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EditorStep::LandscapeEditor) { gDropdownItemsFormat[i++] = STR_MAPGEN_WINDOW_TITLE; } @@ -3313,7 +3313,7 @@ static void top_toolbar_init_map_menu(rct_window* w, rct_widget* widget) static void top_toolbar_map_menu_dropdown(int16_t dropdownIndex) { int32_t customStartIndex = 3; - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gS6Info.editor_step == EditorStep::LandscapeEditor) { customStartIndex++; } @@ -3768,7 +3768,7 @@ static void toggle_land_window(rct_window* topToolbar, rct_widgetindex widgetInd { _landToolBlocked = false; show_gridlines(); - tool_set(topToolbar, widgetIndex, TOOL_DIG_DOWN); + tool_set(topToolbar, widgetIndex, Tool::DigDown); input_set_flag(INPUT_FLAG_6, true); context_open_window(WC_LAND); } @@ -3788,7 +3788,7 @@ static void toggle_clear_scenery_window(rct_window* topToolbar, rct_widgetindex else { show_gridlines(); - tool_set(topToolbar, widgetIndex, TOOL_CROSSHAIR); + tool_set(topToolbar, widgetIndex, Tool::Crosshair); input_set_flag(INPUT_FLAG_6, true); context_open_window(WC_CLEAR_SCENERY); } @@ -3809,7 +3809,7 @@ static void toggle_water_window(rct_window* topToolbar, rct_widgetindex widgetIn { _landToolBlocked = false; show_gridlines(); - tool_set(topToolbar, widgetIndex, TOOL_WATER_DOWN); + tool_set(topToolbar, widgetIndex, Tool::WaterDown); input_set_flag(INPUT_FLAG_6, true); context_open_window(WC_WATER); } diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 7e755c6668..668bb927a2 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -146,7 +146,7 @@ rct_window* window_track_place_open(const track_design_file_ref* tdFileRef) w->widgets = window_track_place_widgets; w->enabled_widgets = 1 << WIDX_CLOSE | 1 << WIDX_ROTATE | 1 << WIDX_MIRROR | 1 << WIDX_SELECT_DIFFERENT_DESIGN; WindowInitScrollWidgets(w); - tool_set(w, WIDX_PRICE, TOOL_CROSSHAIR); + tool_set(w, WIDX_PRICE, Tool::Crosshair); input_set_flag(INPUT_FLAG_6, true); window_push_others_right(w); show_gridlines(); diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index 7cf12a423b..6f000ff1f5 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -217,7 +217,7 @@ static void window_view_clipping_mouseup(rct_window* w, rct_widgetindex widgetIn break; case WIDX_CLIP_SELECTOR: // Activate the selection tool - tool_set(w, WIDX_BACKGROUND, TOOL_CROSSHAIR); + tool_set(w, WIDX_BACKGROUND, Tool::Crosshair); _toolActive = true; _dragging = false; diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 2a5264d769..0ef3d751de 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -82,7 +82,7 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; - gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info.editor_step = EditorStep::ObjectSelection; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; gS6Info.category = SCENARIO_CATEGORY_OTHER; viewport_init_all(); @@ -137,7 +137,7 @@ namespace Editor climate_reset(gClimate); gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; - gS6Info.editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; + gS6Info.editor_step = EditorStep::ObjectiveSelection; gS6Info.category = SCENARIO_CATEGORY_OTHER; viewport_init_all(); News::InitQueue(); @@ -160,7 +160,7 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); SetAllLandOwned(); - gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info.editor_step = EditorStep::ObjectSelection; viewport_init_all(); rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN); mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); @@ -181,7 +181,7 @@ namespace Editor object_list_load(); OpenRCT2::GetContext()->GetGameState()->InitAll(150); SetAllLandOwned(); - gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info.editor_step = EditorStep::ObjectSelection; viewport_init_all(); rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN); mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); @@ -240,7 +240,7 @@ namespace Editor load_from_sv4(path); ClearMapForEditing(true); - gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info.editor_step = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -254,7 +254,7 @@ namespace Editor load_from_sc4(path); ClearMapForEditing(false); - gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info.editor_step = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -283,7 +283,7 @@ namespace Editor ClearMapForEditing(loadedFromSave); - gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info.editor_step = EditorStep::LandscapeEditor; gScreenAge = 0; gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR; viewport_init_all(); @@ -380,7 +380,7 @@ namespace Editor switch (gS6Info.editor_step) { - case EDITOR_STEP_OBJECT_SELECTION: + case EditorStep::ObjectSelection: if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION)) { return; @@ -398,7 +398,7 @@ namespace Editor context_open_window(WC_EDITOR_OBJECT_SELECTION); break; - case EDITOR_STEP_INVENTIONS_LIST_SET_UP: + case EditorStep::InventionsListSetUp: if (window_find_by_class(WC_EDITOR_INVENTION_LIST)) { return; @@ -406,7 +406,7 @@ namespace Editor context_open_window(WC_EDITOR_INVENTION_LIST); break; - case EDITOR_STEP_OPTIONS_SELECTION: + case EditorStep::OptionsSelection: if (window_find_by_class(WC_EDITOR_SCENARIO_OPTIONS)) { return; @@ -414,7 +414,7 @@ namespace Editor context_open_window(WC_EDITOR_SCENARIO_OPTIONS); break; - case EDITOR_STEP_OBJECTIVE_SELECTION: + case EditorStep::ObjectiveSelection: if (window_find_by_class(WC_EDITOR_OBJECTIVE_OPTIONS)) { return; @@ -422,6 +422,12 @@ namespace Editor context_open_window(WC_EDITOR_OBJECTIVE_OPTIONS); break; + case EditorStep::LandscapeEditor: + case EditorStep::SaveScenario: + case EditorStep::RollercoasterDesigner: + case EditorStep::DesignsManager: + case EditorStep::Invalid: + break; } } diff --git a/src/openrct2/Editor.h b/src/openrct2/Editor.h index 60a20a6ade..3faf90f33b 100644 --- a/src/openrct2/Editor.h +++ b/src/openrct2/Editor.h @@ -31,16 +31,17 @@ namespace Editor void SetSelectedObject(ObjectType objectType, size_t index, uint32_t flags); } // namespace Editor -enum RCT2_EDITOR_STEP +enum class EditorStep : uint8_t { - EDITOR_STEP_OBJECT_SELECTION, // 0 - EDITOR_STEP_LANDSCAPE_EDITOR, // 1 - EDITOR_STEP_INVENTIONS_LIST_SET_UP, // 2 - EDITOR_STEP_OPTIONS_SELECTION, // 3 - EDITOR_STEP_OBJECTIVE_SELECTION, // 4 - EDITOR_STEP_SAVE_SCENARIO, // 5 - EDITOR_STEP_ROLLERCOASTER_DESIGNER, // 6 - EDITOR_STEP_TRACK_DESIGNS_MANAGER // 7 + ObjectSelection, // 0 + LandscapeEditor, // 1 + InventionsListSetUp, // 2 + OptionsSelection, // 3 + ObjectiveSelection, // 4 + SaveScenario, // 5 + RollercoasterDesigner, // 6 + DesignsManager, // 7 + Invalid = 255, // 255 }; void editor_open_windows_for_current_step(); diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index d3318f30bf..beb0c068f3 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -399,14 +399,14 @@ void finish_object_selection() { set_every_ride_type_invented(); set_every_ride_entry_invented(); - gS6Info.editor_step = EDITOR_STEP_ROLLERCOASTER_DESIGNER; + gS6Info.editor_step = EditorStep::RollercoasterDesigner; gfx_invalidate_screen(); } else { set_all_scenery_items_invented(); scenery_set_default_placement_configuration(); - gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; + gS6Info.editor_step = EditorStep::LandscapeEditor; gfx_invalidate_screen(); } } diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index b9b0b402eb..361d54a6d5 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -366,7 +366,7 @@ void rct2_to_utf8_self(char* buffer, size_t length) { if (length > 0) { - auto temp = rct2_to_utf8(buffer, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto temp = rct2_to_utf8(buffer, RCT2LanguageId::EnglishUK); safe_strcpy(buffer, temp.data(), length); } } @@ -377,9 +377,9 @@ void rct2_to_utf8_self(char* buffer, size_t length) void game_convert_strings_to_utf8() { // Scenario details - gScenarioCompletedBy = rct2_to_utf8(gScenarioCompletedBy, RCT2_LANGUAGE_ID_ENGLISH_UK); - gScenarioName = rct2_to_utf8(gScenarioName, RCT2_LANGUAGE_ID_ENGLISH_UK); - gScenarioDetails = rct2_to_utf8(gScenarioDetails, RCT2_LANGUAGE_ID_ENGLISH_UK); + gScenarioCompletedBy = rct2_to_utf8(gScenarioCompletedBy, RCT2LanguageId::EnglishUK); + gScenarioName = rct2_to_utf8(gScenarioName, RCT2LanguageId::EnglishUK); + gScenarioDetails = rct2_to_utf8(gScenarioDetails, RCT2LanguageId::EnglishUK); // News items game_convert_news_items_to_utf8(); diff --git a/src/openrct2/Input.cpp b/src/openrct2/Input.cpp index 48e4a17179..9fd03e71af 100644 --- a/src/openrct2/Input.cpp +++ b/src/openrct2/Input.cpp @@ -20,7 +20,7 @@ widget_ref gPressedWidget; uint16_t _tooltipNotShownTicks; -TOOL_IDX gCurrentToolId; +Tool gCurrentToolId; widget_ref gCurrentToolWidget; /** diff --git a/src/openrct2/Input.h b/src/openrct2/Input.h index 5443d21c35..c27addc3da 100644 --- a/src/openrct2/Input.h +++ b/src/openrct2/Input.h @@ -85,7 +85,7 @@ extern uint16_t gTooltipTimeout; extern widget_ref gTooltipWidget; extern ScreenCoordsXY gTooltipCursor; -extern TOOL_IDX gCurrentToolId; +extern Tool gCurrentToolId; extern widget_ref gCurrentToolWidget; // TODO: Move to openrct2-ui and make static again diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 66f1105ae0..7e60af7326 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -101,6 +101,13 @@ namespace Config ConfigEnumEntry("SMOOTH_NEAREST_NEIGHBOUR", ScaleQuality::SmoothNearestNeighbour), }); + static const auto Enum_Sort = ConfigEnum({ + ConfigEnumEntry("NAME_ASCENDING", Sort::NameAscending), + ConfigEnumEntry("NAME_DESCENDING", Sort::NameDescending), + ConfigEnumEntry("DATE_ASCENDING", Sort::DateAscending), + ConfigEnumEntry("DATE_DESCENDING", Sort::DateDescending), + }); + static const auto Enum_VirtualFloorStyle = ConfigEnum({ ConfigEnumEntry("OFF", VirtualFloorStyles::Off), ConfigEnumEntry("CLEAR", VirtualFloorStyles::Clear), @@ -183,7 +190,7 @@ namespace Config model->default_inspection_interval = reader->GetInt32("default_inspection_interval", 2); model->last_run_version = reader->GetCString("last_run_version", nullptr); model->invert_viewport_drag = reader->GetBoolean("invert_viewport_drag", false); - model->load_save_sort = reader->GetInt32("load_save_sort", SORT_NAME_ASCENDING); + model->load_save_sort = reader->GetEnum("load_save_sort", Sort::NameAscending, Enum_Sort); model->minimize_fullscreen_focus_loss = reader->GetBoolean("minimize_fullscreen_focus_loss", true); model->disable_screensaver = reader->GetBoolean("disable_screensaver", true); @@ -263,7 +270,7 @@ namespace Config writer->WriteInt32("default_inspection_interval", model->default_inspection_interval); writer->WriteString("last_run_version", model->last_run_version); writer->WriteBoolean("invert_viewport_drag", model->invert_viewport_drag); - writer->WriteInt32("load_save_sort", model->load_save_sort); + writer->WriteEnum("load_save_sort", model->load_save_sort, Enum_Sort); writer->WriteBoolean("minimize_fullscreen_focus_loss", model->minimize_fullscreen_focus_loss); writer->WriteBoolean("disable_screensaver", model->disable_screensaver); writer->WriteBoolean("day_night_cycle", model->day_night_cycle); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 9e523d6225..3766743c30 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -18,6 +18,7 @@ enum class MeasurementFormat : int32_t; enum class TemperatureUnit : int32_t; enum class ScaleQuality : int32_t; +enum class Sort : int32_t; enum class VirtualFloorStyles : int32_t; enum class DrawingEngine : int32_t; @@ -98,7 +99,7 @@ struct GeneralConfiguration // Loading and saving bool confirmation_prompt; - int32_t load_save_sort; + Sort load_save_sort; utf8* last_save_game_directory; utf8* last_save_landscape_directory; utf8* last_save_scenario_directory; @@ -207,12 +208,12 @@ struct PluginConfiguration std::string allowed_hosts; }; -enum SORT +enum class Sort : int32_t { - SORT_NAME_ASCENDING, - SORT_NAME_DESCENDING, - SORT_DATE_ASCENDING, - SORT_DATE_DESCENDING, + NameAscending, + NameDescending, + DateAscending, + DateDescending, }; enum class TemperatureUnit : int32_t diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 0baaad4d34..0fabc9878f 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -351,7 +351,7 @@ void window_close_top() if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - if (gS6Info.editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) + if (gS6Info.editor_step != EditorStep::LandscapeEditor) return; } @@ -1084,7 +1084,7 @@ void main_window_zoom(bool zoomIn, bool atCursor) { if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) return; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EditorStep::LandscapeEditor) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { @@ -1331,7 +1331,7 @@ void window_set_resize(rct_window* w, int32_t minWidth, int32_t minHeight, int32 * @param widgetIndex (dx) * @param w (esi) */ -bool tool_set(rct_window* w, rct_widgetindex widgetIndex, TOOL_IDX tool) +bool tool_set(rct_window* w, rct_widgetindex widgetIndex, Tool tool) { if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) { diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index e73650786b..232798ae0b 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -632,19 +632,19 @@ enum class GuestListFilterType : int32_t GuestsThinkingX, }; -enum TOOL_IDX +enum class Tool { - TOOL_ARROW = 0, - TOOL_UP_ARROW = 2, - TOOL_UP_DOWN_ARROW = 3, - TOOL_PICKER = 7, - TOOL_CROSSHAIR = 12, - TOOL_PATH_DOWN = 17, - TOOL_DIG_DOWN = 18, - TOOL_WATER_DOWN = 19, - TOOL_WALK_DOWN = 22, - TOOL_PAINT_DOWN = 23, - TOOL_ENTRANCE_DOWN = 24, + Arrow = 0, + UpArrow = 2, + UpDownArrow = 3, + Picker = 7, + Crosshair = 12, + PathDown = 17, + DigDown = 18, + WaterDown = 19, + WalkDown = 22, + PaintDown = 23, + EntranceDown = 24, }; using modal_callback = void (*)(int32_t result); @@ -733,7 +733,7 @@ void window_move_position(rct_window* w, const ScreenCoordsXY& screenCoords); void window_resize(rct_window* w, int32_t dw, int32_t dh); void window_set_resize(rct_window* w, int32_t minWidth, int32_t minHeight, int32_t maxWidth, int32_t maxHeight); -bool tool_set(rct_window* w, rct_widgetindex widgetIndex, TOOL_IDX tool); +bool tool_set(rct_window* w, rct_widgetindex widgetIndex, Tool tool); void tool_cancel(); void window_close_construction_windows(); diff --git a/src/openrct2/localisation/Convert.cpp b/src/openrct2/localisation/Convert.cpp index 6642113845..0a3d568a0f 100644 --- a/src/openrct2/localisation/Convert.cpp +++ b/src/openrct2/localisation/Convert.cpp @@ -116,13 +116,13 @@ static int32_t GetCodePageForRCT2Language(RCT2LanguageId languageId) { switch (languageId) { - case RCT2_LANGUAGE_ID_JAPANESE: + case RCT2LanguageId::Japanese: return CODE_PAGE::CP_932; - case RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED: + case RCT2LanguageId::ChineseSimplified: return CODE_PAGE::CP_936; - case RCT2_LANGUAGE_ID_KOREAN: + case RCT2LanguageId::Korean: return CODE_PAGE::CP_949; - case RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL: + case RCT2LanguageId::ChineseTraditional: return CODE_PAGE::CP_950; default: return CODE_PAGE::CP_1252; diff --git a/src/openrct2/localisation/Language.h b/src/openrct2/localisation/Language.h index b9114c92de..09d46b1325 100644 --- a/src/openrct2/localisation/Language.h +++ b/src/openrct2/localisation/Language.h @@ -46,24 +46,24 @@ enum LANGUAGE_COUNT }; -enum RCT2LanguageId +enum class RCT2LanguageId { - RCT2_LANGUAGE_ID_ENGLISH_UK, - RCT2_LANGUAGE_ID_ENGLISH_US, - RCT2_LANGUAGE_ID_FRENCH, - RCT2_LANGUAGE_ID_GERMAN, - RCT2_LANGUAGE_ID_SPANISH, - RCT2_LANGUAGE_ID_ITALIAN, - RCT2_LANGUAGE_ID_DUTCH, - RCT2_LANGUAGE_ID_SWEDISH, - RCT2_LANGUAGE_ID_JAPANESE, - RCT2_LANGUAGE_ID_KOREAN, - RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED, - RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL, - RCT2_LANGUAGE_ID_12, - RCT2_LANGUAGE_ID_PORTUGUESE, - RCT2_LANGUAGE_ID_BLANK = 254, - RCT2_LANGUAGE_ID_END = 255 + EnglishUK, + EnglishUS, + French, + German, + Spanish, + Italian, + Dutch, + Swedish, + Japanese, + Korean, + ChineseSimplified, + ChineseTraditional, + Undefined, + Portuguese, + Blank = 254, + End = 255 }; #define FONT_OPENRCT2_SPRITE NULL diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 85539ee6dc..92016fb62e 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -395,7 +395,7 @@ void News::OpenSubject(News::ItemType type, int32_t subject) if (window != nullptr) { window->Invalidate(); - if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, TOOL_ARROW)) + if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, Tool::Arrow)) { input_set_flag(INPUT_FLAG_6, true); context_open_window(WC_SCENERY); diff --git a/src/openrct2/network/NetworkServerAdvertiser.cpp b/src/openrct2/network/NetworkServerAdvertiser.cpp index 210bb28eae..b7b43a1d3a 100644 --- a/src/openrct2/network/NetworkServerAdvertiser.cpp +++ b/src/openrct2/network/NetworkServerAdvertiser.cpp @@ -34,12 +34,12 @@ # include # include -enum MASTER_SERVER_STATUS +enum class MasterServerStatus { - MASTER_SERVER_STATUS_OK = 200, - MASTER_SERVER_STATUS_INVALID_TOKEN = 401, - MASTER_SERVER_STATUS_SERVER_NOT_FOUND = 404, - MASTER_SERVER_STATUS_INTERNAL_ERROR = 500 + Ok = 200, + InvalidToken = 401, + ServerNotFound = 404, + InternalError = 500 }; # ifndef DISABLE_HTTP @@ -229,9 +229,9 @@ private: { Guard::Assert(jsonRoot.is_object(), "OnRegistrationResponse expects parameter jsonRoot to be object"); - int32_t status = Json::GetNumber(jsonRoot["status"]); + auto status = Json::GetEnum(jsonRoot["status"], MasterServerStatus::InternalError); - if (status == MASTER_SERVER_STATUS_OK) + if (status == MasterServerStatus::Ok) { json_t jsonToken = jsonRoot["token"]; if (jsonToken.is_string()) @@ -251,7 +251,7 @@ private: // Hack for https://github.com/OpenRCT2/OpenRCT2/issues/6277 // Master server may not reply correctly if using IPv6, retry forcing IPv4, // don't wait the full timeout. - if (!_forceIPv4 && status == 500) + if (!_forceIPv4 && status == MasterServerStatus::InternalError) { _forceIPv4 = true; _lastAdvertiseTime = 0; @@ -268,12 +268,12 @@ private: { Guard::Assert(jsonRoot.is_object(), "OnHeartbeatResponse expects parameter jsonRoot to be object"); - int32_t status = Json::GetNumber(jsonRoot["status"]); - if (status == MASTER_SERVER_STATUS_OK) + auto status = Json::GetEnum(jsonRoot["status"], MasterServerStatus::InternalError); + if (status == MasterServerStatus::Ok) { // Master server has successfully updated our server status } - else if (status == MASTER_SERVER_STATUS_INVALID_TOKEN) + else if (status == MasterServerStatus::InvalidToken) { _status = ADVERTISE_STATUS::UNREGISTERED; Console::WriteLine("Master server heartbeat failed: Invalid Token"); diff --git a/src/openrct2/object/StringTable.cpp b/src/openrct2/object/StringTable.cpp index f800719ce4..82dd2a75bd 100644 --- a/src/openrct2/object/StringTable.cpp +++ b/src/openrct2/object/StringTable.cpp @@ -53,10 +53,11 @@ void StringTable::Read(IReadObjectContext* context, OpenRCT2::IStream* stream, O try { RCT2LanguageId rct2LanguageId; - while ((rct2LanguageId = static_cast(stream->ReadValue())) != RCT2_LANGUAGE_ID_END) + while ((rct2LanguageId = static_cast(stream->ReadValue())) != RCT2LanguageId::End) { - uint8_t languageId = (rct2LanguageId <= RCT2_LANGUAGE_ID_PORTUGUESE) ? RCT2ToOpenRCT2LanguageId[rct2LanguageId] - : static_cast(LANGUAGE_UNDEFINED); + uint8_t languageId = (EnumValue(rct2LanguageId) <= EnumValue(RCT2LanguageId::Portuguese)) + ? RCT2ToOpenRCT2LanguageId[EnumValue(rct2LanguageId)] + : static_cast(LANGUAGE_UNDEFINED); std::string stringAsWin1252 = stream->ReadStdString(); auto stringAsUtf8 = rct2_to_utf8(stringAsWin1252, rct2LanguageId); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 4e509e22cb..26cf2ec4c2 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -240,7 +240,7 @@ public: dst->objective_arg_3 = GetBuildTheBestRideId(); } - auto name = rct2_to_utf8(_s4.scenario_name, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto name = rct2_to_utf8(_s4.scenario_name, RCT2LanguageId::EnglishUK); std::string details; // TryGetById won't set this property if the scenario is not recognised, @@ -342,7 +342,7 @@ private: auto context = OpenRCT2::GetContext(); context->GetObjectManager().UnloadAll(); context->GetGameState()->InitAll(mapSize); - gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; + gS6Info.editor_step = EditorStep::ObjectSelection; gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; gS6Info.category = SCENARIO_CATEGORY_OTHER; } @@ -3006,7 +3006,7 @@ private: const auto originalString = _s4.string_table[(stringId - USER_STRING_START) % 1024]; auto originalStringView = std::string_view( originalString, GetRCT2StringBufferLen(originalString, USER_STRING_MAX_LENGTH)); - auto asUtf8 = rct2_to_utf8(originalStringView, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto asUtf8 = rct2_to_utf8(originalStringView, RCT2LanguageId::EnglishUK); auto justText = RCT12RemoveFormattingUTF8(asUtf8); return justText.data(); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 13e33efd4e..60c8104451 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -198,9 +198,9 @@ public: // Some scenarios have their scenario details in UTF-8, due to earlier bugs in OpenRCT2. if (!IsLikelyUTF8(_s6.info.name) && !IsLikelyUTF8(_s6.info.details)) { - auto temp = rct2_to_utf8(_s6.info.name, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto temp = rct2_to_utf8(_s6.info.name, RCT2LanguageId::EnglishUK); safe_strcpy(gS6Info.name, temp.data(), sizeof(gS6Info.name)); - auto temp2 = rct2_to_utf8(_s6.info.details, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto temp2 = rct2_to_utf8(_s6.info.details, RCT2LanguageId::EnglishUK); safe_strcpy(gS6Info.details, temp2.data(), sizeof(gS6Info.details)); } else @@ -1660,7 +1660,7 @@ public: const auto originalString = _s6.custom_strings[(stringId - USER_STRING_START) % 1024]; auto originalStringView = std::string_view( originalString, GetRCT2StringBufferLen(originalString, USER_STRING_MAX_LENGTH)); - auto asUtf8 = rct2_to_utf8(originalStringView, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto asUtf8 = rct2_to_utf8(originalStringView, RCT2LanguageId::EnglishUK); auto justText = RCT12RemoveFormattingUTF8(asUtf8); return justText.data(); } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 669d1d2392..c167e3ad3f 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1756,7 +1756,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) tool_set( constructionWindow, entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE : WC_RIDE_CONSTRUCTION__WIDX_EXIT, - TOOL_CROSSHAIR); + Tool::Crosshair); gRideEntranceExitPlaceType = entranceType; gRideEntranceExitPlaceRideIndex = rideIndex; gRideEntranceExitPlaceStationIndex = stationIndex; @@ -1944,7 +1944,7 @@ int32_t ride_initialise_construction_window(Ride* ride) w = ride_create_or_find_construction_window(ride->id); - tool_set(w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, TOOL_CROSSHAIR); + tool_set(w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, Tool::Crosshair); input_set_flag(INPUT_FLAG_6, true); ride = get_ride(_currentRideIndex); @@ -1984,9 +1984,22 @@ void Ride::UpdateAll() // Remove all rides if scenario editor if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { - if (gS6Info.editor_step <= EDITOR_STEP_INVENTIONS_LIST_SET_UP) - for (auto& ride : GetRideManager()) - ride.Delete(); + switch (gS6Info.editor_step) + { + case EditorStep::ObjectSelection: + case EditorStep::LandscapeEditor: + case EditorStep::InventionsListSetUp: + for (auto& ride : GetRideManager()) + ride.Delete(); + break; + case EditorStep::OptionsSelection: + case EditorStep::ObjectiveSelection: + case EditorStep::SaveScenario: + case EditorStep::RollercoasterDesigner: + case EditorStep::DesignsManager: + case EditorStep::Invalid: + break; + } return; } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 162fa950f7..7b5b781c95 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -915,7 +915,7 @@ bool Vehicle::SoundCanPlay() const if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) return false; - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) return false; if (sound1_id == OpenRCT2::Audio::SoundId::Null && sound2_id == OpenRCT2::Audio::SoundId::Null) @@ -1359,7 +1359,7 @@ void vehicle_update_all() if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) return; - if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) + if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EditorStep::RollercoasterDesigner) return; for (auto vehicle : EntityList(EntityListId::TrainHead)) diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index 054e45dff3..e4ac2d5254 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -27,6 +27,8 @@ using random_engine_t = Random::Rct2::Engine; +enum class EditorStep : uint8_t; + struct ParkLoadResult; #pragma pack(push, 1) @@ -51,7 +53,7 @@ assert_struct_size(rct_s6_header, 0x20); */ struct rct_s6_info { - uint8_t editor_step; + EditorStep editor_step; uint8_t category; // 0x01 uint8_t objective_type; // 0x02 uint8_t objective_arg_1; // 0x03 diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index 3c1d38c447..e16234003f 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -653,7 +653,7 @@ private: if (scBasic.CompanyValue > highscore->company_value) { SafeFree(highscore->name); - std::string name = rct2_to_utf8(scBasic.CompletedBy, RCT2_LANGUAGE_ID_ENGLISH_UK); + std::string name = rct2_to_utf8(scBasic.CompletedBy, RCT2LanguageId::EnglishUK); highscore->name = String::Duplicate(name.c_str()); highscore->company_value = scBasic.CompanyValue; highscore->timestamp = DATETIME64_MIN; @@ -665,7 +665,7 @@ private: { scenario_highscore_entry* highscore = InsertHighscore(); highscore->fileName = String::Duplicate(scBasic.Path); - std::string name = rct2_to_utf8(scBasic.CompletedBy, RCT2_LANGUAGE_ID_ENGLISH_UK); + std::string name = rct2_to_utf8(scBasic.CompletedBy, RCT2LanguageId::EnglishUK); highscore->name = String::Duplicate(name.c_str()); highscore->company_value = scBasic.CompanyValue; highscore->timestamp = DATETIME64_MIN; diff --git a/src/openrct2/windows/Intent.cpp b/src/openrct2/windows/Intent.cpp index dc9e96e564..fe90115f1f 100644 --- a/src/openrct2/windows/Intent.cpp +++ b/src/openrct2/windows/Intent.cpp @@ -22,7 +22,7 @@ Intent* Intent::putExtra(uint32_t key, uint32_t value) { IntentData data = {}; data.intVal.unsignedInt = value; - data.type = IntentData::DT_INT; + data.type = IntentData::DataType::Int; _Data.insert(std::make_pair(key, data)); @@ -33,7 +33,7 @@ Intent* Intent::putExtra(uint32_t key, void* value) { IntentData data = {}; data.pointerVal = value; - data.type = IntentData::DT_POINTER; + data.type = IntentData::DataType::Pointer; _Data.insert(std::make_pair(key, data)); @@ -44,7 +44,7 @@ Intent* Intent::putExtra(uint32_t key, int32_t value) { IntentData data = {}; data.intVal.signedInt = value; - data.type = IntentData::DT_INT; + data.type = IntentData::DataType::Int; _Data.insert(std::make_pair(key, data)); @@ -55,7 +55,7 @@ Intent* Intent::putExtra(uint32_t key, std::string value) { IntentData data = {}; data.stringVal = std::move(value); - data.type = IntentData::DT_STRING; + data.type = IntentData::DataType::String; _Data.insert(std::make_pair(key, data)); @@ -66,7 +66,7 @@ Intent* Intent::putExtra(uint32_t key, close_callback value) { IntentData data = {}; data.closeCallbackVal = value; - data.type = IntentData::DT_CLOSE_CALLBACK; + data.type = IntentData::DataType::CloseCallback; _Data.insert(std::make_pair(key, data)); @@ -86,7 +86,7 @@ void* Intent::GetPointerExtra(uint32_t key) const } auto data = _Data.at(key); - openrct2_assert(data.type == IntentData::DT_POINTER, "Actual type doesn't match requested type"); + openrct2_assert(data.type == IntentData::DataType::Pointer, "Actual type doesn't match requested type"); return static_cast(data.pointerVal); } @@ -98,7 +98,7 @@ uint32_t Intent::GetUIntExtra(uint32_t key) const } auto data = _Data.at(key); - openrct2_assert(data.type == IntentData::DT_INT, "Actual type doesn't match requested type"); + openrct2_assert(data.type == IntentData::DataType::Int, "Actual type doesn't match requested type"); return data.intVal.unsignedInt; } @@ -110,7 +110,7 @@ int32_t Intent::GetSIntExtra(uint32_t key) const } auto data = _Data.at(key); - openrct2_assert(data.type == IntentData::DT_INT, "Actual type doesn't match requested type"); + openrct2_assert(data.type == IntentData::DataType::Int, "Actual type doesn't match requested type"); return data.intVal.signedInt; } @@ -122,7 +122,7 @@ std::string Intent::GetStringExtra(uint32_t key) const } auto data = _Data.at(key); - openrct2_assert(data.type == IntentData::DT_STRING, "Actual type doesn't match requested type"); + openrct2_assert(data.type == IntentData::DataType::String, "Actual type doesn't match requested type"); return data.stringVal; } @@ -134,6 +134,6 @@ close_callback Intent::GetCloseCallbackExtra(uint32_t key) const } auto data = _Data.at(key); - openrct2_assert(data.type == IntentData::DT_CLOSE_CALLBACK, "Actual type doesn't match requested type"); + openrct2_assert(data.type == IntentData::DataType::CloseCallback, "Actual type doesn't match requested type"); return data.closeCallbackVal; } diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index 9484adeb3e..77c5ecbb03 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -17,12 +17,12 @@ struct IntentData { - enum DATATYPE + enum class DataType { - DT_INT, - DT_STRING, - DT_POINTER, - DT_CLOSE_CALLBACK + Int, + String, + Pointer, + CloseCallback } type; union diff --git a/test/tests/Localisation.cpp b/test/tests/Localisation.cpp index 74e1adea67..cd32a44e93 100644 --- a/test/tests/Localisation.cpp +++ b/test/tests/Localisation.cpp @@ -25,7 +25,7 @@ TEST_F(Localisation, RCT2_to_UTF8_UK) { auto input = "The quick brown fox"; auto expected = u8"The quick brown fox"; - auto actual = rct2_to_utf8(input, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto actual = rct2_to_utf8(input, RCT2LanguageId::EnglishUK); ASSERT_EQ(expected, actual); } @@ -33,7 +33,7 @@ TEST_F(Localisation, RCT2_to_UTF8_JP) { auto input = StringFromHex("ff8374ff8340ff8358ff8367ff8375ff8389ff8345ff8393ff8374ff8348ff8362ff834eff8358"); auto expected = u8"ファストブラウンフォックス"; - auto actual = rct2_to_utf8(input, RCT2_LANGUAGE_ID_JAPANESE); + auto actual = rct2_to_utf8(input, RCT2LanguageId::Japanese); ASSERT_EQ(expected, actual); } @@ -41,7 +41,7 @@ TEST_F(Localisation, RCT2_to_UTF8_ZH_TW) { auto input = StringFromHex("ffa7d6ffb374ffaabaffb4c4ffa6e2ffaab0ffaf57"); auto expected = u8"快速的棕色狐狸"; - auto actual = rct2_to_utf8(input, RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL); + auto actual = rct2_to_utf8(input, RCT2LanguageId::ChineseTraditional); ASSERT_EQ(expected, actual); } @@ -49,7 +49,7 @@ TEST_F(Localisation, RCT2_to_UTF8_PL) { auto input = StringFromHex("47F372736b6120446ff76b692054e6637a6f7779"); auto expected = u8"Górska Dołki Tęczowy"; - auto actual = rct2_to_utf8(input, RCT2_LANGUAGE_ID_ENGLISH_UK); + auto actual = rct2_to_utf8(input, RCT2LanguageId::EnglishUK); ASSERT_EQ(expected, actual); } @@ -58,7 +58,7 @@ TEST_F(Localisation, RCT2_to_UTF8_ZH_TW_PREMATURE_END) // This string can be found in BATFL.DAT, the last double byte character is missing its second byte. auto input = StringFromHex("ffa470ffabacffa8aeffbdf8ffa662ffc54bffb944ffa457ffaeb6ffb0caffb76effc2"); auto expected = u8"小型車輛在鐵道上振動搖"; - auto actual = rct2_to_utf8(input, RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL); + auto actual = rct2_to_utf8(input, RCT2LanguageId::ChineseTraditional); ASSERT_EQ(expected, actual); }