| 833 | } |
| 834 | |
| 835 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 836 | { |
| 837 | switch (widget) { |
| 838 | case WID_NS_FILE_LIST: { |
| 839 | const Rect br = r.Shrink(WidgetDimensions::scaled.bevel); |
| 840 | GfxFillRect(br, PC_BLACK); |
| 841 | |
| 842 | Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); |
| 843 | uint step_height = this->GetWidget<NWidgetBase>(WID_NS_FILE_LIST)->resize_y; |
| 844 | Dimension square = GetSpriteSize(SPR_SQUARE); |
| 845 | Dimension warning = GetSpriteSize(SPR_WARNING_SIGN); |
| 846 | int square_offset_y = (step_height - square.height) / 2; |
| 847 | int warning_offset_y = (step_height - warning.height) / 2; |
| 848 | int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2; |
| 849 | |
| 850 | bool rtl = _current_text_dir == TD_RTL; |
| 851 | uint text_left = rtl ? tr.left : tr.left + square.width + 13; |
| 852 | uint text_right = rtl ? tr.right - square.width - 13 : tr.right; |
| 853 | uint square_left = rtl ? tr.right - square.width - 3 : tr.left + 3; |
| 854 | uint warning_left = rtl ? tr.right - square.width - warning.width - 8 : tr.left + square.width + 8; |
| 855 | |
| 856 | int i = 0; |
| 857 | for (const auto &c : this->actives) { |
| 858 | if (this->vscroll->IsVisible(i)) { |
| 859 | std::string text = c->GetName(); |
| 860 | bool h = (this->active_sel == c.get()); |
| 861 | PaletteID pal = this->GetPalette(*c); |
| 862 | |
| 863 | if (h) { |
| 864 | GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE); |
| 865 | } else if (i == this->active_over) { |
| 866 | /* Get index of current selection. */ |
| 867 | int active_sel_pos = this->GetCurrentActivePosition(); |
| 868 | if (active_sel_pos != this->active_over) { |
| 869 | uint top = (active_sel_pos < 0 || this->active_over < active_sel_pos) ? tr.top + 1 : tr.top + step_height - 2; |
| 870 | GfxFillRect(tr.left, top - 1, tr.right, top + 1, PC_GREY); |
| 871 | } |
| 872 | } |
| 873 | DrawSprite(SPR_SQUARE, pal, square_left, tr.top + square_offset_y); |
| 874 | if (!c->errors.empty()) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, tr.top + warning_offset_y); |
| 875 | uint txtoffset = c->errors.empty() ? 0 : warning.width; |
| 876 | DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), tr.top + offset_y, std::move(text), h ? TC_WHITE : TC_ORANGE); |
| 877 | tr.top += step_height; |
| 878 | } |
| 879 | i++; |
| 880 | } |
| 881 | if (i == this->active_over && this->vscroll->IsVisible(i)) { // Highlight is after the last GRF entry. |
| 882 | GfxFillRect(tr.left, tr.top, tr.right, tr.top + 2, PC_GREY); |
| 883 | } |
| 884 | break; |
| 885 | } |
| 886 | |
| 887 | case WID_NS_AVAIL_LIST: { |
| 888 | const Rect br = r.Shrink(WidgetDimensions::scaled.bevel); |
| 889 | GfxFillRect(br, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK); |
| 890 | |
| 891 | Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); |
| 892 | uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y; |
nothing calls this directly
no test coverage detected