diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-04-22 18:21:14 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-04-30 17:08:15 +0100 |
commit | 1df510c297636652d826c512b009015f3de3a3b8 (patch) | |
tree | 0e43aedd3e94f9d860c53b22ba57a924ea1f4ec9 | |
parent | 09206be05448a7900bfa1f83c0b87212110fd96e (diff) | |
download | openttd-1df510c297636652d826c512b009015f3de3a3b8.tar.xz |
Fix: Company Key window scaling.
-rw-r--r-- | src/graph_gui.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 67399c327..52b37d677 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -21,6 +21,7 @@ #include "sortlist_type.h" #include "core/geometry_func.hpp" #include "currency.h" +#include "zoom_func.h" #include "widgets/graph_widget.h" @@ -65,11 +66,11 @@ struct GraphLegendWindow : Window { bool rtl = _current_text_dir == TD_RTL; Dimension d = GetSpriteSize(SPR_COMPANY_ICON); - DrawCompanyIcon(cid, rtl ? r.right - d.width - 2 : r.left + 2, r.top + (r.bottom - r.top - d.height) / 2); + DrawCompanyIcon(cid, rtl ? r.right - d.width - ScaleGUITrad(2) : r.left + ScaleGUITrad(2), CenterBounds(r.top, r.bottom, d.height)); SetDParam(0, cid); SetDParam(1, cid); - DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + 4)), r.right - (rtl ? (d.width + 4) : (uint)WD_FRAMERECT_RIGHT), r.top + (r.bottom - r.top + 1 - FONT_HEIGHT_NORMAL) / 2, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); + DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + ScaleGUITrad(4))), r.right - (rtl ? (d.width + ScaleGUITrad(4)) : (uint)WD_FRAMERECT_RIGHT), CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); } void OnClick(Point pt, int widget, int click_count) override @@ -110,11 +111,12 @@ struct GraphLegendWindow : Window { static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) { NWidgetVertical *vert = new NWidgetVertical(); - uint line_height = std::max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; + uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height; for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); - panel->SetMinimalSize(246, line_height); + panel->SetMinimalSize(246, sprite_height); + panel->SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, FS_NORMAL); panel->SetFill(1, 0); panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); vert->Add(panel); @@ -137,6 +139,7 @@ static const NWidgetPart _nested_graph_legend_widgets[] = { NWidgetFunction(MakeNWidgetCompanyLines), NWidget(NWID_SPACER), SetMinimalSize(2, 0), EndContainer(), + NWidget(NWID_SPACER), SetMinimalSize(0, 2), EndContainer(), }; |