Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple of livery related issues. #7160

Merged
merged 2 commits into from Feb 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/company_gui.cpp
Expand Up @@ -700,9 +700,6 @@ struct SelectCompanyLiveryWindow : public Window {
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_SCL_MATRIX_SCROLLBAR);

this->square = GetSpriteSize(SPR_SQUARE);
this->line_height = max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + 4;

if (group == INVALID_GROUP) {
this->livery_class = LC_OTHER;
this->sel = 1;
Expand Down Expand Up @@ -770,6 +767,9 @@ struct SelectCompanyLiveryWindow : public Window {

case WID_SCL_MATRIX: {
/* 11 items in the default rail class */
this->square = GetSpriteSize(SPR_SQUARE);
this->line_height = max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + 4;

size->height = 11 * this->line_height;
resize->width = 1;
resize->height = this->line_height;
Expand All @@ -784,6 +784,7 @@ struct SelectCompanyLiveryWindow : public Window {
FALLTHROUGH;

case WID_SCL_PRI_COL_DROPDOWN: {
this->square = GetSpriteSize(SPR_SQUARE);
int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
for (const StringID *id = _colour_dropdown; id != endof(_colour_dropdown); id++) {
size->width = max(size->width, GetStringBoundingBox(*id).width + padding);
Expand Down
5 changes: 3 additions & 2 deletions src/vehicle.cpp
Expand Up @@ -1813,11 +1813,12 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
if (parent_engine_type == INVALID_ENGINE) {
return LS_PASSENGER_WAGON_STEAM;
} else {
bool is_mu = HasBit(EngInfo(parent_engine_type)->misc_flags, EF_RAIL_IS_MU);
switch (RailVehInfo(parent_engine_type)->engclass) {
default: NOT_REACHED();
case EC_STEAM: return LS_PASSENGER_WAGON_STEAM;
case EC_DIESEL: return LS_PASSENGER_WAGON_DIESEL;
case EC_ELECTRIC: return LS_PASSENGER_WAGON_ELECTRIC;
case EC_DIESEL: return is_mu ? LS_DMU : LS_PASSENGER_WAGON_DIESEL;
case EC_ELECTRIC: return is_mu ? LS_EMU : LS_PASSENGER_WAGON_ELECTRIC;
case EC_MONORAIL: return LS_PASSENGER_WAGON_MONORAIL;
case EC_MAGLEV: return LS_PASSENGER_WAGON_MAGLEV;
}
Expand Down