summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-31 12:15:12 +0000
committeryexo <yexo@openttd.org>2010-07-31 12:15:12 +0000
commit5a2862814ac310e5e4629e0242def8ebf3a6da1c (patch)
tree9b2d2740d3d0c808253fa9e2f084a4023b2e6bcc /src/newgrf_config.cpp
parent9c241135f2d035c9e02b72c433517eb77d58c502 (diff)
downloadopenttd-5a2862814ac310e5e4629e0242def8ebf3a6da1c.tar.xz
(svn r20258) -Feature: more user-friendly gui to change NewGRF parameters
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index ea5a68c39..41be0c1c0 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -17,6 +17,7 @@
#include "network/network_func.h"
#include "gfx_func.h"
#include "newgrf_text.h"
+#include "window_func.h"
#include "fileio_func.h"
#include "fios.h"
@@ -196,6 +197,35 @@ GRFParameterInfo::~GRFParameterInfo()
}
/**
+ * Get the value of this user-changeable parameter from the given config.
+ * @param config The GRFConfig to get the value from.
+ * @return The value of this parameter.
+ */
+uint32 GRFParameterInfo::GetValue(struct GRFConfig *config) const
+{
+ /* GB doesn't work correctly with nbits == 32, so handle that case here. */
+ if (this->num_bit == 32) return config->param[this->param_nr];
+ return GB(config->param[this->param_nr], this->first_bit, this->num_bit);
+}
+
+/**
+ * Set the value of this user-changeable parameter in the given config.
+ * @param config The GRFConfig to set the value in.
+ * @param value The new value.
+ */
+void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32 value)
+{
+ /* SB doesn't work correctly with nbits == 32, so handle that case here. */
+ if (this->num_bit == 32) {
+ config->param[this->param_nr] = value;
+ } else {
+ SB(config->param[this->param_nr], this->first_bit, this->num_bit, value);
+ }
+ config->num_params = max<uint>(config->num_params, this->param_nr + 1);
+ SetWindowClassesDirty(WC_GAME_OPTIONS); // Is always the newgrf window
+}
+
+/**
* Update the palettes of the graphics from the config file.
* This is needed because the config file gets read and parsed
* before the palette is chosen (one can configure the base