Change: Store running AI config inside Company (#12003)
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
void ScriptConfig::Change(std::optional<const std::string> name, int version, bool force_exact_match, bool is_random)
|
||||
void ScriptConfig::Change(std::optional<const std::string> name, int version, bool force_exact_match)
|
||||
{
|
||||
if (name.has_value()) {
|
||||
this->name = std::move(name.value());
|
||||
@@ -27,7 +27,6 @@ void ScriptConfig::Change(std::optional<const std::string> name, int version, bo
|
||||
this->info = nullptr;
|
||||
}
|
||||
this->version = (info == nullptr) ? -1 : info->GetVersion();
|
||||
this->is_random = is_random;
|
||||
this->config_list.reset();
|
||||
this->to_load_data.reset();
|
||||
|
||||
@@ -39,7 +38,6 @@ ScriptConfig::ScriptConfig(const ScriptConfig *config)
|
||||
this->name = config->name;
|
||||
this->info = config->info;
|
||||
this->version = config->version;
|
||||
this->is_random = config->is_random;
|
||||
this->to_load_data.reset();
|
||||
|
||||
for (const auto &item : config->settings) {
|
||||
@@ -139,11 +137,6 @@ bool ScriptConfig::HasScript() const
|
||||
return this->info != nullptr;
|
||||
}
|
||||
|
||||
bool ScriptConfig::IsRandom() const
|
||||
{
|
||||
return this->is_random;
|
||||
}
|
||||
|
||||
const std::string &ScriptConfig::GetName() const
|
||||
{
|
||||
return this->name;
|
||||
|
@@ -56,7 +56,6 @@ public:
|
||||
ScriptConfig() :
|
||||
version(-1),
|
||||
info(nullptr),
|
||||
is_random(false),
|
||||
to_load_data(nullptr)
|
||||
{}
|
||||
|
||||
@@ -77,7 +76,7 @@ public:
|
||||
* as specified. If false any compatible version is ok.
|
||||
* @param is_random Is the Script chosen randomly?
|
||||
*/
|
||||
void Change(std::optional<const std::string> name, int version = -1, bool force_exact_match = false, bool is_random = false);
|
||||
void Change(std::optional<const std::string> name, int version = -1, bool force_exact_match = false);
|
||||
|
||||
/**
|
||||
* Get the ScriptInfo linked to this ScriptConfig.
|
||||
@@ -144,11 +143,6 @@ public:
|
||||
*/
|
||||
bool HasScript() const;
|
||||
|
||||
/**
|
||||
* Is the current Script a randomly chosen Script?
|
||||
*/
|
||||
bool IsRandom() const;
|
||||
|
||||
/**
|
||||
* Get the name of the Script.
|
||||
*/
|
||||
@@ -188,7 +182,6 @@ protected:
|
||||
class ScriptInfo *info; ///< ScriptInfo object for related to this Script version
|
||||
SettingValueList settings; ///< List with all setting=>value pairs that are configure for this Script
|
||||
std::unique_ptr<ScriptConfigItemList> config_list; ///< List with all settings defined by this Script
|
||||
bool is_random; ///< True if the AI in this slot was randomly chosen.
|
||||
std::unique_ptr<ScriptInstance::ScriptData> to_load_data; ///< Data to load after the Script start.
|
||||
|
||||
/**
|
||||
|
@@ -307,13 +307,11 @@ struct ScriptSettingsWindow : public Window {
|
||||
clicked_dropdown(false),
|
||||
closing_dropdown(false)
|
||||
{
|
||||
this->script_config = GetConfig(slot);
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_SCRS_SCROLLBAR);
|
||||
this->FinishInitNested(slot); // Initializes 'this->line_height' as side effect.
|
||||
|
||||
this->RebuildVisibleSettings();
|
||||
this->OnInvalidateData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,6 +589,8 @@ struct ScriptSettingsWindow : public Window {
|
||||
*/
|
||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||
{
|
||||
this->script_config = GetConfig(this->slot);
|
||||
if (this->script_config->GetConfigList()->empty()) this->Close();
|
||||
this->RebuildVisibleSettings();
|
||||
this->CloseChildWindows(WC_DROPDOWN_MENU);
|
||||
this->CloseChildWindows(WC_QUERY_STRING);
|
||||
@@ -1206,7 +1206,8 @@ struct ScriptDebugWindow : public Window {
|
||||
this->SetWidgetLoweredState(WID_SCRD_BREAK_STR_ON_OFF_BTN, this->filter.break_check_enabled);
|
||||
this->SetWidgetLoweredState(WID_SCRD_MATCH_CASE_BTN, this->filter.case_sensitive_break_check);
|
||||
|
||||
this->SetWidgetDisabledState(WID_SCRD_SETTINGS, this->filter.script_debug_company == INVALID_COMPANY);
|
||||
this->SetWidgetDisabledState(WID_SCRD_SETTINGS, this->filter.script_debug_company == INVALID_COMPANY ||
|
||||
GetConfig(this->filter.script_debug_company)->GetConfigList()->empty());
|
||||
extern CompanyID _local_company;
|
||||
this->SetWidgetDisabledState(WID_SCRD_RELOAD_TOGGLE,
|
||||
this->filter.script_debug_company == INVALID_COMPANY ||
|
||||
|
Reference in New Issue
Block a user