mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Move Widget, Window, Intent, MouseInput into OpenRCT2 namespace (#23642)
This commit is contained in:
@@ -41,7 +41,8 @@
|
||||
#include <openrct2/world/Scenery.h>
|
||||
#include <optional>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using namespace OpenRCT2::Ui;
|
||||
using namespace OpenRCT2::Ui::Windows;
|
||||
|
||||
@@ -592,7 +593,8 @@ static void InputViewportDragContinue()
|
||||
// As the user moved the mouse, don't interpret it as right click in any case.
|
||||
_ticksSinceDragStart = std::nullopt;
|
||||
|
||||
// applying the zoom only with negative values avoids a "deadzone" effect where small positive value round to zero.
|
||||
// applying the zoom only with negative values avoids a "deadzone" effect where small positive value round to
|
||||
// zero.
|
||||
const bool posX = differentialCoords.x > 0;
|
||||
const bool posY = differentialCoords.y > 0;
|
||||
differentialCoords.x = (viewport->zoom + 1).ApplyTo(-std::abs(differentialCoords.x));
|
||||
@@ -1009,8 +1011,8 @@ static void InputWidgetOverChangeCheck(WindowClass windowClass, rct_windownumber
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to invalidate flat button widgets when the mouse leaves and enters them. This should be generalised so that all widgets
|
||||
* can use this in the future.
|
||||
* Used to invalidate flat button widgets when the mouse leaves and enters them. This should be generalised so that all
|
||||
* widgets can use this in the future.
|
||||
*/
|
||||
static void InputWidgetOverFlatbuttonInvalidate()
|
||||
{
|
||||
@@ -1021,7 +1023,8 @@ static void InputWidgetOverFlatbuttonInvalidate()
|
||||
w->OnPrepareDraw();
|
||||
if (w->widgets[gHoverWidget.widget_index].type == WindowWidgetType::FlatBtn)
|
||||
{
|
||||
WidgetInvalidateByNumber(gHoverWidget.window_classification, gHoverWidget.window_number, gHoverWidget.widget_index);
|
||||
WidgetInvalidateByNumber(
|
||||
gHoverWidget.window_classification, gHoverWidget.window_number, gHoverWidget.widget_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1524,7 +1527,8 @@ void InputStateWidgetPressed(
|
||||
gDropdownLastColourHover = dropdown_index;
|
||||
WindowTooltipClose();
|
||||
|
||||
WindowTooltipShow(OpenRCT2String{ kColourToTip.at(ColourDropDownIndexToColour(dropdown_index)), {} }, screenCoords);
|
||||
WindowTooltipShow(
|
||||
OpenRCT2String{ kColourToTip.at(ColourDropDownIndexToColour(dropdown_index)), {} }, screenCoords);
|
||||
}
|
||||
|
||||
if (dropdown_index < Dropdown::ItemsMaxSize && Dropdown::IsDisabled(dropdown_index))
|
||||
@@ -1738,3 +1742,4 @@ void InputScrollViewport(const ScreenCoordsXY& scrollScreenCoords)
|
||||
_inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING;
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <openrct2/interface/Window.h>
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class MouseState : uint32_t
|
||||
{
|
||||
Released,
|
||||
@@ -29,3 +31,4 @@ void GameHandleEdgeScroll();
|
||||
void StoreMouseInput(MouseState state, 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;
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include <openrct2/ui/WindowManager.h>
|
||||
#include <openrct2/world/Location.hpp>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
// The amount of pixels to scroll per wheel click
|
||||
@@ -97,7 +98,8 @@ static bool WindowFitsOnScreen(const ScreenCoordsXY& loc, int32_t width, int32_t
|
||||
}
|
||||
|
||||
static ScreenCoordsXY ClampWindowToScreen(
|
||||
const ScreenCoordsXY& pos, const int32_t screenWidth, const int32_t screenHeight, const int32_t width, const int32_t height)
|
||||
const ScreenCoordsXY& pos, const int32_t screenWidth, const int32_t screenHeight, const int32_t width,
|
||||
const int32_t height)
|
||||
{
|
||||
auto screenPos = pos;
|
||||
if (width > screenWidth || screenPos.x < 0)
|
||||
@@ -214,7 +216,8 @@ static ScreenCoordsXY GetCentrePositionForNewWindow(int32_t width, int32_t heigh
|
||||
|
||||
static int32_t WindowGetWidgetIndex(const WindowBase& w, Widget* widget)
|
||||
{
|
||||
const auto it = std::find_if(w.widgets.begin(), w.widgets.end(), [&](auto& otherWidget) { return &otherWidget == widget; });
|
||||
const auto it = std::find_if(
|
||||
w.widgets.begin(), w.widgets.end(), [&](auto& otherWidget) { return &otherWidget == widget; });
|
||||
if (it == w.widgets.end())
|
||||
return -1;
|
||||
return std::distance(w.widgets.begin(), it);
|
||||
@@ -721,6 +724,7 @@ ScreenCoordsXY WindowGetViewportSoundIconPos(WindowBase& w)
|
||||
const uint8_t buttonOffset = (Config::Get().interface.WindowButtonsOnTheLeft) ? kCloseButtonWidth + 2 : 0;
|
||||
return w.windowPos + ScreenCoordsXY{ 2 + buttonOffset, 2 };
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
|
||||
struct TextInputSession;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct Window : WindowBase
|
||||
{
|
||||
virtual void OnDraw(DrawPixelInfo& dpi) override;
|
||||
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
||||
void OnDraw(DrawPixelInfo& dpi) override;
|
||||
void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
||||
|
||||
void ScrollToViewport();
|
||||
void InitScrollWidgets();
|
||||
@@ -35,8 +37,8 @@ struct Window : WindowBase
|
||||
void CloseOthersOfThisClass();
|
||||
CloseWindowModifier GetCloseModifier();
|
||||
void TextInputOpen(
|
||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText,
|
||||
uintptr_t existingArgs, int32_t maxLength);
|
||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs,
|
||||
StringId existingText, uintptr_t existingArgs, int32_t maxLength);
|
||||
|
||||
void ResizeFrame();
|
||||
void ResizeFrameWithPage();
|
||||
@@ -49,6 +51,7 @@ 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>
|
||||
|
||||
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,6 +12,8 @@
|
||||
#include "Context.h"
|
||||
#include "Game.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
InputState _inputState;
|
||||
uint8_t _inputFlags;
|
||||
|
||||
@@ -74,3 +76,4 @@ void ResetTooltipNotShown()
|
||||
{
|
||||
_tooltipNotShownTimeout = gCurrentRealTimeTicks + 50;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "interface/Window.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum INPUT_FLAGS
|
||||
{
|
||||
INPUT_FLAG_WIDGET_PRESSED = (1 << 0),
|
||||
@@ -73,3 +75,4 @@ void InputSetState(InputState state);
|
||||
InputState InputGetState();
|
||||
|
||||
void ResetTooltipNotShown();
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using namespace OpenRCT2::Numerics;
|
||||
|
||||
enum : uint8_t
|
||||
@@ -951,8 +952,8 @@ static void ViewportPaintColumn(PaintSession& session)
|
||||
|
||||
PaintDrawStructs(session);
|
||||
|
||||
if (Config::Get().general.RenderWeatherGloom && !gTrackDesignSaveMode && !(session.ViewFlags & VIEWPORT_FLAG_HIDE_ENTITIES)
|
||||
&& !(session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
|
||||
if (Config::Get().general.RenderWeatherGloom && !gTrackDesignSaveMode
|
||||
&& !(session.ViewFlags & VIEWPORT_FLAG_HIDE_ENTITIES) && !(session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
|
||||
{
|
||||
ViewportPaintWeatherGloom(session.DPI);
|
||||
}
|
||||
@@ -982,7 +983,8 @@ static void ViewportPaint(const Viewport* viewport, DrawPixelInfo& dpi)
|
||||
const int32_t worldX = viewport->zoom.ApplyInversedTo(viewport->viewPos.x) + std::max(0, offsetX);
|
||||
const int32_t worldY = viewport->zoom.ApplyInversedTo(viewport->viewPos.y) + std::max(0, offsetY);
|
||||
const int32_t width = std::min(viewport->pos.x + viewport->width, dpi.x + dpi.width) - std::max(viewport->pos.x, dpi.x);
|
||||
const int32_t height = std::min(viewport->pos.y + viewport->height, dpi.y + dpi.height) - std::max(viewport->pos.y, dpi.y);
|
||||
const int32_t height = std::min(viewport->pos.y + viewport->height, dpi.y + dpi.height)
|
||||
- std::max(viewport->pos.y, dpi.y);
|
||||
|
||||
DrawPixelInfo worldDpi;
|
||||
worldDpi.DrawingEngine = dpi.DrawingEngine;
|
||||
@@ -1480,7 +1482,8 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag
|
||||
{
|
||||
if (viewFlags & VIEWPORT_FLAG_HIDE_SCENERY)
|
||||
{
|
||||
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? VisibilityKind::Hidden : VisibilityKind::Partial;
|
||||
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? VisibilityKind::Hidden
|
||||
: VisibilityKind::Partial;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1567,7 +1570,8 @@ static bool IsPixelPresentRLE(const uint8_t* imgData, const int32_t x, const int
|
||||
* rct2: 0x00679074
|
||||
*/
|
||||
static bool IsSpriteInteractedWithPaletteSet(
|
||||
DrawPixelInfo& dpi, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap, const uint8_t imageType)
|
||||
DrawPixelInfo& dpi, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap,
|
||||
const uint8_t imageType)
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
@@ -1608,7 +1612,8 @@ static bool IsSpriteInteractedWithPaletteSet(
|
||||
origin.y += g1->y_offset;
|
||||
interactionPoint -= origin;
|
||||
|
||||
if (interactionPoint.x < 0 || interactionPoint.y < 0 || interactionPoint.x >= g1->width || interactionPoint.y >= g1->height)
|
||||
if (interactionPoint.x < 0 || interactionPoint.y < 0 || interactionPoint.x >= g1->width
|
||||
|| interactionPoint.y >= g1->height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1797,10 +1802,10 @@ void ViewportInvalidate(const Viewport* viewport, const ScreenRect& screenRect)
|
||||
auto viewPos = viewport->viewPos;
|
||||
auto viewportScreenPos = viewport->pos;
|
||||
|
||||
ScreenRect invalidRect = {
|
||||
{ zoom.ApplyInversedTo(screenRect.GetLeft() - viewPos.x), zoom.ApplyInversedTo(screenRect.GetTop() - viewPos.y) },
|
||||
{ zoom.ApplyInversedTo(screenRect.GetRight() - viewPos.x), zoom.ApplyInversedTo(screenRect.GetBottom() - viewPos.y) }
|
||||
};
|
||||
ScreenRect invalidRect = { { zoom.ApplyInversedTo(screenRect.GetLeft() - viewPos.x),
|
||||
zoom.ApplyInversedTo(screenRect.GetTop() - viewPos.y) },
|
||||
{ zoom.ApplyInversedTo(screenRect.GetRight() - viewPos.x),
|
||||
zoom.ApplyInversedTo(screenRect.GetBottom() - viewPos.y) } };
|
||||
|
||||
if (invalidRect.GetTop() >= viewport->height || invalidRect.GetBottom() <= 0 || invalidRect.GetLeft() >= viewport->width
|
||||
|| invalidRect.GetRight() <= 0)
|
||||
@@ -2018,6 +2023,7 @@ void ViewportSetSavedView()
|
||||
gameState.SavedViewRotation = viewport->rotation;
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
ZoomLevel ZoomLevel::min()
|
||||
{
|
||||
|
||||
@@ -20,12 +20,15 @@ struct PaintSession;
|
||||
struct PaintStruct;
|
||||
struct DrawPixelInfo;
|
||||
struct TileElement;
|
||||
struct WindowBase;
|
||||
struct EntityBase;
|
||||
struct Guest;
|
||||
struct Staff;
|
||||
struct PaintEntry;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct WindowBase;
|
||||
|
||||
// Flags must currenly retain their values to avoid breaking plugins.
|
||||
// Values can be changed when plugins move to using named constants.
|
||||
enum : uint32_t
|
||||
@@ -68,6 +71,7 @@ enum : uint32_t
|
||||
VIEWPORT_FLAG_INDEPEDENT_ROTATION = (1u << 30),
|
||||
VIEWPORT_FLAG_RENDERING_INHIBITED = (1u << 31),
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
enum class VisibilityKind
|
||||
{
|
||||
@@ -103,6 +107,8 @@ enum class ViewportVisibility : uint8_t
|
||||
UndergroundViewGhostOff = 5,
|
||||
};
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
constexpr uint16_t ViewportInteractionItemAll = std::numeric_limits<uint16_t>::max();
|
||||
|
||||
struct InteractionInfo
|
||||
@@ -175,3 +181,4 @@ int32_t GetHeightMarkerOffset();
|
||||
void ViewportSetSavedView();
|
||||
|
||||
VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlags);
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../core/StringTypes.h"
|
||||
#include "../drawing/ImageId.hpp"
|
||||
#include "../localisation/StringIdType.h"
|
||||
#include "../world/Location.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct WindowBase;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using WidgetIndex = uint16_t;
|
||||
|
||||
constexpr WidgetIndex kWidgetIndexNull = 0xFFFF;
|
||||
|
||||
enum class WindowWidgetType : uint8_t
|
||||
@@ -45,6 +49,107 @@ enum class WindowWidgetType : uint8_t
|
||||
TextBox = 27,
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
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;
|
||||
@@ -56,10 +161,4 @@ constexpr uint8_t kDropdownHeight = 12;
|
||||
|
||||
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
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
|
||||
std::list<std::shared_ptr<WindowBase>> g_window_list;
|
||||
WindowBase* gWindowAudioExclusive;
|
||||
@@ -76,11 +77,11 @@ static constexpr float window_scroll_locations[][2] = {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
namespace OpenRCT2::WindowCloseFlags
|
||||
namespace WindowCloseFlags
|
||||
{
|
||||
static constexpr uint32_t None = 0;
|
||||
static constexpr uint32_t CloseSingle = (1 << 0);
|
||||
} // namespace OpenRCT2::WindowCloseFlags
|
||||
} // namespace WindowCloseFlags
|
||||
|
||||
static void WindowDrawCore(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
@@ -194,7 +195,8 @@ static void WindowCloseSurplus(int32_t cap, WindowClass avoid_classification)
|
||||
}
|
||||
}
|
||||
// skip window if window matches specified WindowClass (as user may be modifying via options)
|
||||
if (avoid_classification != WindowClass::Null && foundW != nullptr && foundW->classification == avoid_classification)
|
||||
if (avoid_classification != WindowClass::Null && foundW != nullptr
|
||||
&& foundW->classification == avoid_classification)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -276,7 +278,8 @@ void WindowCloseByClass(WindowClass cls)
|
||||
*/
|
||||
void WindowCloseByNumber(WindowClass cls, rct_windownumber number)
|
||||
{
|
||||
WindowCloseByCondition([cls, number](WindowBase* w) -> bool { return w->classification == cls && w->number == number; });
|
||||
WindowCloseByCondition(
|
||||
[cls, number](WindowBase* w) -> bool { return w->classification == cls && w->number == number; });
|
||||
}
|
||||
|
||||
// TODO: Refactor this to use variant once the new window class is done.
|
||||
@@ -1056,11 +1059,13 @@ void ToolCancel()
|
||||
{
|
||||
// Invalidate tool widget
|
||||
WidgetInvalidateByNumber(
|
||||
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number, gCurrentToolWidget.widget_index);
|
||||
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number,
|
||||
gCurrentToolWidget.widget_index);
|
||||
|
||||
// Abort tool event
|
||||
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
|
||||
WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
||||
WindowBase* w = windowMgr->FindByNumber(
|
||||
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
||||
if (w != nullptr)
|
||||
w->OnToolAbort(gCurrentToolWidget.widget_index);
|
||||
}
|
||||
@@ -1333,3 +1338,4 @@ Viewport* WindowGetViewport(WindowBase* w)
|
||||
|
||||
return w->viewport;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -11,40 +11,34 @@
|
||||
|
||||
#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
|
||||
{
|
||||
@@ -60,102 +54,6 @@ struct WidgetIdentifier
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Viewport structure
|
||||
*/
|
||||
@@ -308,6 +206,7 @@ enum WindowDetail
|
||||
|
||||
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,6 +343,8 @@ enum class Tool
|
||||
Bulldozer = 27,
|
||||
};
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct WidgetRef
|
||||
{
|
||||
WindowClass window_classification;
|
||||
@@ -546,3 +447,5 @@ void WindowInitAll();
|
||||
|
||||
void WindowFollowSprite(WindowBase& w, EntityId spriteIndex);
|
||||
void WindowUnfollowSprite(WindowBase& w);
|
||||
|
||||
} // namespace OpenRCT2
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "Cursors.h"
|
||||
#include "Viewport.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
void WindowBase::SetLocation(const CoordsXYZ& coords)
|
||||
{
|
||||
WindowScrollToLocation(*this, coords);
|
||||
@@ -35,3 +37,4 @@ 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,6 +30,8 @@ struct RCTObjectEntry;
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
/**
|
||||
* Window structure
|
||||
* size: 0x4C0
|
||||
@@ -180,3 +184,4 @@ struct WindowBase
|
||||
|
||||
// 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,6 +17,8 @@
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum IntentAction
|
||||
{
|
||||
INTENT_ACTION_MAP,
|
||||
@@ -126,3 +128,4 @@ enum
|
||||
INTENT_EXTRA_PROGRESS_TOTAL,
|
||||
INTENT_EXTRA_STRING_ID,
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
Reference in New Issue
Block a user