Mercurial > hg > openttd
annotate src/script/script_config.hpp @ 20641:5eb738001301 draft
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 12 Jul 2013 18:54:27 +0000 |
parents | 7fcb23b6305e |
children |
rev | line source |
---|---|
18520
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
2 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
3 /* |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
4 * This file is part of OpenTTD. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
8 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
9 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
10 /** @file script_config.hpp ScriptConfig stores the configuration settings of every Script. */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
11 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
12 #ifndef SCRIPT_CONFIG_HPP |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
13 #define SCRIPT_CONFIG_HPP |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
14 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
15 #include <map> |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
16 #include <list> |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
17 #include "../core/smallmap_type.hpp" |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
18 #include "../core/string_compare_type.hpp" |
19082
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
19 #include "../company_type.h" |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
20 #include "../textfile_gui.h" |
18520
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
21 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
22 /** Bitmask of flags for Script settings. */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
23 enum ScriptConfigFlags { |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
24 SCRIPTCONFIG_NONE = 0x0, ///< No flags set. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
25 SCRIPTCONFIG_RANDOM = 0x1, ///< When randomizing the Script, pick any value between min_value and max_value when on custom difficulty setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
26 SCRIPTCONFIG_BOOLEAN = 0x2, ///< This value is a boolean (either 0 (false) or 1 (true) ). |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
27 SCRIPTCONFIG_INGAME = 0x4, ///< This setting can be changed while the Script is running. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
28 SCRIPTCONFIG_DEVELOPER = 0x8, ///< This setting will only be visible when the Script development tools are active. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
29 }; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
30 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
31 typedef SmallMap<int, char *> LabelMapping; ///< Map-type used to map the setting numbers to labels. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
32 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
33 /** Info about a single Script setting. */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
34 struct ScriptConfigItem { |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
35 const char *name; ///< The name of the configuration setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
36 const char *description; ///< The description of the configuration setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
37 int min_value; ///< The minimal value this configuration setting can have. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
38 int max_value; ///< The maximal value this configuration setting can have. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
39 int custom_value; ///< The default value on custom difficulty setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
40 int easy_value; ///< The default value on easy difficulty setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
41 int medium_value; ///< The default value on medium difficulty setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
42 int hard_value; ///< The default value on hard difficulty setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
43 int random_deviation; ///< The maximum random deviation from the default value. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
44 int step_size; ///< The step size in the gui. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
45 ScriptConfigFlags flags; ///< Flags for the configuration setting. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
46 LabelMapping *labels; ///< Text labels for the integer values. |
19414
7fcb23b6305e
(svn r24317) -Feature: Add dropdowns to AI configurations, if all values have labels.
frosch <frosch@openttd.org>
parents:
19082
diff
changeset
|
47 bool complete_labels; ///< True if all values have a label. |
18520
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
48 }; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
49 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
50 typedef std::list<ScriptConfigItem> ScriptConfigItemList; ///< List of ScriptConfig items. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
51 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
52 extern ScriptConfigItem _start_date_config; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
53 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
54 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
55 * Script settings. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
56 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
57 class ScriptConfig { |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
58 protected: |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
59 /** List with name=>value pairs of all script-specific settings */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
60 typedef std::map<const char *, int, StringCompare> SettingValueList; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
61 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
62 public: |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
63 ScriptConfig() : |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
64 name(NULL), |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
65 version(-1), |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
66 info(NULL), |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
67 config_list(NULL), |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
68 is_random(false) |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
69 {} |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
70 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
71 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
72 * Create a new Script config that is a copy of an existing config. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
73 * @param config The object to copy. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
74 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
75 ScriptConfig(const ScriptConfig *config); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
76 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
77 /** Delete an Script configuration. */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
78 virtual ~ScriptConfig(); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
79 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
80 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
81 * Set another Script to be loaded in this slot. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
82 * @param name The name of the Script. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
83 * @param version The version of the Script to load, or -1 of latest. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
84 * @param force_exact_match If true try to find the exact same version |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
85 * as specified. If false any compatible version is ok. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
86 * @param is_random Is the Script chosen randomly? |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
87 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
88 void Change(const char *name, int version = -1, bool force_exact_match = false, bool is_random = false); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
89 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
90 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
91 * Get the ScriptInfo linked to this ScriptConfig. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
92 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
93 class ScriptInfo *GetInfo() const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
94 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
95 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
96 * Get the config list for this ScriptConfig. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
97 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
98 const ScriptConfigItemList *GetConfigList(); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
99 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
100 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
101 * Where to get the config from, either default (depends on current game |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
102 * mode) or force either newgame or normal |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
103 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
104 enum ScriptSettingSource { |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
105 SSS_DEFAULT, ///< Get the Script config from the current game mode |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
106 SSS_FORCE_NEWGAME, ///< Get the newgame Script config |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
107 SSS_FORCE_GAME, ///< Get the Script config from the current game |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
108 }; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
109 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
110 /** |
20641
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
111 * As long as the default of a setting has not been changed, the value of |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
112 * the setting is not stored. This to allow changing the difficulty setting |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
113 * without having to reset the script's config. However, when a setting may |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
114 * not be changed in game, we must "anchor" this value to what the setting |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
115 * would be at the time of starting. Otherwise changing the difficulty |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
116 * setting would change the setting's value (which isn't allowed). |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
117 */ |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
118 void AnchorUnchangeableSettings(); |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
119 |
5eb738001301
(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game
rubidium <rubidium@openttd.org>
parents:
19414
diff
changeset
|
120 /** |
18520
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
121 * Get the value of a setting for this config. It might fallback to his |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
122 * 'info' to find the default value (if not set or if not-custom difficulty |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
123 * level). |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
124 * @return The (default) value of the setting, or -1 if the setting was not |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
125 * found. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
126 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
127 virtual int GetSetting(const char *name) const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
128 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
129 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
130 * Set the value of a setting for this config. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
131 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
132 virtual void SetSetting(const char *name, int value); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
133 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
134 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
135 * Reset all settings to their default value. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
136 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
137 void ResetSettings(); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
138 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
139 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
140 * Randomize all settings the Script requested to be randomized. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
141 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
142 void AddRandomDeviation(); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
143 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
144 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
145 * Is this config attached to an Script? In other words, is there a Script |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
146 * that is assigned to this slot. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
147 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
148 bool HasScript() const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
149 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
150 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
151 * Is the current Script a randomly chosen Script? |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
152 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
153 bool IsRandom() const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
154 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
155 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
156 * Get the name of the Script. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
157 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
158 const char *GetName() const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
159 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
160 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
161 * Get the version of the Script. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
162 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
163 int GetVersion() const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
164 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
165 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
166 * Convert a string which is stored in the config file or savegames to |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
167 * custom settings of this Script. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
168 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
169 void StringToSettings(const char *value); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
170 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
171 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
172 * Convert the custom settings to a string that can be stored in the config |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
173 * file or savegames. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
174 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
175 void SettingsToString(char *string, size_t size) const; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
176 |
19082
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
177 /** |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
178 * Search a textfile file next to this script. |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
179 * @param type The type of the textfile to search for. |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
180 * @param slot #CompanyID to check status of. |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
181 * @return The filename for the textfile, \c NULL otherwise. |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
182 */ |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
183 const char *GetTextfile(TextfileType type, CompanyID slot) const; |
b75090cfaa3c
(svn r23936) -Feature [FS#5047]: readme/licence/changelog viewer for AI and game scripts (LordAro)
rubidium <rubidium@openttd.org>
parents:
18886
diff
changeset
|
184 |
18520
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
185 protected: |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
186 const char *name; ///< Name of the Script |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
187 int version; ///< Version of the Script |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
188 class ScriptInfo *info; ///< ScriptInfo object for related to this Script version |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
189 SettingValueList settings; ///< List with all setting=>value pairs that are configure for this Script |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
190 ScriptConfigItemList *config_list; ///< List with all settings defined by this Script |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
191 bool is_random; ///< True if the AI in this slot was randomly chosen. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
192 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
193 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
194 * In case you have mandatory non-Script-definable config entries in your |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
195 * list, add them to this function. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
196 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
197 virtual void PushExtraConfigList() {}; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
198 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
199 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
200 * Routine that clears the config list. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
201 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
202 virtual void ClearConfigList(); |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
203 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
204 /** |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
205 * This function should call back to the Scanner in charge of this Config, |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
206 * to find the ScriptInfo belonging to a name+version. |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
207 */ |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
208 virtual ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) = 0; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
209 }; |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
210 |
bb2c3b72ca78
(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
211 #endif /* SCRIPT_CONFIG_HPP */ |