1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Use larger cross glyph for close button when title bar is enlarged

This commit is contained in:
Aaron van Geffen
2025-04-11 20:39:26 +02:00
parent 3f87e2b67a
commit 883845bcf9
4 changed files with 36 additions and 15 deletions

View File

@@ -15,18 +15,25 @@
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Widget.h>
// clang-format off
#define WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, CLOSE_STR) \
{ WindowWidgetType::Frame, 0, 0, WIDTH - 1, 0, HEIGHT - 1, 0xFFFFFFFF, kStringIdNone }, \
{ WindowWidgetType::Caption, 0, 1, WIDTH - 2, 1, 14, TITLE, STR_WINDOW_TITLE_TIP }, \
{ .type = WindowWidgetType::CloseBox, \
.colour = 0, \
.left = WIDTH - 13, \
.right = WIDTH - 3, \
.top = 2, \
.bottom = 13, \
.string = CLOSE_STR, \
.tooltip = STR_CLOSE_WINDOW_TIP }
#define WINDOW_SHIM(TITLE, WIDTH, HEIGHT) WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, kCloseBoxStringBlackNormal)
#define WINDOW_SHIM_WHITE(TITLE, WIDTH, HEIGHT) WINDOW_SHIM_RAW(TITLE, WIDTH, HEIGHT, kCloseBoxStringWhiteNormal)
// clang-format on
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, kStringIdNone }, \
{ WindowWidgetType::Caption, 0, 1, WIDTH - 2, 1, 14, TITLE, STR_WINDOW_TITLE_TIP }, \
{ WindowWidgetType::CloseBox, 0, WIDTH - 13, WIDTH - 3, 2, 13, CLOSE_STR, STR_CLOSE_WINDOW_TIP }
#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
ImageId GetColourButtonImage(colour_t colour);
Widget* GetWidgetByIndex(const WindowBase& w, WidgetIndex widgetIndex);

View File

@@ -21,6 +21,7 @@
#include <limits>
#include <openrct2/SpriteIds.h>
#include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Window.h>
#include <openrct2/localisation/Formatter.h>
@@ -475,10 +476,11 @@ namespace OpenRCT2::Ui::Windows
void OnPrepareDraw() override
{
// This has to be called to ensure the window frame is correctly initialised - not doing this will
// cause an assertion to be hit.
ResizeFrameWithPage();
widgets[WIDX_CLOSE].text = colours[0].hasFlag(ColourFlag::translucent) ? STR_CLOSE_X_WHITE : STR_CLOSE_X;
bool useWhite = colours[0].hasFlag(ColourFlag::translucent);
if (Config::Get().interface.EnlargedUi)
widgets[WIDX_CLOSE].string = !useWhite ? kCloseBoxStringBlackLarge : kCloseBoxStringWhiteLarge;
else
widgets[WIDX_CLOSE].string = !useWhite ? kCloseBoxStringBlackNormal : kCloseBoxStringWhiteNormal;
// Having the content panel visible for transparent windows makes the borders darker than they should be
// For now just hide it if there are no tabs and the window is not resizable

View File

@@ -68,6 +68,11 @@ namespace OpenRCT2
SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL
};
constexpr const char* kCloseBoxStringBlackNormal = u8"{BLACK}❌";
constexpr const char* kCloseBoxStringBlackLarge = u8"{BLACK}X";
constexpr const char* kCloseBoxStringWhiteNormal = u8"{WHITE}❌";
constexpr const char* kCloseBoxStringWhiteLarge = u8"{WHITE}X";
struct Widget
{
WindowWidgetType type{};
@@ -81,7 +86,7 @@ namespace OpenRCT2
uint32_t content;
ImageId image{};
StringId text;
utf8* string;
const utf8* string;
};
StringId tooltip{ kStringIdNone };

View File

@@ -54,6 +54,13 @@ namespace OpenRCT2
closeButton.left = windowWidth - 3 - closeButtonSize;
closeButton.right = windowWidth - 3;
}
// Set appropriate close button
bool useWhite = closeButton.string == kCloseBoxStringWhiteLarge || closeButton.string == kCloseBoxStringWhiteNormal;
if (closeButtonSize == kCloseButtonSizeTouch)
closeButton.string = !useWhite ? kCloseBoxStringBlackLarge : kCloseBoxStringWhiteLarge;
else
closeButton.string = !useWhite ? kCloseBoxStringBlackNormal : kCloseBoxStringWhiteNormal;
}
void WindowBase::ResizeFrame()