summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-06-01 15:20:18 +0000
committerfrosch <frosch@openttd.org>2012-06-01 15:20:18 +0000
commitc3ca57c42be1416d93738546acd2ad746ad02de6 (patch)
tree52475fb363477b3fe40f244fdc9009dc56579859 /src/newgrf_config.cpp
parentbe0b94400d6e7e9136703d60b70b495d84f25108 (diff)
downloadopenttd-c3ca57c42be1416d93738546acd2ad746ad02de6.tar.xz
(svn r24318) -Feature: Add dropdowns to NewGRF configurations, if all values have labels.
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp29
1 files changed, 28 insertions, 1 deletions
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<uint32, GRFText *> *data = info.value_names.Get(i);
@@ -281,6 +293,20 @@ void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32 value)
}
/**
+ * 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.
* @param p1 Unused.
@@ -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;