diff --git a/src/openrct2-ui/interface/Graph.cpp b/src/openrct2-ui/interface/Graph.cpp index e66ce4a23a..be170829a3 100644 --- a/src/openrct2-ui/interface/Graph.cpp +++ b/src/openrct2-ui/interface/Graph.cpp @@ -161,44 +161,40 @@ namespace OpenRCT2::Graph } } - void DrawFinanceGraph(DrawPixelInfo& dpi, const GraphProperties& p) + template + static void DrawGraph( + DrawPixelInfo& dpi, const GraphProperties& p, const FmtString& labelFmt, const FmtString& tooltipFmt) { - const FmtString fmt("{BLACK}{CURRENCY2DP}"); - DrawYLabels(dpi, p.internalBounds, p.min, p.max, p.numYLabels, p.yLabelStepPx, p.lineCol, fmt); - DrawMonths(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); + DrawYLabels(dpi, p.internalBounds, p.min, p.max, p.numYLabels, p.yLabelStepPx, p.lineCol, labelFmt); + DrawMonths(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx); + DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); + DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); if (p.hoverIdx >= 0 && p.hoverIdx < p.numPoints) { - const money64 value = p.series[p.hoverIdx]; - if (value != kMoney64Undefined) + const T value = p.series[p.hoverIdx]; + if (value != TkNoValue) { char buffer[64]{}; - FormatStringToBuffer(buffer, sizeof(buffer), "{CURRENCY2DP}", value); - DrawHoveredValue( + FormatStringToBuffer(buffer, sizeof(buffer), tooltipFmt, value); + DrawHoveredValue( dpi, value, p.hoverIdx, p.internalBounds, p.xStepPx, p.min, p.max, buffer, p.lineCol.withFlag(ColourFlag::withOutline, true)); } } } + void DrawFinanceGraph(DrawPixelInfo& dpi, const GraphProperties& p) + { + DrawGraph(dpi, p, "{BLACK}{CURRENCY2DP}", "{CURRENCY2DP}"); + } + void DrawRatingGraph(DrawPixelInfo& dpi, const GraphProperties& p) { - constexpr uint16_t noValue = kParkRatingHistoryUndefined; - const FmtString fmt("{BLACK}{COMMA32}"); - DrawYLabels(dpi, p.internalBounds, p.min, p.max, p.numYLabels, p.yLabelStepPx, p.lineCol, fmt); - DrawMonths(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); + DrawGraph(dpi, p, "{BLACK}{COMMA32}", "{COMMA32}"); } void DrawGuestGraph(DrawPixelInfo& dpi, const GraphProperties& p) { - constexpr uint32_t noValue = kGuestsInParkHistoryUndefined; - const FmtString fmt("{BLACK}{COMMA32}"); - DrawYLabels(dpi, p.internalBounds, p.min, p.max, p.numYLabels, p.yLabelStepPx, p.lineCol, fmt); - DrawMonths(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); - DrawLine(dpi, p.series, p.numPoints, p.internalBounds, p.xStepPx, p.min, p.max); + DrawGraph(dpi, p, "{BLACK}{COMMA32}", "{COMMA32}"); } } // namespace OpenRCT2::Graph diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 2aaa3b0e89..a152c51583 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -832,7 +832,7 @@ namespace OpenRCT2::Ui::Windows _graphProps.min = centredGraph ? -max : 0.00_GBP; _graphProps.max = max; - // dynamic padding for long axis lables: + // dynamic padding for long axis labels: char buffer[64]{}; FormatStringToBuffer(buffer, sizeof(buffer), "{BLACK}{CURRENCY2DP}", centredGraph ? -max : max); int32_t maxWidth = GfxGetStringWidth(buffer, FontStyle::Small) + Graph::kYTickMarkPadding + 1; diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index d9f806de09..cc951ae8a6 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -39,8 +39,8 @@ namespace OpenRCT2::Ui::Windows static constexpr StringId WINDOW_TITLE = STR_STRINGID; static constexpr int32_t WH = 224; - static constexpr ScreenCoordsXY kGraphTopLeftPadding{ 45, 15 }; - static constexpr ScreenCoordsXY kGraphBottomRightPadding{ 5, 5 }; + static constexpr ScreenCoordsXY kGraphTopLeftPadding{ 45, 20 }; + static constexpr ScreenCoordsXY kGraphBottomRightPadding{ 25, 10 }; static constexpr uint8_t kGraphNumYLabels = 6; enum WindowParkPage @@ -685,13 +685,18 @@ namespace OpenRCT2::Ui::Windows #pragma region Rating page void OnResizeRating() { - WindowSetResize(*this, 255, 182, 255, 182); + flags |= WF_RESIZABLE; + WindowSetResize(*this, 268, 174 + 9, 2000, 2000); } void OnUpdateRating() { frame_no++; WidgetInvalidate(*this, WIDX_TAB_2); + if (_ratingProps.UpdateHoverIndex()) + { + InvalidateWidget(WIDX_BACKGROUND); + } } void OnPrepareDrawRating() @@ -740,6 +745,13 @@ namespace OpenRCT2::Ui::Windows // Graph border GfxFillRectInset(dpi, _ratingGraphBounds, colours[1], INSET_RECT_F_30); + // hide resize widget on graph area + constexpr ScreenCoordsXY offset{ 1, 1 }; + constexpr ScreenCoordsXY bigOffset{ 5, 5 }; + GfxFillRectInset( + dpi, { _ratingGraphBounds.Point2 - bigOffset, _ratingGraphBounds.Point2 - offset }, colours[1], + INSET_RECT_FLAG_FILL_DONT_LIGHTEN | INSET_RECT_FLAG_BORDER_NONE); + Graph::DrawRatingGraph(dpi, _ratingProps); } @@ -748,7 +760,8 @@ namespace OpenRCT2::Ui::Windows #pragma region Guests page void OnResizeGuests() { - WindowSetResize(*this, 255, 182, 255, 182); + flags |= WF_RESIZABLE; + WindowSetResize(*this, 268, 174 + 9, 2000, 2000); } void OnUpdateGuests() @@ -756,6 +769,10 @@ namespace OpenRCT2::Ui::Windows frame_no++; _peepAnimationFrame = (_peepAnimationFrame + 1) % 24; WidgetInvalidate(*this, WIDX_TAB_3); + if (_guestProps.UpdateHoverIndex()) + { + InvalidateWidget(WIDX_BACKGROUND); + } } void OnPrepareDrawGuests() @@ -815,6 +832,13 @@ namespace OpenRCT2::Ui::Windows // Graph border GfxFillRectInset(dpi, _guestGraphBounds, colours[1], INSET_RECT_F_30); + // hide resize widget on graph area + constexpr ScreenCoordsXY offset{ 1, 1 }; + constexpr ScreenCoordsXY bigOffset{ 5, 5 }; + GfxFillRectInset( + dpi, { _guestGraphBounds.Point2 - bigOffset, _guestGraphBounds.Point2 - offset }, colours[1], + INSET_RECT_FLAG_FILL_DONT_LIGHTEN | INSET_RECT_FLAG_BORDER_NONE); + Graph::DrawGuestGraph(dpi, _guestProps); }