diff options
author | frosch <frosch@openttd.org> | 2010-09-25 22:00:49 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-09-25 22:00:49 +0000 |
commit | 717fcd09c65a5e26116059d30bcd9e1b6e924c66 (patch) | |
tree | 13d5eabddff42d853e2e49333efbd47afe80b6fa /src | |
parent | a54b711dc10bf34929ec080d6507db0067455c64 (diff) | |
download | openttd-717fcd09c65a5e26116059d30bcd9e1b6e924c66.tar.xz |
(svn r20849) -Change: Only display liveries in the liverywindow if they are used by some vehicle somewhen (not considering date or such).
Diffstat (limited to 'src')
-rw-r--r-- | src/company_gui.cpp | 50 | ||||
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | src/table/settings.h | 3 |
3 files changed, 42 insertions, 17 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 273dea524..5bb4efd48 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -613,19 +613,11 @@ public: this->InitNested(desc, company); this->owner = company; this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL); + this->InvalidateData(1); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) { - /* Number of liveries in each class, used to determine the height of the livery matrix widget. */ - static const byte livery_height[] = { - 1, - 13, - 4, - 2, - 3, - }; - switch (widget) { case SCLW_WIDGET_SPACER_DROPDOWN: { /* The matrix widget below needs enough room to print all the schemes. */ @@ -637,10 +629,17 @@ public: break; } - case SCLW_WIDGET_MATRIX: - size->height = livery_height[this->livery_class] * (4 + FONT_HEIGHT_NORMAL); - this->GetWidget<NWidgetCore>(SCLW_WIDGET_MATRIX)->widget_data = (livery_height[this->livery_class] << MAT_ROW_START) | (1 << MAT_COL_START); + case SCLW_WIDGET_MATRIX: { + uint livery_height = 0; + for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { + if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) { + livery_height++; + } + } + size->height = livery_height * (4 + FONT_HEIGHT_NORMAL); + this->GetWidget<NWidgetCore>(SCLW_WIDGET_MATRIX)->widget_data = (livery_height << MAT_ROW_START) | (1 << MAT_COL_START); break; + } case SCLW_WIDGET_SEC_COL_DROPDOWN: if (!_loaded_newgrf_features.has_2CC) { @@ -711,7 +710,7 @@ public: int y = r.top + 3; const Company *c = Company::Get((CompanyID)this->window_number); for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { - if (_livery_class[scheme] == this->livery_class) { + if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) { bool sel = HasBit(this->sel, scheme) != 0; /* Optional check box + scheme name. */ @@ -751,7 +750,7 @@ public: /* Select the first item in the list */ this->sel = 0; for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { - if (_livery_class[scheme] == this->livery_class) { + if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) { this->sel = 1 << scheme; break; } @@ -773,7 +772,7 @@ public: LiveryScheme j = (LiveryScheme)((pt.y - wid->pos_y) / (4 + FONT_HEIGHT_NORMAL)); for (LiveryScheme scheme = LS_BEGIN; scheme <= j; scheme++) { - if (_livery_class[scheme] != this->livery_class) j++; + if (_livery_class[scheme] != this->livery_class || !HasBit(_loaded_newgrf_features.used_liveries, scheme)) j++; if (scheme >= LS_END) return; } if (j >= LS_END) return; @@ -805,7 +804,26 @@ public: virtual void OnInvalidateData(int data = 0) { - this->ReInit(); + this->SetWidgetsDisabledState(true, SCLW_WIDGET_CLASS_RAIL, SCLW_WIDGET_CLASS_ROAD, SCLW_WIDGET_CLASS_SHIP, SCLW_WIDGET_CLASS_AIRCRAFT, WIDGET_LIST_END); + + bool current_class_valid = this->livery_class == LC_OTHER; + if (_settings_client.gui.liveries == LIT_ALL || (_settings_client.gui.liveries == LIT_COMPANY && this->window_number == _local_company)) { + for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { + if (HasBit(_loaded_newgrf_features.used_liveries, scheme)) { + if (_livery_class[scheme] == this->livery_class) current_class_valid = true; + this->EnableWidget(SCLW_WIDGET_CLASS_GENERAL + _livery_class[scheme]); + } else { + ClrBit(this->sel, scheme); + } + } + } + + if (!current_class_valid) { + Point pt = {0, 0}; + this->OnClick(pt, SCLW_WIDGET_CLASS_GENERAL, 1); + } else if (data == 0) { + this->ReInit(); + } } }; diff --git a/src/settings.cpp b/src/settings.cpp index 2c7766869..b3ef6e6c2 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -890,6 +890,12 @@ static bool InvalidateVehTimetableWindow(int32 p1) return true; } +static bool InvalidateCompanyLiveryWindow(int32 p1) +{ + InvalidateWindowClassesData(WC_COMPANY_COLOUR); + return RedrawScreen(p1); +} + /* * A: competitors * B: competitor start time. Deprecated since savegame version 110. diff --git a/src/table/settings.h b/src/table/settings.h index 579d2bb8f..8baeb4562 100644 --- a/src/table/settings.h +++ b/src/table/settings.h @@ -39,6 +39,7 @@ static bool CheckFreeformEdges(int32 p1); static bool ChangeDynamicEngines(int32 p1); static bool StationCatchmentChanged(int32 p1); static bool InvalidateVehTimetableWindow(int32 p1); +static bool InvalidateCompanyLiveryWindow(int32 p1); #ifdef ENABLE_NETWORK static bool UpdateClientName(int32 p1); @@ -569,7 +570,7 @@ const SettingDesc _settings[] = { SDTC_BOOL(gui.population_in_label, S, 0, true, STR_CONFIG_SETTING_POPULATION_IN_LABEL, PopulationInLabelActive), SDTC_BOOL(gui.link_terraform_toolbar, S, 0, false, STR_CONFIG_SETTING_LINK_TERRAFORM_TOOLBAR, NULL), SDTC_VAR(gui.smallmap_land_colour, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR, RedrawSmallmap), - SDTC_VAR(gui.liveries, SLE_UINT8, S, MS, 2, 0, 2, 0, STR_CONFIG_SETTING_LIVERIES, RedrawScreen), + SDTC_VAR(gui.liveries, SLE_UINT8, S, MS, 2, 0, 2, 0, STR_CONFIG_SETTING_LIVERIES, InvalidateCompanyLiveryWindow), SDTC_BOOL(gui.prefer_teamchat, S, 0, false, STR_CONFIG_SETTING_PREFER_TEAMCHAT, NULL), SDTC_VAR(gui.scrollwheel_scrolling, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING, NULL), SDTC_VAR(gui.scrollwheel_multiplier, SLE_UINT8, S, 0, 5, 1, 15, 1, STR_CONFIG_SETTING_SCROLLWHEEL_MULTIPLIER, NULL), |