From c3ca57c42be1416d93738546acd2ad746ad02de6 Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 1 Jun 2012 15:20:18 +0000 Subject: (svn r24318) -Feature: Add dropdowns to NewGRF configurations, if all values have labels. --- src/newgrf_config.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/newgrf_config.cpp') diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 352740a59..d327da550 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -164,6 +164,17 @@ void GRFConfig::SetSuitablePalette() SB(this->palette, GRFP_USE_BIT, 1, pal == PAL_WINDOWS ? GRFP_USE_WINDOWS : GRFP_USE_DOS); } +/** + * Finalize Action 14 info after file scan is finished. + */ +void GRFConfig::FinalizeParameterInfo() +{ + for (GRFParameterInfo **info = this->param_info.Begin(); info != this->param_info.End(); ++info) { + if (*info == NULL) continue; + (*info)->Finalize(); + } +} + GRFConfig *_all_grfs; GRFConfig *_grfconfig; GRFConfig *_grfconfig_newgame; @@ -232,7 +243,8 @@ GRFParameterInfo::GRFParameterInfo(GRFParameterInfo &info) : def_value(info.def_value), param_nr(info.param_nr), first_bit(info.first_bit), - num_bit(info.num_bit) + num_bit(info.num_bit), + complete_labels(info.complete_labels) { for (uint i = 0; i < info.value_names.Length(); i++) { SmallPair *data = info.value_names.Get(i); @@ -280,6 +292,20 @@ void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32 value) SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE); } +/** + * Finalize Action 14 info after file scan is finished. + */ +void GRFParameterInfo::Finalize() +{ + this->complete_labels = true; + for (uint32 value = this->min_value; value <= this->max_value; value++) { + if (!this->value_names.Contains(value)) { + this->complete_labels = false; + break; + } + } +} + /** * Update the palettes of the graphics from the config file. * Called when changing the default palette in advanced settings. @@ -367,6 +393,7 @@ bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir) /* Find and load the Action 8 information */ LoadNewGRFFile(config, CONFIG_SLOT, GLS_FILESCAN, subdir); config->SetSuitablePalette(); + config->FinalizeParameterInfo(); /* Skip if the grfid is 0 (not read) or 0xFFFFFFFF (ttdp system grf) */ if (config->ident.grfid == 0 || config->ident.grfid == 0xFFFFFFFF || config->IsOpenTTDBaseGRF()) return false; -- cgit v1.2.3-54-g00ecf