Move screen and line functions out of Drawing.{cpp,h} (#27079)

* Move stuff that affects the whole screen/viewport out of Drawing.{cpp,h}

* Move line drawing stuff into Line.{cpp.h}

* Move ImageId::GetCatalogue() out of Drawing.cpp

* Move GfxFilterPixel to Rectangle.cpp
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2026-09-07 21:41:30 +02:00
commit c3a2fe508f
68 files changed
+451 -362

No files matched your search

+1
View File
@@ -35,6 +35,7 @@
#include <openrct2/audio/AudioMixer.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/IDrawingEngine.h>
#include <openrct2/drawing/NewDrawing.h>
+1 -1
View File
@@ -27,7 +27,7 @@
#include <openrct2/config/Config.h>
#include <openrct2/core/Console.hpp>
#include <openrct2/core/Guard.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/NewDrawing.h>
#include <openrct2/interface/Viewport.h>
#include <openrct2/ride/Ride.h>
#include <openrct2/ride/RideConstruction.h>
+6 -6
View File
@@ -30,7 +30,7 @@
#include <openrct2/audio/Audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/EnumUtils.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/interface/Chat.h>
#include <openrct2/interface/Screenshot.h>
#include <openrct2/interface/Viewport.h>
@@ -189,7 +189,7 @@ static void ShortcutRemoveTopBottomToolbarToggle()
ContextOpenWindow(WindowClass::editorStepController); // next step
}
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
static void ShortcutAdjustLand()
@@ -459,7 +459,7 @@ static void ShortcutScaleUp()
{
Config::Get().general.windowScale += 0.25f;
Config::Save();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
ContextTriggerResize();
ContextUpdateCursorScale();
}
@@ -469,7 +469,7 @@ static void ShortcutScaleDown()
Config::Get().general.windowScale -= 0.25f;
Config::Get().general.windowScale = std::max(0.5f, Config::Get().general.windowScale);
Config::Save();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
ContextTriggerResize();
ContextUpdateCursorScale();
}
@@ -739,7 +739,7 @@ static void ShortcutToggleTransparentWater()
Config::Get().general.transparentWater ^= 1;
Config::Save();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
#pragma endregion
@@ -805,7 +805,7 @@ void ShortcutManager::registerDefaultShortcuts()
ChatToggle();
}
});
registerShortcut(ShortcutId::kInterfaceScaleToggleWindowMode, STR_SHORTCUT_WINDOWED_MODE_TOGGLE, "ALT+RETURN", ToggleWindowedMode);
registerShortcut(ShortcutId::kInterfaceScaleToggleWindowMode, STR_SHORTCUT_WINDOWED_MODE_TOGGLE, "ALT+RETURN", Drawing::ToggleWindowedMode);
registerShortcut(ShortcutId::kInterfaceScaleIncrease, STR_SHORTCUT_SCALE_UP, ShortcutScaleUp);
registerShortcut(ShortcutId::kInterfaceScaleDecrease, STR_SHORTCUT_SCALE_DOWN, ShortcutScaleDown);
registerShortcut(ShortcutId::kInterfaceOpenLand, STR_SHORTCUT_ADJUST_LAND, "F1", ShortcutAdjustLand);
+5 -5
View File
@@ -19,7 +19,7 @@
#include <openrct2/config/Config.h>
#include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/interface/WindowTypes.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/StringIds.h>
@@ -286,7 +286,7 @@ namespace OpenRCT2::Ui::FileBrowser
{
InvokeCallback(ModalResult::ok, pathBuffer);
windowMgr->CloseByClass(WindowClass::loadsave);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
else
{
@@ -310,7 +310,7 @@ namespace OpenRCT2::Ui::FileBrowser
if (editorScene->LoadLandscape(pathBuffer))
{
gCurrentLoadedPath = pathBuffer;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
InvokeCallback(ModalResult::ok, pathBuffer);
}
else
@@ -381,7 +381,7 @@ namespace OpenRCT2::Ui::FileBrowser
gFirstTimeSaving = false;
windowMgr->CloseByClass(WindowClass::loadsave);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
InvokeCallback(ModalResult::ok, pathBuffer);
}
@@ -400,7 +400,7 @@ namespace OpenRCT2::Ui::FileBrowser
{
gCurrentLoadedPath = pathBuffer;
windowMgr->CloseByClass(WindowClass::loadsave);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
InvokeCallback(ModalResult::ok, pathBuffer);
}
else
+1 -1
View File
@@ -11,7 +11,7 @@
#include <openrct2-ui/interface/Graph.h>
#include <openrct2/Date.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Line.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/interface/ColourWithFlags.h>
+3 -2
View File
@@ -20,9 +20,10 @@
#include <openrct2/config/Config.h>
#include <openrct2/core/UTF8.h>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/FilterPaletteIds.h>
#include <openrct2/drawing/NewDrawing.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/interface/ColourWithFlags.h>
@@ -280,7 +281,7 @@ void InGameConsole::Update()
{
_lastMainViewport = mainViewport->viewPos;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
}
+2 -1
View File
@@ -22,6 +22,7 @@
#include <openrct2/core/Json.hpp>
#include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/ColourWithFlags.h>
#include <openrct2/interface/WindowBase.h>
@@ -621,7 +622,7 @@ namespace OpenRCT2::Ui
CurrentTheme = theme;
CurrentThemePath.clear();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
static void LoadTheme(const std::string& path)
@@ -19,6 +19,7 @@
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/FilterPaletteIds.h>
#include <openrct2/drawing/Line.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/RenderTarget.h>
#include <openrct2/drawing/Text.h>
@@ -15,6 +15,7 @@
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Line.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/RenderTarget.h>
#include <openrct2/drawing/Text.h>
+8 -7
View File
@@ -12,6 +12,7 @@
#include <openrct2-ui/windows/Windows.h>
#include <openrct2/Context.h>
#include <openrct2/core/Guard.hpp>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Font.h>
@@ -76,37 +77,37 @@ namespace OpenRCT2::Ui::Windows
{
case WIDX_TOGGLE_SHOW_WIDE_PATHS:
gPaintWidePathsAsGhost = !gPaintWidePathsAsGhost;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_SHOW_BLOCKED_TILES:
gPaintBlockedTiles = !gPaintBlockedTiles;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS:
gShowSupportSegmentHeights = !gShowSupportSegmentHeights;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_SHOW_BOUND_BOXES:
gPaintBoundingBoxes = !gPaintBoundingBoxes;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_SHOW_DIRTY_VISUALS:
gShowDirtyVisuals = !gShowDirtyVisuals;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_STABLE_PAINT_SORT:
gPaintStableSort = !gPaintStableSort;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_TOGGLE_FORCE_REDRAW:
gPaintForceRedraw = !gPaintForceRedraw;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
}
}
@@ -26,6 +26,7 @@
#include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Palette.h>
#include <openrct2/drawing/Rectangle.h>
@@ -487,7 +488,7 @@ namespace OpenRCT2::Ui::Windows
{
objectManager.UnloadObjects({ descriptor });
objectManager.LoadObject(descriptor, entryIndex);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
break;
@@ -18,6 +18,7 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/SpriteIds.h>
#include <openrct2/actions/ResultWithMessage.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/Text.h>
+2 -1
View File
@@ -19,6 +19,7 @@
#include <openrct2/core/FileSystem.hpp>
#include <openrct2/core/UnitConversion.h>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/localisation/Formatter.h>
@@ -330,7 +331,7 @@ namespace OpenRCT2::Ui::Windows
}
MapGenerator::generate(&mapgenSettings);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
#pragma region Base page
+1
View File
@@ -29,6 +29,7 @@
#include <openrct2/config/Config.h>
#include <openrct2/core/EnumUtils.hpp>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/IDrawingEngine.h>
+4 -3
View File
@@ -19,6 +19,7 @@
#include <openrct2/actions/GameActionRunner.h>
#include <openrct2/actions/peep/StaffSetPatrolAreaAction.h>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/entity/EntityRegistry.h>
@@ -191,7 +192,7 @@ namespace OpenRCT2::Ui::Windows
{
HideGridlines();
ClearPatrolAreaToRender();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void onToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
@@ -241,7 +242,7 @@ namespace OpenRCT2::Ui::Windows
if (PatrolAreaToolIsActive())
{
SetPatrolAreaToRender(_staffId);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
else
{
@@ -249,7 +250,7 @@ namespace OpenRCT2::Ui::Windows
{
ShowGridlines();
SetPatrolAreaToRender(_staffId);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
}
+1
View File
@@ -41,6 +41,7 @@
#include <openrct2/core/String.hpp>
#include <openrct2/core/UnitConversion.h>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.Sprite.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
@@ -25,6 +25,7 @@
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Line.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/RenderTarget.h>
#include <openrct2/drawing/Text.h>
+1
View File
@@ -26,6 +26,7 @@
#include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/drawing/RenderTarget.h>
+1
View File
@@ -16,6 +16,7 @@
#include <openrct2/Context.h>
#include <openrct2/SpriteIds.h>
#include <openrct2/drawing/ColourMap.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Rectangle.h>
+4 -5
View File
@@ -14,7 +14,6 @@
#include <openrct2/Context.h>
#include <openrct2/Input.h>
#include <openrct2/drawing/Drawing.String.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Font.h>
#include <openrct2/drawing/Rectangle.h>
#include <openrct2/localisation/Formatter.h>
@@ -125,10 +124,10 @@ namespace OpenRCT2::Ui::Windows
Rectangle::filter(rt, { { left + 2, top + 0 }, { right - 2, top + 0 } }, FilterPaletteID::paletteDarken3);
// Corners
GfxFilterPixel(rt, { left + 1, top + 1 }, FilterPaletteID::paletteDarken3);
GfxFilterPixel(rt, { right - 1, top + 1 }, FilterPaletteID::paletteDarken3);
GfxFilterPixel(rt, { left + 1, bottom - 1 }, FilterPaletteID::paletteDarken3);
GfxFilterPixel(rt, { right - 1, bottom - 1 }, FilterPaletteID::paletteDarken3);
Rectangle::filterPixel(rt, { left + 1, top + 1 }, FilterPaletteID::paletteDarken3);
Rectangle::filterPixel(rt, { right - 1, top + 1 }, FilterPaletteID::paletteDarken3);
Rectangle::filterPixel(rt, { left + 1, bottom - 1 }, FilterPaletteID::paletteDarken3);
Rectangle::filterPixel(rt, { right - 1, bottom - 1 }, FilterPaletteID::paletteDarken3);
// Text
left = windowPos.x + ((width + 1) / 2) - 1;
+4 -3
View File
@@ -12,6 +12,7 @@
#include <openrct2-ui/interface/Window.h>
#include <openrct2-ui/windows/Windows.h>
#include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.Screen.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/interface/Viewport.h>
@@ -128,7 +129,7 @@ namespace OpenRCT2::Ui::Windows
_previousClipSelectionB = gClipSelectionB;
gClipSelectionA = { 0, 0 };
gClipSelectionB = { kMaximumMapSizeBig - 1, kMaximumMapSizeBig - 1 };
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_CLIP_CLEAR:
if (IsActive())
@@ -138,7 +139,7 @@ namespace OpenRCT2::Ui::Windows
}
gClipSelectionA = { 0, 0 };
gClipSelectionB = { kMaximumMapSizeBig - 1, kMaximumMapSizeBig - 1 };
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case WIDX_CLIP_SEE_THROUGH_CHECKBOX_ENABLE:
{
@@ -263,7 +264,7 @@ namespace OpenRCT2::Ui::Windows
gClipSelectionB = gMapSelectPositionB;
_toolActive = false;
ToolCancel();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void onPrepareDraw() override
@@ -17,7 +17,7 @@
#include "../../core/EnumUtils.hpp"
#include "../../core/Guard.hpp"
#include "../../drawing/Colour.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/Duck.h"
#include "../../entity/EntityList.h"
#include "../../entity/EntityRegistry.h"
@@ -457,7 +457,7 @@ namespace OpenRCT2::GameActions
}
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void CheatSetAction::WaterPlants() const
@@ -473,7 +473,7 @@ namespace OpenRCT2::GameActions
}
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void CheatSetAction::FixVandalism() const
@@ -492,7 +492,7 @@ namespace OpenRCT2::GameActions
it.element->asPath()->setIsBroken(false);
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void CheatSetAction::RemoveLitter(GameState_t& gameState) const
@@ -519,7 +519,7 @@ namespace OpenRCT2::GameActions
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void CheatSetAction::FixBrokenRides(GameState_t& gameState) const
@@ -766,7 +766,7 @@ namespace OpenRCT2::GameActions
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::ride);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void CheatSetAction::SetStaffSpeed(uint8_t value) const
@@ -855,6 +855,6 @@ namespace OpenRCT2::GameActions
}
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
} // namespace OpenRCT2::GameActions
@@ -11,7 +11,7 @@
#include "../../Context.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../scripting/ScriptEngine.h"
#include "../../ui/UiContext.h"
#include "../../ui/WindowManager.h"
@@ -88,7 +88,7 @@ namespace OpenRCT2::GameActions
Park::UpdateSize(park);
windowManager->BroadcastIntent(Intent(INTENT_ACTION_MAP));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
auto& hookEngine = ctx->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::mapResize))
@@ -10,7 +10,7 @@
#include "ParkSetNameAction.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../world/Park.h"
#include "../../world/ParkData.h"
@@ -54,7 +54,7 @@ namespace OpenRCT2::GameActions
{
park.name = _name;
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
return Result();
}
@@ -12,7 +12,7 @@
#include "../../Context.h"
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/EntityRegistry.h"
#include "../../localisation/StringIds.h"
#include "../../windows/Intent.h"
@@ -93,7 +93,7 @@ namespace OpenRCT2::GameActions
// Easter egg functions are for guests only
guest->handleEasterEggName();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
auto intent = Intent(INTENT_ACTION_REFRESH_GUEST_LIST);
ContextBroadcastIntent(&intent);
@@ -11,7 +11,7 @@
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/EntityRegistry.h"
#include "../../entity/Staff.h"
#include "../../ui/WindowManager.h"
@@ -80,7 +80,7 @@ namespace OpenRCT2::GameActions
PeepEntityRemove(staff);
// Due to patrol areas best to invalidate the whole screen on removal of staff
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return Result();
}
@@ -10,7 +10,7 @@
#include "StaffSetColourAction.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/EntityList.h"
#include "../../entity/Staff.h"
#include "../../localisation/StringIds.h"
@@ -70,7 +70,7 @@ namespace OpenRCT2::GameActions
}
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return Result();
}
} // namespace OpenRCT2::GameActions
@@ -12,7 +12,7 @@
#include "../../Context.h"
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/EntityRegistry.h"
#include "../../entity/Staff.h"
#include "../../localisation/StringIds.h"
@@ -82,7 +82,7 @@ namespace OpenRCT2::GameActions
return Result(Status::unknown, STR_CANT_NAME_GUEST, kStringIdNone);
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
auto intent = Intent(INTENT_ACTION_REFRESH_STAFF_LIST);
ContextBroadcastIntent(&intent);
@@ -11,7 +11,7 @@
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../entity/EntityRegistry.h"
#include "../../entity/PatrolArea.h"
#include "../../entity/Staff.h"
@@ -99,7 +99,7 @@ namespace OpenRCT2::GameActions
break;
case StaffSetPatrolAreaMode::clearAll:
staff->clearPatrolArea();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
}
UpdateConsolidatedPatrolAreas();
@@ -13,7 +13,7 @@
#include "../../Diagnostic.h"
#include "../../Game.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/ScrollingText.h"
#include "../../entity/EntityList.h"
#include "../../management/NewsItem.h"
@@ -170,7 +170,7 @@ namespace OpenRCT2::GameActions
windowMgr->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST));
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return res;
}
@@ -10,7 +10,7 @@
#include "RideSetAppearanceAction.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../localisation/StringIds.h"
#include "../../ride/Ride.h"
#include "../../ui/WindowManager.h"
@@ -100,15 +100,15 @@ namespace OpenRCT2::GameActions
{
case RideSetAppearanceType::trackColourMain:
ride->trackColours[_index].main = static_cast<Drawing::Colour>(_value);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case RideSetAppearanceType::trackColourAdditional:
ride->trackColours[_index].additional = static_cast<Drawing::Colour>(_value);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case RideSetAppearanceType::trackColourSupports:
ride->trackColours[_index].supports = static_cast<Drawing::Colour>(_value);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case RideSetAppearanceType::vehicleColourBody:
ride->vehicleColours[_index].Body = static_cast<Drawing::Colour>(_value);
@@ -132,7 +132,7 @@ namespace OpenRCT2::GameActions
break;
case RideSetAppearanceType::entranceStyle:
ride->entranceStyle = _value;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
case RideSetAppearanceType::sellingItemColourIsRandom:
ride->flags.set(RideFlag::randomShopColours, static_cast<bool>(_value));
@@ -10,7 +10,7 @@
#include "RideSetNameAction.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/ScrollingText.h"
#include "../../localisation/StringIds.h"
#include "../../ride/Ride.h"
@@ -79,7 +79,7 @@ namespace OpenRCT2::GameActions
}
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
// Refresh windows that display ride name
auto windowManager = Ui::GetWindowManager();
@@ -12,7 +12,7 @@
#include "../../Context.h"
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../object/MusicObject.h"
#include "../../object/ObjectManager.h"
#include "../../ride/Ride.h"
@@ -237,7 +237,7 @@ namespace OpenRCT2::GameActions
case RideSetSetting::rideType:
ride->type = _value;
ride->updateRideTypeForAllPieces();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
break;
}
@@ -14,7 +14,7 @@
#include "../../Diagnostic.h"
#include "../../GameState.h"
#include "../../core/EnumUtils.hpp"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../localisation/StringIds.h"
#include "../../management/Research.h"
#include "../../object/ObjectManager.h"
@@ -222,7 +222,7 @@ namespace OpenRCT2::GameActions
intent.PutExtra(INTENT_EXTRA_RIDE_ID, _rideIndex.ToUnderlying());
ContextBroadcastIntent(&intent);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return res;
}
@@ -11,7 +11,7 @@
#include "../../Context.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/ScrollingText.h"
#include "../../localisation/StringIds.h"
#include "../../windows/Intent.h"
@@ -93,7 +93,7 @@ namespace OpenRCT2::GameActions
ContextBroadcastIntent(&intent);
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return Result();
}
@@ -11,7 +11,7 @@
#include "../../Context.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/ScrollingText.h"
#include "../../localisation/StringIdType.h"
#include "../../management/Finance.h"
@@ -179,7 +179,7 @@ namespace OpenRCT2::GameActions
ContextBroadcastIntent(&intent);
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return res;
}
@@ -10,7 +10,7 @@
#include "SignSetNameAction.h"
#include "../../Diagnostic.h"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/ScrollingText.h"
#include "../../localisation/StringIds.h"
#include "../../world/Banner.h"
@@ -108,7 +108,7 @@ namespace OpenRCT2::GameActions
}
Drawing::ScrollingText::invalidate();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return Result();
}
} // namespace OpenRCT2::GameActions
+43
View File
@@ -0,0 +1,43 @@
/*****************************************************************************
* Copyright (c) 2014-2026 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 "Drawing.Screen.h"
#include "../Context.h"
#include "../config/Config.h"
#include "../interface/ScreenCoords.hpp"
#include "NewDrawing.h"
#include "Palette.h"
namespace OpenRCT2::Drawing
{
/**
*
* rct2: 0x006ED7E5
*/
void GfxInvalidateScreen()
{
GfxSetDirtyBlocks({ { 0, 0 }, { ContextGetWidth(), ContextGetHeight() } });
}
void RefreshVideo()
{
ContextRecreateWindow();
DrawingEngineSetPalette(gPalette);
GfxInvalidateScreen();
}
void ToggleWindowedMode()
{
int32_t rt = Config::Get().general.fullscreenMode == 0 ? 2 : 0;
ContextSetFullscreenMode(rt);
Config::Get().general.fullscreenMode = rt;
Config::Save();
}
} // namespace OpenRCT2::Drawing
+17
View File
@@ -0,0 +1,17 @@
/*****************************************************************************
* Copyright (c) 2014-2026 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.
*****************************************************************************/
#pragma once
namespace OpenRCT2::Drawing
{
void GfxInvalidateScreen();
void RefreshVideo();
void ToggleWindowedMode();
} // namespace OpenRCT2::Drawing
+1 -61
View File
@@ -9,24 +9,19 @@
#include "Drawing.h"
#include "../Context.h"
#include "../Game.h"
#include "../GameState.h"
#include "../SpriteIds.h"
#include "../config/Config.h"
#include "../interface/ScreenCoords.hpp"
#include "Drawing.Sprite.h"
#include "FilterPaletteIds.h"
#include "Font.h"
#include "NewDrawing.h"
#include "Palette.h"
#include "Line.h"
#include "Rectangle.h"
#include "RenderTarget.h"
#include "Text.h"
#include <array>
#include <cassert>
#include <cstring>
using namespace OpenRCT2;
using namespace OpenRCT2::Drawing;
@@ -379,46 +374,6 @@ const TranslucentWindowPalette kTranslucentWindowPalettes[kColourNumTotal] = {
};
// clang-format on
ImageCatalogue ImageId::GetCatalogue() const
{
auto index = GetIndex();
if (index >= SPR_TEMP_BEGIN && index < SPR_TEMP_END)
{
return ImageCatalogue::temporary;
}
if (index < SPR_RCTC_G1_END)
{
return ImageCatalogue::g1;
}
if (index < SPR_G2_END)
{
return ImageCatalogue::g2;
}
if (index < SPR_CSG_END)
{
return ImageCatalogue::csg;
}
if (index < SPR_IMAGE_LIST_END)
{
return ImageCatalogue::object;
}
return ImageCatalogue::unknown;
}
void GfxFilterPixel(RenderTarget& rt, const ScreenCoordsXY& coords, FilterPaletteID palette)
{
Rectangle::filter(rt, { coords, coords }, palette);
}
/**
*
* rct2: 0x006ED7E5
*/
void GfxInvalidateScreen()
{
GfxSetDirtyBlocks({ { 0, 0 }, { ContextGetWidth(), ContextGetHeight() } });
}
/*
*
* rct2: 0x006EE53B
@@ -506,21 +461,6 @@ FilterPaletteID GetGlassPaletteId(Colour c)
return kGlassPaletteIds[EnumValue(c)];
}
void RefreshVideo()
{
ContextRecreateWindow();
DrawingEngineSetPalette(Drawing::gPalette);
GfxInvalidateScreen();
}
void ToggleWindowedMode()
{
int32_t rt = Config::Get().general.fullscreenMode == 0 ? 2 : 0;
ContextSetFullscreenMode(rt);
Config::Get().general.fullscreenMode = rt;
Config::Save();
}
void DebugRT(RenderTarget& rt)
{
ScreenCoordsXY topLeft = { rt.x, rt.y };
-14
View File
@@ -48,20 +48,9 @@ extern bool gPaintForceRedraw;
bool ClipRenderTarget(
OpenRCT2::Drawing::RenderTarget& dst, OpenRCT2::Drawing::RenderTarget& src, const ScreenCoordsXY& coords, int32_t width,
int32_t height);
void GfxSetDirtyBlocks(const ScreenRect& rect);
void GfxInvalidateScreen();
// other
void GfxClear(OpenRCT2::Drawing::RenderTarget& rt, OpenRCT2::Drawing::PaletteIndex paletteIndex);
void GfxFilterPixel(
OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, OpenRCT2::Drawing::FilterPaletteID palette);
// line
void GfxDrawLine(OpenRCT2::Drawing::RenderTarget& rt, const ScreenLine& line, OpenRCT2::Drawing::PaletteIndex colour);
void GfxDrawLineSoftware(OpenRCT2::Drawing::RenderTarget& rt, const ScreenLine& line, OpenRCT2::Drawing::PaletteIndex colour);
void GfxDrawDashedLine(
OpenRCT2::Drawing::RenderTarget& rt, const ScreenLine& screenLine, int32_t dashedLineSegmentLength,
OpenRCT2::Drawing::PaletteIndex colour);
// sprite (NewDrawing.cpp functions that use the drawing engine)
void FASTCALL GfxDrawSprite(OpenRCT2::Drawing::RenderTarget& rt, ImageId image_id, const ScreenCoordsXY& coords);
@@ -76,7 +65,4 @@ void FASTCALL GfxDrawSpriteRawMasked(
std::optional<uint32_t> GetPaletteG1Index(OpenRCT2::Drawing::FilterPaletteID paletteId);
std::optional<OpenRCT2::Drawing::PaletteMap> GetPaletteMapForColour(OpenRCT2::Drawing::FilterPaletteID paletteId);
void RefreshVideo();
void ToggleWindowedMode();
void DebugRT(OpenRCT2::Drawing::RenderTarget& rt);
+38
View File
@@ -0,0 +1,38 @@
/*****************************************************************************
* Copyright (c) 2014-2026 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 "ImageId.hpp"
#include "../SpriteIds.h"
ImageCatalogue ImageId::GetCatalogue() const
{
auto index = GetIndex();
if (index >= SPR_TEMP_BEGIN && index < SPR_TEMP_END)
{
return ImageCatalogue::temporary;
}
if (index < SPR_RCTC_G1_END)
{
return ImageCatalogue::g1;
}
if (index < SPR_G2_END)
{
return ImageCatalogue::g2;
}
if (index < SPR_CSG_END)
{
return ImageCatalogue::csg;
}
if (index < SPR_IMAGE_LIST_END)
{
return ImageCatalogue::object;
}
return ImageCatalogue::unknown;
}
+185 -136
View File
@@ -7,164 +7,213 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "Line.h"
#include "../interface/ScreenCoords.hpp"
#include "Drawing.h"
#include "IDrawingContext.h"
#include "IDrawingEngine.h"
#include "RenderTarget.h"
#include <cmath>
using namespace OpenRCT2::Drawing;
/**
* Draws a horizontal line of specified colour to a buffer.
* rct2: 0x0068474C
*/
static void GfxDrawLineOnBuffer(RenderTarget& rt, PaletteIndex colour, const ScreenCoordsXY& coords, int32_t no_pixels)
namespace OpenRCT2::Drawing
{
ScreenCoordsXY offset{ coords.x - rt.x, coords.y - rt.y };
const int32_t width = rt.width;
const int32_t height = rt.height;
// Check to make sure point is in the y range
if (offset.y < 0)
return;
if (offset.y >= height)
return;
// Check to make sure we are drawing at least a pixel
if (!no_pixels)
no_pixels++;
// If x coord outside range leave
if (offset.x < 0)
/**
* Draws a horizontal line of specified colour to a buffer.
* rct2: 0x0068474C
*/
static void GfxDrawLineOnBuffer(RenderTarget& rt, PaletteIndex colour, const ScreenCoordsXY& coords, int32_t no_pixels)
{
// Unless the number of pixels is enough to be in range
no_pixels += offset.x;
if (no_pixels <= 0)
ScreenCoordsXY offset{ coords.x - rt.x, coords.y - rt.y };
const int32_t width = rt.width;
const int32_t height = rt.height;
// Check to make sure point is in the y range
if (offset.y < 0)
return;
// Resets starting point to 0 as we don't draw outside the range
offset.x = 0;
}
// Ensure that the end point of the line is within range
if (offset.x + no_pixels - width > 0)
{
// If the end point has any pixels outside range
// cut them off. If there are now no pixels return.
no_pixels -= offset.x + no_pixels - width;
if (no_pixels <= 0)
if (offset.y >= height)
return;
// Check to make sure we are drawing at least a pixel
if (!no_pixels)
no_pixels++;
// If x coord outside range leave
if (offset.x < 0)
{
// Unless the number of pixels is enough to be in range
no_pixels += offset.x;
if (no_pixels <= 0)
return;
// Resets starting point to 0 as we don't draw outside the range
offset.x = 0;
}
// Ensure that the end point of the line is within range
if (offset.x + no_pixels - width > 0)
{
// If the end point has any pixels outside range
// cut them off. If there are now no pixels return.
no_pixels -= offset.x + no_pixels - width;
if (no_pixels <= 0)
return;
}
// Get the buffer we are drawing to and move to the first coordinate.
PaletteIndex* bits_pointer = reinterpret_cast<PaletteIndex*>(rt.bits + offset.y * rt.LineStride() + offset.x);
// Draw the line to the specified colour
for (; no_pixels > 0; --no_pixels, ++bits_pointer)
{
*bits_pointer = colour;
}
}
// Get the buffer we are drawing to and move to the first coordinate.
PaletteIndex* bits_pointer = reinterpret_cast<PaletteIndex*>(rt.bits + offset.y * rt.LineStride() + offset.x);
/**
* Draws a line on rt if within rt boundaries
* rct2: 0x00684466
* rt (edi)
* x1 (ax)
* y1 (bx)
* x2 (cx)
* y2 (dx)
* colour (ebp)
*/
// Draw the line to the specified colour
for (; no_pixels > 0; --no_pixels, ++bits_pointer)
void GfxDrawLineSoftware(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour)
{
*bits_pointer = colour;
}
}
const ZoomLevel zoom = rt.zoom_level;
int32_t x1 = zoom.ApplyInversedTo(line.GetX1());
int32_t x2 = zoom.ApplyInversedTo(line.GetX2());
int32_t y1 = zoom.ApplyInversedTo(line.GetY1());
int32_t y2 = zoom.ApplyInversedTo(line.GetY2());
// Check to make sure the line is within the drawing area
if ((x1 < rt.x) && (x2 < rt.x))
{
return;
}
/**
* Draws a line on rt if within rt boundaries
* rct2: 0x00684466
* rt (edi)
* x1 (ax)
* y1 (bx)
* x2 (cx)
* y2 (dx)
* colour (ebp)
*/
if ((y1 < rt.y) && (y2 < rt.y))
{
return;
}
void GfxDrawLineSoftware(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour)
{
const ZoomLevel zoom = rt.zoom_level;
int32_t x1 = zoom.ApplyInversedTo(line.GetX1());
int32_t x2 = zoom.ApplyInversedTo(line.GetX2());
int32_t y1 = zoom.ApplyInversedTo(line.GetY1());
int32_t y2 = zoom.ApplyInversedTo(line.GetY2());
// Check to make sure the line is within the drawing area
if ((x1 < rt.x) && (x2 < rt.x))
{
return;
}
if ((x1 > (rt.x + rt.width)) && (x2 > (rt.x + rt.width)))
{
return;
}
if ((y1 < rt.y) && (y2 < rt.y))
{
return;
}
if ((y1 > (rt.y + rt.height)) && (y2 > (rt.y + rt.height)))
{
return;
}
if ((x1 > (rt.x + rt.width)) && (x2 > (rt.x + rt.width)))
{
return;
}
// Bresenham's algorithm
if ((y1 > (rt.y + rt.height)) && (y2 > (rt.y + rt.height)))
{
return;
}
// Bresenham's algorithm
// If vertical plot points upwards
int32_t steep = std::abs(y2 - y1) > std::abs(x2 - x1);
if (steep)
{
int32_t temp_y2 = y2;
int32_t temp_x2 = x2;
y2 = x1;
x2 = y1;
y1 = temp_x2;
x1 = temp_y2;
}
// If line is right to left swap direction
if (x1 > x2)
{
int32_t temp_y2 = y2;
int32_t temp_x2 = x2;
y2 = y1;
x2 = x1;
y1 = temp_y2;
x1 = temp_x2;
}
int32_t delta_x = x2 - x1;
int32_t delta_y = std::abs(y2 - y1);
int32_t error = delta_x / 2;
int32_t y_step;
int32_t y = y1;
// Direction of step
if (y1 < y2)
y_step = 1;
else
y_step = -1;
for (int32_t x = x1, x_start = x1, length = 1; x < x2; ++x, ++length)
{
// Vertical lines are drawn 1 pixel at a time
// If vertical plot points upwards
int32_t steep = std::abs(y2 - y1) > std::abs(x2 - x1);
if (steep)
GfxDrawLineOnBuffer(rt, colour, { y, x }, 1);
error -= delta_y;
if (error < 0)
{
// Non vertical lines are drawn with as many pixels in a horizontal line as possible
if (!steep)
GfxDrawLineOnBuffer(rt, colour, { x_start, y }, length);
// Reset non vertical line vars
x_start = x + 1;
length = 0; // NB: will be incremented in next iteration
y += y_step;
error += delta_x;
int32_t temp_y2 = y2;
int32_t temp_x2 = x2;
y2 = x1;
x2 = y1;
y1 = temp_x2;
x1 = temp_y2;
}
// Catch the case of the last line
if (x + 1 == x2 && !steep)
// If line is right to left swap direction
if (x1 > x2)
{
GfxDrawLineOnBuffer(rt, colour, { x_start, y }, length);
int32_t temp_y2 = y2;
int32_t temp_x2 = x2;
y2 = y1;
x2 = x1;
y1 = temp_y2;
x1 = temp_x2;
}
int32_t delta_x = x2 - x1;
int32_t delta_y = std::abs(y2 - y1);
int32_t error = delta_x / 2;
int32_t y_step;
int32_t y = y1;
// Direction of step
if (y1 < y2)
y_step = 1;
else
y_step = -1;
for (int32_t x = x1, x_start = x1, length = 1; x < x2; ++x, ++length)
{
// Vertical lines are drawn 1 pixel at a time
if (steep)
GfxDrawLineOnBuffer(rt, colour, { y, x }, 1);
error -= delta_y;
if (error < 0)
{
// Non vertical lines are drawn with as many pixels in a horizontal line as possible
if (!steep)
GfxDrawLineOnBuffer(rt, colour, { x_start, y }, length);
// Reset non vertical line vars
x_start = x + 1;
length = 0; // NB: will be incremented in next iteration
y += y_step;
error += delta_x;
}
// Catch the case of the last line
if (x + 1 == x2 && !steep)
{
GfxDrawLineOnBuffer(rt, colour, { x_start, y }, length);
}
}
}
}
void GfxDrawLine(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour)
{
auto drawingEngine = rt.DrawingEngine;
if (drawingEngine != nullptr)
{
IDrawingContext* dc = drawingEngine->GetDrawingContext();
dc->DrawLine(rt, colour, line);
}
}
void GfxDrawDashedLine(
RenderTarget& rt, const ScreenLine& screenLine, const int32_t dashedLineSegmentLength, const PaletteIndex colour)
{
assert(dashedLineSegmentLength > 0);
const auto drawingEngine = rt.DrawingEngine;
if (drawingEngine != nullptr)
{
constexpr int32_t kPrecisionFactor = 1000;
const int32_t dashedLineLength = std::hypot(
screenLine.GetX2() - screenLine.GetX1(), screenLine.GetY2() - screenLine.GetY1());
const int32_t lineSegmentCount = dashedLineLength / dashedLineSegmentLength / 2;
if (lineSegmentCount == 0)
{
return;
}
const int32_t lineXDist = std::abs(screenLine.GetX2() - screenLine.GetX1());
const int32_t lineYDist = std::abs(screenLine.GetY2() - screenLine.GetY1());
const int32_t dxPrecise = kPrecisionFactor * lineXDist / lineSegmentCount / 2;
const int32_t dyPrecise = kPrecisionFactor * lineYDist / lineSegmentCount / 2;
IDrawingContext* dc = drawingEngine->GetDrawingContext();
for (int32_t i = 0, x, y; i < lineSegmentCount; ++i)
{
x = screenLine.GetX1() + dxPrecise * i * 2 / kPrecisionFactor;
y = screenLine.GetY1() + dyPrecise * i * 2 / kPrecisionFactor;
dc->DrawLine(rt, colour, { { x, y }, { x + dxPrecise / kPrecisionFactor, y + dyPrecise / kPrecisionFactor } });
}
}
}
} // namespace OpenRCT2::Drawing
+25
View File
@@ -0,0 +1,25 @@
/*****************************************************************************
* Copyright (c) 2014-2026 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.
*****************************************************************************/
#pragma once
#include <cstdint>
struct ScreenLine;
namespace OpenRCT2::Drawing
{
enum class PaletteIndex : uint8_t;
struct RenderTarget;
void GfxDrawLine(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour);
void GfxDrawLineSoftware(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour);
void GfxDrawDashedLine(
RenderTarget& rt, const ScreenLine& screenLine, int32_t dashedLineSegmentLength, PaletteIndex colour);
} // namespace OpenRCT2::Drawing
-43
View File
@@ -163,49 +163,6 @@ void GfxClear(RenderTarget& rt, PaletteIndex paletteIndex)
}
}
void GfxDrawLine(RenderTarget& rt, const ScreenLine& line, PaletteIndex colour)
{
auto drawingEngine = rt.DrawingEngine;
if (drawingEngine != nullptr)
{
IDrawingContext* dc = drawingEngine->GetDrawingContext();
dc->DrawLine(rt, colour, line);
}
}
void GfxDrawDashedLine(
RenderTarget& rt, const ScreenLine& screenLine, const int32_t dashedLineSegmentLength, const PaletteIndex colour)
{
assert(dashedLineSegmentLength > 0);
const auto drawingEngine = rt.DrawingEngine;
if (drawingEngine != nullptr)
{
constexpr int32_t kPrecisionFactor = 1000;
const int32_t dashedLineLength = std::hypot(
screenLine.GetX2() - screenLine.GetX1(), screenLine.GetY2() - screenLine.GetY1());
const int32_t lineSegmentCount = dashedLineLength / dashedLineSegmentLength / 2;
if (lineSegmentCount == 0)
{
return;
}
const int32_t lineXDist = std::abs(screenLine.GetX2() - screenLine.GetX1());
const int32_t lineYDist = std::abs(screenLine.GetY2() - screenLine.GetY1());
const int32_t dxPrecise = kPrecisionFactor * lineXDist / lineSegmentCount / 2;
const int32_t dyPrecise = kPrecisionFactor * lineYDist / lineSegmentCount / 2;
IDrawingContext* dc = drawingEngine->GetDrawingContext();
for (int32_t i = 0, x, y; i < lineSegmentCount; ++i)
{
x = screenLine.GetX1() + dxPrecise * i * 2 / kPrecisionFactor;
y = screenLine.GetY1() + dyPrecise * i * 2 / kPrecisionFactor;
dc->DrawLine(rt, colour, { { x, y }, { x + dxPrecise / kPrecisionFactor, y + dyPrecise / kPrecisionFactor } });
}
}
}
void FASTCALL GfxDrawSprite(RenderTarget& rt, const ImageId imageId, const ScreenCoordsXY& coords)
{
auto drawingEngine = rt.DrawingEngine;
+2
View File
@@ -17,6 +17,7 @@ namespace OpenRCT2::Drawing
}
enum class DrawingEngine : int32_t;
struct ScreenRect;
DrawingEngine drawing_engine_get_type();
bool DrawingEngineRequiresNewWindow(DrawingEngine srcEngine, DrawingEngine dstEngine);
@@ -30,3 +31,4 @@ OpenRCT2::Drawing::RenderTarget& DrawingEngineGetRT();
bool DrawingEngineHasDirtyOptimisations();
void DrawingEngineInvalidateImage(uint32_t image);
void DrawingEngineSetVSync(bool vsync);
void GfxSetDirtyBlocks(const ScreenRect& rect);
+1 -1
View File
@@ -17,8 +17,8 @@
#include "../object/WaterEntry.h"
#include "../util/Util.h"
#include "../world/Weather.h"
#include "Drawing.Screen.h"
#include "Drawing.Sprite.h"
#include "Drawing.h"
#include "FilterPaletteIds.h"
#include "LightFX.h"
#include "NewDrawing.h"
+1
View File
@@ -8,6 +8,7 @@
#include "Drawing.Sprite.h"
#include "Drawing.h"
#include "ImageId.hpp"
#include "NewDrawing.h"
#include "RenderTarget.h"
namespace OpenRCT2::Drawing
+5
View File
@@ -153,4 +153,9 @@ namespace OpenRCT2::Drawing::Rectangle
dc->FilterRect(rt, palette, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
}
}
void filterPixel(RenderTarget& rt, const ScreenCoordsXY& coords, FilterPaletteID palette)
{
filter(rt, { coords, coords }, palette);
}
} // namespace OpenRCT2::Drawing::Rectangle
+2
View File
@@ -11,6 +11,7 @@
#include <cstdint>
struct ScreenCoordsXY;
struct ScreenRect;
namespace OpenRCT2
@@ -51,4 +52,5 @@ namespace OpenRCT2::Drawing::Rectangle
RenderTarget& rt, const ScreenRect& rect, ColourWithFlags colour, BorderStyle borderStyle = BorderStyle::outset,
FillBrightness brightness = FillBrightness::light, FillMode fillMode = FillMode::standard);
void filter(RenderTarget& rt, const ScreenRect& rect, FilterPaletteID palette);
void filterPixel(RenderTarget& rt, const ScreenCoordsXY& coords, FilterPaletteID palette);
} // namespace OpenRCT2::Drawing::Rectangle
+2
View File
@@ -17,12 +17,14 @@
#include "../interface/Window.h"
#include "../scenes/intro/IntroScene.h"
#include "BlendColourMap.h"
#include "Drawing.Screen.h"
#include "Drawing.Sprite.h"
#include "Drawing.String.h"
#include "Drawing.h"
#include "IDrawingEngine.h"
#include "InvalidationGrid.h"
#include "LightFX.h"
#include "Line.h"
#include "TTF.h"
#include "WeatherDrawer.h"
+2 -2
View File
@@ -21,7 +21,7 @@
#include "../core/EnumUtils.hpp"
#include "../core/Guard.hpp"
#include "../core/String.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../drawing/PickupPeep.h"
#include "../entity/Balloon.h"
#include "../entity/EntityList.h"
@@ -2581,7 +2581,7 @@ namespace OpenRCT2
auto intent = Intent(INTENT_ACTION_REFRESH_GUEST_LIST);
ContextBroadcastIntent(&intent);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
void IncrementGuestsInPark()
+1 -1
View File
@@ -15,8 +15,8 @@
#include "../audio/AudioMixer.h"
#include "../core/UTF8.h"
#include "../drawing/Drawing.String.h"
#include "../drawing/Drawing.h"
#include "../drawing/FilterPaletteIds.h"
#include "../drawing/NewDrawing.h"
#include "../drawing/Rectangle.h"
#include "../drawing/Text.h"
#include "../interface/ColourWithFlags.h"
@@ -32,7 +32,7 @@
#include "../core/Guard.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../drawing/Image.h"
#include "../entity/Balloon.h"
#include "../entity/EntityList.h"
@@ -922,7 +922,7 @@ static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& ar
float newScale = static_cast<float>(0.001 * std::trunc(1000 * double_val[0]));
Config::Get().general.windowScale = std::clamp(newScale, 0.5f, 5.0f);
Config::Save();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
ContextTriggerResize();
ContextUpdateCursorScale();
console.Execute("get window_scale");
@@ -1020,7 +1020,7 @@ static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& ar
console.WriteLineError("Invalid variable.");
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
else
{
@@ -1114,7 +1114,7 @@ static void ConsoleCommandLoadObject(InteractiveConsole& console, const argument
ContextBroadcastIntent(&ridesIntent);
gWindowUpdateTicks = 0;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
console.WriteLine("Object file loaded.");
}
+2 -1
View File
@@ -17,6 +17,7 @@
#include "../core/Guard.hpp"
#include "../core/JobPool.h"
#include "../core/Numerics.hpp"
#include "../drawing/Drawing.Screen.h"
#include "../drawing/Drawing.Sprite.h"
#include "../drawing/Drawing.h"
#include "../drawing/IDrawingEngine.h"
@@ -472,7 +473,7 @@ namespace OpenRCT2
}
else
{
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
+2 -2
View File
@@ -15,8 +15,8 @@
#include "../OpenRCT2.h"
#include "../audio/Audio.h"
#include "../config/Config.h"
#include "../drawing/Drawing.Screen.h"
#include "../drawing/Drawing.String.h"
#include "../drawing/Drawing.h"
#include "../drawing/RenderTarget.h"
#include "../entity/EntityRegistry.h"
#include "../ride/RideAudio.h"
@@ -870,7 +870,7 @@ static constexpr float kWindowScrollLocations[][2] = {
WindowResizeGuiCentredWindows(width, height);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
/**
+1 -1
View File
@@ -1,7 +1,7 @@
#include "WindowBase.h"
#include "../config/Config.h"
#include "../drawing/Drawing.h"
#include "../drawing/NewDrawing.h"
#include "Cursors.h"
#include "Viewport.h"
+4
View File
@@ -253,6 +253,7 @@
<ClInclude Include="drawing\Colour.h" />
<ClInclude Include="drawing\ColourMap.h" />
<ClInclude Include="drawing\Drawing.h" />
<ClInclude Include="drawing\Drawing.Screen.h" />
<ClInclude Include="drawing\Drawing.String.h" />
<ClInclude Include="drawing\FilterPaletteIds.h" />
<ClInclude Include="drawing\Font.h" />
@@ -264,6 +265,7 @@
<ClInclude Include="drawing\ImageImporter.h" />
<ClInclude Include="drawing\InvalidationGrid.h" />
<ClInclude Include="drawing\LightFX.h" />
<ClInclude Include="drawing\Line.h" />
<ClInclude Include="drawing\NewDrawing.h" />
<ClInclude Include="drawing\PaletteIndex.h" />
<ClInclude Include="drawing\Palette.h" />
@@ -901,12 +903,14 @@
<ClCompile Include="drawing\Colour.cpp" />
<ClCompile Include="drawing\ColourMap.cpp" />
<ClCompile Include="drawing\Drawing.cpp" />
<ClCompile Include="drawing\Drawing.Screen.cpp" />
<ClCompile Include="drawing\Drawing.Sprite.BMP.cpp" />
<ClCompile Include="drawing\Drawing.Sprite.cpp" />
<ClCompile Include="drawing\Drawing.Sprite.RLE.cpp" />
<ClCompile Include="drawing\Drawing.String.cpp" />
<ClCompile Include="drawing\Font.cpp" />
<ClCompile Include="drawing\Image.cpp" />
<ClCompile Include="drawing\ImageId.cpp" />
<ClCompile Include="drawing\ImageImporter.cpp" />
<ClCompile Include="drawing\InvalidationGrid.cpp" />
<ClCompile Include="drawing\LightFX.cpp" />
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../core/File.h"
#include "../core/Guard.hpp"
#include "../core/Json.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../entity/EntityRegistry.h"
#include "../entity/EntityTweener.h"
#include "../localisation/Formatter.h"
@@ -204,7 +204,7 @@ namespace OpenRCT2::Network
scriptEngine.RemoveNetworkPlugins();
#endif
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
_requireClose = false;
}
+1
View File
@@ -17,6 +17,7 @@
#include "../drawing/Drawing.String.h"
#include "../drawing/Drawing.h"
#include "../drawing/Font.h"
#include "../drawing/Line.h"
#include "../interface/Viewport.h"
#include "../localisation/Currency.h"
#include "../localisation/Formatting.h"
+1
View File
@@ -16,6 +16,7 @@
#include "../drawing/Drawing.String.h"
#include "../drawing/Drawing.h"
#include "../drawing/IDrawingEngine.h"
#include "../drawing/NewDrawing.h"
#include "../drawing/Palette.h"
#include "../drawing/PickupPeep.h"
#include "../drawing/Text.h"
+3 -3
View File
@@ -23,7 +23,7 @@
#include "../core/OrcaStream.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../entity/Balloon.h"
#include "../entity/Duck.h"
#include "../entity/EntityList.h"
@@ -2776,10 +2776,10 @@ int32_t ScenarioSave(GameState_t& gameState, u8string_view path, int32_t flags)
Formatter ft;
ft.Add<const char*>(e.what());
ContextShowError(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_STRING, ft);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
if (result && !(flags & S6_SAVE_FLAG_AUTOMATIC))
{
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../core/EnumUtils.hpp"
#include "../core/Guard.hpp"
#include "../core/Numerics.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../entity/EntityList.h"
#include "../entity/EntityRegistry.h"
#include "../entity/Peep.h"
@@ -4453,7 +4453,7 @@ namespace OpenRCT2
const auto& rtd = ride.getRideTypeDescriptor();
if (rtd.specialType == RtdSpecialType::spaceRings || rtd.flags.has(RtdFlag::vehicleIsIntegral))
{
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
auto& entities = getGameState().entities;
+3 -3
View File
@@ -9,7 +9,7 @@
#include "../Context.h"
#include "../Diagnostic.h"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../interface/Viewport.h"
#include "../localisation/Formatter.h"
#include "../localisation/StringIds.h"
@@ -111,7 +111,7 @@ void TrackDesignSaveSelectNearbyScenery(RideId rideIndex)
}
} while (TileElementIteratorNext(&it));
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
/**
@@ -121,7 +121,7 @@ void TrackDesignSaveSelectNearbyScenery(RideId rideIndex)
void TrackDesignSaveResetScenery()
{
TrackDesignSaveInit();
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
bool TrackDesignSaveContainsTileElement(const TileElement* tileElement)
@@ -16,7 +16,7 @@
#include "../../actions/ResultWithMessage.h"
#include "../../audio/Audio.h"
#include "../../core/EnumUtils.hpp"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/Palette.h"
#include "../../entity/EntityList.h"
#include "../../entity/Guest.h"
@@ -721,7 +721,7 @@ namespace OpenRCT2::Editor
}
gameState.editorStep = Editor::Step::rollerCoasterDesigner;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
else
{
@@ -731,7 +731,7 @@ namespace OpenRCT2::Editor
ContextBroadcastIntent(&intent);
gameState.editorStep = Editor::Step::landscapeEditor;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
+2 -2
View File
@@ -18,7 +18,7 @@
#include "../../audio/Audio.h"
#include "../../config/Config.h"
#include "../../core/Console.hpp"
#include "../../drawing/Drawing.h"
#include "../../drawing/Drawing.Screen.h"
#include "../../drawing/Palette.h"
#include "../../interface/Screenshot.h"
#include "../../interface/Window.h"
@@ -311,7 +311,7 @@ bool TitleScene::TryLoadSequence(bool loadPreview)
Config::Get().interface.currentTitleSequencePreset = configId;
}
_currentSequence = targetSequence;
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return true;
}
targetSequence = (targetSequence + 1) % numSequences;
@@ -14,7 +14,7 @@
#include "../../../Context.h"
#include "../../../GameState.h"
#include "../../../core/EnumMap.hpp"
#include "../../../drawing/Drawing.h"
#include "../../../drawing/Drawing.Screen.h"
#include "../../../ui/WindowManager.h"
#include "../../../windows/Intent.h"
#include "../../../world/Park.h"
@@ -322,7 +322,7 @@ namespace OpenRCT2::Scripting
if (park.name != valueStr)
{
park.name = std::move(valueStr);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
return JS_UNDEFINED;
}
@@ -343,7 +343,7 @@ namespace OpenRCT2::Scripting
const auto flag = kParkFlagMap[key];
auto& gameState = getGameState();
gameState.park.flags.set(flag, value);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
return JS_UNDEFINED;
}
+2 -2
View File
@@ -18,7 +18,7 @@
#include "../audio/AudioChannel.h"
#include "../config/Config.h"
#include "../core/EnumUtils.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/Drawing.Screen.h"
#include "../drawing/FilterPaletteIds.h"
#include "../object/ClimateObject.h"
#include "../object/ObjectManager.h"
@@ -189,7 +189,7 @@ namespace OpenRCT2::Weather
{
gameState.weatherCurrent.weatherGloom = stepWeatherLevel(
gameState.weatherCurrent.weatherGloom, gameState.weatherNext.weatherGloom);
GfxInvalidateScreen();
Drawing::GfxInvalidateScreen();
}
}
else