diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index ca7d4cbfa5..5cf1bf62d1 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3659,6 +3659,23 @@ STR_6467 :Nausea: {COMMA2DP32} STR_6468 :Not Yet Known STR_6469 :Adjust smaller area of patrol area STR_6470 :Adjust larger area of patrol area +STR_6471 :See-Through Vegetation +STR_6472 :See-Through Vehicles +STR_6473 :See-Through Supports +STR_6474 :See-Through Guests +STR_6475 :See-Through Staff +STR_6476 :Invisible Vegetation +STR_6477 :Invisible Scenery +STR_6478 :Invisible Paths +STR_6479 :Invisible Rides +STR_6480 :Invisible Vehicles +STR_6481 :Transparency Options +STR_6482 :Transparency Options +STR_6483 :Open transparency options +STR_6484 :See-Through vegetation toggle +STR_6485 :See-Through vehicles toggle +STR_6486 :See-Through guests toggle +STR_6487 :See-Through staff toggle ############# # Scenarios # diff --git a/resources/g2/icons/hide_full.png b/resources/g2/icons/hide_full.png new file mode 100644 index 0000000000..30ea23476d Binary files /dev/null and b/resources/g2/icons/hide_full.png differ diff --git a/resources/g2/icons/hide_partial.png b/resources/g2/icons/hide_partial.png new file mode 100644 index 0000000000..7f563b1db6 Binary files /dev/null and b/resources/g2/icons/hide_partial.png differ diff --git a/resources/g2/icons/hide_scenery.png b/resources/g2/icons/hide_scenery.png new file mode 100644 index 0000000000..5c3b8d6619 Binary files /dev/null and b/resources/g2/icons/hide_scenery.png differ diff --git a/resources/g2/icons/hide_supports.png b/resources/g2/icons/hide_supports.png new file mode 100644 index 0000000000..4b97d30967 Binary files /dev/null and b/resources/g2/icons/hide_supports.png differ diff --git a/resources/g2/icons/hide_vegetation.png b/resources/g2/icons/hide_vegetation.png new file mode 100644 index 0000000000..e9e13e4239 Binary files /dev/null and b/resources/g2/icons/hide_vegetation.png differ diff --git a/resources/g2/icons/hide_vehicles.png b/resources/g2/icons/hide_vehicles.png new file mode 100644 index 0000000000..97d47a93cf Binary files /dev/null and b/resources/g2/icons/hide_vehicles.png differ diff --git a/resources/g2/sprites.json b/resources/g2/sprites.json index 8b41b622c5..7c472f3bac 100644 --- a/resources/g2/sprites.json +++ b/resources/g2/sprites.json @@ -503,6 +503,32 @@ "x_offset": 1, "y_offset": 1 }, + { + "path": "icons/hide_vegetation.png", + "x_offset": 1, + "y_offset": 1 + }, + { + "path": "icons/hide_scenery.png", + "x_offset": 1, + "y_offset": 1 + }, + { + "path": "icons/hide_vehicles.png" + }, + { + "path": "icons/hide_supports.png" + }, + { + "path": "icons/hide_partial.png", + "x_offset": 4, + "y_offset": 2 + }, + { + "path": "icons/hide_full.png", + "x_offset": 4, + "y_offset": 2 + }, { "path": "font/latin/ae-uc-small.png", "y_offset": 0, diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 48ee350982..14a7594dce 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -133,6 +133,8 @@ public: return WindowViewportOpen(); case WC_WATER: return WindowWaterOpen(); + case WC_TRANSPARENCY: + return WindowTransparencyOpen(); default: Console::Error::WriteLine("Unhandled window class (%d)", wc); return nullptr; diff --git a/src/openrct2-ui/input/ShortcutIds.h b/src/openrct2-ui/input/ShortcutIds.h index 5cf208fab5..e562489b0d 100644 --- a/src/openrct2-ui/input/ShortcutIds.h +++ b/src/openrct2-ui/input/ShortcutIds.h @@ -52,6 +52,7 @@ namespace OpenRCT2::Ui::ShortcutId constexpr std::string_view InterfaceOpenMessages = "interface.open.messages"; constexpr std::string_view InterfaceOpenMap = "interface.open.map"; constexpr std::string_view InterfaceShowOptions = "interface.open.options"; + constexpr std::string_view InterfaceOpenTransparencyOptions = "interface.open.transparency_options"; constexpr std::string_view InterfaceOpenCheats = "interface.open.cheats"; constexpr std::string_view InterfaceOpenTileInspector = "interface.open.tileinspector"; constexpr std::string_view MultiplayerShow = "interface.open.multiplayer"; @@ -74,13 +75,16 @@ namespace OpenRCT2::Ui::ShortcutId constexpr std::string_view ViewToggleBaseLand = "view.toggle.hide_base_land"; constexpr std::string_view ViewToggleVerticalLand = "view.toggle.hide_vertical_land"; constexpr std::string_view ViewToggleRides = "view.toggle.transparent_rides"; + constexpr std::string_view ViewToggleVehicles = "view.toggle.transparent_vehicles"; + constexpr std::string_view ViewToggleVegetation = "view.toggle.transparent_vegetation"; constexpr std::string_view ViewToggleScenery = "view.toggle.transparent_scenery"; + constexpr std::string_view ViewToggleFootpaths = "view.toggle.transparent_footpaths"; constexpr std::string_view ViewToggleSupports = "view.toggle.hide_supports"; - constexpr std::string_view ViewTogglePeeps = "view.toggle.hide_peeps"; + constexpr std::string_view ViewToggleGuests = "view.toggle.hide_guests"; + constexpr std::string_view ViewToggleStaff = "view.toggle.hide_staff"; constexpr std::string_view ViewToggleLandHeightMarkers = "view.toggle.show_land_height"; constexpr std::string_view ViewToggleTrackHeightMarkers = "view.toggle.show_track_height"; constexpr std::string_view ViewToggleFootpathHeightMarkers = "view.toggle.show_footpath_height"; - constexpr std::string_view ViewToggleFootpaths = "view.toggle.transparent_footpaths"; constexpr std::string_view ViewToggleGridlines = "view.toggle.show_gridlines"; constexpr std::string_view ViewToggleCutAway = "view.toggle.toggle_cut_away"; constexpr std::string_view ViewToogleFootpathIssues = "view.toggle.highlight_path_issues"; diff --git a/src/openrct2-ui/input/ShortcutManager.cpp b/src/openrct2-ui/input/ShortcutManager.cpp index 8e653d3e5b..c07ae9f509 100644 --- a/src/openrct2-ui/input/ShortcutManager.cpp +++ b/src/openrct2-ui/input/ShortcutManager.cpp @@ -370,7 +370,7 @@ std::string_view ShortcutManager::GetLegacyShortcutId(size_t index) ShortcutId::ViewToggleRides, ShortcutId::ViewToggleScenery, ShortcutId::ViewToggleSupports, - ShortcutId::ViewTogglePeeps, + ShortcutId::ViewToggleGuests, ShortcutId::ViewToggleLandHeightMarkers, ShortcutId::ViewToggleTrackHeightMarkers, ShortcutId::ViewToggleFootpathHeightMarkers, diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index 401bd826c0..0b8c370cd3 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -391,6 +391,14 @@ static void ShortcutOpenCheatWindow() context_open_window(WC_CHEATS); } +static void ShortcutOpenTransparencyWindow() +{ + if (gScreenFlags != SCREEN_FLAGS_PLAYING) + return; + + context_open_window(WC_TRANSPARENCY); +} + static void ShortcutClearScenery() { if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) @@ -801,6 +809,7 @@ void ShortcutManager::RegisterDefaultShortcuts() RegisterShortcut(ShortcutId::InterfaceSceneryPicker, STR_SHORTCUT_OPEN_SCENERY_PICKER, []() { ShortcutOpenSceneryPicker(); }); RegisterShortcut(ShortcutId::InterfaceShowOptions, STR_SHORTCUT_SHOW_OPTIONS, []() { context_open_window(WC_OPTIONS); }); + RegisterShortcut(ShortcutId::InterfaceOpenTransparencyOptions, STR_SHORTCUT_OPEN_TRANSPARENCY_OPTIONS, "CTRL+T", []() { ShortcutOpenTransparencyWindow(); }); RegisterShortcut(ShortcutId::InterfaceOpenCheats, STR_SHORTCUT_OPEN_CHEATS_WINDOW, "CTRL+ALT+C", []() { ShortcutOpenCheatWindow(); }); RegisterShortcut(ShortcutId::InterfaceOpenMap, STR_SHORTCUT_SHOW_MAP, "TAB", []() { ShortcutShowMap(); }); RegisterShortcut(ShortcutId::InterfaceClearScenery, STR_SHORTCUT_CLEAR_SCENERY, "B", []() { ShortcutClearScenery(); }); @@ -844,11 +853,14 @@ void ShortcutManager::RegisterDefaultShortcuts() RegisterShortcut(ShortcutId::ViewToggleTransparentWater, STR_VIEWPORT_TRANSPARENT_WATER, "2", []() { ShortcutToggleTransparentWater(); }); RegisterShortcut(ShortcutId::ViewToggleBaseLand, STR_SHORTCUT_REMOVE_BASE_LAND_TOGGLE, "H", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_BASE); }); RegisterShortcut(ShortcutId::ViewToggleVerticalLand, STR_SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE, "V", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_VERTICAL); }); - RegisterShortcut(ShortcutId::ViewToggleRides, STR_SHORTCUT_SEE_THROUGH_RIDES_TOGGLE, "3", []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_RIDES); }); - RegisterShortcut(ShortcutId::ViewToggleScenery, STR_SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE, "4", []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_SCENERY); }); - RegisterShortcut(ShortcutId::ViewToggleFootpaths, STR_SHORTCUT_SEE_THROUGH_PATHS_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_PATHS); }); - RegisterShortcut(ShortcutId::ViewToggleSupports, STR_SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE, "5", []() { ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_SUPPORTS); }); - RegisterShortcut(ShortcutId::ViewTogglePeeps, STR_SHORTCUT_INVISIBLE_PEOPLE_TOGGLE, "6", []() { ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_PEEPS); }); + RegisterShortcut(ShortcutId::ViewToggleRides, STR_SHORTCUT_SEE_THROUGH_RIDES_TOGGLE, "3", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_RIDES); }); + RegisterShortcut(ShortcutId::ViewToggleVehicles, STR_SHORTCUT_SEE_THROUGH_VEHICLES_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_VEHICLES); }); + RegisterShortcut(ShortcutId::ViewToggleVegetation, STR_SHORTCUT_SEE_THROUGH_VEGETATION_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_VEGETATION); }); + RegisterShortcut(ShortcutId::ViewToggleScenery, STR_SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE, "4", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_SCENERY); }); + RegisterShortcut(ShortcutId::ViewToggleFootpaths, STR_SHORTCUT_SEE_THROUGH_PATHS_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_PATHS); }); + RegisterShortcut(ShortcutId::ViewToggleSupports, STR_SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE, "5", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_SUPPORTS); }); + RegisterShortcut(ShortcutId::ViewToggleGuests, STR_SHORTCUT_SEE_THROUGH_GUESTS_TOGGLE, "6", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_GUESTS); }); + RegisterShortcut(ShortcutId::ViewToggleStaff, STR_SHORTCUT_SEE_THROUGH_STAFF_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_STAFF); }); RegisterShortcut(ShortcutId::ViewToggleLandHeightMarkers, STR_SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE, "8", []() { ToggleViewFlag(VIEWPORT_FLAG_LAND_HEIGHTS); }); RegisterShortcut(ShortcutId::ViewToggleTrackHeightMarkers, STR_SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE, "9", []() { ToggleViewFlag(VIEWPORT_FLAG_TRACK_HEIGHTS); }); RegisterShortcut(ShortcutId::ViewToggleFootpathHeightMarkers, STR_SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE, "0", []() { ToggleViewFlag(VIEWPORT_FLAG_PATH_HEIGHTS); }); diff --git a/src/openrct2-ui/interface/Theme.cpp b/src/openrct2-ui/interface/Theme.cpp index 65ef37be3b..02b2eb3bf2 100644 --- a/src/openrct2-ui/interface/Theme.cpp +++ b/src/openrct2-ui/interface/Theme.cpp @@ -175,6 +175,7 @@ static constexpr const WindowThemeDesc WindowThemeDescriptors[] = { THEME_WC(WC_TILE_INSPECTOR), STR_TILE_INSPECTOR_TITLE, COLOURS_2(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_VIEW_CLIPPING), STR_VIEW_CLIPPING_TITLE, COLOURS_1(COLOUR_DARK_GREEN ) }, { THEME_WC(WC_PATROL_AREA), STR_SET_PATROL_AREA, COLOURS_3(COLOUR_LIGHT_PURPLE, COLOUR_LIGHT_PURPLE, COLOUR_LIGHT_PURPLE ) }, + { THEME_WC(WC_TRANSPARENCY), STR_TRANSPARENCY_OPTIONS_TITLE, COLOURS_3(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_ABOUT), STR_ABOUT, COLOURS_2(COLOUR_GREY, COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_CHANGELOG), STR_CHANGELOG_TITLE, COLOURS_2(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_MULTIPLAYER), STR_MULTIPLAYER, COLOURS_3(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 5eeb86d108..7b65b6dc1c 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -734,22 +734,21 @@ PeepDistance GetClosestPeep(const ScreenCoordsXY& viewportCoords, const int32_t static Peep* ViewportInteractionGetClosestPeep(ScreenCoordsXY screenCoords, int32_t maxDistance) { - rct_window* w; - rct_viewport* viewport; - - w = window_find_from_point(screenCoords); + auto* w = window_find_from_point(screenCoords); if (w == nullptr) return nullptr; - viewport = w->viewport; + auto* viewport = w->viewport; if (viewport == nullptr || viewport->zoom >= ZoomLevel{ 2 }) return nullptr; auto viewportCoords = viewport->ScreenToViewportCoord(screenCoords); - auto goal = GetClosestPeep(viewportCoords, maxDistance, {}); - goal = GetClosestPeep(viewportCoords, maxDistance, goal); - + PeepDistance goal; + if (!(viewport->flags & VIEWPORT_FLAG_HIDE_GUESTS)) + goal = GetClosestPeep(viewportCoords, maxDistance, goal); + if (!(viewport->flags & VIEWPORT_FLAG_HIDE_STAFF)) + goal = GetClosestPeep(viewportCoords, maxDistance, goal); return goal.peep; } diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 1103d25e87..635125faaf 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -188,6 +188,7 @@ + diff --git a/src/openrct2-ui/windows/Main.cpp b/src/openrct2-ui/windows/Main.cpp index b4838440c0..70208361e5 100644 --- a/src/openrct2-ui/windows/Main.cpp +++ b/src/openrct2-ui/windows/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -20,7 +21,8 @@ static rct_widget window_main_widgets[] = { WIDGETS_END, }; -void WindowMainPaint(rct_window *w, rct_drawpixelinfo *dpi); +static void WindowMainSetViewportFlags(rct_viewport& viewport); +static void WindowMainPaint(rct_window *w, rct_drawpixelinfo *dpi); static rct_window_event_list window_main_events([](auto& events) { @@ -42,7 +44,10 @@ rct_window* WindowMainOpen() window->widgets = window_main_widgets; viewport_create(window, window->windowPos, window->width, window->height, Focus(CoordsXYZ(0x0FFF, 0x0FFF, 0))); - window->viewport->flags |= VIEWPORT_FLAG_SOUND_ON; + if (window->viewport != nullptr) + { + WindowMainSetViewportFlags(*window->viewport); + } gCurrentRotation = 0; gShowGridLinesRefCount = 0; gShowLandRightsRefCount = 0; @@ -52,13 +57,30 @@ rct_window* WindowMainOpen() return window; } +static void WindowMainSetViewportFlags(rct_viewport& viewport) +{ + viewport.flags |= VIEWPORT_FLAG_SOUND_ON; + if (gConfigGeneral.invisible_rides) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_RIDES; + if (gConfigGeneral.invisible_vehicles) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_VEHICLES; + if (gConfigGeneral.invisible_trees) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_VEGETATION; + if (gConfigGeneral.invisible_scenery) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_SCENERY; + if (gConfigGeneral.invisible_paths) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_PATHS; + if (gConfigGeneral.invisible_supports) + viewport.flags |= VIEWPORT_FLAG_INVISIBLE_SUPPORTS; +} + /** * * rct2: 0x66CCAE * This function immediately jumps to 0x00685BE1 this is the second function * decompiled. */ -void WindowMainPaint(rct_window* w, rct_drawpixelinfo* dpi) +static void WindowMainPaint(rct_window* w, rct_drawpixelinfo* dpi) { viewport_render(dpi, w->viewport, { { dpi->x, dpi->y }, { dpi->x + dpi->width, dpi->y + dpi->height } }); } diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index 607e1ebc40..2e2a2d4c81 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -222,6 +222,7 @@ static rct_windowclass window_themes_tab_6_classes[] = { WC_CHEATS, WC_TILE_INSPECTOR, WC_VIEW_CLIPPING, + WC_TRANSPARENCY, WC_THEMES, WC_TITLE_EDITOR, WC_OPTIONS, diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index ea2fd8178a..867cd4e7e0 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -136,18 +136,23 @@ enum TopToolbarViewMenuDdidx DDIDX_HIDE_BASE = 2, DDIDX_HIDE_VERTICAL = 3, // separator - DDIDX_SEETHROUGH_RIDES = 5, - DDIDX_SEETHROUGH_SCENERY = 6, - DDIDX_SEETHROUGH_PATHS = 7, - DDIDX_INVISIBLE_SUPPORTS = 8, - DDIDX_INVISIBLE_PEEPS = 9, + DDIDX_HIDE_RIDES = 5, + DDIDX_HIDE_VEHICLES = 6, + DDIDX_HIDE_VEGETATION = 7, + DDIDX_HIDE_SCENERY = 8, + DDIDX_HIDE_PATHS = 9, + DDIDX_HIDE_SUPPORTS = 10, + DDIDX_HIDE_GUESTS = 11, + DDIDX_HIDE_STAFF = 12, // separator - DDIDX_LAND_HEIGHTS = 11, - DDIDX_TRACK_HEIGHTS = 12, - DDIDX_PATH_HEIGHTS = 13, + DDIDX_LAND_HEIGHTS = 14, + DDIDX_TRACK_HEIGHTS = 15, + DDIDX_PATH_HEIGHTS = 16, // separator - DDIDX_VIEW_CLIPPING = 15, - DDIDX_HIGHLIGHT_PATH_ISSUES = 16, + DDIDX_VIEW_CLIPPING = 18, + DDIDX_HIGHLIGHT_PATH_ISSUES = 19, + // separator + DDIDX_TRANSPARENCY = 21, TOP_TOOLBAR_VIEW_MENU_COUNT, }; @@ -3623,11 +3628,14 @@ static void TopToolbarInitViewMenu(rct_window* w, rct_widget* widget) ToggleOption(DDIDX_HIDE_BASE, STR_REMOVE_BASE_LAND), ToggleOption(DDIDX_HIDE_VERTICAL, STR_REMOVE_VERTICAL_FACES), Separator(), - ToggleOption(DDIDX_SEETHROUGH_RIDES, STR_SEE_THROUGH_RIDES), - ToggleOption(DDIDX_SEETHROUGH_SCENERY, STR_SEE_THROUGH_SCENERY), - ToggleOption(DDIDX_SEETHROUGH_PATHS, STR_SEE_THROUGH_PATHS), - ToggleOption(DDIDX_INVISIBLE_SUPPORTS, STR_INVISIBLE_SUPPORTS), - ToggleOption(DDIDX_INVISIBLE_PEEPS, STR_INVISIBLE_PEOPLE), + ToggleOption(DDIDX_HIDE_RIDES, STR_SEE_THROUGH_RIDES), + ToggleOption(DDIDX_HIDE_VEHICLES, STR_SEE_THROUGH_VEHICLES), + ToggleOption(DDIDX_HIDE_VEGETATION, STR_SEE_THROUGH_VEGETATION), + ToggleOption(DDIDX_HIDE_SCENERY, STR_SEE_THROUGH_SCENERY), + ToggleOption(DDIDX_HIDE_PATHS, STR_SEE_THROUGH_PATHS), + ToggleOption(DDIDX_HIDE_SUPPORTS, STR_SEE_THROUGH_SUPPORTS), + ToggleOption(DDIDX_HIDE_GUESTS, STR_SEE_THROUGH_GUESTS), + ToggleOption(DDIDX_HIDE_STAFF, STR_SEE_THROUGH_STAFF), Separator(), ToggleOption(DDIDX_LAND_HEIGHTS, STR_HEIGHT_MARKS_ON_LAND), ToggleOption(DDIDX_TRACK_HEIGHTS, STR_HEIGHT_MARKS_ON_RIDE_TRACKS), @@ -3635,6 +3643,8 @@ static void TopToolbarInitViewMenu(rct_window* w, rct_widget* widget) Separator(), ToggleOption(DDIDX_VIEW_CLIPPING, STR_VIEW_CLIPPING_MENU), ToggleOption(DDIDX_HIGHLIGHT_PATH_ISSUES, STR_HIGHLIGHT_PATH_ISSUES_MENU), + Separator(), + ToggleOption(DDIDX_TRANSPARENCY, STR_TRANSPARENCY_OPTIONS), }; static_assert(ItemIDsMatchIndices(items)); @@ -3655,16 +3665,22 @@ static void TopToolbarInitViewMenu(rct_window* w, rct_widget* widget) Dropdown::SetChecked(DDIDX_HIDE_BASE, true); if (mainViewport->flags & VIEWPORT_FLAG_HIDE_VERTICAL) Dropdown::SetChecked(DDIDX_HIDE_VERTICAL, true); - if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_RIDES) - Dropdown::SetChecked(DDIDX_SEETHROUGH_RIDES, true); - if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_SCENERY) - Dropdown::SetChecked(DDIDX_SEETHROUGH_SCENERY, true); - if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_PATHS) - Dropdown::SetChecked(DDIDX_SEETHROUGH_PATHS, true); - if (mainViewport->flags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) - Dropdown::SetChecked(DDIDX_INVISIBLE_SUPPORTS, true); - if (mainViewport->flags & VIEWPORT_FLAG_INVISIBLE_PEEPS) - Dropdown::SetChecked(DDIDX_INVISIBLE_PEEPS, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_RIDES) + Dropdown::SetChecked(DDIDX_HIDE_RIDES, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_VEHICLES) + Dropdown::SetChecked(DDIDX_HIDE_VEHICLES, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_VEGETATION) + Dropdown::SetChecked(DDIDX_HIDE_VEGETATION, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_SCENERY) + Dropdown::SetChecked(DDIDX_HIDE_SCENERY, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_PATHS) + Dropdown::SetChecked(DDIDX_HIDE_PATHS, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_SUPPORTS) + Dropdown::SetChecked(DDIDX_HIDE_SUPPORTS, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_GUESTS) + Dropdown::SetChecked(DDIDX_HIDE_GUESTS, true); + if (mainViewport->flags & VIEWPORT_FLAG_HIDE_STAFF) + Dropdown::SetChecked(DDIDX_HIDE_STAFF, true); if (mainViewport->flags & VIEWPORT_FLAG_LAND_HEIGHTS) Dropdown::SetChecked(DDIDX_LAND_HEIGHTS, true); if (mainViewport->flags & VIEWPORT_FLAG_TRACK_HEIGHTS) @@ -3709,20 +3725,29 @@ static void TopToolbarViewMenuDropdown(int16_t dropdownIndex) case DDIDX_HIDE_VERTICAL: w->viewport->flags ^= VIEWPORT_FLAG_HIDE_VERTICAL; break; - case DDIDX_SEETHROUGH_RIDES: - w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_RIDES; + case DDIDX_HIDE_RIDES: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_RIDES; break; - case DDIDX_SEETHROUGH_SCENERY: - w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_SCENERY; + case DDIDX_HIDE_VEHICLES: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_VEHICLES; break; - case DDIDX_SEETHROUGH_PATHS: - w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_PATHS; + case DDIDX_HIDE_VEGETATION: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_VEGETATION; break; - case DDIDX_INVISIBLE_SUPPORTS: - w->viewport->flags ^= VIEWPORT_FLAG_INVISIBLE_SUPPORTS; + case DDIDX_HIDE_SCENERY: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_SCENERY; break; - case DDIDX_INVISIBLE_PEEPS: - w->viewport->flags ^= VIEWPORT_FLAG_INVISIBLE_PEEPS; + case DDIDX_HIDE_PATHS: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_PATHS; + break; + case DDIDX_HIDE_SUPPORTS: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_SUPPORTS; + break; + case DDIDX_HIDE_GUESTS: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_GUESTS; + break; + case DDIDX_HIDE_STAFF: + w->viewport->flags ^= VIEWPORT_FLAG_HIDE_STAFF; break; case DDIDX_LAND_HEIGHTS: w->viewport->flags ^= VIEWPORT_FLAG_LAND_HEIGHTS; @@ -3747,6 +3772,9 @@ static void TopToolbarViewMenuDropdown(int16_t dropdownIndex) case DDIDX_HIGHLIGHT_PATH_ISSUES: w->viewport->flags ^= VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES; break; + case DDIDX_TRANSPARENCY: + context_open_window(WC_TRANSPARENCY); + break; default: return; } diff --git a/src/openrct2-ui/windows/Transparency.cpp b/src/openrct2-ui/windows/Transparency.cpp new file mode 100644 index 0000000000..7a324b472b --- /dev/null +++ b/src/openrct2-ui/windows/Transparency.cpp @@ -0,0 +1,244 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// clang-format off +enum WINDOW_TRANSPARENCY_WIDGET_IDX +{ + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + + WIDX_HIDE_VEGETATION, + WIDX_HIDE_SCENERY, + WIDX_HIDE_PATHS, + WIDX_HIDE_RIDES, + WIDX_HIDE_VEHICLES, + WIDX_HIDE_SUPPORTS, + WIDX_HIDE_GUESTS, + WIDX_HIDE_STAFF, + WIDX_INVISIBLE_VEGETATION, + WIDX_INVISIBLE_SCENERY, + WIDX_INVISIBLE_PATHS, + WIDX_INVISIBLE_RIDES, + WIDX_INVISIBLE_VEHICLES, + WIDX_INVISIBLE_SUPPORTS, +}; + +#pragma region MEASUREMENTS + +static constexpr const rct_string_id WINDOW_TITLE = STR_TRANSPARENCY_OPTIONS_TITLE; +static constexpr const int32_t WW = 204; +static constexpr const int32_t WH = 57; + +static constexpr ScreenSize HIDE_SIZE = {24, 24}; +static constexpr ScreenSize INVISIBLE_SIZE = {24, 12}; + +#pragma endregion + +static rct_widget window_transparency_main_widgets[] = +{ + WINDOW_SHIM(WINDOW_TITLE, WW, WH), + MakeWidget({ 2, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_BUTTON_HIDE_VEGETATION, STR_SEE_THROUGH_VEGETATION), + MakeWidget({ 27, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_BUTTON_HIDE_SCENERY, STR_SEE_THROUGH_SCENERY), + MakeWidget({ 52, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_BUTTON_FOOTPATH, STR_SEE_THROUGH_PATHS), + MakeWidget({ 77, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_RIDE, STR_SEE_THROUGH_RIDES), + MakeWidget({102, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_BUTTON_HIDE_VEHICLES, STR_SEE_THROUGH_VEHICLES), + MakeWidget({127, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_BUTTON_HIDE_SUPPORTS, STR_SEE_THROUGH_SUPPORTS), + MakeWidget({152, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_GUESTS, STR_SEE_THROUGH_GUESTS), + MakeWidget({177, 17}, HIDE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Secondary, 0xFFFFFFFF, STR_SEE_THROUGH_STAFF), + + MakeWidget({ 2, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_VEGETATION), + MakeWidget({ 27, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_SCENERY), + MakeWidget({ 52, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_PATHS), + MakeWidget({ 77, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_RIDES), + MakeWidget({102, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_VEHICLES), + MakeWidget({127, 42}, INVISIBLE_SIZE, WindowWidgetType::FlatBtn, WindowColour::Tertiary, STR_NONE, STR_INVISIBLE_SUPPORTS), + + { WIDGETS_END }, +}; +// clang-format on + +class TransparencyWindow final : public Window +{ +private: +public: + void OnOpen() override + { + widgets = window_transparency_main_widgets; + window_push_others_below(this); + + auto* w = window_get_main(); + if (w != nullptr) + windowPos.x = ((w->width / 2) - (width / 2)); + } + + void OnMouseUp(rct_widgetindex widgetIndex) override + { + switch (widgetIndex) + { + case WIDX_CLOSE: + Close(); + break; + default: + ToggleViewportFlag(widgetIndex); + break; + } + } + + void OnPrepareDraw() override + { + uint32_t wflags = 0; + rct_window* w = window_get_main(); + + pressed_widgets = 0; + disabled_widgets = 0; + + if (w != nullptr) + wflags = w->viewport->flags; + + SetWidgetPressed(WIDX_HIDE_VEGETATION, (wflags & VIEWPORT_FLAG_HIDE_VEGETATION)); + SetWidgetPressed(WIDX_HIDE_SCENERY, (wflags & VIEWPORT_FLAG_HIDE_SCENERY)); + SetWidgetPressed(WIDX_HIDE_PATHS, (wflags & VIEWPORT_FLAG_HIDE_PATHS)); + SetWidgetPressed(WIDX_HIDE_RIDES, (wflags & VIEWPORT_FLAG_HIDE_RIDES)); + SetWidgetPressed(WIDX_HIDE_VEHICLES, (wflags & VIEWPORT_FLAG_HIDE_VEHICLES)); + SetWidgetPressed(WIDX_HIDE_SUPPORTS, (wflags & VIEWPORT_FLAG_HIDE_SUPPORTS)); + SetWidgetPressed(WIDX_HIDE_GUESTS, (wflags & VIEWPORT_FLAG_HIDE_GUESTS)); + SetWidgetPressed(WIDX_HIDE_STAFF, (wflags & VIEWPORT_FLAG_HIDE_STAFF)); + SetWidgetPressed(WIDX_INVISIBLE_VEGETATION, (wflags & VIEWPORT_FLAG_INVISIBLE_VEGETATION)); + SetWidgetPressed(WIDX_INVISIBLE_SCENERY, (wflags & VIEWPORT_FLAG_INVISIBLE_SCENERY)); + SetWidgetPressed(WIDX_INVISIBLE_PATHS, (wflags & VIEWPORT_FLAG_INVISIBLE_PATHS)); + SetWidgetPressed(WIDX_INVISIBLE_RIDES, (wflags & VIEWPORT_FLAG_INVISIBLE_RIDES)); + SetWidgetPressed(WIDX_INVISIBLE_VEHICLES, (wflags & VIEWPORT_FLAG_INVISIBLE_VEHICLES)); + SetWidgetPressed(WIDX_INVISIBLE_SUPPORTS, (wflags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)); + + for (rct_widgetindex i = WIDX_INVISIBLE_VEGETATION; i <= WIDX_INVISIBLE_SUPPORTS; i++) + { + widgets[i].image = IsWidgetPressed(i) ? SPR_G2_BUTTON_HIDE_FULL : SPR_G2_BUTTON_HIDE_PARTIAL; + } + } + + void OnDraw(rct_drawpixelinfo& dpi) override + { + DrawWidgets(dpi); + // Locate mechanic button image + const auto& widget = widgets[WIDX_HIDE_STAFF]; + auto screenCoords = windowPos + ScreenCoordsXY{ widget.left, widget.top }; + gfx_draw_sprite( + &dpi, (gStaffMechanicColour << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS | SPR_MECHANIC, screenCoords, 0); + } + +private: + void ToggleViewportFlag(rct_widgetindex widgetIndex) + { + uint32_t wflags = 0; + rct_window* w = window_get_main(); + + if (w == nullptr) + return; + + wflags = w->viewport->flags; + + switch (widgetIndex) + { + case WIDX_HIDE_RIDES: + wflags ^= VIEWPORT_FLAG_HIDE_RIDES; + break; + case WIDX_HIDE_VEHICLES: + wflags ^= VIEWPORT_FLAG_HIDE_VEHICLES; + break; + case WIDX_HIDE_SCENERY: + wflags ^= VIEWPORT_FLAG_HIDE_SCENERY; + break; + case WIDX_HIDE_VEGETATION: + wflags ^= VIEWPORT_FLAG_HIDE_VEGETATION; + break; + case WIDX_HIDE_PATHS: + wflags ^= VIEWPORT_FLAG_HIDE_PATHS; + break; + case WIDX_HIDE_SUPPORTS: + wflags ^= VIEWPORT_FLAG_HIDE_SUPPORTS; + break; + case WIDX_INVISIBLE_RIDES: + wflags ^= VIEWPORT_FLAG_INVISIBLE_RIDES; + gConfigGeneral.invisible_rides = wflags & VIEWPORT_FLAG_INVISIBLE_RIDES; + config_save_default(); + break; + case WIDX_INVISIBLE_VEHICLES: + wflags ^= VIEWPORT_FLAG_INVISIBLE_VEHICLES; + gConfigGeneral.invisible_vehicles = wflags & VIEWPORT_FLAG_INVISIBLE_VEHICLES; + config_save_default(); + break; + case WIDX_INVISIBLE_SCENERY: + wflags ^= VIEWPORT_FLAG_INVISIBLE_SCENERY; + gConfigGeneral.invisible_scenery = wflags & VIEWPORT_FLAG_INVISIBLE_SCENERY; + config_save_default(); + break; + case WIDX_INVISIBLE_VEGETATION: + wflags ^= VIEWPORT_FLAG_INVISIBLE_VEGETATION; + gConfigGeneral.invisible_trees = wflags & VIEWPORT_FLAG_INVISIBLE_VEGETATION; + config_save_default(); + break; + case WIDX_INVISIBLE_PATHS: + wflags ^= VIEWPORT_FLAG_INVISIBLE_PATHS; + gConfigGeneral.invisible_paths = wflags & VIEWPORT_FLAG_INVISIBLE_PATHS; + config_save_default(); + break; + case WIDX_INVISIBLE_SUPPORTS: + wflags ^= VIEWPORT_FLAG_INVISIBLE_SUPPORTS; + gConfigGeneral.invisible_supports = wflags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS; + config_save_default(); + break; + case WIDX_HIDE_GUESTS: + wflags ^= VIEWPORT_FLAG_HIDE_GUESTS; + break; + case WIDX_HIDE_STAFF: + wflags ^= VIEWPORT_FLAG_HIDE_STAFF; + break; + default: + return; + } + + if (w->viewport->flags == wflags) + return; + + w->viewport->flags = wflags; + w->Invalidate(); + } +}; + +rct_window* WindowTransparencyOpen() +{ + auto* window = window_bring_to_front_by_class(WC_TRANSPARENCY); + if (window == nullptr) + window = WindowCreate(WC_TRANSPARENCY, ScreenCoordsXY(32, 32), WW, WH); + + return window; +} diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index ae814db5d4..e2df438e6a 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -75,6 +75,7 @@ rct_window* WindowTitleOptionsOpen(); rct_window* WindowViewportOpen(); rct_window* WindowWaterOpen(); rct_window* WindowViewClippingOpen(); +rct_window* WindowTransparencyOpen(); // WC_FINANCES rct_window* WindowFinancesOpen(); diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 0b509b91d9..bc3af9af21 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -216,6 +216,14 @@ namespace Config model->allow_early_completion = reader->GetBoolean("allow_early_completion", false); model->transparent_screenshot = reader->GetBoolean("transparent_screenshot", true); model->transparent_water = reader->GetBoolean("transparent_water", true); + + model->invisible_rides = reader->GetBoolean("invisible_rides", false); + model->invisible_vehicles = reader->GetBoolean("invisible_vehicles", false); + model->invisible_trees = reader->GetBoolean("invisible_trees", false); + model->invisible_scenery = reader->GetBoolean("invisible_scenery", false); + model->invisible_paths = reader->GetBoolean("invisible_paths", false); + model->invisible_supports = reader->GetBoolean("invisible_supports", false); + model->last_version_check_time = reader->GetInt64("last_version_check_time", 0); } } @@ -293,6 +301,12 @@ namespace Config writer->WriteEnum("virtual_floor_style", model->virtual_floor_style, Enum_VirtualFloorStyle); writer->WriteBoolean("transparent_screenshot", model->transparent_screenshot); writer->WriteBoolean("transparent_water", model->transparent_water); + writer->WriteBoolean("invisible_rides", model->invisible_rides); + writer->WriteBoolean("invisible_vehicles", model->invisible_vehicles); + writer->WriteBoolean("invisible_trees", model->invisible_trees); + writer->WriteBoolean("invisible_scenery", model->invisible_scenery); + writer->WriteBoolean("invisible_paths", model->invisible_paths); + writer->WriteBoolean("invisible_supports", model->invisible_supports); writer->WriteInt64("last_version_check_time", model->last_version_check_time); } diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 9dc7d55c61..8a9b5fd7c8 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -60,6 +60,13 @@ struct GeneralConfiguration bool transparent_screenshot; bool transparent_water; + bool invisible_rides; + bool invisible_vehicles; + bool invisible_trees; + bool invisible_scenery; + bool invisible_paths; + bool invisible_supports; + // Localisation int32_t language; MeasurementFormat measurement_format; diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 888b416e21..3b434fac5f 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -311,7 +311,8 @@ void lightfx_prepare_light_list() paint_session* session = PaintSessionAlloc(&dpi, w->viewport->flags); PaintSessionGenerate(*session); PaintSessionArrange(*session); - auto info = set_interaction_info_from_paint_session(session, ViewportInteractionItemAll); + auto info = set_interaction_info_from_paint_session( + session, w->viewport->flags, ViewportInteractionItemAll); PaintSessionFree(session); // log_warning("[%i, %i]", dpi->x, dpi->y); diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 946906d13e..cfca4da97a 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -2733,11 +2733,6 @@ void Peep::Paint(paint_session& session, int32_t imageDirection) const return; } - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_PEEPS) - { - return; - } - PeepActionSpriteType actionSpriteType = ActionSpriteType; uint8_t imageOffset = ActionSpriteImageOffset; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 1286125f5b..b65a50cd2b 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -564,12 +564,12 @@ static void ApplyOptions(const ScreenshotOptions* options, rct_viewport& viewpor if (options->hide_guests) { - viewport.flags |= VIEWPORT_FLAG_INVISIBLE_PEEPS; + viewport.flags |= VIEWPORT_FLAG_HIDE_GUESTS | VIEWPORT_FLAG_HIDE_STAFF; } if (options->hide_sprites) { - viewport.flags |= VIEWPORT_FLAG_INVISIBLE_SPRITES; + viewport.flags |= VIEWPORT_FLAG_HIDE_ENTITIES; } if (options->mowed_grass) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index bbda3980fb..c1fceb32a0 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -32,6 +32,7 @@ #include "../util/Math.hpp" #include "../world/Climate.h" #include "../world/Map.h" +#include "../world/SmallScenery.h" #include "Colour.h" #include "Window.h" #include "Window_internal.h" @@ -65,6 +66,7 @@ static uint32_t _currentImageType; InteractionInfo::InteractionInfo(const paint_struct* ps) : Loc(ps->map_x, ps->map_y) , Element(ps->tileElement) + , Entity(ps->entity) , SpriteType(ps->sprite_type) { } @@ -922,7 +924,7 @@ static void viewport_paint_column(paint_session& session) && (~session.ViewFlags & VIEWPORT_FLAG_TRANSPARENT_BACKGROUND)) { uint8_t colour = COLOUR_AQUAMARINE; - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_ENTITIES) { colour = COLOUR_BLACK; } @@ -931,7 +933,7 @@ static void viewport_paint_column(paint_session& session) PaintDrawStructs(session); - if (gConfigGeneral.render_weather_gloom && !gTrackDesignSaveMode && !(session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) + if (gConfigGeneral.render_weather_gloom && !gTrackDesignSaveMode && !(session.ViewFlags & VIEWPORT_FLAG_HIDE_ENTITIES) && !(session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)) { viewport_paint_weather_gloom(&session.DPI); @@ -1316,10 +1318,13 @@ void viewport_set_visibility(uint8_t mode) { case 0: { // Set all these flags to 0, and invalidate if any were active - uint32_t mask = VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_SEETHROUGH_RIDES - | VIEWPORT_FLAG_SEETHROUGH_SCENERY | VIEWPORT_FLAG_SEETHROUGH_PATHS | VIEWPORT_FLAG_INVISIBLE_SUPPORTS - | VIEWPORT_FLAG_LAND_HEIGHTS | VIEWPORT_FLAG_TRACK_HEIGHTS | VIEWPORT_FLAG_PATH_HEIGHTS - | VIEWPORT_FLAG_INVISIBLE_PEEPS | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL; + uint32_t mask = VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_HIDE_RIDES | VIEWPORT_FLAG_HIDE_SCENERY + | VIEWPORT_FLAG_HIDE_PATHS | VIEWPORT_FLAG_INVISIBLE_SUPPORTS | VIEWPORT_FLAG_LAND_HEIGHTS + | VIEWPORT_FLAG_TRACK_HEIGHTS | VIEWPORT_FLAG_PATH_HEIGHTS | VIEWPORT_FLAG_HIDE_GUESTS + | VIEWPORT_FLAG_HIDE_STAFF | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL + | VIEWPORT_FLAG_HIDE_VEHICLES | VIEWPORT_FLAG_INVISIBLE_RIDES | VIEWPORT_FLAG_INVISIBLE_VEHICLES + | VIEWPORT_FLAG_HIDE_SUPPORTS | VIEWPORT_FLAG_INVISIBLE_PATHS | VIEWPORT_FLAG_INVISIBLE_SCENERY + | VIEWPORT_FLAG_HIDE_VEGETATION | VIEWPORT_FLAG_INVISIBLE_VEGETATION; invalidate += vp->flags & mask; vp->flags &= ~mask; @@ -1348,6 +1353,138 @@ void viewport_set_visibility(uint8_t mode) } } +static bool IsCursorIdVegetation(CursorID cursor) +{ + switch (cursor) + { + case CursorID::TreeDown: + case CursorID::FlowerDown: + return true; + default: + return false; + } +} + +static bool IsTileElementVegetation(const TileElement* tileElement) +{ + switch (tileElement->GetType()) + { + case TileElementType::SmallScenery: + { + auto sceneryItem = tileElement->AsSmallScenery(); + auto sceneryEntry = sceneryItem->GetEntry(); + if (sceneryEntry != nullptr + && (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) || IsCursorIdVegetation(sceneryEntry->tool_id))) + { + return true; + } + break; + } + case TileElementType::LargeScenery: + { + auto sceneryItem = tileElement->AsLargeScenery(); + auto sceneryEntry = sceneryItem->GetEntry(); + if (sceneryEntry != nullptr && IsCursorIdVegetation(sceneryEntry->tool_id)) + { + return true; + } + break; + } + case TileElementType::Wall: + { + auto sceneryItem = tileElement->AsWall(); + auto sceneryEntry = sceneryItem->GetEntry(); + if (sceneryEntry != nullptr && IsCursorIdVegetation(sceneryEntry->tool_id)) + { + return true; + } + break; + } + default: + break; + } + return false; +} + +VisibilityKind GetPaintStructVisibility(const paint_struct* ps, uint32_t viewFlags) +{ + switch (ps->sprite_type) + { + case ViewportInteractionItem::Entity: + if (ps->entity != nullptr) + { + switch (ps->entity->Type) + { + case EntityType::Vehicle: + if (viewFlags & VIEWPORT_FLAG_HIDE_VEHICLES) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES) ? VisibilityKind::Hidden + : VisibilityKind::Partial; + } + break; + case EntityType::Guest: + if (viewFlags & VIEWPORT_FLAG_HIDE_GUESTS) + { + return VisibilityKind::Hidden; + } + break; + case EntityType::Staff: + if (viewFlags & VIEWPORT_FLAG_HIDE_STAFF) + { + return VisibilityKind::Hidden; + } + break; + default: + break; + } + } + break; + case ViewportInteractionItem::Ride: + if (viewFlags & VIEWPORT_FLAG_HIDE_RIDES) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES) ? VisibilityKind::Hidden : VisibilityKind::Partial; + } + break; + case ViewportInteractionItem::Footpath: + case ViewportInteractionItem::FootpathItem: + case ViewportInteractionItem::Banner: + if (viewFlags & VIEWPORT_FLAG_HIDE_PATHS) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_PATHS) ? VisibilityKind::Hidden : VisibilityKind::Partial; + } + break; + case ViewportInteractionItem::Scenery: + case ViewportInteractionItem::LargeScenery: + case ViewportInteractionItem::Wall: + if (ps->tileElement != nullptr) + { + if (IsTileElementVegetation(ps->tileElement)) + { + if (viewFlags & VIEWPORT_FLAG_HIDE_VEGETATION) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_VEGETATION) ? VisibilityKind::Hidden + : VisibilityKind::Partial; + } + } + else + { + if (viewFlags & VIEWPORT_FLAG_HIDE_SCENERY) + { + return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? VisibilityKind::Hidden : VisibilityKind::Partial; + } + } + } + if (ps->sprite_type == ViewportInteractionItem::Wall && (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE)) + { + return VisibilityKind::Partial; + } + break; + default: + break; + } + return VisibilityKind::Visible; +} + /** * Checks if a paint_struct sprite type is in the filter mask. */ @@ -1669,7 +1806,7 @@ static bool is_sprite_interacted_with(rct_drawpixelinfo* dpi, ImageId imageId, c * * rct2: 0x0068862C */ -InteractionInfo set_interaction_info_from_paint_session(paint_session* session, uint16_t filter) +InteractionInfo set_interaction_info_from_paint_session(paint_session* session, uint32_t viewFlags, uint16_t filter) { PROFILED_FUNCTION(); @@ -1686,7 +1823,7 @@ InteractionInfo set_interaction_info_from_paint_session(paint_session* session, ps = next_ps; if (is_sprite_interacted_with(dpi, ps->image_id, { ps->x, ps->y })) { - if (PSSpriteTypeIsInFilter(ps, filter)) + if (PSSpriteTypeIsInFilter(ps, filter) && GetPaintStructVisibility(ps, viewFlags) != VisibilityKind::Hidden) { info = { ps }; } @@ -1698,7 +1835,7 @@ InteractionInfo set_interaction_info_from_paint_session(paint_session* session, { if (is_sprite_interacted_with(dpi, attached_ps->image_id, { (attached_ps->x + ps->x), (attached_ps->y + ps->y) })) { - if (PSSpriteTypeIsInFilter(ps, filter)) + if (PSSpriteTypeIsInFilter(ps, filter) && GetPaintStructVisibility(ps, viewFlags) != VisibilityKind::Hidden) { info = { ps }; } @@ -1760,7 +1897,7 @@ InteractionInfo get_map_coordinates_from_pos_window(rct_window* window, const Sc paint_session* session = PaintSessionAlloc(&dpi, myviewport->flags); PaintSessionGenerate(*session); PaintSessionArrange(*session); - info = set_interaction_info_from_paint_session(session, flags & 0xFFFF); + info = set_interaction_info_from_paint_session(session, myviewport->flags, flags & 0xFFFF); PaintSessionFree(session); } return info; diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index b2c655c195..289136f1fd 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -27,28 +27,49 @@ struct Guest; struct Staff; struct paint_entry; +// Flags must currenly retain their values to avoid breaking plugins. +// Values can be changed when plugins move to using named constants. enum { - VIEWPORT_FLAG_UNDERGROUND_INSIDE = (1 << 0), - VIEWPORT_FLAG_SEETHROUGH_RIDES = (1 << 1), - VIEWPORT_FLAG_SEETHROUGH_SCENERY = (1 << 2), - VIEWPORT_FLAG_INVISIBLE_SUPPORTS = (1 << 3), - VIEWPORT_FLAG_LAND_HEIGHTS = (1 << 4), - VIEWPORT_FLAG_TRACK_HEIGHTS = (1 << 5), - VIEWPORT_FLAG_PATH_HEIGHTS = (1 << 6), VIEWPORT_FLAG_GRIDLINES = (1 << 7), - VIEWPORT_FLAG_LAND_OWNERSHIP = (1 << 8), - VIEWPORT_FLAG_CONSTRUCTION_RIGHTS = (1 << 9), - VIEWPORT_FLAG_SOUND_ON = (1 << 10), - VIEWPORT_FLAG_INVISIBLE_PEEPS = (1 << 11), + VIEWPORT_FLAG_UNDERGROUND_INSIDE = (1 << 0), VIEWPORT_FLAG_HIDE_BASE = (1 << 12), VIEWPORT_FLAG_HIDE_VERTICAL = (1 << 13), - VIEWPORT_FLAG_INVISIBLE_SPRITES = (1 << 14), - VIEWPORT_FLAG_15 = (1 << 15), - VIEWPORT_FLAG_SEETHROUGH_PATHS = (1 << 16), + + VIEWPORT_FLAG_SOUND_ON = (1 << 10), + VIEWPORT_FLAG_LAND_OWNERSHIP = (1 << 8), + VIEWPORT_FLAG_CONSTRUCTION_RIGHTS = (1 << 9), + VIEWPORT_FLAG_HIDE_ENTITIES = (1 << 14), VIEWPORT_FLAG_CLIP_VIEW = (1 << 17), VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1 << 18), VIEWPORT_FLAG_TRANSPARENT_BACKGROUND = (1 << 19), + + VIEWPORT_FLAG_LAND_HEIGHTS = (1 << 4), + VIEWPORT_FLAG_TRACK_HEIGHTS = (1 << 5), + VIEWPORT_FLAG_PATH_HEIGHTS = (1 << 6), + + VIEWPORT_FLAG_HIDE_RIDES = (1 << 1), + VIEWPORT_FLAG_HIDE_VEHICLES = (1 << 20), + VIEWPORT_FLAG_HIDE_VEGETATION = (1 << 21), + VIEWPORT_FLAG_HIDE_SCENERY = (1 << 2), + VIEWPORT_FLAG_HIDE_PATHS = (1 << 16), + VIEWPORT_FLAG_HIDE_SUPPORTS = (1 << 3), + VIEWPORT_FLAG_HIDE_GUESTS = (1 << 11), + VIEWPORT_FLAG_HIDE_STAFF = (1 << 23), + + VIEWPORT_FLAG_INVISIBLE_RIDES = (1 << 24), + VIEWPORT_FLAG_INVISIBLE_VEHICLES = (1 << 25), + VIEWPORT_FLAG_INVISIBLE_VEGETATION = (1 << 26), + VIEWPORT_FLAG_INVISIBLE_SCENERY = (1 << 27), + VIEWPORT_FLAG_INVISIBLE_PATHS = (1 << 28), + VIEWPORT_FLAG_INVISIBLE_SUPPORTS = (1 << 29), +}; + +enum class VisibilityKind +{ + Visible, + Partial, + Hidden }; enum class ViewportInteractionItem : uint8_t @@ -75,11 +96,8 @@ struct InteractionInfo InteractionInfo() = default; InteractionInfo(const paint_struct* ps); CoordsXY Loc; - union - { - TileElement* Element = nullptr; - EntityBase* Entity; - }; + TileElement* Element{}; + EntityBase* Entity{}; ViewportInteractionItem SpriteType = ViewportInteractionItem::None; }; @@ -136,7 +154,7 @@ void viewport_set_visibility(uint8_t mode); InteractionInfo get_map_coordinates_from_pos(const ScreenCoordsXY& screenCoords, int32_t flags); InteractionInfo get_map_coordinates_from_pos_window(rct_window* window, const ScreenCoordsXY& screenCoords, int32_t flags); -InteractionInfo set_interaction_info_from_paint_session(paint_session* session, uint16_t filter); +InteractionInfo set_interaction_info_from_paint_session(paint_session* session, uint32_t viewFlags, uint16_t filter); InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoords); bool ViewportInteractionLeftOver(const ScreenCoordsXY& screenCoords); bool ViewportInteractionLeftClick(const ScreenCoordsXY& screenCoords); @@ -159,3 +177,5 @@ uint8_t get_current_rotation(); int32_t get_height_marker_offset(); void viewport_set_saved_view(); + +VisibilityKind GetPaintStructVisibility(const paint_struct* ps, uint32_t viewFlags); diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index eb10c816f9..1723e87b91 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -463,6 +463,7 @@ enum WC_VIEW_CLIPPING = 131, WC_OBJECT_LOAD_ERROR = 132, WC_PATROL_AREA = 133, + WC_TRANSPARENCY = 134, // Only used for colour schemes WC_STAFF = 220, diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 5d34226047..d389c6c060 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3928,6 +3928,24 @@ enum : uint16_t STR_ADJUST_SMALLER_PATROL_AREA_TIP = 6469, STR_ADJUST_LARGER_PATROL_AREA_TIP = 6470, + STR_SEE_THROUGH_VEGETATION = 6471, + STR_SEE_THROUGH_VEHICLES = 6472, + STR_SEE_THROUGH_SUPPORTS = 6473, + STR_SEE_THROUGH_GUESTS = 6474, + STR_SEE_THROUGH_STAFF = 6475, + STR_INVISIBLE_VEGETATION = 6476, + STR_INVISIBLE_SCENERY = 6477, + STR_INVISIBLE_PATHS = 6478, + STR_INVISIBLE_RIDES = 6479, + STR_INVISIBLE_VEHICLES = 6480, + STR_TRANSPARENCY_OPTIONS = 6481, + STR_TRANSPARENCY_OPTIONS_TITLE = 6482, + STR_SHORTCUT_OPEN_TRANSPARENCY_OPTIONS = 6483, + STR_SHORTCUT_SEE_THROUGH_VEGETATION_TOGGLE = 6484, + STR_SHORTCUT_SEE_THROUGH_VEHICLES_TOGGLE = 6485, + STR_SHORTCUT_SEE_THROUGH_GUESTS_TOGGLE = 6486, + STR_SHORTCUT_SEE_THROUGH_STAFF_TOGGLE = 6487, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings }; diff --git a/src/openrct2/paint/Paint.Entity.cpp b/src/openrct2/paint/Paint.Entity.cpp index d8681e85f5..f30d45957e 100644 --- a/src/openrct2/paint/Paint.Entity.cpp +++ b/src/openrct2/paint/Paint.Entity.cpp @@ -42,7 +42,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos) { return; } - if (gTrackDesignSaveMode || (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES)) + if (gTrackDesignSaveMode || (session.ViewFlags & VIEWPORT_FLAG_HIDE_ENTITIES)) { return; } @@ -55,7 +55,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos) const bool highlightPathIssues = (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES); - for (const auto* spr : EntityTileList(pos)) + for (auto* spr : EntityTileList(pos)) { if (highlightPathIssues) { @@ -108,7 +108,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos) image_direction += spr->sprite_direction; image_direction &= 0x1F; - session.CurrentlyDrawnItem = spr; + session.CurrentlyDrawnEntity = spr; session.SpritePosition.x = entityPos.x; session.SpritePosition.y = entityPos.y; session.InteractionType = ViewportInteractionItem::Entity; diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 84175fbc77..51dff01d52 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -19,6 +19,7 @@ #include "../paint/Painter.h" #include "../profiling/Profiling.h" #include "../util/Math.hpp" +#include "../world/SmallScenery.h" #include "Paint.Entity.h" #include "tile_element/Paint.TileElement.h" @@ -56,7 +57,7 @@ bool gPaintBlockedTiles; static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags); static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y); static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y); -static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags); +static ImageId PaintPSColourifyImage(const paint_struct* ps, ImageId imageId, uint32_t viewFlags); static int32_t RemapPositionToQuadrant(const paint_struct& ps, uint8_t rotation) { @@ -192,7 +193,8 @@ static paint_struct* CreateNormalPaintStruct( ps->sprite_type = session.InteractionType; ps->map_x = session.MapPosition.x; ps->map_y = session.MapPosition.y; - ps->tileElement = reinterpret_cast(const_cast(session.CurrentlyDrawnItem)); + ps->tileElement = session.CurrentlyDrawnTileElement; + ps->entity = session.CurrentlyDrawnEntity; return ps; } @@ -503,7 +505,7 @@ static void PaintDrawStruct(paint_session& session, paint_struct* ps) } } - auto imageId = PaintPSColourifyImage(ps->image_id, ps->sprite_type, session.ViewFlags); + auto imageId = PaintPSColourifyImage(ps, ps->image_id, session.ViewFlags); if (gPaintBoundingBoxes && dpi->zoom_level == ZoomLevel{ 0 }) { PaintPSImageWithBoundingBoxes(dpi, ps, imageId, x, y); @@ -553,7 +555,7 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v { auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y }; - auto imageId = PaintPSColourifyImage(attached_ps->image_id, ps->sprite_type, viewFlags); + auto imageId = PaintPSColourifyImage(ps, attached_ps->image_id, viewFlags); if (attached_ps->flags & PAINT_STRUCT_FLAG_IS_MASKED) { gfx_draw_sprite_raw_masked(dpi, screenCoords, imageId, attached_ps->colour_image_id); @@ -661,48 +663,18 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image gfx_draw_sprite(dpi, imageId, { x, y }); } -static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags) +static ImageId PaintPSColourifyImage(const paint_struct* ps, ImageId imageId, uint32_t viewFlags) { - auto seeThrough = imageId.WithTransparancy(FilterPaletteID::PaletteDarken1); - if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES) + auto visibility = GetPaintStructVisibility(ps, viewFlags); + switch (visibility) { - if (spriteType == ViewportInteractionItem::Ride) - { - return seeThrough; - } + case VisibilityKind::Partial: + return imageId.WithTransparancy(FilterPaletteID::PaletteDarken1); + case VisibilityKind::Hidden: + return ImageId(); + default: + return imageId; } - if (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE) - { - if (spriteType == ViewportInteractionItem::Wall) - { - return seeThrough; - } - } - if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_PATHS) - { - switch (spriteType) - { - case ViewportInteractionItem::Footpath: - case ViewportInteractionItem::FootpathItem: - case ViewportInteractionItem::Banner: - return seeThrough; - default: - break; - } - } - if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_SCENERY) - { - switch (spriteType) - { - case ViewportInteractionItem::Scenery: - case ViewportInteractionItem::LargeScenery: - case ViewportInteractionItem::Wall: - return seeThrough; - default: - break; - } - } - return imageId; } paint_session* PaintSessionAlloc(rct_drawpixelinfo* dpi, uint32_t viewFlags) diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 4053ebc4dc..19cfde643a 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -19,6 +19,7 @@ #include #include +struct EntityBase; struct TileElement; enum class RailingEntrySupportType : uint8_t; enum class ViewportInteractionItem : uint8_t; @@ -50,6 +51,7 @@ struct paint_struct paint_struct* children; paint_struct* next_quadrant_ps; TileElement* tileElement; + EntityBase* entity; ImageId image_id; ImageId colour_image_id; int32_t x; @@ -192,7 +194,8 @@ struct PaintSessionCore paint_string_struct* LastPSString; attached_paint_struct* LastAttachedPS; const TileElement* SurfaceElement; - const void* CurrentlyDrawnItem; + EntityBase* CurrentlyDrawnEntity; + TileElement* CurrentlyDrawnTileElement; const TileElement* PathElementOnSameHeight; const TileElement* TrackElementOnSameHeight; paint_struct* WoodenSupportsPrependTo; diff --git a/src/openrct2/paint/Painter.cpp b/src/openrct2/paint/Painter.cpp index ab5a59349c..3f9289a6e8 100644 --- a/src/openrct2/paint/Painter.cpp +++ b/src/openrct2/paint/Painter.cpp @@ -165,7 +165,8 @@ paint_session* Painter::CreateSession(rct_drawpixelinfo* dpi, uint32_t viewFlags session->PSStringHead = nullptr; session->LastPSString = nullptr; session->WoodenSupportsPrependTo = nullptr; - session->CurrentlyDrawnItem = nullptr; + session->CurrentlyDrawnEntity = nullptr; + session->CurrentlyDrawnTileElement = nullptr; session->SurfaceElement = nullptr; return session; diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index a990a7bd4a..71b0b41cb7 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -445,6 +445,7 @@ static constexpr const uint16_t word_97B3C4[] = { 15, 0, }; + // clang-format on bool wooden_a_supports_paint_setup( @@ -472,14 +473,18 @@ bool wooden_b_supports_paint_setup( bool wooden_a_supports_paint_setup( paint_session& session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate) { - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) { - return false; + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); } int32_t z = floor2(session.Support.height + 15, 16); @@ -629,16 +634,18 @@ bool wooden_a_supports_paint_setup( bool wooden_b_supports_paint_setup( paint_session& session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate) { - bool _9E32B1 = false; - - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) { - return false; + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); } uint16_t baseHeight = ceil2(session.Support.height, 16); @@ -651,8 +658,8 @@ bool wooden_b_supports_paint_setup( int16_t heightSteps = supportLength / 16; + bool _9E32B1 = false; bool goTo662E8B = false; - if (session.Support.slope & 0x20) { goTo662E8B = true; @@ -801,14 +808,18 @@ bool metal_a_supports_paint_setup( { support_height* supportSegments = session.SupportSegments; - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) { - return false; + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageColourFlags = ImageId(0).WithTransparancy(FilterPaletteID::PaletteDarken1).ToUInt32(); } int16_t originalHeight = height; @@ -1000,14 +1011,18 @@ bool metal_b_supports_paint_setup( support_height* supportSegments = session.SupportSegments; uint8_t originalSegment = segment; - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; // AND } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) { - return false; // AND + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageColourFlags = ImageId(0).WithTransparancy(FilterPaletteID::PaletteDarken1).ToUInt32(); } uint16_t _9E3294 = 0xFFFF; @@ -1180,14 +1195,18 @@ bool path_a_supports_paint_setup( *underground = false; // AND } - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) { - return false; + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); } uint16_t baseHeight = ceil2(session.Support.height, 16); @@ -1330,14 +1349,18 @@ bool path_b_supports_paint_setup( { support_height* supportSegments = session.SupportSegments; - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) - { - return false; // AND - } - if (!(session.Flags & PaintSessionFlags::PassedSurface)) { - return false; // AND + return false; + } + + if (session.ViewFlags & VIEWPORT_FLAG_HIDE_SUPPORTS) + { + if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) + { + return false; + } + imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1); } if (height < supportSegments[segment].height) diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index b47cf74b3d..f0f7ca1b30 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -103,45 +103,15 @@ static void SetSupportHeights( } } -/** - * - * rct2: 0x006DFF47 - */ -void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement) +static void PaintSmallSceneryBody( + paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement, + const SmallSceneryEntry* sceneryEntry, ImageId imageTemplate) { PROFILED_FUNCTION(); - if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) - { - return; - } - - auto* sceneryEntry = sceneryElement.GetEntry(); - if (sceneryEntry == nullptr) - { - return; - } - session.InteractionType = ViewportInteractionItem::Scenery; CoordsXYZ boxLength; CoordsXYZ boxOffset{ 0, 0, height }; - ImageId imageTemplate; - if (gTrackDesignSaveMode) - { - if (!track_design_save_contains_tile_element(reinterpret_cast(&sceneryElement))) - { - imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette46); - } - } - if (sceneryElement.IsGhost()) - { - session.InteractionType = ViewportInteractionItem::None; - imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44); - } - else if (OpenRCT2::TileInspector::IsElementSelected(reinterpret_cast(&sceneryElement))) - { - imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44); - } boxLength.x = 2; boxLength.y = 2; @@ -335,7 +305,43 @@ void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height } } } +} +void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height, const SmallSceneryElement& sceneryElement) +{ + PROFILED_FUNCTION(); + + if (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) + { + return; + } + + auto* sceneryEntry = sceneryElement.GetEntry(); + if (sceneryEntry == nullptr) + { + return; + } + + session.InteractionType = ViewportInteractionItem::Scenery; + ImageId imageTemplate; + if (gTrackDesignSaveMode) + { + if (!track_design_save_contains_tile_element(reinterpret_cast(&sceneryElement))) + { + imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette46); + } + } + if (sceneryElement.IsGhost()) + { + session.InteractionType = ViewportInteractionItem::None; + imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44); + } + else if (OpenRCT2::TileInspector::IsElementSelected(reinterpret_cast(&sceneryElement))) + { + imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44); + } + + PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate); PaintSmallScenerySupports(session, *sceneryEntry, sceneryElement, direction, height, imageTemplate); SetSupportHeights(session, *sceneryEntry, sceneryElement, height); } diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 9a3e93dc7d..d1ad543fc0 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -140,7 +140,7 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo session.MapPosition.x = coords.x; session.MapPosition.y = coords.y; - const TileElement* tile_element = map_get_first_element_at(session.MapPosition); + auto* tile_element = map_get_first_element_at(session.MapPosition); if (tile_element == nullptr) return; uint8_t rotation = session.CurrentRotation; @@ -263,7 +263,7 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo } CoordsXY mapPosition = session.MapPosition; - session.CurrentlyDrawnItem = tile_element; + session.CurrentlyDrawnTileElement = tile_element; // Setup the painting of for example: the underground, signs, rides, scenery, etc. switch (tile_element->GetType()) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 052ae3a1d6..b682c31eac 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2115,7 +2115,7 @@ void TrackDesignDrawPreview(TrackDesign* td6, uint8_t* pixels) view.view_height = size_y; view.pos = { 0, 0 }; view.zoom = zoom_level; - view.flags = VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_INVISIBLE_SPRITES; + view.flags = VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_ENTITIES; rct_drawpixelinfo dpi; dpi.zoom_level = zoom_level; diff --git a/src/openrct2/ride/gentle/Circus.cpp b/src/openrct2/ride/gentle/Circus.cpp index 57b5c48add..20d09ea45c 100644 --- a/src/openrct2/ride/gentle/Circus.cpp +++ b/src/openrct2/ride/gentle/Circus.cpp @@ -11,6 +11,7 @@ #include "../../interface/Viewport.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" +#include "../../ride/Vehicle.h" #include "../Ride.h" #include "../RideEntry.h" #include "../Track.h" @@ -18,8 +19,6 @@ static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t direction, int8_t al, int8_t cl, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - auto rideEntry = ride.GetRideEntry(); if (rideEntry == nullptr) return; @@ -28,7 +27,7 @@ static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t di if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } auto imageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim); @@ -42,7 +41,7 @@ static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t di PaintAddImageAsParent( session, imageTemplate.WithIndex(imageIndex), { al, cl, height + 3 }, { 24, 24, 47 }, { al + 16, cl + 16, height + 3 }); - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/gentle/CrookedHouse.cpp b/src/openrct2/ride/gentle/CrookedHouse.cpp index 43fbe1fc18..b133a461d2 100644 --- a/src/openrct2/ride/gentle/CrookedHouse.cpp +++ b/src/openrct2/ride/gentle/CrookedHouse.cpp @@ -11,6 +11,7 @@ #include "../../interface/Viewport.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" +#include "../../ride/Vehicle.h" #include "../Ride.h" #include "../RideEntry.h" #include "../Track.h" @@ -52,9 +53,11 @@ static constexpr const rct_crooked_house_bound_box crooked_house_data[] = { static void PaintCrookedHouseStructure( paint_session& session, uint8_t direction, int32_t x_offset, int32_t y_offset, uint32_t segment, int32_t height) { - const TileElement* original_tile_element = static_cast(session.CurrentlyDrawnItem); + const auto* tileElement = session.CurrentlyDrawnTileElement; + if (tileElement == nullptr) + return; - auto ride = get_ride(original_tile_element->AsTrack()->GetRideIndex()); + auto ride = get_ride(tileElement->AsTrack()->GetRideIndex()); if (ride == nullptr) return; @@ -68,7 +71,7 @@ static void PaintCrookedHouseStructure( if (vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } } @@ -78,6 +81,8 @@ static void PaintCrookedHouseStructure( PaintAddImageAsParent( session, imageTemplate.WithIndex(imageIndex), { x_offset, y_offset, height + 3 }, { boundBox.length, 127 }, { boundBox.offset, height + 3 }); + + session.CurrentlyDrawnEntity = nullptr; } static void PaintCrookedHouse( diff --git a/src/openrct2/ride/gentle/FerrisWheel.cpp b/src/openrct2/ride/gentle/FerrisWheel.cpp index 89714ca3ea..fdfbd1d899 100644 --- a/src/openrct2/ride/gentle/FerrisWheel.cpp +++ b/src/openrct2/ride/gentle/FerrisWheel.cpp @@ -66,8 +66,6 @@ static void PaintFerrisWheelRiders( static void PaintFerrisWheelStructure( paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - auto rideEntry = ride.GetRideEntry(); if (rideEntry == nullptr) return; @@ -76,7 +74,7 @@ static void PaintFerrisWheelStructure( if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } const auto& boundBox = FerrisWheelData[direction]; @@ -105,7 +103,7 @@ static void PaintFerrisWheelStructure( } PaintAddImageAsChild(session, rightSupportImageId, offset, bbLength, bbOffset); - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/gentle/HauntedHouse.cpp b/src/openrct2/ride/gentle/HauntedHouse.cpp index 1c580ed9ba..be20b24dda 100644 --- a/src/openrct2/ride/gentle/HauntedHouse.cpp +++ b/src/openrct2/ride/gentle/HauntedHouse.cpp @@ -31,8 +31,6 @@ static constexpr haunted_house_bound_box haunted_house_data[] = { static void PaintHauntedHouseStructure( paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint8_t part, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - uint8_t frameNum = 0; auto rideEntry = ride.GetRideEntry(); @@ -43,7 +41,7 @@ static void PaintHauntedHouseStructure( if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; frameNum = vehicle->Pitch; } @@ -63,7 +61,7 @@ static void PaintHauntedHouseStructure( { boundBox.length.x, boundBox.length.y, 127 }, { boundBox.offset.x, boundBox.offset.y, height }); } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/gentle/MerryGoRound.cpp b/src/openrct2/ride/gentle/MerryGoRound.cpp index a5292ebad1..e85f702888 100644 --- a/src/openrct2/ride/gentle/MerryGoRound.cpp +++ b/src/openrct2/ride/gentle/MerryGoRound.cpp @@ -53,7 +53,6 @@ static void PaintRiders( static void PaintCarousel( paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); height += 7; auto rideEntry = ride.GetRideEntry(); @@ -64,7 +63,7 @@ static void PaintCarousel( if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; if (ride.lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN) && ride.breakdown_reason_pending == BREAKDOWN_CONTROL_FAILURE && ride.breakdown_sound_modifier >= 128) @@ -96,7 +95,7 @@ static void PaintCarousel( PaintRiders(session, ride, *rideEntry, *vehicle, rotationOffset, offset, bbLength, bbOffset); - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/gentle/MiniGolf.cpp b/src/openrct2/ride/gentle/MiniGolf.cpp index 95c896496f..8a835beaf2 100644 --- a/src/openrct2/ride/gentle/MiniGolf.cpp +++ b/src/openrct2/ride/gentle/MiniGolf.cpp @@ -1213,11 +1213,6 @@ void vehicle_visual_mini_golf_player( return; } - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_PEEPS) - { - return; - } - auto ride = vehicle->GetRide(); if (ride == nullptr) return; @@ -1255,11 +1250,6 @@ void vehicle_visual_mini_golf_ball( return; } - if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_PEEPS) - { - return; - } - auto ride = vehicle->GetRide(); if (ride == nullptr) return; diff --git a/src/openrct2/ride/gentle/SpaceRings.cpp b/src/openrct2/ride/gentle/SpaceRings.cpp index cb8b51957d..d992e2b89b 100644 --- a/src/openrct2/ride/gentle/SpaceRings.cpp +++ b/src/openrct2/ride/gentle/SpaceRings.cpp @@ -36,8 +36,6 @@ static constexpr const uint32_t space_rings_fence_sprites[] = { static void paint_space_rings_structure( paint_session& session, const Ride& ride, uint8_t direction, uint32_t segment, int32_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - uint32_t vehicleIndex = (segment - direction) & 0x3; if (ride.num_stations == 0 || vehicleIndex < ride.num_vehicles) @@ -51,7 +49,7 @@ static void paint_space_rings_structure( if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; frameNum += static_cast(vehicle->Pitch) * 4; } @@ -82,7 +80,7 @@ static void paint_space_rings_structure( } } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/3dCinema.cpp b/src/openrct2/ride/thrill/3dCinema.cpp index 5be7aadac0..1444f0e039 100644 --- a/src/openrct2/ride/thrill/3dCinema.cpp +++ b/src/openrct2/ride/thrill/3dCinema.cpp @@ -15,12 +15,11 @@ #include "../RideEntry.h" #include "../Track.h" #include "../TrackPaint.h" +#include "../Vehicle.h" static void Paint3dCinemaDome( paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - auto rideEntry = ride.GetRideEntry(); if (rideEntry == nullptr) return; @@ -28,7 +27,7 @@ static void Paint3dCinemaDome( if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && !ride.vehicles[0].IsNull()) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = GetEntity(ride.vehicles[0]); + session.CurrentlyDrawnEntity = GetEntity(ride.vehicles[0]); } auto imageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim); @@ -42,7 +41,7 @@ static void Paint3dCinemaDome( PaintAddImageAsParent( session, imageId, { xOffset, yOffset, height + 3 }, { 24, 24, 47 }, { xOffset + 16, yOffset + 16, height + 3 }); - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/Enterprise.cpp b/src/openrct2/ride/thrill/Enterprise.cpp index 5cb2646d33..c00bf57e35 100644 --- a/src/openrct2/ride/thrill/Enterprise.cpp +++ b/src/openrct2/ride/thrill/Enterprise.cpp @@ -44,7 +44,6 @@ static void PaintEnterpriseRiders( static void PaintEnterpriseStructure( paint_session& session, const Ride& ride, int8_t xOffset, int8_t yOffset, uint16_t height, const TrackElement& trackElement) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); const auto* rideEntry = get_ride_entry(ride.subtype); if (rideEntry == nullptr) return; @@ -56,7 +55,7 @@ static void PaintEnterpriseStructure( if (vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } } @@ -84,7 +83,7 @@ static void PaintEnterpriseStructure( PaintEnterpriseRiders(session, *rideEntry, *vehicle, imageOffset, offset, bbLength, bbOffset); } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/MagicCarpet.cpp b/src/openrct2/ride/thrill/MagicCarpet.cpp index b0a3c32dd6..8406e95ee7 100644 --- a/src/openrct2/ride/thrill/MagicCarpet.cpp +++ b/src/openrct2/ride/thrill/MagicCarpet.cpp @@ -94,7 +94,7 @@ static ImageIndex GetMagicCarpetPendulumImage(Plane plane, Direction direction, return imageIndex; } -static const Vehicle* GetFirstVehicle(const Ride& ride) +static Vehicle* GetFirstVehicle(const Ride& ride) { if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { @@ -193,15 +193,13 @@ static void PaintMagicCarpetVehicle( static void PaintMagicCarpetStructure( paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - auto swing = 0; auto* vehicle = GetFirstVehicle(ride); if (vehicle != nullptr) { swing = vehicle->Pitch; session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } bound_box bb = MagicCarpetBounds[direction]; @@ -222,8 +220,8 @@ static void PaintMagicCarpetStructure( PaintMagicCarpetPendulum(session, Plane::Front, swing, direction, offset, bbOffset, bbSize); PaintMagicCarpetFrame(session, Plane::Front, direction, offset, bbOffset, bbSize); + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; - session.CurrentlyDrawnItem = savedTileElement; } static void PaintMagicCarpet( diff --git a/src/openrct2/ride/thrill/MotionSimulator.cpp b/src/openrct2/ride/thrill/MotionSimulator.cpp index aa7128709f..cb31c5520b 100644 --- a/src/openrct2/ride/thrill/MotionSimulator.cpp +++ b/src/openrct2/ride/thrill/MotionSimulator.cpp @@ -37,7 +37,6 @@ static void PaintMotionSimulatorVehicle( if (rideEntry == nullptr) return; - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); CoordsXYZ offset(offsetX, offsetY, height + 2); Vehicle* vehicle = nullptr; @@ -47,7 +46,7 @@ static void PaintMotionSimulatorVehicle( if (vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } } @@ -97,7 +96,7 @@ static void PaintMotionSimulatorVehicle( break; } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/SwingingInverterShip.cpp b/src/openrct2/ride/thrill/SwingingInverterShip.cpp index cdd959e53a..d57836bc69 100644 --- a/src/openrct2/ride/thrill/SwingingInverterShip.cpp +++ b/src/openrct2/ride/thrill/SwingingInverterShip.cpp @@ -68,8 +68,6 @@ static constexpr const uint32_t SwingingInverterShipFrameSprites[] = { static void PaintSwingingInverterShipStructure( paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - rct_ride_entry* rideEntry = get_ride_entry(ride.subtype); if (rideEntry == nullptr) return; @@ -86,7 +84,7 @@ static void PaintSwingingInverterShipStructure( if (vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } } @@ -130,7 +128,7 @@ static void PaintSwingingInverterShipStructure( PaintAddImageAsChild(session, vehicleImageId, offset, bbLength, bbOffset); } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/SwingingShip.cpp b/src/openrct2/ride/thrill/SwingingShip.cpp index 9b1c613fbc..d7aba79122 100644 --- a/src/openrct2/ride/thrill/SwingingShip.cpp +++ b/src/openrct2/ride/thrill/SwingingShip.cpp @@ -94,8 +94,6 @@ static void PaintSwingingShipRiders( static void PaintSwingingShipStructure( paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - rct_ride_entry* rideEntry = get_ride_entry(ride.subtype); if (rideEntry == nullptr) return; @@ -105,7 +103,7 @@ static void PaintSwingingShipStructure( { vehicle = GetEntity(ride.vehicles[0]); session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } const auto& bounds = SwingingShipData[direction]; @@ -157,7 +155,7 @@ static void PaintSwingingShipStructure( imageId = supportsImageTemplate.WithIndex(SwingingShipFrameSprites[(direction & 1)][1]); PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/TopSpin.cpp b/src/openrct2/ride/thrill/TopSpin.cpp index 5d53d8ef8a..ea818c6a61 100644 --- a/src/openrct2/ride/thrill/TopSpin.cpp +++ b/src/openrct2/ride/thrill/TopSpin.cpp @@ -124,18 +124,14 @@ static void PaintTopSpinVehicle( const auto& vehicleEntry = rideEntry->vehicles[0]; - // As we will be drawing a vehicle we need to backup the trackElement that - // is assigned to the drawings. - const TileElement* curTileElement = static_cast(session.CurrentlyDrawnItem); - height += 3; uint8_t seatRotation = 0; uint8_t armRotation = 0; - const auto* vehicle = GetEntity(ride.vehicles[0]); + auto* vehicle = GetEntity(ride.vehicles[0]); if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; armRotation = vehicle->Pitch; seatRotation = vehicle->bank_rotation; @@ -181,7 +177,7 @@ static void PaintTopSpinVehicle( imageIndex = vehicleEntry.base_image_id + 573 + ((direction & 1) << 1); PaintAddImageAsChild(session, supportImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); - session.CurrentlyDrawnItem = curTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/thrill/Twist.cpp b/src/openrct2/ride/thrill/Twist.cpp index bff5fa967e..af5222a014 100644 --- a/src/openrct2/ride/thrill/Twist.cpp +++ b/src/openrct2/ride/thrill/Twist.cpp @@ -22,8 +22,6 @@ static void paint_twist_structure( paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height) { - const TileElement* savedTileElement = static_cast(session.CurrentlyDrawnItem); - rct_ride_entry* rideEntry = get_ride_entry(ride.subtype); Vehicle* vehicle = nullptr; @@ -39,7 +37,7 @@ static void paint_twist_structure( vehicle = GetEntity(ride.vehicles[0]); session.InteractionType = ViewportInteractionItem::Entity; - session.CurrentlyDrawnItem = vehicle; + session.CurrentlyDrawnEntity = vehicle; } uint32_t frameNum = (direction * 88) % 216; @@ -75,7 +73,7 @@ static void paint_twist_structure( } } - session.CurrentlyDrawnItem = savedTileElement; + session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; } diff --git a/src/openrct2/ride/water/SplashBoats.cpp b/src/openrct2/ride/water/SplashBoats.cpp index 6f1df3e7f1..bebc25d7e1 100644 --- a/src/openrct2/ride/water/SplashBoats.cpp +++ b/src/openrct2/ride/water/SplashBoats.cpp @@ -1268,23 +1268,17 @@ void vehicle_visual_splash_boats_or_water_coaster( paint_session& session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle, const rct_ride_entry_vehicle* vehicleEntry) { - if (vehicle->IsHead()) - { - vehicle = GetEntity(vehicle->next_vehicle_on_ride); - } - else - { - vehicle = GetEntity(vehicle->prev_vehicle_on_ride); - } - if (vehicle == nullptr) + auto* vehicleToPaint = vehicle->IsHead() ? GetEntity(vehicle->next_vehicle_on_ride) + : GetEntity(vehicle->prev_vehicle_on_ride); + if (vehicleToPaint == nullptr) { return; } - session.CurrentlyDrawnItem = vehicle; - imageDirection = ((session.CurrentRotation * 8) + vehicle->sprite_direction) & 0x1F; - session.SpritePosition.x = vehicle->x; - session.SpritePosition.y = vehicle->y; - vehicle->Paint(session, imageDirection); + session.CurrentlyDrawnEntity = vehicleToPaint; + imageDirection = ((session.CurrentRotation * 8) + vehicle->sprite_direction) & 0x1F; + session.SpritePosition.x = vehicleToPaint->x; + session.SpritePosition.y = vehicleToPaint->y; + vehicleToPaint->Paint(session, imageDirection); } #endif diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index 5e8715991f..e205b6e6b6 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -888,7 +888,14 @@ enum SPR_G2_RIDE_STATION_TAB = SPR_G2_BEGIN + 141, SPR_G2_TERRAIN_EDGE_TAB = SPR_G2_BEGIN + 142, - SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 143, + SPR_G2_BUTTON_HIDE_VEGETATION = SPR_G2_BEGIN + 143, + SPR_G2_BUTTON_HIDE_SCENERY = SPR_G2_BEGIN + 144, + SPR_G2_BUTTON_HIDE_VEHICLES = SPR_G2_BEGIN + 145, + SPR_G2_BUTTON_HIDE_SUPPORTS = SPR_G2_BEGIN + 146, + SPR_G2_BUTTON_HIDE_PARTIAL = SPR_G2_BEGIN + 147, + SPR_G2_BUTTON_HIDE_FULL = SPR_G2_BEGIN + 148, + + SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 149, SPR_G2_AE_UPPER = SPR_G2_CHAR_BEGIN, SPR_G2_AE_LOWER = SPR_G2_CHAR_BEGIN + 1, diff --git a/test/testpaint/TestTrack.cpp b/test/testpaint/TestTrack.cpp index 6753fab615..b37ab30907 100644 --- a/test/testpaint/TestTrack.cpp +++ b/test/testpaint/TestTrack.cpp @@ -273,7 +273,7 @@ static uint8_t TestTrackElementPaintCalls(uint8_t rideType, uint8_t trackType, u gSurfaceElement = &surfaceElement; gDidPassSurface = true; - gPaintSession.CurrentlyDrawnItem = &tileElement; + gPaintSession.CurrentlyDrawnTileElement = &tileElement; gPaintSession.SurfaceElement = &surfaceElement; gPaintSession.DidPassSurface = true; @@ -436,7 +436,7 @@ static uint8_t TestTrackElementSegmentSupportHeight( gSurfaceElement = &surfaceElement; gDidPassSurface = true; - gPaintSession.CurrentlyDrawnItem = &tileElement; + gPaintSession.CurrentlyDrawnTileElement = &tileElement; gPaintSession.SurfaceElement = &surfaceElement; gPaintSession.DidPassSurface = true; @@ -523,7 +523,7 @@ static uint8_t TestTrackElementGeneralSupportHeight( gSurfaceElement = &surfaceElement; gDidPassSurface = true; - gPaintSession.CurrentlyDrawnItem = &tileElement; + gPaintSession.CurrentlyDrawnTileElement = &tileElement; gPaintSession.SurfaceElement = &surfaceElement; gPaintSession.DidPassSurface = true; @@ -624,7 +624,7 @@ static uint8_t TestTrackElementSideTunnels(uint8_t rideType, uint8_t trackType, gSurfaceElement = &surfaceElement; gDidPassSurface = true; - gPaintSession.CurrentlyDrawnItem = &tileElement; + gPaintSession.CurrentlyDrawnTileElement = &tileElement; gPaintSession.SurfaceElement = &surfaceElement; gPaintSession.DidPassSurface = true; @@ -752,7 +752,7 @@ static uint8_t TestTrackElementVerticalTunnels(uint8_t rideType, uint8_t trackTy gSurfaceElement = &surfaceElement; gDidPassSurface = true; - gPaintSession.CurrentlyDrawnItem = &tileElement; + gPaintSession.CurrentlyDrawnTileElement = &tileElement; gPaintSession.SurfaceElement = &surfaceElement; gPaintSession.DidPassSurface = true;