1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 04:53:12 +01:00

Refactor out IMAGE_TYPE_REMAP from widgets

This commit is contained in:
Gymnasiast
2022-12-24 16:39:43 +01:00
parent b712cc8f07
commit b97ee766d5
9 changed files with 21 additions and 24 deletions

View File

@@ -229,7 +229,7 @@ static void WidgetTabDraw(rct_drawpixelinfo* dpi, rct_window& w, WidgetIndex wid
if (widget.image == static_cast<uint32_t>(SPR_NONE))
{
// Set standard tab sprite to use.
widget.image = IMAGE_TYPE_REMAP | SPR_TAB;
widget.image = ImageId(SPR_TAB, FilterPaletteID::PaletteNull).ToUInt32();
}
}

View File

@@ -472,14 +472,14 @@ static bool WindowOtherWheelInput(rct_window& w, WidgetIndex widgetIndex, int32_
case WindowWidgetType::ImgBtn:
buttonWidgetIndex = wheel < 0 ? widgetIndex + 2 : widgetIndex + 1;
expectedType = WindowWidgetType::TrnBtn;
expectedContent[0] = IMAGE_TYPE_REMAP | SPR_LAND_TOOL_DECREASE;
expectedContent[1] = IMAGE_TYPE_REMAP | SPR_LAND_TOOL_INCREASE;
expectedContent[0] = ImageId(SPR_LAND_TOOL_DECREASE, FilterPaletteID::PaletteNull).ToUInt32();
expectedContent[1] = ImageId(SPR_LAND_TOOL_INCREASE, FilterPaletteID::PaletteNull).ToUInt32();
break;
case WindowWidgetType::Spinner:
buttonWidgetIndex = wheel < 0 ? widgetIndex + 1 : widgetIndex + 2;
expectedType = WindowWidgetType::Button;
expectedContent[0] = STR_NUMERIC_UP;
expectedContent[1] = STR_NUMERIC_DOWN;
expectedContent[0] = ImageId(STR_NUMERIC_UP, FilterPaletteID::PaletteNull).ToUInt32();
expectedContent[1] = ImageId(STR_NUMERIC_DOWN, FilterPaletteID::PaletteNull).ToUInt32();
break;
default:
return false;

View File

@@ -902,7 +902,7 @@ namespace OpenRCT2::Ui::Windows
widget.right = widget.left + 30;
widget.top = 17;
widget.bottom = 43;
widget.image = IMAGE_TYPE_REMAP | SPR_TAB;
widget.image = ImageId(SPR_TAB, FilterPaletteID::PaletteNull).ToUInt32();
widget.tooltip = STR_NONE;
widgetList.push_back(widget);
info.WidgetIndexMap.push_back(std::numeric_limits<size_t>::max());

View File

@@ -1036,7 +1036,7 @@ private:
if (tabInfo.SceneryGroupIndex == OBJECT_ENTRY_INDEX_NULL)
{
widget.image = SPR_TAB_QUESTION | IMAGE_TYPE_REMAP;
widget.image = ImageId(SPR_TAB_QUESTION, FilterPaletteID::PaletteNull).ToUInt32();
}
_widgets.push_back(widget);

View File

@@ -836,9 +836,9 @@ static void WindowTopToolbarInvalidate(rct_window* w)
w->pressed_widgets &= ~(1uLL << WIDX_PAUSE);
if (!OpenRCT2::Audio::gGameSoundsOff)
window_top_toolbar_widgets[WIDX_MUTE].image = IMAGE_TYPE_REMAP | SPR_G2_TOOLBAR_MUTE;
window_top_toolbar_widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_MUTE, FilterPaletteID::PaletteNull).ToUInt32();
else
window_top_toolbar_widgets[WIDX_MUTE].image = IMAGE_TYPE_REMAP | SPR_G2_TOOLBAR_UNMUTE;
window_top_toolbar_widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_UNMUTE, FilterPaletteID::PaletteNull).ToUInt32();
// Set map button to the right image.
if (window_top_toolbar_widgets[WIDX_MAP].type != WindowWidgetType::Empty)
@@ -851,7 +851,7 @@ static void WindowTopToolbarInvalidate(rct_window* w)
};
uint32_t mapImageId = _imageIdByRotation[get_current_rotation()];
window_top_toolbar_widgets[WIDX_MAP].image = IMAGE_TYPE_REMAP | mapImageId;
window_top_toolbar_widgets[WIDX_MAP].image = ImageId(mapImageId, FilterPaletteID::PaletteNull).ToUInt32();
}
// Zoomed out/in disable. Not sure where this code is in the original.

View File

@@ -154,16 +154,6 @@ enum
G1_FLAG_NO_ZOOM_DRAW = (1 << 5), // Does not get drawn at higher zoom levels (only zoom 0)
};
enum : uint32_t
{
IMAGE_TYPE_DEFAULT = 0,
IMAGE_TYPE_REMAP = (1 << 29),
IMAGE_TYPE_TRANSPARENT = (1 << 30),
IMAGE_TYPE_REMAP_2_PLUS = (1u << 31)
// REMAP_2_PLUS + REMAP = REMAP 2
// REMAP_2_PLUS = REMAP 3
};
using DrawBlendOp = uint8_t;
constexpr DrawBlendOp BLEND_NONE = 0;

View File

@@ -121,7 +121,7 @@ public:
{
}
[[nodiscard]] uint32_t ToUInt32() const
[[nodiscard]] constexpr uint32_t ToUInt32() const
{
auto result = (_index & MASK_INDEX);
result |= (_primary << SHIFT_REMAP) & MASK_REMAP;

View File

@@ -45,6 +45,13 @@
using namespace OpenRCT2;
enum : uint32_t
{
IMAGE_TYPE_DEFAULT = 0,
IMAGE_TYPE_REMAP = (1 << 29),
IMAGE_TYPE_TRANSPARENT = (1 << 30),
};
uint8_t gShowGridLinesRefCount;
uint8_t gShowLandRightsRefCount;
uint8_t gShowConstructionRightsRefCount;
@@ -1818,7 +1825,7 @@ static bool is_sprite_interacted_with(rct_drawpixelinfo* dpi, ImageId imageId, c
}
else
{
_currentImageType = 0;
_currentImageType = IMAGE_TYPE_DEFAULT;
}
return is_sprite_interacted_with_palette_set(dpi, imageId, coords, paletteMap);
}

View File

@@ -81,9 +81,9 @@ constexpr rct_widget MakeWidget(
constexpr rct_widget MakeRemapWidget(
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour,
uint32_t content = 0xFFFFFFFF, StringId tooltip = STR_NONE)
ImageIndex content, StringId tooltip = STR_NONE)
{
return MakeWidget(origin, size, type, colour, IMAGE_TYPE_REMAP | content, tooltip);
return MakeWidget(origin, size, type, colour, ImageId(content, FilterPaletteID::PaletteNull).ToUInt32(), tooltip);
}
constexpr rct_widget MakeTab(const ScreenCoordsXY& origin, StringId tooltip = STR_NONE)