mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Move Widget, Window, Intent, MouseInput into OpenRCT2 namespace (#23642)
This commit is contained in:
parent
b9f6b6f754
commit
e1fa0b539d
21 changed files with 6070 additions and 6009 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,21 +11,24 @@
|
|||
|
||||
#include <openrct2/interface/Window.h>
|
||||
|
||||
enum class MouseState : uint32_t
|
||||
namespace OpenRCT2
|
||||
{
|
||||
Released,
|
||||
LeftPress,
|
||||
LeftRelease,
|
||||
RightPress,
|
||||
RightRelease
|
||||
};
|
||||
enum class MouseState : uint32_t
|
||||
{
|
||||
Released,
|
||||
LeftPress,
|
||||
LeftRelease,
|
||||
RightPress,
|
||||
RightRelease
|
||||
};
|
||||
|
||||
extern ScreenCoordsXY gInputDragLast;
|
||||
extern ScreenCoordsXY gInputDragLast;
|
||||
|
||||
void InputWindowPositionBegin(WindowBase& w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords);
|
||||
void GameHandleInput();
|
||||
void GameHandleEdgeScroll();
|
||||
void InputWindowPositionBegin(WindowBase& w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords);
|
||||
void GameHandleInput();
|
||||
void GameHandleEdgeScroll();
|
||||
|
||||
void StoreMouseInput(MouseState state, const ScreenCoordsXY& screenCoords);
|
||||
void StoreMouseInput(MouseState state, const ScreenCoordsXY& screenCoords);
|
||||
|
||||
void InputScrollViewport(const ScreenCoordsXY& screenCoords);
|
||||
void InputScrollViewport(const ScreenCoordsXY& screenCoords);
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <openrct2-ui/interface/Window.h>
|
||||
#include <openrct2/object/ObjectTypes.h>
|
||||
|
||||
constexpr uint16_t kLandToolMinimumSize = 1;
|
||||
constexpr uint16_t kLandToolMaximumSize = 64;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,41 +14,44 @@
|
|||
|
||||
struct TextInputSession;
|
||||
|
||||
struct Window : WindowBase
|
||||
namespace OpenRCT2
|
||||
{
|
||||
virtual void OnDraw(DrawPixelInfo& dpi) override;
|
||||
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
||||
struct Window : WindowBase
|
||||
{
|
||||
void OnDraw(DrawPixelInfo& dpi) override;
|
||||
void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
||||
|
||||
void ScrollToViewport();
|
||||
void InitScrollWidgets();
|
||||
void InvalidateWidget(WidgetIndex widgetIndex);
|
||||
bool IsWidgetDisabled(WidgetIndex widgetIndex) const;
|
||||
bool IsWidgetPressed(WidgetIndex widgetIndex) const;
|
||||
void SetWidgetEnabled(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetDisabled(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetDisabledAndInvalidate(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetPressed(WidgetIndex widgetIndex, bool value);
|
||||
void SetCheckboxValue(WidgetIndex widgetIndex, bool value);
|
||||
void DrawWidgets(DrawPixelInfo& dpi);
|
||||
void Close();
|
||||
void CloseOthers();
|
||||
void CloseOthersOfThisClass();
|
||||
CloseWindowModifier GetCloseModifier();
|
||||
void TextInputOpen(
|
||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText,
|
||||
uintptr_t existingArgs, int32_t maxLength);
|
||||
void ScrollToViewport();
|
||||
void InitScrollWidgets();
|
||||
void InvalidateWidget(WidgetIndex widgetIndex);
|
||||
bool IsWidgetDisabled(WidgetIndex widgetIndex) const;
|
||||
bool IsWidgetPressed(WidgetIndex widgetIndex) const;
|
||||
void SetWidgetEnabled(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetDisabled(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetDisabledAndInvalidate(WidgetIndex widgetIndex, bool value);
|
||||
void SetWidgetPressed(WidgetIndex widgetIndex, bool value);
|
||||
void SetCheckboxValue(WidgetIndex widgetIndex, bool value);
|
||||
void DrawWidgets(DrawPixelInfo& dpi);
|
||||
void Close();
|
||||
void CloseOthers();
|
||||
void CloseOthersOfThisClass();
|
||||
CloseWindowModifier GetCloseModifier();
|
||||
void TextInputOpen(
|
||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs,
|
||||
StringId existingText, uintptr_t existingArgs, int32_t maxLength);
|
||||
|
||||
void ResizeFrame();
|
||||
void ResizeFrameWithPage();
|
||||
void ResizeFrame();
|
||||
void ResizeFrameWithPage();
|
||||
|
||||
void ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||
void ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||
};
|
||||
void ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||
void ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||
};
|
||||
|
||||
void WindowAllWheelInput();
|
||||
void ApplyScreenSaverLockSetting();
|
||||
void WindowAlignTabs(WindowBase* w, WidgetIndex start_tab_id, WidgetIndex end_tab_id);
|
||||
ScreenCoordsXY WindowGetViewportSoundIconPos(WindowBase& w);
|
||||
void WindowAllWheelInput();
|
||||
void ApplyScreenSaverLockSetting();
|
||||
void WindowAlignTabs(WindowBase* w, WidgetIndex start_tab_id, WidgetIndex end_tab_id);
|
||||
ScreenCoordsXY WindowGetViewportSoundIconPos(WindowBase& w);
|
||||
} // namespace OpenRCT2
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
|
|
|
@ -830,7 +830,7 @@ std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& po
|
|||
return result;
|
||||
}
|
||||
|
||||
Widget* CustomListView::GetWidget() const
|
||||
OpenRCT2::Widget* CustomListView::GetWidget() const
|
||||
{
|
||||
size_t scrollIndex = 0;
|
||||
for (WidgetIndex widgetIndex = 0; widgetIndex < ParentWindow->widgets.size(); widgetIndex++)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <openrct2-ui/interface/Window.h>
|
||||
#include <openrct2/Identifiers.h>
|
||||
#include <openrct2/world/ScenerySelection.h>
|
||||
#include <string_view>
|
||||
|
||||
struct ObjectEntryDescriptor;
|
||||
|
|
|
@ -25,12 +25,13 @@ enum class CursorID : uint8_t;
|
|||
namespace OpenRCT2
|
||||
{
|
||||
struct IStream;
|
||||
}
|
||||
class Intent;
|
||||
struct WindowBase;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
struct ITrackDesignRepository;
|
||||
struct IGameStateSnapshots;
|
||||
|
||||
class Intent;
|
||||
struct WindowBase;
|
||||
struct NewVersionInfo;
|
||||
|
||||
struct TTFFontDescriptor;
|
||||
|
@ -221,12 +222,12 @@ int32_t ContextGetWidth();
|
|||
int32_t ContextGetHeight();
|
||||
bool ContextHasFocus();
|
||||
void ContextSetCursorTrap(bool value);
|
||||
WindowBase* ContextOpenWindow(WindowClass wc);
|
||||
WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id);
|
||||
WindowBase* ContextOpenWindowView(uint8_t view);
|
||||
WindowBase* ContextShowError(StringId title, StringId message, const class Formatter& args, bool autoClose = false);
|
||||
WindowBase* ContextOpenIntent(Intent* intent);
|
||||
void ContextBroadcastIntent(Intent* intent);
|
||||
OpenRCT2::WindowBase* ContextOpenWindow(WindowClass wc);
|
||||
OpenRCT2::WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id);
|
||||
OpenRCT2::WindowBase* ContextOpenWindowView(uint8_t view);
|
||||
OpenRCT2::WindowBase* ContextShowError(StringId title, StringId message, const class Formatter& args, bool autoClose = false);
|
||||
OpenRCT2::WindowBase* ContextOpenIntent(OpenRCT2::Intent* intent);
|
||||
void ContextBroadcastIntent(OpenRCT2::Intent* intent);
|
||||
void ContextForceCloseWindowByClass(WindowClass wc);
|
||||
void ContextHandleInput();
|
||||
void ContextInputHandleKeyboard(bool isTitle);
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
class Intent;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Intent;
|
||||
}
|
||||
|
||||
struct ParkLoadResult;
|
||||
|
||||
enum class GameCommand : int32_t
|
||||
|
@ -165,7 +169,7 @@ void PauseToggle();
|
|||
bool GameIsPaused();
|
||||
bool GameIsNotPaused();
|
||||
void SaveGame();
|
||||
std::unique_ptr<Intent> CreateSaveGameAsIntent();
|
||||
std::unique_ptr<OpenRCT2::Intent> CreateSaveGameAsIntent();
|
||||
void SaveGameAs();
|
||||
void SaveGameCmd(u8string_view name = {});
|
||||
void SaveGameWithName(u8string_view name);
|
||||
|
|
|
@ -12,65 +12,68 @@
|
|||
#include "Context.h"
|
||||
#include "Game.h"
|
||||
|
||||
InputState _inputState;
|
||||
uint8_t _inputFlags;
|
||||
|
||||
WidgetRef gHoverWidget;
|
||||
WidgetRef gPressedWidget;
|
||||
|
||||
uint32_t _tooltipNotShownTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3B43
|
||||
*/
|
||||
void TitleHandleKeyboardInput()
|
||||
namespace OpenRCT2
|
||||
{
|
||||
ContextInputHandleKeyboard(true);
|
||||
}
|
||||
InputState _inputState;
|
||||
uint8_t _inputFlags;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3B43
|
||||
*/
|
||||
void GameHandleKeyboardInput()
|
||||
{
|
||||
ContextInputHandleKeyboard(false);
|
||||
}
|
||||
WidgetRef gHoverWidget;
|
||||
WidgetRef gPressedWidget;
|
||||
|
||||
void InputSetFlag(INPUT_FLAGS flag, bool on)
|
||||
{
|
||||
if (on)
|
||||
uint32_t _tooltipNotShownTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3B43
|
||||
*/
|
||||
void TitleHandleKeyboardInput()
|
||||
{
|
||||
_inputFlags |= flag;
|
||||
ContextInputHandleKeyboard(true);
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3B43
|
||||
*/
|
||||
void GameHandleKeyboardInput()
|
||||
{
|
||||
_inputFlags &= ~flag;
|
||||
ContextInputHandleKeyboard(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool InputTestFlag(INPUT_FLAGS flag)
|
||||
{
|
||||
return _inputFlags & flag;
|
||||
}
|
||||
void InputSetFlag(INPUT_FLAGS flag, bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_inputFlags |= flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
_inputFlags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
void InputResetFlags()
|
||||
{
|
||||
_inputFlags = 0;
|
||||
}
|
||||
bool InputTestFlag(INPUT_FLAGS flag)
|
||||
{
|
||||
return _inputFlags & flag;
|
||||
}
|
||||
|
||||
void InputSetState(InputState state)
|
||||
{
|
||||
_inputState = state;
|
||||
}
|
||||
void InputResetFlags()
|
||||
{
|
||||
_inputFlags = 0;
|
||||
}
|
||||
|
||||
InputState InputGetState()
|
||||
{
|
||||
return _inputState;
|
||||
}
|
||||
void InputSetState(InputState state)
|
||||
{
|
||||
_inputState = state;
|
||||
}
|
||||
|
||||
void ResetTooltipNotShown()
|
||||
{
|
||||
_tooltipNotShownTimeout = gCurrentRealTimeTicks + 50;
|
||||
}
|
||||
InputState InputGetState()
|
||||
{
|
||||
return _inputState;
|
||||
}
|
||||
|
||||
void ResetTooltipNotShown()
|
||||
{
|
||||
_tooltipNotShownTimeout = gCurrentRealTimeTicks + 50;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -11,65 +11,68 @@
|
|||
|
||||
#include "interface/Window.h"
|
||||
|
||||
enum INPUT_FLAGS
|
||||
namespace OpenRCT2
|
||||
{
|
||||
INPUT_FLAG_WIDGET_PRESSED = (1 << 0),
|
||||
enum INPUT_FLAGS
|
||||
{
|
||||
INPUT_FLAG_WIDGET_PRESSED = (1 << 0),
|
||||
|
||||
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen
|
||||
INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1),
|
||||
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen
|
||||
INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1),
|
||||
|
||||
// The mouse has been released and the dropdown is still open
|
||||
// INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens
|
||||
INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2),
|
||||
// The mouse has been released and the dropdown is still open
|
||||
// INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens
|
||||
INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2),
|
||||
|
||||
INPUT_FLAG_TOOL_ACTIVE = (1 << 3),
|
||||
INPUT_FLAG_TOOL_ACTIVE = (1 << 3),
|
||||
|
||||
// Left click on a viewport
|
||||
INPUT_FLAG_4 = (1 << 4),
|
||||
// Left click on a viewport
|
||||
INPUT_FLAG_4 = (1 << 4),
|
||||
|
||||
INPUT_FLAG_5 = (1 << 5),
|
||||
INPUT_FLAG_5 = (1 << 5),
|
||||
|
||||
// Some of the map tools (clear, footpath, scenery)
|
||||
// never read as far as I know.
|
||||
INPUT_FLAG_6 = (1 << 6),
|
||||
// Some of the map tools (clear, footpath, scenery)
|
||||
// never read as far as I know.
|
||||
INPUT_FLAG_6 = (1 << 6),
|
||||
|
||||
INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7)
|
||||
};
|
||||
INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7)
|
||||
};
|
||||
|
||||
enum class InputState
|
||||
{
|
||||
Reset,
|
||||
Normal,
|
||||
WidgetPressed,
|
||||
PositioningWindow,
|
||||
ViewportRight,
|
||||
DropdownActive,
|
||||
ViewportLeft,
|
||||
ScrollLeft,
|
||||
Resizing,
|
||||
ScrollRight
|
||||
};
|
||||
enum class InputState
|
||||
{
|
||||
Reset,
|
||||
Normal,
|
||||
WidgetPressed,
|
||||
PositioningWindow,
|
||||
ViewportRight,
|
||||
DropdownActive,
|
||||
ViewportLeft,
|
||||
ScrollLeft,
|
||||
Resizing,
|
||||
ScrollRight
|
||||
};
|
||||
|
||||
extern WidgetRef gHoverWidget;
|
||||
extern WidgetRef gPressedWidget;
|
||||
extern WidgetRef gHoverWidget;
|
||||
extern WidgetRef gPressedWidget;
|
||||
|
||||
extern uint32_t gTooltipCloseTimeout;
|
||||
extern WidgetRef gTooltipWidget;
|
||||
extern ScreenCoordsXY gTooltipCursor;
|
||||
extern uint32_t gTooltipCloseTimeout;
|
||||
extern WidgetRef gTooltipWidget;
|
||||
extern ScreenCoordsXY gTooltipCursor;
|
||||
|
||||
// TODO: Move to openrct2-ui and make static again
|
||||
extern InputState _inputState;
|
||||
extern uint8_t _inputFlags;
|
||||
extern uint32_t _tooltipNotShownTimeout;
|
||||
// TODO: Move to openrct2-ui and make static again
|
||||
extern InputState _inputState;
|
||||
extern uint8_t _inputFlags;
|
||||
extern uint32_t _tooltipNotShownTimeout;
|
||||
|
||||
void TitleHandleKeyboardInput();
|
||||
void GameHandleKeyboardInput();
|
||||
void TitleHandleKeyboardInput();
|
||||
void GameHandleKeyboardInput();
|
||||
|
||||
void InputSetFlag(INPUT_FLAGS flag, bool on);
|
||||
bool InputTestFlag(INPUT_FLAGS flag);
|
||||
void InputResetFlags();
|
||||
void InputSetFlag(INPUT_FLAGS flag, bool on);
|
||||
bool InputTestFlag(INPUT_FLAGS flag);
|
||||
void InputResetFlags();
|
||||
|
||||
void InputSetState(InputState state);
|
||||
InputState InputGetState();
|
||||
void InputSetState(InputState state);
|
||||
InputState InputGetState();
|
||||
|
||||
void ResetTooltipNotShown();
|
||||
void ResetTooltipNotShown();
|
||||
} // namespace OpenRCT2
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,54 +20,58 @@ struct PaintSession;
|
|||
struct PaintStruct;
|
||||
struct DrawPixelInfo;
|
||||
struct TileElement;
|
||||
struct WindowBase;
|
||||
struct EntityBase;
|
||||
struct Guest;
|
||||
struct Staff;
|
||||
struct PaintEntry;
|
||||
|
||||
// Flags must currenly retain their values to avoid breaking plugins.
|
||||
// Values can be changed when plugins move to using named constants.
|
||||
enum : uint32_t
|
||||
namespace OpenRCT2
|
||||
{
|
||||
VIEWPORT_FLAG_NONE = 0u,
|
||||
struct WindowBase;
|
||||
|
||||
VIEWPORT_FLAG_GRIDLINES = (1u << 7),
|
||||
VIEWPORT_FLAG_UNDERGROUND_INSIDE = (1u << 0),
|
||||
VIEWPORT_FLAG_HIDE_BASE = (1u << 12),
|
||||
VIEWPORT_FLAG_HIDE_VERTICAL = (1u << 13),
|
||||
// Flags must currenly retain their values to avoid breaking plugins.
|
||||
// Values can be changed when plugins move to using named constants.
|
||||
enum : uint32_t
|
||||
{
|
||||
VIEWPORT_FLAG_NONE = 0u,
|
||||
|
||||
VIEWPORT_FLAG_SOUND_ON = (1u << 10),
|
||||
VIEWPORT_FLAG_LAND_OWNERSHIP = (1u << 8),
|
||||
VIEWPORT_FLAG_CONSTRUCTION_RIGHTS = (1u << 9),
|
||||
VIEWPORT_FLAG_HIDE_ENTITIES = (1u << 14),
|
||||
VIEWPORT_FLAG_CLIP_VIEW = (1u << 17),
|
||||
VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1u << 18),
|
||||
VIEWPORT_FLAG_TRANSPARENT_BACKGROUND = (1u << 19),
|
||||
VIEWPORT_FLAG_GRIDLINES = (1u << 7),
|
||||
VIEWPORT_FLAG_UNDERGROUND_INSIDE = (1u << 0),
|
||||
VIEWPORT_FLAG_HIDE_BASE = (1u << 12),
|
||||
VIEWPORT_FLAG_HIDE_VERTICAL = (1u << 13),
|
||||
|
||||
VIEWPORT_FLAG_LAND_HEIGHTS = (1u << 4),
|
||||
VIEWPORT_FLAG_TRACK_HEIGHTS = (1u << 5),
|
||||
VIEWPORT_FLAG_PATH_HEIGHTS = (1u << 6),
|
||||
VIEWPORT_FLAG_SOUND_ON = (1u << 10),
|
||||
VIEWPORT_FLAG_LAND_OWNERSHIP = (1u << 8),
|
||||
VIEWPORT_FLAG_CONSTRUCTION_RIGHTS = (1u << 9),
|
||||
VIEWPORT_FLAG_HIDE_ENTITIES = (1u << 14),
|
||||
VIEWPORT_FLAG_CLIP_VIEW = (1u << 17),
|
||||
VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1u << 18),
|
||||
VIEWPORT_FLAG_TRANSPARENT_BACKGROUND = (1u << 19),
|
||||
|
||||
VIEWPORT_FLAG_HIDE_RIDES = (1u << 1),
|
||||
VIEWPORT_FLAG_HIDE_VEHICLES = (1u << 20),
|
||||
VIEWPORT_FLAG_HIDE_VEGETATION = (1u << 21),
|
||||
VIEWPORT_FLAG_HIDE_SCENERY = (1u << 2),
|
||||
VIEWPORT_FLAG_HIDE_PATHS = (1u << 16),
|
||||
VIEWPORT_FLAG_HIDE_SUPPORTS = (1u << 3),
|
||||
VIEWPORT_FLAG_HIDE_GUESTS = (1u << 11),
|
||||
VIEWPORT_FLAG_HIDE_STAFF = (1u << 23),
|
||||
VIEWPORT_FLAG_LAND_HEIGHTS = (1u << 4),
|
||||
VIEWPORT_FLAG_TRACK_HEIGHTS = (1u << 5),
|
||||
VIEWPORT_FLAG_PATH_HEIGHTS = (1u << 6),
|
||||
|
||||
VIEWPORT_FLAG_INVISIBLE_RIDES = (1u << 24),
|
||||
VIEWPORT_FLAG_INVISIBLE_VEHICLES = (1u << 25),
|
||||
VIEWPORT_FLAG_INVISIBLE_VEGETATION = (1u << 26),
|
||||
VIEWPORT_FLAG_INVISIBLE_SCENERY = (1u << 27),
|
||||
VIEWPORT_FLAG_INVISIBLE_PATHS = (1u << 28),
|
||||
VIEWPORT_FLAG_INVISIBLE_SUPPORTS = (1u << 29),
|
||||
VIEWPORT_FLAG_HIDE_RIDES = (1u << 1),
|
||||
VIEWPORT_FLAG_HIDE_VEHICLES = (1u << 20),
|
||||
VIEWPORT_FLAG_HIDE_VEGETATION = (1u << 21),
|
||||
VIEWPORT_FLAG_HIDE_SCENERY = (1u << 2),
|
||||
VIEWPORT_FLAG_HIDE_PATHS = (1u << 16),
|
||||
VIEWPORT_FLAG_HIDE_SUPPORTS = (1u << 3),
|
||||
VIEWPORT_FLAG_HIDE_GUESTS = (1u << 11),
|
||||
VIEWPORT_FLAG_HIDE_STAFF = (1u << 23),
|
||||
|
||||
VIEWPORT_FLAG_INDEPEDENT_ROTATION = (1u << 30),
|
||||
VIEWPORT_FLAG_RENDERING_INHIBITED = (1u << 31),
|
||||
};
|
||||
VIEWPORT_FLAG_INVISIBLE_RIDES = (1u << 24),
|
||||
VIEWPORT_FLAG_INVISIBLE_VEHICLES = (1u << 25),
|
||||
VIEWPORT_FLAG_INVISIBLE_VEGETATION = (1u << 26),
|
||||
VIEWPORT_FLAG_INVISIBLE_SCENERY = (1u << 27),
|
||||
VIEWPORT_FLAG_INVISIBLE_PATHS = (1u << 28),
|
||||
VIEWPORT_FLAG_INVISIBLE_SUPPORTS = (1u << 29),
|
||||
|
||||
VIEWPORT_FLAG_INDEPEDENT_ROTATION = (1u << 30),
|
||||
VIEWPORT_FLAG_RENDERING_INHIBITED = (1u << 31),
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
enum class VisibilityKind
|
||||
{
|
||||
|
@ -103,75 +107,78 @@ enum class ViewportVisibility : uint8_t
|
|||
UndergroundViewGhostOff = 5,
|
||||
};
|
||||
|
||||
constexpr uint16_t ViewportInteractionItemAll = std::numeric_limits<uint16_t>::max();
|
||||
|
||||
struct InteractionInfo
|
||||
namespace OpenRCT2
|
||||
{
|
||||
InteractionInfo() = default;
|
||||
InteractionInfo(const PaintStruct* ps);
|
||||
CoordsXY Loc;
|
||||
TileElement* Element{};
|
||||
EntityBase* Entity{};
|
||||
ViewportInteractionItem interactionType = ViewportInteractionItem::None;
|
||||
};
|
||||
constexpr uint16_t ViewportInteractionItemAll = std::numeric_limits<uint16_t>::max();
|
||||
|
||||
constexpr int32_t kMaxViewportCount = kWindowLimitMax;
|
||||
struct InteractionInfo
|
||||
{
|
||||
InteractionInfo() = default;
|
||||
InteractionInfo(const PaintStruct* ps);
|
||||
CoordsXY Loc;
|
||||
TileElement* Element{};
|
||||
EntityBase* Entity{};
|
||||
ViewportInteractionItem interactionType = ViewportInteractionItem::None;
|
||||
};
|
||||
|
||||
/**
|
||||
* A reference counter for whether something is forcing the grid lines to show. When the counter
|
||||
* is decremented to 0, the grid lines are hidden.
|
||||
*/
|
||||
extern uint8_t gShowGridLinesRefCount;
|
||||
extern uint8_t gShowLandRightsRefCount;
|
||||
extern uint8_t gShowConstructionRightsRefCount;
|
||||
constexpr int32_t kMaxViewportCount = kWindowLimitMax;
|
||||
|
||||
// rct2: 0x014234BC
|
||||
extern Viewport* g_music_tracking_viewport;
|
||||
/**
|
||||
* A reference counter for whether something is forcing the grid lines to show. When the counter
|
||||
* is decremented to 0, the grid lines are hidden.
|
||||
*/
|
||||
extern uint8_t gShowGridLinesRefCount;
|
||||
extern uint8_t gShowLandRightsRefCount;
|
||||
extern uint8_t gShowConstructionRightsRefCount;
|
||||
|
||||
void ViewportInitAll();
|
||||
std::optional<ScreenCoordsXY> centre_2d_coordinates(const CoordsXYZ& loc, Viewport* viewport);
|
||||
void ViewportCreate(WindowBase* w, const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, const Focus& focus);
|
||||
void ViewportRemove(Viewport* viewport);
|
||||
// rct2: 0x014234BC
|
||||
extern Viewport* g_music_tracking_viewport;
|
||||
|
||||
void ViewportsInvalidate(int32_t x, int32_t y, int32_t z0, int32_t z1, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const CoordsXYZ& pos, int32_t width, int32_t minHeight, int32_t maxHeight, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const ScreenRect& screenRect, ZoomLevel maxZoom = ZoomLevel{ -1 });
|
||||
void ViewportUpdatePosition(WindowBase* window);
|
||||
void ViewportUpdateSmartFollowGuest(WindowBase* window, const Guest& peep);
|
||||
void ViewportRotateSingle(WindowBase* window, int32_t direction);
|
||||
void ViewportRotateAll(int32_t direction);
|
||||
void ViewportRender(DrawPixelInfo& dpi, const Viewport* viewport);
|
||||
void ViewportInitAll();
|
||||
std::optional<ScreenCoordsXY> centre_2d_coordinates(const CoordsXYZ& loc, Viewport* viewport);
|
||||
void ViewportCreate(WindowBase* w, const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, const Focus& focus);
|
||||
void ViewportRemove(Viewport* viewport);
|
||||
|
||||
CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords, uint8_t rotation);
|
||||
void ViewportsInvalidate(int32_t x, int32_t y, int32_t z0, int32_t z1, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const CoordsXYZ& pos, int32_t width, int32_t minHeight, int32_t maxHeight, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const ScreenRect& screenRect, ZoomLevel maxZoom = ZoomLevel{ -1 });
|
||||
void ViewportUpdatePosition(WindowBase* window);
|
||||
void ViewportUpdateSmartFollowGuest(WindowBase* window, const Guest& peep);
|
||||
void ViewportRotateSingle(WindowBase* window, int32_t direction);
|
||||
void ViewportRotateAll(int32_t direction);
|
||||
void ViewportRender(DrawPixelInfo& dpi, const Viewport* viewport);
|
||||
|
||||
CoordsXY ViewportPosToMapPos(const ScreenCoordsXY& coords, int32_t z, uint8_t rotation);
|
||||
std::optional<CoordsXY> ScreenPosToMapPos(const ScreenCoordsXY& screenCoords, int32_t* direction);
|
||||
CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords, uint8_t rotation);
|
||||
|
||||
void ShowGridlines();
|
||||
void HideGridlines();
|
||||
void ShowLandRights();
|
||||
void HideLandRights();
|
||||
void ShowConstructionRights();
|
||||
void HideConstructionRights();
|
||||
void ViewportSetVisibility(ViewportVisibility mode);
|
||||
CoordsXY ViewportPosToMapPos(const ScreenCoordsXY& coords, int32_t z, uint8_t rotation);
|
||||
std::optional<CoordsXY> ScreenPosToMapPos(const ScreenCoordsXY& screenCoords, int32_t* direction);
|
||||
|
||||
InteractionInfo GetMapCoordinatesFromPos(const ScreenCoordsXY& screenCoords, int32_t flags);
|
||||
InteractionInfo GetMapCoordinatesFromPosWindow(WindowBase* window, const ScreenCoordsXY& screenCoords, int32_t flags);
|
||||
void ShowGridlines();
|
||||
void HideGridlines();
|
||||
void ShowLandRights();
|
||||
void HideLandRights();
|
||||
void ShowConstructionRights();
|
||||
void HideConstructionRights();
|
||||
void ViewportSetVisibility(ViewportVisibility mode);
|
||||
|
||||
InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32_t viewFlags, uint16_t filter);
|
||||
InteractionInfo GetMapCoordinatesFromPos(const ScreenCoordsXY& screenCoords, int32_t flags);
|
||||
InteractionInfo GetMapCoordinatesFromPosWindow(WindowBase* window, const ScreenCoordsXY& screenCoords, int32_t flags);
|
||||
|
||||
std::optional<CoordsXY> ScreenGetMapXY(const ScreenCoordsXY& screenCoords, Viewport** viewport);
|
||||
std::optional<CoordsXY> ScreenGetMapXYWithZ(const ScreenCoordsXY& screenCoords, int32_t z);
|
||||
std::optional<CoordsXY> ScreenGetMapXYQuadrant(const ScreenCoordsXY& screenCoords, uint8_t* quadrant);
|
||||
std::optional<CoordsXY> ScreenGetMapXYQuadrantWithZ(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* quadrant);
|
||||
std::optional<CoordsXY> ScreenGetMapXYSide(const ScreenCoordsXY& screenCoords, uint8_t* side);
|
||||
std::optional<CoordsXY> ScreenGetMapXYSideWithZ(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* side);
|
||||
InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32_t viewFlags, uint16_t filter);
|
||||
|
||||
ScreenCoordsXY Translate3DTo2DWithZ(int32_t rotation, const CoordsXYZ& pos);
|
||||
std::optional<CoordsXY> ScreenGetMapXY(const ScreenCoordsXY& screenCoords, Viewport** viewport);
|
||||
std::optional<CoordsXY> ScreenGetMapXYWithZ(const ScreenCoordsXY& screenCoords, int32_t z);
|
||||
std::optional<CoordsXY> ScreenGetMapXYQuadrant(const ScreenCoordsXY& screenCoords, uint8_t* quadrant);
|
||||
std::optional<CoordsXY> ScreenGetMapXYQuadrantWithZ(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* quadrant);
|
||||
std::optional<CoordsXY> ScreenGetMapXYSide(const ScreenCoordsXY& screenCoords, uint8_t* side);
|
||||
std::optional<CoordsXY> ScreenGetMapXYSideWithZ(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* side);
|
||||
|
||||
uint8_t GetCurrentRotation();
|
||||
int32_t GetHeightMarkerOffset();
|
||||
ScreenCoordsXY Translate3DTo2DWithZ(int32_t rotation, const CoordsXYZ& pos);
|
||||
|
||||
void ViewportSetSavedView();
|
||||
uint8_t GetCurrentRotation();
|
||||
int32_t GetHeightMarkerOffset();
|
||||
|
||||
VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlags);
|
||||
void ViewportSetSavedView();
|
||||
|
||||
VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlags);
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -9,57 +9,156 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../core/StringTypes.h"
|
||||
#include "../drawing/ImageId.hpp"
|
||||
#include "../localisation/StringIdType.h"
|
||||
#include "../world/Location.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct WindowBase;
|
||||
|
||||
using WidgetIndex = uint16_t;
|
||||
|
||||
constexpr WidgetIndex kWidgetIndexNull = 0xFFFF;
|
||||
|
||||
enum class WindowWidgetType : uint8_t
|
||||
namespace OpenRCT2
|
||||
{
|
||||
Empty = 0,
|
||||
Frame = 1,
|
||||
Resize = 2,
|
||||
ImgBtn = 3,
|
||||
ColourBtn = 6,
|
||||
TrnBtn = 7,
|
||||
Tab = 8,
|
||||
FlatBtn = 9,
|
||||
Button = 10,
|
||||
LabelCentred = 12, // Centred text
|
||||
TableHeader = 13, // Left-aligned textual button
|
||||
Label = 14, // Left-aligned text
|
||||
Spinner = 15,
|
||||
DropdownMenu = 16,
|
||||
Viewport = 17,
|
||||
Groupbox = 19,
|
||||
Caption = 20,
|
||||
CloseBox = 21,
|
||||
Scroll = 22,
|
||||
Checkbox = 23,
|
||||
Placeholder = 25,
|
||||
ProgressBar = 29,
|
||||
Custom = 28,
|
||||
TextBox = 27,
|
||||
};
|
||||
using WidgetIndex = uint16_t;
|
||||
constexpr WidgetIndex kWidgetIndexNull = 0xFFFF;
|
||||
|
||||
constexpr uint8_t kCloseButtonWidth = 10;
|
||||
enum class WindowWidgetType : uint8_t
|
||||
{
|
||||
Empty = 0,
|
||||
Frame = 1,
|
||||
Resize = 2,
|
||||
ImgBtn = 3,
|
||||
ColourBtn = 6,
|
||||
TrnBtn = 7,
|
||||
Tab = 8,
|
||||
FlatBtn = 9,
|
||||
Button = 10,
|
||||
LabelCentred = 12, // Centred text
|
||||
TableHeader = 13, // Left-aligned textual button
|
||||
Label = 14, // Left-aligned text
|
||||
Spinner = 15,
|
||||
DropdownMenu = 16,
|
||||
Viewport = 17,
|
||||
Groupbox = 19,
|
||||
Caption = 20,
|
||||
CloseBox = 21,
|
||||
Scroll = 22,
|
||||
Checkbox = 23,
|
||||
Placeholder = 25,
|
||||
ProgressBar = 29,
|
||||
Custom = 28,
|
||||
TextBox = 27,
|
||||
};
|
||||
|
||||
constexpr int32_t kScrollableRowHeight = 12;
|
||||
constexpr uint8_t kListRowHeight = 12;
|
||||
constexpr uint8_t kTableCellHeight = 12;
|
||||
constexpr uint8_t kButtonFaceHeight = 12;
|
||||
constexpr uint8_t kSpinnerHeight = 12;
|
||||
constexpr uint8_t kDropdownHeight = 12;
|
||||
using WidgetFlags = uint32_t;
|
||||
namespace WIDGET_FLAGS
|
||||
{
|
||||
const WidgetFlags TEXT_IS_STRING = 1 << 0;
|
||||
const WidgetFlags IS_PRESSED = 1 << 2;
|
||||
const WidgetFlags IS_DISABLED = 1 << 3;
|
||||
const WidgetFlags TOOLTIP_IS_STRING = 1 << 4;
|
||||
const WidgetFlags IS_HIDDEN = 1 << 5;
|
||||
const WidgetFlags IS_HOLDABLE = 1 << 6;
|
||||
} // namespace WIDGET_FLAGS
|
||||
|
||||
constexpr uint16_t kTextInputSize = 1024;
|
||||
constexpr uint16_t kTopToolbarHeight = 27;
|
||||
enum
|
||||
{
|
||||
SCROLL_HORIZONTAL = (1 << 0),
|
||||
SCROLL_VERTICAL = (1 << 1),
|
||||
SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SCROLL_HORIZONTAL = (1 << 0),
|
||||
SCROLL_VERTICAL = (1 << 1),
|
||||
SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL
|
||||
};
|
||||
struct Widget
|
||||
{
|
||||
WindowWidgetType type{};
|
||||
uint8_t colour{};
|
||||
int16_t left{};
|
||||
int16_t right{};
|
||||
int16_t top{};
|
||||
int16_t bottom{};
|
||||
union
|
||||
{
|
||||
uint32_t content;
|
||||
ImageId image{};
|
||||
StringId text;
|
||||
utf8* string;
|
||||
};
|
||||
StringId tooltip{ STR_NONE };
|
||||
|
||||
// New properties
|
||||
WidgetFlags flags{};
|
||||
utf8* sztooltip{};
|
||||
|
||||
int16_t width() const
|
||||
{
|
||||
return right - left;
|
||||
}
|
||||
|
||||
int16_t height() const
|
||||
{
|
||||
return bottom - top;
|
||||
}
|
||||
|
||||
int16_t midX() const
|
||||
{
|
||||
return (left + right) / 2;
|
||||
}
|
||||
|
||||
int16_t midY() const
|
||||
{
|
||||
return (top + bottom) / 2;
|
||||
}
|
||||
|
||||
int16_t textTop() const
|
||||
{
|
||||
if (height() >= 10)
|
||||
return std::max<int32_t>(top, top + (height() / 2) - 5);
|
||||
|
||||
return top - 1;
|
||||
}
|
||||
|
||||
void moveRight(int32_t amount)
|
||||
{
|
||||
left += amount;
|
||||
right += amount;
|
||||
}
|
||||
|
||||
void moveDown(int32_t amount)
|
||||
{
|
||||
top += amount;
|
||||
bottom += amount;
|
||||
}
|
||||
|
||||
void moveTo(ScreenCoordsXY coords)
|
||||
{
|
||||
moveRight(coords.x - left);
|
||||
moveDown(coords.y - top);
|
||||
}
|
||||
|
||||
void moveToX(int16_t x)
|
||||
{
|
||||
moveRight(x - left);
|
||||
}
|
||||
|
||||
void moveToY(int16_t y)
|
||||
{
|
||||
moveDown(y - top);
|
||||
}
|
||||
|
||||
bool IsVisible() const
|
||||
{
|
||||
return !(flags & OpenRCT2::WIDGET_FLAGS::IS_HIDDEN);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr uint8_t kCloseButtonWidth = 10;
|
||||
|
||||
constexpr int32_t kScrollableRowHeight = 12;
|
||||
constexpr uint8_t kListRowHeight = 12;
|
||||
constexpr uint8_t kTableCellHeight = 12;
|
||||
constexpr uint8_t kButtonFaceHeight = 12;
|
||||
constexpr uint8_t kSpinnerHeight = 12;
|
||||
constexpr uint8_t kDropdownHeight = 12;
|
||||
|
||||
constexpr uint16_t kTextInputSize = 1024;
|
||||
constexpr uint16_t kTopToolbarHeight = 27;
|
||||
} // namespace OpenRCT2
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,303 +11,202 @@
|
|||
|
||||
#include "../Identifiers.h"
|
||||
#include "../core/EnumUtils.hpp"
|
||||
#include "../drawing/ImageId.hpp"
|
||||
#include "../localisation/Formatter.h"
|
||||
#include "../ride/RideTypes.h"
|
||||
#include "../windows/TileInspectorGlobals.h"
|
||||
#include "../world/Location.hpp"
|
||||
#include "../world/ScenerySelection.h"
|
||||
#include "Colour.h"
|
||||
#include "Widget.h"
|
||||
#include "WindowClasses.h"
|
||||
#include "ZoomLevel.h"
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
struct DrawPixelInfo;
|
||||
struct WindowBase;
|
||||
struct TrackDesignFileRef;
|
||||
struct ScenarioIndexEntry;
|
||||
struct WindowCloseModifier;
|
||||
|
||||
enum class VisibilityCache : uint8_t;
|
||||
enum class CursorID : uint8_t;
|
||||
enum class CloseWindowModifier : uint8_t;
|
||||
|
||||
using rct_windownumber = int16_t;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using rct_windownumber = int16_t;
|
||||
|
||||
struct WindowBase;
|
||||
struct WindowCloseModifier;
|
||||
|
||||
enum class RideConstructionState : uint8_t;
|
||||
}
|
||||
|
||||
struct WindowIdentifier
|
||||
{
|
||||
WindowClass classification;
|
||||
rct_windownumber number;
|
||||
};
|
||||
|
||||
struct WidgetIdentifier
|
||||
{
|
||||
WindowIdentifier window;
|
||||
WidgetIndex widget_index;
|
||||
};
|
||||
|
||||
extern WindowCloseModifier gLastCloseModifier;
|
||||
|
||||
using WidgetFlags = uint32_t;
|
||||
namespace OpenRCT2::WIDGET_FLAGS
|
||||
{
|
||||
const WidgetFlags TEXT_IS_STRING = 1 << 0;
|
||||
const WidgetFlags IS_PRESSED = 1 << 2;
|
||||
const WidgetFlags IS_DISABLED = 1 << 3;
|
||||
const WidgetFlags TOOLTIP_IS_STRING = 1 << 4;
|
||||
const WidgetFlags IS_HIDDEN = 1 << 5;
|
||||
const WidgetFlags IS_HOLDABLE = 1 << 6;
|
||||
} // namespace OpenRCT2::WIDGET_FLAGS
|
||||
|
||||
enum class WindowWidgetType : uint8_t;
|
||||
|
||||
struct Widget
|
||||
{
|
||||
WindowWidgetType type{};
|
||||
uint8_t colour{};
|
||||
int16_t left{};
|
||||
int16_t right{};
|
||||
int16_t top{};
|
||||
int16_t bottom{};
|
||||
union
|
||||
struct WindowIdentifier
|
||||
{
|
||||
uint32_t content;
|
||||
ImageId image{};
|
||||
StringId text;
|
||||
utf8* string;
|
||||
WindowClass classification;
|
||||
rct_windownumber number;
|
||||
};
|
||||
StringId tooltip{ STR_NONE };
|
||||
|
||||
// New properties
|
||||
WidgetFlags flags{};
|
||||
utf8* sztooltip{};
|
||||
|
||||
int16_t width() const
|
||||
struct WidgetIdentifier
|
||||
{
|
||||
return right - left;
|
||||
}
|
||||
WindowIdentifier window;
|
||||
WidgetIndex widget_index;
|
||||
};
|
||||
|
||||
int16_t height() const
|
||||
extern WindowCloseModifier gLastCloseModifier;
|
||||
|
||||
/**
|
||||
* Viewport structure
|
||||
*/
|
||||
struct Viewport
|
||||
{
|
||||
return bottom - top;
|
||||
}
|
||||
int32_t width{};
|
||||
int32_t height{};
|
||||
ScreenCoordsXY pos{};
|
||||
ScreenCoordsXY viewPos{};
|
||||
uint32_t flags{};
|
||||
ZoomLevel zoom{};
|
||||
uint8_t rotation{};
|
||||
VisibilityCache visibility{};
|
||||
|
||||
int16_t midX() const
|
||||
{
|
||||
return (left + right) / 2;
|
||||
}
|
||||
|
||||
int16_t midY() const
|
||||
{
|
||||
return (top + bottom) / 2;
|
||||
}
|
||||
|
||||
int16_t textTop() const
|
||||
{
|
||||
if (height() >= 10)
|
||||
return std::max<int32_t>(top, top + (height() / 2) - 5);
|
||||
|
||||
return top - 1;
|
||||
}
|
||||
|
||||
void moveRight(int32_t amount)
|
||||
{
|
||||
left += amount;
|
||||
right += amount;
|
||||
}
|
||||
|
||||
void moveDown(int32_t amount)
|
||||
{
|
||||
top += amount;
|
||||
bottom += amount;
|
||||
}
|
||||
|
||||
void moveTo(ScreenCoordsXY coords)
|
||||
{
|
||||
moveRight(coords.x - left);
|
||||
moveDown(coords.y - top);
|
||||
}
|
||||
|
||||
void moveToX(int16_t x)
|
||||
{
|
||||
moveRight(x - left);
|
||||
}
|
||||
|
||||
void moveToY(int16_t y)
|
||||
{
|
||||
moveDown(y - top);
|
||||
}
|
||||
|
||||
bool IsVisible() const
|
||||
{
|
||||
return !(flags & OpenRCT2::WIDGET_FLAGS::IS_HIDDEN);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Viewport structure
|
||||
*/
|
||||
struct Viewport
|
||||
{
|
||||
int32_t width{};
|
||||
int32_t height{};
|
||||
ScreenCoordsXY pos{};
|
||||
ScreenCoordsXY viewPos{};
|
||||
uint32_t flags{};
|
||||
ZoomLevel zoom{};
|
||||
uint8_t rotation{};
|
||||
VisibilityCache visibility{};
|
||||
|
||||
[[nodiscard]] constexpr int32_t ViewWidth() const
|
||||
{
|
||||
return zoom.ApplyTo(width);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr int32_t ViewHeight() const
|
||||
{
|
||||
return zoom.ApplyTo(height);
|
||||
}
|
||||
|
||||
// Use this function on coordinates that are relative to the viewport zoom i.e. a peeps x, y position after transforming
|
||||
// from its x, y, z
|
||||
[[nodiscard]] constexpr bool Contains(const ScreenCoordsXY& vpos) const
|
||||
{
|
||||
return (
|
||||
vpos.y >= viewPos.y && vpos.y < viewPos.y + ViewHeight() && vpos.x >= viewPos.x
|
||||
&& vpos.x < viewPos.x + ViewWidth());
|
||||
}
|
||||
|
||||
// Use this function on coordinates that are relative to the screen that is been drawn i.e. the cursor position
|
||||
[[nodiscard]] constexpr bool ContainsScreen(const ScreenCoordsXY& sPos) const
|
||||
{
|
||||
return (sPos.x >= pos.x && sPos.x < pos.x + width && sPos.y >= pos.y && sPos.y < pos.y + height);
|
||||
}
|
||||
|
||||
[[nodiscard]] ScreenCoordsXY ScreenToViewportCoord(const ScreenCoordsXY& screenCoord) const;
|
||||
|
||||
void Invalidate() const;
|
||||
};
|
||||
|
||||
struct Focus
|
||||
{
|
||||
using CoordinateFocus = CoordsXYZ;
|
||||
using EntityFocus = EntityId;
|
||||
|
||||
ZoomLevel zoom{};
|
||||
std::variant<CoordinateFocus, EntityFocus> data;
|
||||
|
||||
template<typename T>
|
||||
constexpr explicit Focus(T newValue, ZoomLevel newZoom = {})
|
||||
{
|
||||
data = newValue;
|
||||
zoom = newZoom;
|
||||
}
|
||||
|
||||
CoordsXYZ GetPos() const;
|
||||
|
||||
constexpr bool operator==(const Focus& other) const
|
||||
{
|
||||
if (zoom != other.zoom)
|
||||
[[nodiscard]] constexpr int32_t ViewWidth() const
|
||||
{
|
||||
return false;
|
||||
return zoom.ApplyTo(width);
|
||||
}
|
||||
return data == other.data;
|
||||
}
|
||||
constexpr bool operator!=(const Focus& other) const
|
||||
|
||||
[[nodiscard]] constexpr int32_t ViewHeight() const
|
||||
{
|
||||
return zoom.ApplyTo(height);
|
||||
}
|
||||
|
||||
// Use this function on coordinates that are relative to the viewport zoom i.e. a peeps x, y position after transforming
|
||||
// from its x, y, z
|
||||
[[nodiscard]] constexpr bool Contains(const ScreenCoordsXY& vpos) const
|
||||
{
|
||||
return (
|
||||
vpos.y >= viewPos.y && vpos.y < viewPos.y + ViewHeight() && vpos.x >= viewPos.x
|
||||
&& vpos.x < viewPos.x + ViewWidth());
|
||||
}
|
||||
|
||||
// Use this function on coordinates that are relative to the screen that is been drawn i.e. the cursor position
|
||||
[[nodiscard]] constexpr bool ContainsScreen(const ScreenCoordsXY& sPos) const
|
||||
{
|
||||
return (sPos.x >= pos.x && sPos.x < pos.x + width && sPos.y >= pos.y && sPos.y < pos.y + height);
|
||||
}
|
||||
|
||||
[[nodiscard]] ScreenCoordsXY ScreenToViewportCoord(const ScreenCoordsXY& screenCoord) const;
|
||||
|
||||
void Invalidate() const;
|
||||
};
|
||||
|
||||
struct Focus
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
using CoordinateFocus = CoordsXYZ;
|
||||
using EntityFocus = EntityId;
|
||||
|
||||
struct WindowCloseModifier
|
||||
{
|
||||
WindowIdentifier window;
|
||||
CloseWindowModifier modifier;
|
||||
};
|
||||
ZoomLevel zoom{};
|
||||
std::variant<CoordinateFocus, EntityFocus> data;
|
||||
|
||||
struct WindowBase;
|
||||
template<typename T>
|
||||
constexpr explicit Focus(T newValue, ZoomLevel newZoom = {})
|
||||
{
|
||||
data = newValue;
|
||||
zoom = newZoom;
|
||||
}
|
||||
|
||||
CoordsXYZ GetPos() const;
|
||||
|
||||
constexpr bool operator==(const Focus& other) const
|
||||
{
|
||||
if (zoom != other.zoom)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return data == other.data;
|
||||
}
|
||||
constexpr bool operator!=(const Focus& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
struct WindowCloseModifier
|
||||
{
|
||||
WindowIdentifier window;
|
||||
CloseWindowModifier modifier;
|
||||
};
|
||||
|
||||
struct WindowBase;
|
||||
|
||||
#define RCT_WINDOW_RIGHT(w) ((w)->windowPos.x + (w)->width)
|
||||
#define RCT_WINDOW_BOTTOM(w) ((w)->windowPos.y + (w)->height)
|
||||
|
||||
enum WINDOW_FLAGS
|
||||
{
|
||||
/*
|
||||
WF_TIMEOUT_SHL = 0,
|
||||
WF_TIMEOUT_MASK = 7,
|
||||
WF_DRAGGING = 1 << 3,
|
||||
WF_SCROLLER_UP = 1 << 4,
|
||||
WF_SCROLLER_DOWN = 1 << 5,
|
||||
WF_SCROLLER_MIDDLE = 1 << 6,
|
||||
WF_DISABLE_VP_SCROLL = 1 << 9,
|
||||
*/
|
||||
enum WINDOW_FLAGS
|
||||
{
|
||||
/*
|
||||
WF_TIMEOUT_SHL = 0,
|
||||
WF_TIMEOUT_MASK = 7,
|
||||
WF_DRAGGING = 1 << 3,
|
||||
WF_SCROLLER_UP = 1 << 4,
|
||||
WF_SCROLLER_DOWN = 1 << 5,
|
||||
WF_SCROLLER_MIDDLE = 1 << 6,
|
||||
WF_DISABLE_VP_SCROLL = 1 << 9,
|
||||
*/
|
||||
|
||||
WF_STICK_TO_BACK = (1 << 0),
|
||||
WF_STICK_TO_FRONT = (1 << 1),
|
||||
WF_NO_SCROLLING = (1 << 2), // User is unable to scroll this viewport
|
||||
WF_SCROLLING_TO_LOCATION = (1 << 3),
|
||||
WF_TRANSPARENT = (1 << 4),
|
||||
WF_NO_BACKGROUND = (1 << 5), // Instead of half transparency, completely remove the window background
|
||||
WF_DEAD = (1u << 6), // Window is closed and will be deleted in the next update.
|
||||
WF_7 = (1 << 7),
|
||||
WF_RESIZABLE = (1 << 8),
|
||||
WF_NO_AUTO_CLOSE = (1 << 9), // Don't auto close this window if too many windows are open
|
||||
WF_10 = (1 << 10),
|
||||
WF_WHITE_BORDER_ONE = (1 << 12),
|
||||
WF_WHITE_BORDER_MASK = (1 << 12) | (1 << 13),
|
||||
WF_STICK_TO_BACK = (1 << 0),
|
||||
WF_STICK_TO_FRONT = (1 << 1),
|
||||
WF_NO_SCROLLING = (1 << 2), // User is unable to scroll this viewport
|
||||
WF_SCROLLING_TO_LOCATION = (1 << 3),
|
||||
WF_TRANSPARENT = (1 << 4),
|
||||
WF_NO_BACKGROUND = (1 << 5), // Instead of half transparency, completely remove the window background
|
||||
WF_DEAD = (1u << 6), // Window is closed and will be deleted in the next update.
|
||||
WF_7 = (1 << 7),
|
||||
WF_RESIZABLE = (1 << 8),
|
||||
WF_NO_AUTO_CLOSE = (1 << 9), // Don't auto close this window if too many windows are open
|
||||
WF_10 = (1 << 10),
|
||||
WF_WHITE_BORDER_ONE = (1 << 12),
|
||||
WF_WHITE_BORDER_MASK = (1 << 12) | (1 << 13),
|
||||
|
||||
WF_NO_SNAPPING = (1 << 15),
|
||||
WF_NO_SNAPPING = (1 << 15),
|
||||
|
||||
// Create only flags
|
||||
WF_AUTO_POSITION = (1 << 16),
|
||||
WF_CENTRE_SCREEN = (1 << 17),
|
||||
};
|
||||
// Create only flags
|
||||
WF_AUTO_POSITION = (1 << 16),
|
||||
WF_CENTRE_SCREEN = (1 << 17),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
WV_PARK_AWARDS,
|
||||
WV_PARK_RATING,
|
||||
WV_PARK_OBJECTIVE,
|
||||
WV_PARK_GUESTS,
|
||||
WV_FINANCES_RESEARCH,
|
||||
WV_RIDE_RESEARCH,
|
||||
WV_MAZE_CONSTRUCTION,
|
||||
WV_NETWORK_PASSWORD,
|
||||
WV_EDITOR_BOTTOM_TOOLBAR,
|
||||
WV_CHANGELOG,
|
||||
WV_NEW_VERSION_INFO,
|
||||
WV_FINANCE_MARKETING,
|
||||
WV_CONTRIBUTORS,
|
||||
};
|
||||
enum
|
||||
{
|
||||
WV_PARK_AWARDS,
|
||||
WV_PARK_RATING,
|
||||
WV_PARK_OBJECTIVE,
|
||||
WV_PARK_GUESTS,
|
||||
WV_FINANCES_RESEARCH,
|
||||
WV_RIDE_RESEARCH,
|
||||
WV_MAZE_CONSTRUCTION,
|
||||
WV_NETWORK_PASSWORD,
|
||||
WV_EDITOR_BOTTOM_TOOLBAR,
|
||||
WV_CHANGELOG,
|
||||
WV_NEW_VERSION_INFO,
|
||||
WV_FINANCE_MARKETING,
|
||||
WV_CONTRIBUTORS,
|
||||
};
|
||||
|
||||
enum WindowDetail
|
||||
{
|
||||
WD_BANNER,
|
||||
WD_NEW_CAMPAIGN,
|
||||
WD_DEMOLISH_RIDE,
|
||||
WD_REFURBISH_RIDE,
|
||||
WD_SIGN,
|
||||
WD_SIGN_SMALL,
|
||||
enum WindowDetail
|
||||
{
|
||||
WD_BANNER,
|
||||
WD_NEW_CAMPAIGN,
|
||||
WD_DEMOLISH_RIDE,
|
||||
WD_REFURBISH_RIDE,
|
||||
WD_SIGN,
|
||||
WD_SIGN_SMALL,
|
||||
|
||||
WD_PLAYER,
|
||||
WD_PLAYER,
|
||||
|
||||
WD_VEHICLE,
|
||||
WD_TRACK,
|
||||
WD_VEHICLE,
|
||||
WD_TRACK,
|
||||
|
||||
WD_NULL = 255,
|
||||
};
|
||||
WD_NULL = 255,
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
#define validate_global_widx(wc, widx) \
|
||||
static_assert(widx == wc##__##widx, "Global WIDX of " #widx " doesn't match actual value.")
|
||||
|
@ -444,105 +343,109 @@ enum class Tool
|
|||
Bulldozer = 27,
|
||||
};
|
||||
|
||||
struct WidgetRef
|
||||
namespace OpenRCT2
|
||||
{
|
||||
WindowClass window_classification;
|
||||
rct_windownumber window_number;
|
||||
WidgetIndex widget_index;
|
||||
};
|
||||
struct WidgetRef
|
||||
{
|
||||
WindowClass window_classification;
|
||||
rct_windownumber window_number;
|
||||
WidgetIndex widget_index;
|
||||
};
|
||||
|
||||
extern Tool gCurrentToolId;
|
||||
extern WidgetRef gCurrentToolWidget;
|
||||
extern Tool gCurrentToolId;
|
||||
extern WidgetRef gCurrentToolWidget;
|
||||
|
||||
using modal_callback = void (*)(int32_t result);
|
||||
using CloseCallback = void (*)();
|
||||
using modal_callback = void (*)(int32_t result);
|
||||
using CloseCallback = void (*)();
|
||||
|
||||
constexpr int8_t kWindowLimitMin = 4;
|
||||
constexpr int8_t kWindowLimitMax = 64;
|
||||
constexpr int8_t kWindowLimitReserved = 4; // Used to reserve room for the main viewport, toolbars, etc.
|
||||
constexpr int8_t kWindowLimitMin = 4;
|
||||
constexpr int8_t kWindowLimitMax = 64;
|
||||
constexpr int8_t kWindowLimitReserved = 4; // Used to reserve room for the main viewport, toolbars, etc.
|
||||
|
||||
extern WindowBase* gWindowAudioExclusive;
|
||||
extern WindowBase* gWindowAudioExclusive;
|
||||
|
||||
extern uint32_t gWindowUpdateTicks;
|
||||
extern uint32_t gWindowUpdateTicks;
|
||||
|
||||
extern colour_t gCurrentWindowColours[3];
|
||||
extern colour_t gCurrentWindowColours[3];
|
||||
|
||||
std::list<std::shared_ptr<WindowBase>>::iterator WindowGetIterator(const WindowBase* w);
|
||||
void WindowVisitEach(std::function<void(WindowBase*)> func);
|
||||
std::list<std::shared_ptr<WindowBase>>::iterator WindowGetIterator(const WindowBase* w);
|
||||
void WindowVisitEach(std::function<void(WindowBase*)> func);
|
||||
|
||||
void WindowSetFlagForAllViewports(uint32_t viewportFlag, bool enabled);
|
||||
void WindowSetFlagForAllViewports(uint32_t viewportFlag, bool enabled);
|
||||
|
||||
void WindowDispatchUpdateAll();
|
||||
void WindowUpdateAllViewports();
|
||||
void WindowUpdateAll();
|
||||
void WindowNotifyLanguageChange();
|
||||
void WindowDispatchUpdateAll();
|
||||
void WindowUpdateAllViewports();
|
||||
void WindowUpdateAll();
|
||||
void WindowNotifyLanguageChange();
|
||||
|
||||
void WindowSetWindowLimit(int32_t value);
|
||||
void WindowSetWindowLimit(int32_t value);
|
||||
|
||||
WindowBase* WindowBringToFront(WindowBase& w);
|
||||
WindowBase* WindowBringToFrontByClass(WindowClass cls);
|
||||
WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags);
|
||||
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number);
|
||||
WindowBase* WindowBringToFront(WindowBase& w);
|
||||
WindowBase* WindowBringToFrontByClass(WindowClass cls);
|
||||
WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags);
|
||||
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number);
|
||||
|
||||
void WindowClose(WindowBase& window);
|
||||
void WindowCloseByClass(WindowClass cls);
|
||||
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
|
||||
void WindowCloseByNumber(WindowClass cls, EntityId number);
|
||||
void WindowCloseTop();
|
||||
void WindowCloseAll();
|
||||
void WindowCloseAllExceptClass(WindowClass cls);
|
||||
void WindowCloseAllExceptFlags(uint16_t flags);
|
||||
void WindowCloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls);
|
||||
void WindowInvalidateByClass(WindowClass cls);
|
||||
void WindowInvalidateByNumber(WindowClass cls, rct_windownumber number);
|
||||
void WindowInvalidateByNumber(WindowClass cls, EntityId id);
|
||||
void WindowInvalidateAll();
|
||||
void WidgetInvalidate(WindowBase& w, WidgetIndex widgetIndex);
|
||||
void WidgetInvalidateByClass(WindowClass cls, WidgetIndex widgetIndex);
|
||||
void WidgetInvalidateByNumber(WindowClass cls, rct_windownumber number, WidgetIndex widgetIndex);
|
||||
void WindowClose(WindowBase& window);
|
||||
void WindowCloseByClass(WindowClass cls);
|
||||
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
|
||||
void WindowCloseByNumber(WindowClass cls, EntityId number);
|
||||
void WindowCloseTop();
|
||||
void WindowCloseAll();
|
||||
void WindowCloseAllExceptClass(WindowClass cls);
|
||||
void WindowCloseAllExceptFlags(uint16_t flags);
|
||||
void WindowCloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls);
|
||||
void WindowInvalidateByClass(WindowClass cls);
|
||||
void WindowInvalidateByNumber(WindowClass cls, rct_windownumber number);
|
||||
void WindowInvalidateByNumber(WindowClass cls, EntityId id);
|
||||
void WindowInvalidateAll();
|
||||
void WidgetInvalidate(WindowBase& w, WidgetIndex widgetIndex);
|
||||
void WidgetInvalidateByClass(WindowClass cls, WidgetIndex widgetIndex);
|
||||
void WidgetInvalidateByNumber(WindowClass cls, rct_windownumber number, WidgetIndex widgetIndex);
|
||||
|
||||
int32_t WindowGetScrollDataIndex(const WindowBase& w, WidgetIndex widget_index);
|
||||
int32_t WindowGetScrollDataIndex(const WindowBase& w, WidgetIndex widget_index);
|
||||
|
||||
void WindowPushOthersRight(WindowBase& w);
|
||||
void WindowPushOthersBelow(WindowBase& w1);
|
||||
void WindowPushOthersRight(WindowBase& w);
|
||||
void WindowPushOthersBelow(WindowBase& w1);
|
||||
|
||||
WindowBase* WindowGetMain();
|
||||
WindowBase* WindowGetMain();
|
||||
|
||||
void WindowScrollToLocation(WindowBase& w, const CoordsXYZ& coords);
|
||||
void WindowViewportGetMapCoordsByCursor(
|
||||
const WindowBase& w, int32_t* map_x, int32_t* map_y, int32_t* offset_x, int32_t* offset_y);
|
||||
void WindowViewportCentreTileAroundCursor(WindowBase& w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y);
|
||||
void WindowCheckAllValidZoom();
|
||||
void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor);
|
||||
void WindowScrollToLocation(WindowBase& w, const CoordsXYZ& coords);
|
||||
void WindowViewportGetMapCoordsByCursor(
|
||||
const WindowBase& w, int32_t* map_x, int32_t* map_y, int32_t* offset_x, int32_t* offset_y);
|
||||
void WindowViewportCentreTileAroundCursor(WindowBase& w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y);
|
||||
void WindowCheckAllValidZoom();
|
||||
void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor);
|
||||
|
||||
void WindowDrawAll(DrawPixelInfo& dpi, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
void WindowDraw(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
void WindowDrawAll(DrawPixelInfo& dpi, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
void WindowDraw(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
|
||||
bool isToolActive(WindowClass cls);
|
||||
bool isToolActive(WindowClass cls, rct_windownumber number);
|
||||
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex);
|
||||
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex, rct_windownumber number);
|
||||
bool isToolActive(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool);
|
||||
void ToolCancel();
|
||||
bool isToolActive(WindowClass cls);
|
||||
bool isToolActive(WindowClass cls, rct_windownumber number);
|
||||
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex);
|
||||
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex, rct_windownumber number);
|
||||
bool isToolActive(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool);
|
||||
void ToolCancel();
|
||||
|
||||
void WindowCloseConstructionWindows();
|
||||
void WindowCloseConstructionWindows();
|
||||
|
||||
void WindowUpdateViewportRideMusic();
|
||||
void WindowUpdateViewportRideMusic();
|
||||
|
||||
Viewport* WindowGetViewport(WindowBase* window);
|
||||
Viewport* WindowGetViewport(WindowBase* window);
|
||||
|
||||
// Open window functions
|
||||
void WindowResizeGui(int32_t width, int32_t height);
|
||||
void WindowResizeGuiScenarioEditor(int32_t width, int32_t height);
|
||||
// Open window functions
|
||||
void WindowResizeGui(int32_t width, int32_t height);
|
||||
void WindowResizeGuiScenarioEditor(int32_t width, int32_t height);
|
||||
|
||||
void TextinputCancel();
|
||||
void TextinputCancel();
|
||||
|
||||
bool WindowIsVisible(WindowBase& w);
|
||||
bool WindowIsVisible(WindowBase& w);
|
||||
|
||||
Viewport* WindowGetPreviousViewport(Viewport* current);
|
||||
void WindowResetVisibilities();
|
||||
void WindowInitAll();
|
||||
Viewport* WindowGetPreviousViewport(Viewport* current);
|
||||
void WindowResetVisibilities();
|
||||
void WindowInitAll();
|
||||
|
||||
void WindowFollowSprite(WindowBase& w, EntityId spriteIndex);
|
||||
void WindowUnfollowSprite(WindowBase& w);
|
||||
void WindowFollowSprite(WindowBase& w, EntityId spriteIndex);
|
||||
void WindowUnfollowSprite(WindowBase& w);
|
||||
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -5,33 +5,36 @@
|
|||
#include "Cursors.h"
|
||||
#include "Viewport.h"
|
||||
|
||||
void WindowBase::SetLocation(const CoordsXYZ& coords)
|
||||
namespace OpenRCT2
|
||||
{
|
||||
WindowScrollToLocation(*this, coords);
|
||||
flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
}
|
||||
void WindowBase::SetLocation(const CoordsXYZ& coords)
|
||||
{
|
||||
WindowScrollToLocation(*this, coords);
|
||||
flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
}
|
||||
|
||||
void WindowBase::Invalidate()
|
||||
{
|
||||
GfxSetDirtyBlocks({ windowPos, windowPos + ScreenCoordsXY{ width, height } });
|
||||
}
|
||||
void WindowBase::Invalidate()
|
||||
{
|
||||
GfxSetDirtyBlocks({ windowPos, windowPos + ScreenCoordsXY{ width, height } });
|
||||
}
|
||||
|
||||
void WindowBase::RemoveViewport()
|
||||
{
|
||||
if (viewport == nullptr)
|
||||
return;
|
||||
void WindowBase::RemoveViewport()
|
||||
{
|
||||
if (viewport == nullptr)
|
||||
return;
|
||||
|
||||
ViewportRemove(viewport);
|
||||
viewport = nullptr;
|
||||
}
|
||||
ViewportRemove(viewport);
|
||||
viewport = nullptr;
|
||||
}
|
||||
|
||||
void WindowBase::SetWidgets(const std::span<const Widget> newWidgets)
|
||||
{
|
||||
widgets.clear();
|
||||
widgets.insert(widgets.end(), newWidgets.begin(), newWidgets.end());
|
||||
}
|
||||
void WindowBase::SetWidgets(const std::span<const Widget> newWidgets)
|
||||
{
|
||||
widgets.clear();
|
||||
widgets.insert(widgets.end(), newWidgets.begin(), newWidgets.end());
|
||||
}
|
||||
|
||||
CursorID WindowBase::OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID)
|
||||
{
|
||||
return CursorID::Arrow;
|
||||
}
|
||||
CursorID WindowBase::OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID)
|
||||
{
|
||||
return CursorID::Arrow;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../localisation/Formatter.h"
|
||||
#include "Colour.h"
|
||||
#include "ScrollArea.h"
|
||||
#include "Window.h"
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
enum class TileInspectorPage : int16_t;
|
||||
|
@ -28,155 +30,158 @@ struct RCTObjectEntry;
|
|||
#pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Window structure
|
||||
* size: 0x4C0
|
||||
*/
|
||||
struct WindowBase
|
||||
namespace OpenRCT2
|
||||
{
|
||||
Viewport* viewport{};
|
||||
uint64_t disabled_widgets{};
|
||||
uint64_t pressed_widgets{};
|
||||
uint64_t hold_down_widgets{};
|
||||
std::vector<Widget> widgets{};
|
||||
ScreenCoordsXY windowPos;
|
||||
int16_t width{};
|
||||
int16_t height{};
|
||||
int16_t min_width{};
|
||||
int16_t max_width{};
|
||||
int16_t min_height{};
|
||||
int16_t max_height{};
|
||||
union
|
||||
/**
|
||||
* Window structure
|
||||
* size: 0x4C0
|
||||
*/
|
||||
struct WindowBase
|
||||
{
|
||||
rct_windownumber number{};
|
||||
RideId rideId;
|
||||
Viewport* viewport{};
|
||||
uint64_t disabled_widgets{};
|
||||
uint64_t pressed_widgets{};
|
||||
uint64_t hold_down_widgets{};
|
||||
std::vector<Widget> widgets{};
|
||||
ScreenCoordsXY windowPos;
|
||||
int16_t width{};
|
||||
int16_t height{};
|
||||
int16_t min_width{};
|
||||
int16_t max_width{};
|
||||
int16_t min_height{};
|
||||
int16_t max_height{};
|
||||
union
|
||||
{
|
||||
rct_windownumber number{};
|
||||
RideId rideId;
|
||||
};
|
||||
uint16_t flags{};
|
||||
OpenRCT2::ScrollArea scrolls[3];
|
||||
uint16_t no_list_items{}; // 0 for no items
|
||||
int16_t selected_list_item{}; // -1 for none selected
|
||||
std::optional<Focus> focus;
|
||||
union
|
||||
{
|
||||
int16_t page{};
|
||||
TileInspectorPage tileInspectorPage;
|
||||
};
|
||||
uint16_t frame_no{}; // updated every tic for motion in windows sprites
|
||||
uint16_t list_information_type{}; // 0 for none
|
||||
int16_t picked_peep_frame; // Animation frame of picked peep in staff window and guest window
|
||||
int16_t selected_tab{};
|
||||
EntityId viewport_target_sprite{ EntityId::GetNull() };
|
||||
ScreenCoordsXY savedViewPos{};
|
||||
WindowClass classification{};
|
||||
ColourWithFlags colours[6]{};
|
||||
VisibilityCache visibility{};
|
||||
EntityId viewport_smart_follow_sprite{ EntityId::GetNull() }; // Handles setting viewport target sprite etc
|
||||
|
||||
void SetLocation(const CoordsXYZ& coords);
|
||||
void Invalidate();
|
||||
void RemoveViewport();
|
||||
void SetWidgets(const std::span<const Widget> newWidgets);
|
||||
|
||||
WindowBase() = default;
|
||||
WindowBase(WindowBase&) = delete;
|
||||
virtual ~WindowBase() = default;
|
||||
|
||||
WindowBase& operator=(const WindowBase&) = delete;
|
||||
|
||||
// Events
|
||||
virtual void OnOpen()
|
||||
{
|
||||
}
|
||||
virtual bool CanClose()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual void OnClose()
|
||||
{
|
||||
}
|
||||
virtual void OnResize()
|
||||
{
|
||||
}
|
||||
virtual void OnUpdate()
|
||||
{
|
||||
}
|
||||
virtual void OnPeriodicUpdate()
|
||||
{
|
||||
}
|
||||
virtual void OnPrepareDraw()
|
||||
{
|
||||
}
|
||||
virtual void OnDraw(DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual OpenRCT2String OnTooltip(WidgetIndex widgetIndex, StringId fallback)
|
||||
{
|
||||
return { fallback, {} };
|
||||
}
|
||||
virtual void OnMouseDown(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnMouseUp(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnDropdown(WidgetIndex widgetIndex, int32_t selectedIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnTextInput(WidgetIndex widgetIndex, std::string_view text)
|
||||
{
|
||||
}
|
||||
virtual ScreenSize OnScrollGetSize(int32_t scrollIndex)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual void OnScrollSelect(int32_t scrollIndex, int32_t scrollAreaType)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseDrag(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolUp(WidgetIndex widgetIndex, const ScreenCoordsXY&)
|
||||
{
|
||||
}
|
||||
virtual void OnToolAbort(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnViewportRotate()
|
||||
{
|
||||
}
|
||||
virtual void OnMoved(const ScreenCoordsXY&)
|
||||
{
|
||||
}
|
||||
virtual CursorID OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID);
|
||||
virtual void OnLanguageChange()
|
||||
{
|
||||
}
|
||||
};
|
||||
uint16_t flags{};
|
||||
OpenRCT2::ScrollArea scrolls[3];
|
||||
uint16_t no_list_items{}; // 0 for no items
|
||||
int16_t selected_list_item{}; // -1 for none selected
|
||||
std::optional<Focus> focus;
|
||||
union
|
||||
{
|
||||
int16_t page{};
|
||||
TileInspectorPage tileInspectorPage;
|
||||
};
|
||||
uint16_t frame_no{}; // updated every tic for motion in windows sprites
|
||||
uint16_t list_information_type{}; // 0 for none
|
||||
int16_t picked_peep_frame; // Animation frame of picked peep in staff window and guest window
|
||||
int16_t selected_tab{};
|
||||
EntityId viewport_target_sprite{ EntityId::GetNull() };
|
||||
ScreenCoordsXY savedViewPos{};
|
||||
WindowClass classification{};
|
||||
ColourWithFlags colours[6]{};
|
||||
VisibilityCache visibility{};
|
||||
EntityId viewport_smart_follow_sprite{ EntityId::GetNull() }; // Handles setting viewport target sprite etc
|
||||
|
||||
void SetLocation(const CoordsXYZ& coords);
|
||||
void Invalidate();
|
||||
void RemoveViewport();
|
||||
void SetWidgets(const std::span<const Widget> newWidgets);
|
||||
|
||||
WindowBase() = default;
|
||||
WindowBase(WindowBase&) = delete;
|
||||
virtual ~WindowBase() = default;
|
||||
|
||||
WindowBase& operator=(const WindowBase&) = delete;
|
||||
|
||||
// Events
|
||||
virtual void OnOpen()
|
||||
{
|
||||
}
|
||||
virtual bool CanClose()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual void OnClose()
|
||||
{
|
||||
}
|
||||
virtual void OnResize()
|
||||
{
|
||||
}
|
||||
virtual void OnUpdate()
|
||||
{
|
||||
}
|
||||
virtual void OnPeriodicUpdate()
|
||||
{
|
||||
}
|
||||
virtual void OnPrepareDraw()
|
||||
{
|
||||
}
|
||||
virtual void OnDraw(DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual OpenRCT2String OnTooltip(WidgetIndex widgetIndex, StringId fallback)
|
||||
{
|
||||
return { fallback, {} };
|
||||
}
|
||||
virtual void OnMouseDown(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnMouseUp(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnDropdown(WidgetIndex widgetIndex, int32_t selectedIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnTextInput(WidgetIndex widgetIndex, std::string_view text)
|
||||
{
|
||||
}
|
||||
virtual ScreenSize OnScrollGetSize(int32_t scrollIndex)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual void OnScrollSelect(int32_t scrollIndex, int32_t scrollAreaType)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseDrag(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi)
|
||||
{
|
||||
}
|
||||
virtual void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
}
|
||||
virtual void OnToolUp(WidgetIndex widgetIndex, const ScreenCoordsXY&)
|
||||
{
|
||||
}
|
||||
virtual void OnToolAbort(WidgetIndex widgetIndex)
|
||||
{
|
||||
}
|
||||
virtual void OnViewportRotate()
|
||||
{
|
||||
}
|
||||
virtual void OnMoved(const ScreenCoordsXY&)
|
||||
{
|
||||
}
|
||||
virtual CursorID OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID);
|
||||
virtual void OnLanguageChange()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
// rct2: 0x01420078
|
||||
extern std::list<std::shared_ptr<WindowBase>> g_window_list;
|
||||
// rct2: 0x01420078
|
||||
extern std::list<std::shared_ptr<WindowBase>> g_window_list;
|
||||
} // namespace OpenRCT2
|
||||
|
|
|
@ -39,13 +39,13 @@ void NetworkPlayer::Write(NetworkPacket& packet)
|
|||
void NetworkPlayer::IncrementNumCommands()
|
||||
{
|
||||
CommandsRan++;
|
||||
WindowInvalidateByNumber(WindowClass::Player, Id);
|
||||
OpenRCT2::WindowInvalidateByNumber(WindowClass::Player, Id);
|
||||
}
|
||||
|
||||
void NetworkPlayer::AddMoneySpent(money64 cost)
|
||||
{
|
||||
MoneySpent += cost;
|
||||
WindowInvalidateByNumber(WindowClass::Player, Id);
|
||||
OpenRCT2::WindowInvalidateByNumber(WindowClass::Player, Id);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,112 +17,115 @@
|
|||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
enum IntentAction
|
||||
namespace OpenRCT2
|
||||
{
|
||||
INTENT_ACTION_MAP,
|
||||
INTENT_ACTION_NEW_RIDE_OF_TYPE,
|
||||
INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST,
|
||||
INTENT_ACTION_REFRESH_NEW_RIDES,
|
||||
INTENT_ACTION_REFRESH_RIDE_LIST,
|
||||
INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_UPDATE_PIECES,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_UPDATE_ACTIVE_ELEMENTS,
|
||||
INTENT_ACTION_INIT_SCENERY,
|
||||
INTENT_ACTION_SET_DEFAULT_SCENERY_CONFIG,
|
||||
INTENT_ACTION_REFRESH_SCENERY,
|
||||
INTENT_ACTION_INVALIDATE_TICKER_NEWS,
|
||||
INTENT_ACTION_REFRESH_GUEST_LIST,
|
||||
INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD,
|
||||
INTENT_ACTION_REFRESH_STAFF_LIST,
|
||||
INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW,
|
||||
INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE,
|
||||
INTENT_ACTION_UPDATE_CLIMATE,
|
||||
INTENT_ACTION_UPDATE_GUEST_COUNT,
|
||||
INTENT_ACTION_UPDATE_PARK_RATING,
|
||||
INTENT_ACTION_UPDATE_DATE,
|
||||
INTENT_ACTION_UPDATE_CASH,
|
||||
INTENT_ACTION_UPDATE_BANNER,
|
||||
INTENT_ACTION_UPDATE_RESEARCH,
|
||||
INTENT_ACTION_UPDATE_VEHICLE_SOUNDS,
|
||||
INTENT_ACTION_SET_MAP_TOOLTIP,
|
||||
INTENT_ACTION_NEW_SCENERY,
|
||||
INTENT_ACTION_TILE_MODIFY,
|
||||
INTENT_ACTION_PROGRESS_OPEN,
|
||||
INTENT_ACTION_PROGRESS_SET,
|
||||
INTENT_ACTION_PROGRESS_CLOSE,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_ELEMENTS,
|
||||
INTENT_ACTION_RESTORE_PROVISIONAL_ELEMENTS,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_FOOTPATH,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_TRACK_PIECE,
|
||||
|
||||
INTENT_ACTION_NULL = 255,
|
||||
};
|
||||
|
||||
// The maximum amount of data the Intent can hold, 8 should be sufficient, raise this if needed.
|
||||
static constexpr size_t kIntentMaxDataSlots = 8;
|
||||
|
||||
using IntentData = std::variant<int64_t, std::string, CloseCallback, void*>;
|
||||
using IntentDataEntry = std::pair<uint32_t, IntentData>;
|
||||
using IntentDataStorage = sfl::static_vector<IntentDataEntry, kIntentMaxDataSlots>;
|
||||
|
||||
class Intent
|
||||
{
|
||||
WindowClass _Class{ WindowClass::Null };
|
||||
WindowDetail _WindowDetail{ WD_NULL };
|
||||
IntentAction _Action{ INTENT_ACTION_NULL };
|
||||
IntentDataStorage _Data;
|
||||
|
||||
public:
|
||||
explicit Intent(WindowClass windowClass);
|
||||
explicit Intent(WindowDetail windowDetail);
|
||||
explicit Intent(IntentAction windowclass);
|
||||
|
||||
WindowClass GetWindowClass() const;
|
||||
WindowDetail GetWindowDetail() const;
|
||||
IntentAction GetAction() const;
|
||||
|
||||
void* GetPointerExtra(uint32_t key) const;
|
||||
std::string GetStringExtra(uint32_t key) const;
|
||||
uint32_t GetUIntExtra(uint32_t key) const;
|
||||
int32_t GetSIntExtra(uint32_t key) const;
|
||||
CloseCallback GetCloseCallbackExtra(uint32_t key) const;
|
||||
|
||||
Intent* PutExtra(uint32_t key, uint32_t value);
|
||||
Intent* PutExtra(uint32_t key, void* value);
|
||||
Intent* PutExtra(uint32_t key, int32_t value);
|
||||
Intent* PutExtra(uint32_t key, std::string value);
|
||||
Intent* PutExtra(uint32_t key, CloseCallback value);
|
||||
|
||||
template<typename T, T TNull, typename TTag>
|
||||
Intent* PutExtra(uint32_t key, const TIdentifier<T, TNull, TTag>& value)
|
||||
enum IntentAction
|
||||
{
|
||||
const auto val = value.ToUnderlying();
|
||||
return PutExtra(key, static_cast<uint32_t>(val));
|
||||
}
|
||||
};
|
||||
INTENT_ACTION_MAP,
|
||||
INTENT_ACTION_NEW_RIDE_OF_TYPE,
|
||||
INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST,
|
||||
INTENT_ACTION_REFRESH_NEW_RIDES,
|
||||
INTENT_ACTION_REFRESH_RIDE_LIST,
|
||||
INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_UPDATE_PIECES,
|
||||
INTENT_ACTION_RIDE_CONSTRUCTION_UPDATE_ACTIVE_ELEMENTS,
|
||||
INTENT_ACTION_INIT_SCENERY,
|
||||
INTENT_ACTION_SET_DEFAULT_SCENERY_CONFIG,
|
||||
INTENT_ACTION_REFRESH_SCENERY,
|
||||
INTENT_ACTION_INVALIDATE_TICKER_NEWS,
|
||||
INTENT_ACTION_REFRESH_GUEST_LIST,
|
||||
INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD,
|
||||
INTENT_ACTION_REFRESH_STAFF_LIST,
|
||||
INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW,
|
||||
INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE,
|
||||
INTENT_ACTION_UPDATE_CLIMATE,
|
||||
INTENT_ACTION_UPDATE_GUEST_COUNT,
|
||||
INTENT_ACTION_UPDATE_PARK_RATING,
|
||||
INTENT_ACTION_UPDATE_DATE,
|
||||
INTENT_ACTION_UPDATE_CASH,
|
||||
INTENT_ACTION_UPDATE_BANNER,
|
||||
INTENT_ACTION_UPDATE_RESEARCH,
|
||||
INTENT_ACTION_UPDATE_VEHICLE_SOUNDS,
|
||||
INTENT_ACTION_SET_MAP_TOOLTIP,
|
||||
INTENT_ACTION_NEW_SCENERY,
|
||||
INTENT_ACTION_TILE_MODIFY,
|
||||
INTENT_ACTION_PROGRESS_OPEN,
|
||||
INTENT_ACTION_PROGRESS_SET,
|
||||
INTENT_ACTION_PROGRESS_CLOSE,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_ELEMENTS,
|
||||
INTENT_ACTION_RESTORE_PROVISIONAL_ELEMENTS,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_FOOTPATH,
|
||||
INTENT_ACTION_REMOVE_PROVISIONAL_TRACK_PIECE,
|
||||
|
||||
enum
|
||||
{
|
||||
INTENT_EXTRA_GUEST_LIST_FILTER,
|
||||
INTENT_EXTRA_RIDE_ID,
|
||||
INTENT_EXTRA_PATH,
|
||||
INTENT_EXTRA_PEEP,
|
||||
INTENT_EXTRA_LOADSAVE_TYPE,
|
||||
INTENT_EXTRA_CALLBACK,
|
||||
INTENT_EXTRA_TRACK_DESIGN,
|
||||
INTENT_EXTRA_RIDE_TYPE,
|
||||
INTENT_EXTRA_RIDE_ENTRY_INDEX,
|
||||
INTENT_EXTRA_TILE_ELEMENT,
|
||||
INTENT_EXTRA_VEHICLE,
|
||||
INTENT_EXTRA_MESSAGE,
|
||||
INTENT_EXTRA_LIST,
|
||||
INTENT_EXTRA_LIST_COUNT,
|
||||
INTENT_EXTRA_PAGE,
|
||||
INTENT_EXTRA_BANNER_INDEX,
|
||||
INTENT_EXTRA_FORMATTER,
|
||||
INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX,
|
||||
INTENT_EXTRA_PROGRESS_OFFSET,
|
||||
INTENT_EXTRA_PROGRESS_TOTAL,
|
||||
INTENT_EXTRA_STRING_ID,
|
||||
};
|
||||
INTENT_ACTION_NULL = 255,
|
||||
};
|
||||
|
||||
// The maximum amount of data the Intent can hold, 8 should be sufficient, raise this if needed.
|
||||
static constexpr size_t kIntentMaxDataSlots = 8;
|
||||
|
||||
using IntentData = std::variant<int64_t, std::string, CloseCallback, void*>;
|
||||
using IntentDataEntry = std::pair<uint32_t, IntentData>;
|
||||
using IntentDataStorage = sfl::static_vector<IntentDataEntry, kIntentMaxDataSlots>;
|
||||
|
||||
class Intent
|
||||
{
|
||||
WindowClass _Class{ WindowClass::Null };
|
||||
WindowDetail _WindowDetail{ WD_NULL };
|
||||
IntentAction _Action{ INTENT_ACTION_NULL };
|
||||
IntentDataStorage _Data;
|
||||
|
||||
public:
|
||||
explicit Intent(WindowClass windowClass);
|
||||
explicit Intent(WindowDetail windowDetail);
|
||||
explicit Intent(IntentAction windowclass);
|
||||
|
||||
WindowClass GetWindowClass() const;
|
||||
WindowDetail GetWindowDetail() const;
|
||||
IntentAction GetAction() const;
|
||||
|
||||
void* GetPointerExtra(uint32_t key) const;
|
||||
std::string GetStringExtra(uint32_t key) const;
|
||||
uint32_t GetUIntExtra(uint32_t key) const;
|
||||
int32_t GetSIntExtra(uint32_t key) const;
|
||||
CloseCallback GetCloseCallbackExtra(uint32_t key) const;
|
||||
|
||||
Intent* PutExtra(uint32_t key, uint32_t value);
|
||||
Intent* PutExtra(uint32_t key, void* value);
|
||||
Intent* PutExtra(uint32_t key, int32_t value);
|
||||
Intent* PutExtra(uint32_t key, std::string value);
|
||||
Intent* PutExtra(uint32_t key, CloseCallback value);
|
||||
|
||||
template<typename T, T TNull, typename TTag>
|
||||
Intent* PutExtra(uint32_t key, const TIdentifier<T, TNull, TTag>& value)
|
||||
{
|
||||
const auto val = value.ToUnderlying();
|
||||
return PutExtra(key, static_cast<uint32_t>(val));
|
||||
}
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
INTENT_EXTRA_GUEST_LIST_FILTER,
|
||||
INTENT_EXTRA_RIDE_ID,
|
||||
INTENT_EXTRA_PATH,
|
||||
INTENT_EXTRA_PEEP,
|
||||
INTENT_EXTRA_LOADSAVE_TYPE,
|
||||
INTENT_EXTRA_CALLBACK,
|
||||
INTENT_EXTRA_TRACK_DESIGN,
|
||||
INTENT_EXTRA_RIDE_TYPE,
|
||||
INTENT_EXTRA_RIDE_ENTRY_INDEX,
|
||||
INTENT_EXTRA_TILE_ELEMENT,
|
||||
INTENT_EXTRA_VEHICLE,
|
||||
INTENT_EXTRA_MESSAGE,
|
||||
INTENT_EXTRA_LIST,
|
||||
INTENT_EXTRA_LIST_COUNT,
|
||||
INTENT_EXTRA_PAGE,
|
||||
INTENT_EXTRA_BANNER_INDEX,
|
||||
INTENT_EXTRA_FORMATTER,
|
||||
INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX,
|
||||
INTENT_EXTRA_PROGRESS_OFFSET,
|
||||
INTENT_EXTRA_PROGRESS_TOTAL,
|
||||
INTENT_EXTRA_STRING_ID,
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
|
Loading…
Reference in a new issue