From 8ad5bd5a94b272a9bd23a3f1af4c1f35f5671615 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 22 Jun 2025 15:41:51 +0100 Subject: [PATCH] Codechange: Allow unused graph ranges to be masked. --- src/graph_gui.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 70b1ce92bd..bb4b320921 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -181,8 +181,9 @@ protected: static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw. static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines. - uint64_t excluded_data = 0; ///< bitmask of the datasets that shouldn't be displayed. - uint64_t excluded_range = 0; ///< bitmask of ranges that should not be displayed. + uint64_t excluded_data = 0; ///< bitmask of datasets hidden by the player. + uint64_t excluded_range = 0; ///< bitmask of ranges hidden by the player. + uint64_t masked_range = 0; ///< bitmask of ranges that are not available for the current data. uint8_t num_on_x_axis = 0; uint8_t num_vert_lines = GRAPH_NUM_MONTHS; @@ -663,13 +664,17 @@ public: uint index = 0; Rect line = r.WithHeight(line_height); for (const auto &str : this->ranges) { - bool lowered = !HasBit(this->excluded_range, index); + bool lowered = !HasBit(this->excluded_range, index) && !HasBit(this->masked_range, index); /* Redraw frame if lowered */ if (lowered) DrawFrameRect(line, COLOUR_BROWN, FrameFlag::Lowered); const Rect text = line.Shrink(WidgetDimensions::scaled.framerect); - DrawString(text, str, TC_BLACK, SA_CENTER, false, FS_SMALL); + DrawString(text, str, (this->highlight_state && this->highlight_range == index) ? TC_WHITE : TC_BLACK, SA_CENTER, false, FS_SMALL); + + if (HasBit(this->masked_range, index)) { + GfxFillRect(line.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(COLOUR_BROWN, SHADE_DARKER), FILLRECT_CHECKER); + } line = line.Translate(0, line_height); ++index; @@ -692,6 +697,7 @@ public: case WID_GRAPH_RANGE_MATRIX: { int row = GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical()); + if (HasBit(this->masked_range, row)) break; ToggleBit(this->excluded_range, row); this->SetDirty(); break; @@ -1103,6 +1109,7 @@ struct BaseCargoGraphWindow : BaseGraphWindow { { this->CreateNestedTree(); + this->excluded_range = this->masked_range; this->cargo_types = this->GetCargoTypes(number); this->vscroll = this->GetScrollbar(WID_GRAPH_MATRIX_SCROLLBAR);