Skip to content

Commit

Permalink
Merge pull request #16797 from IntelOrca/feature/enhanced-transparency
Browse files Browse the repository at this point in the history
Introduce more transparency toggles and allow each one to be set to either an invisible or ghost state which is a persisted user setting.

A new window is introduced to control these settings and is inspired by OpenTTD.
  • Loading branch information
IntelOrca committed Mar 20, 2022
2 parents 8683122 + 884ef6b commit f909be7
Show file tree
Hide file tree
Showing 55 changed files with 813 additions and 284 deletions.
17 changes: 17 additions & 0 deletions data/language/en-GB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
Binary file added resources/g2/icons/hide_full.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/g2/icons/hide_partial.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/g2/icons/hide_scenery.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/g2/icons/hide_supports.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/g2/icons/hide_vegetation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/g2/icons/hide_vehicles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions resources/g2/sprites.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/openrct2-ui/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class WindowManager final : public IWindowManager
return WindowViewportOpen();
case WC_WATER:
return WindowWaterOpen();
case WC_TRANSPARENCY:
return WindowTransparencyOpen();
default:
Console::Error::WriteLine("Unhandled window class (%d)", wc);
return nullptr;
Expand Down
8 changes: 6 additions & 2 deletions src/openrct2-ui/input/ShortcutIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/input/ShortcutManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 17 additions & 5 deletions src/openrct2-ui/input/Shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(); });
Expand Down Expand Up @@ -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); });
Expand Down
1 change: 1 addition & 0 deletions src/openrct2-ui/interface/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) },
Expand Down
15 changes: 7 additions & 8 deletions src/openrct2-ui/interface/ViewportInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Guest>(viewportCoords, maxDistance, {});
goal = GetClosestPeep<Staff>(viewportCoords, maxDistance, goal);

PeepDistance goal;
if (!(viewport->flags & VIEWPORT_FLAG_HIDE_GUESTS))
goal = GetClosestPeep<Guest>(viewportCoords, maxDistance, goal);
if (!(viewport->flags & VIEWPORT_FLAG_HIDE_STAFF))
goal = GetClosestPeep<Staff>(viewportCoords, maxDistance, goal);
return goal.peep;
}

Expand Down
1 change: 1 addition & 0 deletions src/openrct2-ui/libopenrct2ui.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<ClCompile Include="windows\TrackDesignManage.cpp" />
<ClCompile Include="windows\TrackDesignPlace.cpp" />
<ClCompile Include="windows\TrackList.cpp" />
<ClCompile Include="windows\Transparency.cpp" />
<ClCompile Include="windows\ViewClipping.cpp" />
<ClCompile Include="windows\Viewport.cpp" />
<ClCompile Include="windows\Water.cpp" />
Expand Down
28 changes: 25 additions & 3 deletions src/openrct2-ui/windows/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/world/Footpath.h>

Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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 } });
}
1 change: 1 addition & 0 deletions src/openrct2-ui/windows/Themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f909be7

Please sign in to comment.