Fixed 'Build rail' dropdown menu

This commit is contained in:
pelya
2020-03-24 23:24:49 +02:00
parent e3e0559677
commit 77ecfa35fe
3 changed files with 9 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ static int _smallmap_company_count; ///< Number of entries in the owner legend.
static int _smallmap_cargo_count; ///< Number of cargos in the link stats legend.
/** Link stat colours shown in legenda. */
static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7};
static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9};
static const int NUM_NO_COMPANY_ENTRIES = 4; ///< Number of entries in the owner legend that are not companies.
@@ -1177,8 +1177,8 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
}
this->min_number_of_fixed_rows = max(this->min_number_of_fixed_rows, height);
this->min_number_of_columns = max(this->min_number_of_columns, num_columns);
printf("i = %d this->min_number_of_fixed_rows %d this->min_number_of_columns %d num_columns %d\n", i, this->min_number_of_fixed_rows, this->min_number_of_columns, num_columns);
}
/* The width of a column is the minimum width of all texts + the size of the blob + some spacing */
this->column_width = min_width + LEGEND_BLOB_WIDTH + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
}

View File

@@ -898,10 +898,10 @@ static CallBackFunction ToolbarBuildRailClick(Window *w)
DropDownList list = GetRailTypeDropDownList();
if (_settings_client.gui.compact_vertical_toolbar) {
const Company *c = Company::Get(_local_company);
list.emplace_back(new DropDownListStringItem(STR_ROAD_MENU_ROAD_CONSTRUCTION, RAILTYPE_END + ROADTYPE_ROAD, false));
list.emplace_back(new DropDownListStringItem(STR_ROAD_MENU_TRAM_CONSTRUCTION, RAILTYPE_END + ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM)));
list.emplace_back(new DropDownListStringItem(STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, RAILTYPE_END + WID_TN_WATER, false));
list.emplace_back(new DropDownListStringItem(STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, RAILTYPE_END + WID_TN_AIR, false));
list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDROAD, PAL_NONE, STR_ROAD_MENU_ROAD_CONSTRUCTION, RAILTYPE_END + ROADTYPE_ROAD, false));
list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDTRAMS, PAL_NONE, STR_ROAD_MENU_TRAM_CONSTRUCTION, RAILTYPE_END + ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM)));
list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDWATER, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, RAILTYPE_END + WID_TN_WATER, false));
list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDAIR, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, RAILTYPE_END + WID_TN_AIR, false));
}
ShowDropDownList(w, std::move(list), _last_built_railtype, WID_TN_RAILS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);

View File

@@ -83,7 +83,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
uint DropDownListIconItem::Height(uint width) const
{
return max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
return max(this->dim.height, DropDownListParamStringItem::Height(width));
}
uint DropDownListIconItem::Width() const
@@ -94,8 +94,8 @@ uint DropDownListIconItem::Width() const
void DropDownListIconItem::Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
{
bool rtl = _current_text_dir == TD_RTL;
DrawSprite(this->sprite, this->pal, rtl ? right - this->dim.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + this->sprite_y);
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : (this->dim.width + WD_FRAMERECT_LEFT)), right - WD_FRAMERECT_RIGHT - (rtl ? (this->dim.width + WD_FRAMERECT_RIGHT) : 0), top + this->text_y, this->String(), sel ? TC_WHITE : TC_BLACK);
DrawSprite(this->sprite, this->pal, rtl ? right - this->dim.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, Center(top, bottom - top, this->dim.height));
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : (this->dim.width + WD_FRAMERECT_LEFT)), right - WD_FRAMERECT_RIGHT - (rtl ? (this->dim.width + WD_FRAMERECT_RIGHT) : 0), Center(top, bottom - top), this->String(), sel ? TC_WHITE : TC_BLACK);
}
void DropDownListIconItem::SetDimension(Dimension d)