* Draw a row in the settings panel. * * The scrollbar uses rows of the page, while the page data structure is a tree of #SettingsPage and #SettingEntry objects. * As a result, the drawing routing traverses the tree from top to bottom, counting rows in \a cur_row until it reaches \a first_row. * Then it enables drawing rows while traversing until \a max_row is reached, at which point drawing is
| 89 | * @return Row number of the next row to draw |
| 90 | */ |
| 91 | uint BaseSettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const |
| 92 | { |
| 93 | if (this->IsFiltered()) return cur_row; |
| 94 | if (cur_row >= max_row) return cur_row; |
| 95 | |
| 96 | bool rtl = _current_text_dir == TD_RTL; |
| 97 | int offset = (rtl ? -static_cast<int>(BaseSettingEntry::circle_size.width) : static_cast<int>(BaseSettingEntry::circle_size.width)) / 2; |
| 98 | int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent; |
| 99 | |
| 100 | int x = rtl ? right : left; |
| 101 | if (cur_row >= first_row) { |
| 102 | PixelColour colour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL); |
| 103 | y += (cur_row - first_row) * BaseSettingEntry::line_height; // Compute correct y start position |
| 104 | |
| 105 | /* Draw vertical for parent nesting levels */ |
| 106 | for (uint lvl = 0; lvl < this->level; lvl++) { |
| 107 | if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + BaseSettingEntry::line_height - 1, colour); |
| 108 | x += level_width; |
| 109 | } |
| 110 | /* draw own |- prefix */ |
| 111 | int halfway_y = y + BaseSettingEntry::line_height / 2; |
| 112 | int bottom_y = flags.Test(SettingEntryFlag::LastField) ? halfway_y : y + BaseSettingEntry::line_height - 1; |
| 113 | GfxDrawLine(x + offset, y, x + offset, bottom_y, colour); |
| 114 | /* Small horizontal line from the last vertical line */ |
| 115 | GfxDrawLine(x + offset, halfway_y, x + level_width - (rtl ? -WidgetDimensions::scaled.hsep_normal : WidgetDimensions::scaled.hsep_normal), halfway_y, colour); |
| 116 | x += level_width; |
| 117 | |
| 118 | this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected); |
| 119 | } |
| 120 | cur_row++; |
| 121 | |
| 122 | return cur_row; |
| 123 | } |
| 124 | |
| 125 | /* == SettingEntry methods == */ |
| 126 |
nothing calls this directly
no test coverage detected