From 835f45523d5d2aebe33693e3046ba05204120ecf Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 17 Mar 2025 21:47:05 +0100 Subject: [PATCH] Create widget type for horizontal separator --- src/openrct2-ui/input/MouseInput.cpp | 1 + src/openrct2-ui/interface/Widget.cpp | 12 ++++++++++++ src/openrct2-ui/scripting/ScWidget.hpp | 2 ++ src/openrct2-ui/windows/Guest.cpp | 18 ++++++++---------- src/openrct2/interface/Widget.h | 1 + 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 1663124c1f..26914830af 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -1106,6 +1106,7 @@ namespace OpenRCT2 case WindowWidgetType::Groupbox: case WindowWidgetType::ProgressBar: case WindowWidgetType::Placeholder: + case WindowWidgetType::HorizontalSeparator: // Non-interactive widget type break; case WindowWidgetType::ImgBtn: diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 1551e5a039..9b52cb7898 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -39,6 +39,7 @@ namespace OpenRCT2::Ui static void WidgetTextInset(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); static void WidgetProgressBarDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); + static void WidgetHorizontalSeparatorDraw(DrawPixelInfo& dpi, WindowBase& w, const Widget& widget); static void WidgetGroupboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); static void WidgetCaptionDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); static void WidgetCheckboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex); @@ -118,6 +119,9 @@ namespace OpenRCT2::Ui case WindowWidgetType::ProgressBar: WidgetProgressBarDraw(dpi, w, widgetIndex); break; + case WindowWidgetType::HorizontalSeparator: + WidgetHorizontalSeparatorDraw(dpi, w, *widget); + break; default: break; } @@ -1210,6 +1214,14 @@ namespace OpenRCT2::Ui } } + static void WidgetHorizontalSeparatorDraw(DrawPixelInfo& dpi, WindowBase& w, const Widget& widget) + { + ScreenCoordsXY topLeft{ w.windowPos + ScreenCoordsXY{ widget.left, widget.top } }; + ScreenCoordsXY bottomRight{ w.windowPos + ScreenCoordsXY{ widget.right, widget.bottom } }; + + GfxFillRectInset(dpi, { topLeft, bottomRight }, w.colours[1], INSET_RECT_FLAG_BORDER_INSET); + } + ImageId GetColourButtonImage(colour_t colour) { if (colour == COLOUR_INVISIBLE) diff --git a/src/openrct2-ui/scripting/ScWidget.hpp b/src/openrct2-ui/scripting/ScWidget.hpp index 3e55565c92..80e8f95649 100644 --- a/src/openrct2-ui/scripting/ScWidget.hpp +++ b/src/openrct2-ui/scripting/ScWidget.hpp @@ -113,6 +113,8 @@ namespace OpenRCT2::Scripting return "placeholder"; case WindowWidgetType::ProgressBar: return "progress_bar"; + case WindowWidgetType::HorizontalSeparator: + return "horizontal_separator"; case WindowWidgetType::Custom: return "custom"; } diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 7dad750161..05536fe2fb 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -97,6 +97,7 @@ namespace OpenRCT2::Ui::Windows WIDX_NAUSEA_BAR, WIDX_TOILET_LABEL, WIDX_TOILET_BAR, + WIDX_SEPARATOR, WIDX_RIDES_BEEN_ON_LABEL = WIDX_TAB_CONTENT_START, WIDX_RIDE_SCROLL, @@ -135,18 +136,19 @@ namespace OpenRCT2::Ui::Windows static constexpr Widget _guestWindowWidgetsStats[] = { MAIN_GUEST_WIDGETS, - MakeWidget ({ 3, (kListRowHeight * 0) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_HAPPINESS_LABEL), + MakeWidget ({ 3, (kListRowHeight * 0) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_HAPPINESS_LABEL), MakeProgressBar({ 65, (kListRowHeight * 0) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_GREEN, 0, 19), - MakeWidget ({ 3, (kListRowHeight * 1) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_ENERGY_LABEL), + MakeWidget ({ 3, (kListRowHeight * 1) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_ENERGY_LABEL), MakeProgressBar({ 65, (kListRowHeight * 1) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_GREEN, 0, 19), - MakeWidget ({ 3, (kListRowHeight * 2) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_HUNGER_LABEL), + MakeWidget ({ 3, (kListRowHeight * 2) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_HUNGER_LABEL), MakeProgressBar({ 65, (kListRowHeight * 2) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_RED, 67, 100), - MakeWidget ({ 3, (kListRowHeight * 3) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_THIRST_LABEL), + MakeWidget ({ 3, (kListRowHeight * 3) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_THIRST_LABEL), MakeProgressBar({ 65, (kListRowHeight * 3) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_RED, 67, 100), - MakeWidget ({ 3, (kListRowHeight * 4) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_NAUSEA_LABEL), + MakeWidget ({ 3, (kListRowHeight * 4) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_NAUSEA_LABEL), MakeProgressBar({ 65, (kListRowHeight * 4) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_RED, 47, 100), - MakeWidget ({ 3, (kListRowHeight * 5) + 4 + 43 }, { 62, 10}, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_TOILET_LABEL), + MakeWidget ({ 3, (kListRowHeight * 5) + 4 + 43 }, { 62, 10 }, WindowWidgetType::Label, WindowColour::Secondary, STR_GUEST_STAT_TOILET_LABEL), MakeProgressBar({ 65, (kListRowHeight * 5) + 4 + 43 }, { 119, 10 }, COLOUR_BRIGHT_RED, 62, 100), + MakeWidget ({ 3, (kListRowHeight * 7) + 9 + 43 }, { 180, 2 }, WindowWidgetType::HorizontalSeparator, WindowColour::Secondary), }; static constexpr Widget _guestWindowWidgetsRides[] = { @@ -1139,11 +1141,7 @@ namespace OpenRCT2::Ui::Windows DrawTextBasic(dpi, screenCoords, STR_GUEST_STAT_TIME_IN_PARK, ft); } - // Horizontal separator screenCoords.y += kListRowHeight + 9; - GfxFillRectInset( - dpi, { screenCoords - ScreenCoordsXY{ 0, 6 }, screenCoords + ScreenCoordsXY{ 179, -5 } }, colours[1], - INSET_RECT_FLAG_BORDER_INSET); // Preferred Ride DrawTextBasic(dpi, screenCoords, STR_GUEST_STAT_PREFERRED_RIDE); diff --git a/src/openrct2/interface/Widget.h b/src/openrct2/interface/Widget.h index 0b151e5af8..91c9b76f36 100644 --- a/src/openrct2/interface/Widget.h +++ b/src/openrct2/interface/Widget.h @@ -47,6 +47,7 @@ namespace OpenRCT2 ProgressBar = 29, Custom = 28, TextBox = 27, + HorizontalSeparator = 30, }; using WidgetFlags = uint32_t;