mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-21 06:43:04 +01:00
Add Some Items to the OpenRCT2::Ui namespace (#22423)
* Put widget in the Ui namespace * Put theme in the Ui namespace * Put objective in Ui namespace
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <optional>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Ui;
|
||||
using namespace OpenRCT2::Ui::Windows;
|
||||
|
||||
struct RCTMouseData
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <openrct2/drawing/ImageId.hpp>
|
||||
#include <openrct2/util/Util.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
namespace OpenRCT2::Dropdown
|
||||
{
|
||||
struct Item;
|
||||
|
||||
@@ -16,53 +16,56 @@
|
||||
#include <openrct2/ride/RideData.h>
|
||||
#include <openrct2/scenario/Scenario.h>
|
||||
|
||||
const StringId kObjectiveNames[] = {
|
||||
STR_OBJECTIVE_NONE,
|
||||
STR_OBJECTIVE_GUESTS_BY,
|
||||
STR_OBJECTIVE_PARK_VALUE_BY,
|
||||
STR_OBJECTIVE_HAVE_FUN,
|
||||
STR_OBJECTIVE_BUILD_THE_BEST,
|
||||
STR_OBJECTIVE_10_ROLLERCOASTERS,
|
||||
STR_OBJECTIVE_GUESTS_AND_RATING,
|
||||
STR_OBJECTIVE_MONTHLY_RIDE_INCOME,
|
||||
STR_OBJECTIVE_10_ROLLERCOASTERS_LENGTH,
|
||||
STR_OBJECTIVE_FINISH_5_ROLLERCOASTERS,
|
||||
STR_OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE,
|
||||
STR_OBJECTIVE_MONTHLY_FOOD_INCOME,
|
||||
};
|
||||
|
||||
void formatObjective(Formatter& ft, Objective objective)
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
if (objective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
const StringId kObjectiveNames[] = {
|
||||
STR_OBJECTIVE_NONE,
|
||||
STR_OBJECTIVE_GUESTS_BY,
|
||||
STR_OBJECTIVE_PARK_VALUE_BY,
|
||||
STR_OBJECTIVE_HAVE_FUN,
|
||||
STR_OBJECTIVE_BUILD_THE_BEST,
|
||||
STR_OBJECTIVE_10_ROLLERCOASTERS,
|
||||
STR_OBJECTIVE_GUESTS_AND_RATING,
|
||||
STR_OBJECTIVE_MONTHLY_RIDE_INCOME,
|
||||
STR_OBJECTIVE_10_ROLLERCOASTERS_LENGTH,
|
||||
STR_OBJECTIVE_FINISH_5_ROLLERCOASTERS,
|
||||
STR_OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE,
|
||||
STR_OBJECTIVE_MONTHLY_FOOD_INCOME,
|
||||
};
|
||||
|
||||
void formatObjective(Formatter& ft, Objective objective)
|
||||
{
|
||||
StringId rideTypeString = STR_NONE;
|
||||
auto rideTypeId = objective.RideId;
|
||||
if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT)
|
||||
if (objective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
{
|
||||
rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name;
|
||||
StringId rideTypeString = STR_NONE;
|
||||
auto rideTypeId = objective.RideId;
|
||||
if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT)
|
||||
{
|
||||
rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name;
|
||||
}
|
||||
ft.Add<StringId>(rideTypeString);
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_GUESTS_BY)
|
||||
{
|
||||
ft.Add<int32_t>(objective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, objective.Year));
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
{
|
||||
ft.Add<int32_t>(objective.NumGuests);
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
{
|
||||
ft.Add<int16_t>(objective.MinimumLength);
|
||||
}
|
||||
ft.Add<StringId>(rideTypeString);
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_GUESTS_BY)
|
||||
{
|
||||
ft.Add<int32_t>(objective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, objective.Year));
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
{
|
||||
ft.Add<int32_t>(objective.NumGuests);
|
||||
}
|
||||
else if (objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
{
|
||||
ft.Add<int16_t>(objective.MinimumLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft.Add<int16_t>(objective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, objective.Year));
|
||||
if (objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
ft.Add<uint16_t>(objective.MinimumExcitement);
|
||||
else
|
||||
ft.Add<money64>(objective.Currency);
|
||||
{
|
||||
ft.Add<int16_t>(objective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, objective.Year));
|
||||
if (objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
ft.Add<uint16_t>(objective.MinimumExcitement);
|
||||
else
|
||||
ft.Add<money64>(objective.Currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
class Formatter;
|
||||
struct Objective;
|
||||
|
||||
void formatObjective(Formatter& ft, Objective objective);
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
void formatObjective(Formatter& ft, Objective objective);
|
||||
|
||||
extern const StringId kObjectiveNames[12];
|
||||
extern const StringId kObjectiveNames[12];
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,37 +12,40 @@
|
||||
#include <openrct2/interface/Colour.h>
|
||||
#include <openrct2/interface/Window.h>
|
||||
|
||||
enum
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
UITHEME_FLAG_PREDEFINED = 1 << 0,
|
||||
UITHEME_FLAG_USE_LIGHTS_RIDE = 1 << 1,
|
||||
UITHEME_FLAG_USE_LIGHTS_PARK = 1 << 2,
|
||||
UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT = 1 << 3,
|
||||
UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR = 1 << 4,
|
||||
};
|
||||
enum
|
||||
{
|
||||
UITHEME_FLAG_PREDEFINED = 1 << 0,
|
||||
UITHEME_FLAG_USE_LIGHTS_RIDE = 1 << 1,
|
||||
UITHEME_FLAG_USE_LIGHTS_PARK = 1 << 2,
|
||||
UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT = 1 << 3,
|
||||
UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR = 1 << 4,
|
||||
};
|
||||
|
||||
void ColourSchemeUpdate(WindowBase* window);
|
||||
void ColourSchemeUpdateAll();
|
||||
void ColourSchemeUpdateByClass(WindowBase* window, WindowClass classification);
|
||||
void ColourSchemeUpdate(WindowBase* window);
|
||||
void ColourSchemeUpdateAll();
|
||||
void ColourSchemeUpdateByClass(WindowBase* window, WindowClass classification);
|
||||
|
||||
void ThemeManagerInitialise();
|
||||
void ThemeManagerLoadAvailableThemes();
|
||||
size_t ThemeManagerGetNumAvailableThemes();
|
||||
const utf8* ThemeManagerGetAvailableThemePath(size_t index);
|
||||
const utf8* ThemeManagerGetAvailableThemeConfigName(size_t index);
|
||||
const utf8* ThemeManagerGetAvailableThemeName(size_t index);
|
||||
size_t ThemeManagerGetAvailableThemeIndex();
|
||||
void ThemeManagerSetActiveAvailableTheme(size_t index);
|
||||
size_t ThemeGetIndexForName(const utf8* name);
|
||||
void ThemeManagerInitialise();
|
||||
void ThemeManagerLoadAvailableThemes();
|
||||
size_t ThemeManagerGetNumAvailableThemes();
|
||||
const utf8* ThemeManagerGetAvailableThemePath(size_t index);
|
||||
const utf8* ThemeManagerGetAvailableThemeConfigName(size_t index);
|
||||
const utf8* ThemeManagerGetAvailableThemeName(size_t index);
|
||||
size_t ThemeManagerGetAvailableThemeIndex();
|
||||
void ThemeManagerSetActiveAvailableTheme(size_t index);
|
||||
size_t ThemeGetIndexForName(const utf8* name);
|
||||
|
||||
ColourWithFlags ThemeGetColour(WindowClass wc, uint8_t index);
|
||||
void ThemeSetColour(WindowClass wc, uint8_t index, ColourWithFlags colour);
|
||||
uint8_t ThemeGetFlags();
|
||||
void ThemeSetFlags(uint8_t flags);
|
||||
void ThemeSave();
|
||||
void ThemeRename(const utf8* name);
|
||||
void ThemeDuplicate(const utf8* name);
|
||||
void ThemeDelete();
|
||||
ColourWithFlags ThemeGetColour(WindowClass wc, uint8_t index);
|
||||
void ThemeSetColour(WindowClass wc, uint8_t index, ColourWithFlags colour);
|
||||
uint8_t ThemeGetFlags();
|
||||
void ThemeSetFlags(uint8_t flags);
|
||||
void ThemeSave();
|
||||
void ThemeRename(const utf8* name);
|
||||
void ThemeDuplicate(const utf8* name);
|
||||
void ThemeDelete();
|
||||
|
||||
uint8_t ThemeDescGetNumColours(WindowClass wc);
|
||||
StringId ThemeDescGetName(WindowClass wc);
|
||||
uint8_t ThemeDescGetNumColours(WindowClass wc);
|
||||
StringId ThemeDescGetName(WindowClass wc);
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,9 @@
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/interface/Widget.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
// clang-format off
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
// clang-format off
|
||||
#define WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, CLOSE_STR) \
|
||||
{ WindowWidgetType::Frame, 0, 0, WIDTH - 1, 0, HEIGHT - 1, 0xFFFFFFFF, STR_NONE }, \
|
||||
{ WindowWidgetType::Caption, 0, 1, WIDTH - 2, 1, 14, TITLE, STR_WINDOW_TITLE_TIP }, \
|
||||
@@ -25,168 +25,169 @@ using namespace OpenRCT2;
|
||||
|
||||
#define WINDOW_SHIM(TITLE, WIDTH, HEIGHT) WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, STR_CLOSE_X)
|
||||
#define WINDOW_SHIM_WHITE(TITLE, WIDTH, HEIGHT) WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, STR_CLOSE_X_WHITE)
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
|
||||
ImageId GetColourButtonImage(colour_t colour);
|
||||
Widget* GetWidgetByIndex(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
ImageId GetColourButtonImage(colour_t colour);
|
||||
Widget* GetWidgetByIndex(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
|
||||
constexpr auto kWidgetsEnd = Widget{ WindowWidgetType::Last, 0, 0, 0, 0, 0, 0, 0 };
|
||||
constexpr uint32_t kWidgetContentEmpty = 0xFFFFFFFF;
|
||||
constexpr auto kBarBlink = (1u << 31);
|
||||
constexpr uint8_t kScrollBarWidth = 10;
|
||||
constexpr ScreenSize kTabSize = { 31, 27 };
|
||||
constexpr auto kWidgetsEnd = Widget{ WindowWidgetType::Last, 0, 0, 0, 0, 0, 0, 0 };
|
||||
constexpr uint32_t kWidgetContentEmpty = 0xFFFFFFFF;
|
||||
constexpr auto kBarBlink = (1u << 31);
|
||||
constexpr uint8_t kScrollBarWidth = 10;
|
||||
constexpr ScreenSize kTabSize = { 31, 27 };
|
||||
|
||||
constexpr const char* kBlackUpArrowString = u8"{BLACK}▲";
|
||||
constexpr const char* kBlackDownArrowString = u8"{BLACK}▼";
|
||||
constexpr const char* kBlackLeftArrowString = u8"{BLACK}◀";
|
||||
constexpr const char* kBlackRightArrowString = u8"{BLACK}▶";
|
||||
constexpr const char* kCheckMarkString = u8"✓";
|
||||
constexpr const char* kEyeString = u8"👁";
|
||||
constexpr const char* kBlackUpArrowString = u8"{BLACK}▲";
|
||||
constexpr const char* kBlackDownArrowString = u8"{BLACK}▼";
|
||||
constexpr const char* kBlackLeftArrowString = u8"{BLACK}◀";
|
||||
constexpr const char* kBlackRightArrowString = u8"{BLACK}▶";
|
||||
constexpr const char* kCheckMarkString = u8"✓";
|
||||
constexpr const char* kEyeString = u8"👁";
|
||||
|
||||
enum class WindowColour : uint8_t
|
||||
{
|
||||
Primary,
|
||||
Secondary,
|
||||
Tertiary,
|
||||
Quaternary,
|
||||
};
|
||||
enum class WindowColour : uint8_t
|
||||
{
|
||||
Primary,
|
||||
Secondary,
|
||||
Tertiary,
|
||||
Quaternary,
|
||||
};
|
||||
|
||||
constexpr Widget MakeWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour,
|
||||
uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = type;
|
||||
out.colour = static_cast<uint8_t>(colour);
|
||||
out.content = content;
|
||||
out.tooltip = tooltip;
|
||||
constexpr Widget MakeWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour,
|
||||
uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = type;
|
||||
out.colour = static_cast<uint8_t>(colour);
|
||||
out.content = content;
|
||||
out.tooltip = tooltip;
|
||||
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Widget MakeWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour, ImageId image,
|
||||
StringId tooltip = STR_NONE)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = type;
|
||||
out.colour = static_cast<uint8_t>(colour);
|
||||
out.image = image;
|
||||
out.tooltip = tooltip;
|
||||
constexpr Widget MakeWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour, ImageId image,
|
||||
StringId tooltip = STR_NONE)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = type;
|
||||
out.colour = static_cast<uint8_t>(colour);
|
||||
out.image = image;
|
||||
out.tooltip = tooltip;
|
||||
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Widget MakeRemapWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour, ImageIndex content,
|
||||
StringId tooltip = STR_NONE)
|
||||
{
|
||||
return MakeWidget(origin, size, type, colour, ImageId(content, FilterPaletteID::PaletteNull), tooltip);
|
||||
}
|
||||
constexpr Widget MakeRemapWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, WindowWidgetType type, WindowColour colour, ImageIndex content,
|
||||
StringId tooltip = STR_NONE)
|
||||
{
|
||||
return MakeWidget(origin, size, type, colour, ImageId(content, FilterPaletteID::PaletteNull), tooltip);
|
||||
}
|
||||
|
||||
constexpr Widget MakeTab(const ScreenCoordsXY& origin, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const ScreenSize size = kTabSize;
|
||||
const WindowWidgetType type = WindowWidgetType::Tab;
|
||||
const WindowColour colour = WindowColour::Secondary;
|
||||
const auto content = ImageId(ImageIndexUndefined);
|
||||
constexpr Widget MakeTab(const ScreenCoordsXY& origin, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const ScreenSize size = kTabSize;
|
||||
const WindowWidgetType type = WindowWidgetType::Tab;
|
||||
const WindowColour colour = WindowColour::Secondary;
|
||||
const auto content = ImageId(ImageIndexUndefined);
|
||||
|
||||
return MakeWidget(origin, size, type, colour, content, tooltip);
|
||||
}
|
||||
return MakeWidget(origin, size, type, colour, content, tooltip);
|
||||
}
|
||||
|
||||
constexpr Widget MakeProgressBar(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, colour_t colour, uint8_t lowerBlinkBound = 0,
|
||||
uint8_t upperBlinkBound = 0)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = WindowWidgetType::ProgressBar;
|
||||
out.colour = colour;
|
||||
out.content = 0 | (lowerBlinkBound << 8) | (upperBlinkBound << 16);
|
||||
out.tooltip = STR_NONE;
|
||||
constexpr Widget MakeProgressBar(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, colour_t colour, uint8_t lowerBlinkBound = 0,
|
||||
uint8_t upperBlinkBound = 0)
|
||||
{
|
||||
Widget out = {};
|
||||
out.left = origin.x;
|
||||
out.right = origin.x + size.width - 1;
|
||||
out.top = origin.y;
|
||||
out.bottom = origin.y + size.height - 1;
|
||||
out.type = WindowWidgetType::ProgressBar;
|
||||
out.colour = colour;
|
||||
out.content = 0 | (lowerBlinkBound << 8) | (upperBlinkBound << 16);
|
||||
out.tooltip = STR_NONE;
|
||||
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// NOLINTBEGIN
|
||||
#define MakeSpinnerWidgets(...) \
|
||||
MakeWidget(__VA_ARGS__), MakeSpinnerIncreaseWidget(__VA_ARGS__), MakeSpinnerDecreaseWidget(__VA_ARGS__)
|
||||
// NOLINTEND
|
||||
// NOLINTEND
|
||||
|
||||
constexpr Widget MakeSpinnerDecreaseWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 26;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 13;
|
||||
const uint16_t height = size.height - 2;
|
||||
constexpr Widget MakeSpinnerDecreaseWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 26;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 13;
|
||||
const uint16_t height = size.height - 2;
|
||||
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_NUMERIC_DOWN, tooltip);
|
||||
}
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_NUMERIC_DOWN, tooltip);
|
||||
}
|
||||
|
||||
constexpr Widget MakeSpinnerIncreaseWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 13;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 12;
|
||||
const uint16_t height = size.height - 2;
|
||||
constexpr Widget MakeSpinnerIncreaseWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 13;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 12;
|
||||
const uint16_t height = size.height - 2;
|
||||
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_NUMERIC_UP, tooltip);
|
||||
}
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_NUMERIC_UP, tooltip);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
#define MakeDropdownWidgets(...) MakeDropdownBoxWidget(__VA_ARGS__), MakeDropdownButtonWidget(__VA_ARGS__)
|
||||
|
||||
constexpr Widget MakeDropdownBoxWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
return MakeWidget(origin, size, type, colour, content);
|
||||
}
|
||||
constexpr Widget MakeDropdownBoxWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
return MakeWidget(origin, size, type, colour, content);
|
||||
}
|
||||
|
||||
constexpr Widget MakeDropdownButtonWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 11;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 11;
|
||||
const uint16_t height = 10;
|
||||
constexpr Widget MakeDropdownButtonWidget(
|
||||
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
|
||||
[[maybe_unused]] uint32_t content = kWidgetContentEmpty, StringId tooltip = STR_NONE)
|
||||
{
|
||||
const int16_t xPos = origin.x + size.width - 11;
|
||||
const int16_t yPos = origin.y + 1;
|
||||
const uint16_t width = 11;
|
||||
const uint16_t height = 10;
|
||||
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_DROPDOWN_GLYPH, tooltip);
|
||||
}
|
||||
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_DROPDOWN_GLYPH, tooltip);
|
||||
}
|
||||
|
||||
void WidgetDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
|
||||
void WidgetDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
|
||||
|
||||
bool WidgetIsDisabled(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsHoldable(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsVisible(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsPressed(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsHighlighted(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsActiveTool(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
void WidgetScrollGetPart(
|
||||
WindowBase& w, const Widget* widget, const ScreenCoordsXY& screenCoords, ScreenCoordsXY& retScreenCoords,
|
||||
int32_t* output_scroll_area, int32_t* scroll_id);
|
||||
bool WidgetIsDisabled(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsHoldable(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsVisible(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsPressed(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsHighlighted(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
bool WidgetIsActiveTool(const WindowBase& w, WidgetIndex widgetIndex);
|
||||
void WidgetScrollGetPart(
|
||||
WindowBase& w, const Widget* widget, const ScreenCoordsXY& screenCoords, ScreenCoordsXY& retScreenCoords,
|
||||
int32_t* output_scroll_area, int32_t* scroll_id);
|
||||
|
||||
void WidgetSetEnabled(WindowBase& w, WidgetIndex widgetIndex, bool enabled);
|
||||
void WidgetSetDisabled(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetHoldable(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetVisible(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetPressed(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetCheckboxValue(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetEnabled(WindowBase& w, WidgetIndex widgetIndex, bool enabled);
|
||||
void WidgetSetDisabled(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetHoldable(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetVisible(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetPressed(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
void WidgetSetCheckboxValue(WindowBase& w, WidgetIndex widgetIndex, bool value);
|
||||
|
||||
void WidgetProgressBarSetNewPercentage(Widget& widget, uint8_t newPercentage);
|
||||
void WidgetProgressBarSetNewPercentage(Widget& widget, uint8_t newPercentage);
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openrct2/world/Location.hpp>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
// The amount of pixels to scroll per wheel click
|
||||
constexpr int32_t WindowScrollPixels = 17;
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return WidgetIsDisabled(*w, _widgetIndex);
|
||||
return Ui::WidgetIsDisabled(*w, _widgetIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -309,19 +309,19 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
WidgetSetDisabled(*w, _widgetIndex, value);
|
||||
Ui::WidgetSetDisabled(*w, _widgetIndex, value);
|
||||
|
||||
auto widget = GetWidget();
|
||||
if (widget != nullptr)
|
||||
{
|
||||
if (widget->type == WindowWidgetType::DropdownMenu)
|
||||
{
|
||||
WidgetSetDisabled(*w, _widgetIndex + 1, value);
|
||||
Ui::WidgetSetDisabled(*w, _widgetIndex + 1, value);
|
||||
}
|
||||
else if (widget->type == WindowWidgetType::Spinner)
|
||||
{
|
||||
WidgetSetDisabled(*w, _widgetIndex + 1, value);
|
||||
WidgetSetDisabled(*w, _widgetIndex + 2, value);
|
||||
Ui::WidgetSetDisabled(*w, _widgetIndex + 1, value);
|
||||
Ui::WidgetSetDisabled(*w, _widgetIndex + 2, value);
|
||||
}
|
||||
}
|
||||
Invalidate(widget);
|
||||
@@ -333,7 +333,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return WidgetIsVisible(*w, _widgetIndex);
|
||||
return Ui::WidgetIsVisible(*w, _widgetIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -342,19 +342,19 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
WidgetSetVisible(*w, _widgetIndex, value);
|
||||
Ui::WidgetSetVisible(*w, _widgetIndex, value);
|
||||
|
||||
auto widget = GetWidget();
|
||||
if (widget != nullptr)
|
||||
{
|
||||
if (widget->type == WindowWidgetType::DropdownMenu)
|
||||
{
|
||||
WidgetSetVisible(*w, _widgetIndex + 1, value);
|
||||
Ui::WidgetSetVisible(*w, _widgetIndex + 1, value);
|
||||
}
|
||||
else if (widget->type == WindowWidgetType::Spinner)
|
||||
{
|
||||
WidgetSetVisible(*w, _widgetIndex + 1, value);
|
||||
WidgetSetVisible(*w, _widgetIndex + 2, value);
|
||||
Ui::WidgetSetVisible(*w, _widgetIndex + 1, value);
|
||||
Ui::WidgetSetVisible(*w, _widgetIndex + 2, value);
|
||||
}
|
||||
}
|
||||
Invalidate(widget);
|
||||
@@ -486,7 +486,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return WidgetIsPressed(*w, _widgetIndex);
|
||||
return Ui::WidgetIsPressed(*w, _widgetIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
WidgetSetCheckboxValue(*w, _widgetIndex, value ? 1 : 0);
|
||||
Ui::WidgetSetCheckboxValue(*w, _widgetIndex, value ? 1 : 0);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return WidgetIsPressed(*w, _widgetIndex);
|
||||
return Ui::WidgetIsPressed(*w, _widgetIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -557,7 +557,7 @@ namespace OpenRCT2::Scripting
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
WidgetSetCheckboxValue(*w, _widgetIndex, value ? 1 : 0);
|
||||
Ui::WidgetSetCheckboxValue(*w, _widgetIndex, value ? 1 : 0);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,6 +536,7 @@ static constexpr colour_t kColoursDropdownOrder[] = {
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
|
||||
using namespace OpenRCT2::Ui::Windows;
|
||||
using namespace OpenRCT2;
|
||||
|
||||
bool Dropdown::IsChecked(int32_t index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user