mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-19 03:29:26 +01:00
Codechange: Code style changes to AI/GS GUI files (#13665)
This commit is contained in:
parent
893a75f2c0
commit
484f18f987
@ -218,7 +218,7 @@ struct AIConfigWindow : public Window {
|
|||||||
if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) {
|
if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) {
|
||||||
if (this->selected_slot == CompanyID::Invalid() || AIConfig::GetConfig(this->selected_slot) == nullptr) return;
|
if (this->selected_slot == CompanyID::Invalid() || AIConfig::GetConfig(this->selected_slot) == nullptr) return;
|
||||||
|
|
||||||
ShowScriptTextfileWindow(this, (TextfileType)(widget - WID_AIC_TEXTFILE), this->selected_slot);
|
ShowScriptTextfileWindow(this, static_cast<TextfileType>(widget - WID_AIC_TEXTFILE), this->selected_slot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,23 +250,23 @@ struct AIConfigWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_AIC_LIST: { // Select a slot
|
case WID_AIC_LIST: { // Select a slot
|
||||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
this->selected_slot = static_cast<CompanyID>(this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget));
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
|
if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow(this->selected_slot, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WID_AIC_MOVE_UP:
|
case WID_AIC_MOVE_UP:
|
||||||
if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot - 1))) {
|
if (IsEditable(this->selected_slot) && IsEditable(static_cast<CompanyID>(this->selected_slot - 1))) {
|
||||||
std::swap(GetGameSettings().script_config.ai[this->selected_slot], GetGameSettings().script_config.ai[this->selected_slot - 1]);
|
std::swap(GetGameSettings().script_config.ai[this->selected_slot], GetGameSettings().script_config.ai[this->selected_slot - 1]);
|
||||||
this->selected_slot = CompanyID(this->selected_slot - 1);
|
this->selected_slot = static_cast<CompanyID>(this->selected_slot - 1);
|
||||||
this->vscroll->ScrollTowards(this->selected_slot.base());
|
this->vscroll->ScrollTowards(this->selected_slot.base());
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_AIC_MOVE_DOWN:
|
case WID_AIC_MOVE_DOWN:
|
||||||
if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot + 1))) {
|
if (IsEditable(this->selected_slot) && IsEditable(static_cast<CompanyID>(this->selected_slot + 1))) {
|
||||||
std::swap(GetGameSettings().script_config.ai[this->selected_slot], GetGameSettings().script_config.ai[this->selected_slot + 1]);
|
std::swap(GetGameSettings().script_config.ai[this->selected_slot], GetGameSettings().script_config.ai[this->selected_slot + 1]);
|
||||||
++this->selected_slot;
|
++this->selected_slot;
|
||||||
this->vscroll->ScrollTowards(this->selected_slot.base());
|
this->vscroll->ScrollTowards(this->selected_slot.base());
|
||||||
@ -282,11 +282,11 @@ struct AIConfigWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_AIC_CHANGE: // choose other AI
|
case WID_AIC_CHANGE: // choose other AI
|
||||||
if (IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
|
if (IsEditable(this->selected_slot)) ShowScriptListWindow(this->selected_slot, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_AIC_CONFIGURE: // change the settings for an AI
|
case WID_AIC_CONFIGURE: // change the settings for an AI
|
||||||
ShowScriptSettingsWindow((CompanyID)this->selected_slot);
|
ShowScriptSettingsWindow(this->selected_slot);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_AIC_CONTENT_DOWNLOAD:
|
case WID_AIC_CONTENT_DOWNLOAD:
|
||||||
@ -320,8 +320,8 @@ struct AIConfigWindow : public Window {
|
|||||||
this->SetWidgetDisabledState(WID_AIC_INCREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MAX_COMPETITORS_INTERVAL);
|
this->SetWidgetDisabledState(WID_AIC_INCREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MAX_COMPETITORS_INTERVAL);
|
||||||
this->SetWidgetDisabledState(WID_AIC_CHANGE, !IsEditable(this->selected_slot));
|
this->SetWidgetDisabledState(WID_AIC_CHANGE, !IsEditable(this->selected_slot));
|
||||||
this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == CompanyID::Invalid() || config->GetConfigList()->empty());
|
this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == CompanyID::Invalid() || config->GetConfigList()->empty());
|
||||||
this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable((CompanyID)(this->selected_slot - 1)));
|
this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable(static_cast<CompanyID>(this->selected_slot - 1)));
|
||||||
this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, !IsEditable(this->selected_slot) || !IsEditable((CompanyID)(this->selected_slot + 1)));
|
this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, !IsEditable(this->selected_slot) || !IsEditable(static_cast<CompanyID>(this->selected_slot + 1)));
|
||||||
|
|
||||||
this->SetWidgetDisabledState(WID_AIC_OPEN_URL, this->selected_slot == CompanyID::Invalid() || config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
this->SetWidgetDisabledState(WID_AIC_OPEN_URL, this->selected_slot == CompanyID::Invalid() || config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
||||||
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
||||||
|
@ -123,12 +123,12 @@ struct GSConfigWindow : public Window {
|
|||||||
*/
|
*/
|
||||||
void RebuildVisibleSettings()
|
void RebuildVisibleSettings()
|
||||||
{
|
{
|
||||||
visible_settings.clear();
|
this->visible_settings.clear();
|
||||||
|
|
||||||
for (const auto &item : *this->gs_config->GetConfigList()) {
|
for (const auto &item : *this->gs_config->GetConfigList()) {
|
||||||
bool no_hide = !item.flags.Test(ScriptConfigFlag::Developer);
|
bool no_hide = !item.flags.Test(ScriptConfigFlag::Developer);
|
||||||
if (no_hide || _settings_client.gui.ai_developer_tools) {
|
if (no_hide || _settings_client.gui.ai_developer_tools) {
|
||||||
visible_settings.push_back(&item);
|
this->visible_settings.push_back(&item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ struct GSConfigWindow : public Window {
|
|||||||
} else {
|
} else {
|
||||||
int i = static_cast<int>(std::distance(std::begin(this->visible_settings), it));
|
int i = static_cast<int>(std::distance(std::begin(this->visible_settings), it));
|
||||||
if (config_item.complete_labels) {
|
if (config_item.complete_labels) {
|
||||||
DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
|
DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, editable);
|
||||||
} else {
|
} else {
|
||||||
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
||||||
}
|
}
|
||||||
@ -228,19 +228,19 @@ struct GSConfigWindow : public Window {
|
|||||||
if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) {
|
if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) {
|
||||||
if (GameConfig::GetConfig() == nullptr) return;
|
if (GameConfig::GetConfig() == nullptr) return;
|
||||||
|
|
||||||
ShowScriptTextfileWindow(this, (TextfileType)(widget - WID_GSC_TEXTFILE), (CompanyID)OWNER_DEITY);
|
ShowScriptTextfileWindow(this, static_cast<TextfileType>(widget - WID_GSC_TEXTFILE), OWNER_DEITY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_GSC_GSLIST: {
|
case WID_GSC_GSLIST: {
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed);
|
if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow(OWNER_DEITY, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WID_GSC_CHANGE: // choose other Game Script
|
case WID_GSC_CHANGE: // choose other Game Script
|
||||||
ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed);
|
ShowScriptListWindow(OWNER_DEITY, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GSC_CONTENT_DOWNLOAD:
|
case WID_GSC_CONTENT_DOWNLOAD:
|
||||||
@ -350,14 +350,14 @@ struct GSConfigWindow : public Window {
|
|||||||
if (!str.has_value()) return;
|
if (!str.has_value()) return;
|
||||||
auto value = ParseInteger<int32_t>(*str, 10, true);
|
auto value = ParseInteger<int32_t>(*str, 10, true);
|
||||||
if (!value.has_value()) return;
|
if (!value.has_value()) return;
|
||||||
SetValue(*value);
|
this->SetValue(*value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDropdownSelect(WidgetID widget, int index, int) override
|
void OnDropdownSelect(WidgetID widget, int index, int) override
|
||||||
{
|
{
|
||||||
if (widget != WID_GSC_SETTING_DROPDOWN) return;
|
if (widget != WID_GSC_SETTING_DROPDOWN) return;
|
||||||
assert(this->clicked_dropdown);
|
assert(this->clicked_dropdown);
|
||||||
SetValue(index);
|
this->SetValue(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDropdownClose(Point, WidgetID widget, int, int, bool) override
|
void OnDropdownClose(Point, WidgetID widget, int, int, bool) override
|
||||||
@ -397,7 +397,7 @@ struct GSConfigWindow : public Window {
|
|||||||
const GameConfig *config = GameConfig::GetConfig();
|
const GameConfig *config = GameConfig::GetConfig();
|
||||||
this->SetWidgetDisabledState(WID_GSC_OPEN_URL, config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
this->SetWidgetDisabledState(WID_GSC_OPEN_URL, config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
||||||
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
||||||
this->SetWidgetDisabledState(WID_GSC_TEXTFILE + tft, !config->GetTextfile(tft, (CompanyID)OWNER_DEITY).has_value());
|
this->SetWidgetDisabledState(WID_GSC_TEXTFILE + tft, !config->GetTextfile(tft, OWNER_DEITY).has_value());
|
||||||
}
|
}
|
||||||
this->RebuildVisibleSettings();
|
this->RebuildVisibleSettings();
|
||||||
this->CloseChildWindows(WC_DROPDOWN_MENU);
|
this->CloseChildWindows(WC_DROPDOWN_MENU);
|
||||||
|
@ -71,7 +71,7 @@ struct ScriptListWindow : public Window {
|
|||||||
ScriptListWindow(WindowDesc &desc, CompanyID slot, bool show_all) : Window(desc),
|
ScriptListWindow(WindowDesc &desc, CompanyID slot, bool show_all) : Window(desc),
|
||||||
slot(slot), show_all(show_all)
|
slot(slot), show_all(show_all)
|
||||||
{
|
{
|
||||||
if (slot == OWNER_DEITY) {
|
if (this->slot == OWNER_DEITY) {
|
||||||
this->info_list = this->show_all ? Game::GetInfoList() : Game::GetUniqueInfoList();
|
this->info_list = this->show_all ? Game::GetInfoList() : Game::GetUniqueInfoList();
|
||||||
} else {
|
} else {
|
||||||
this->info_list = this->show_all ? AI::GetInfoList() : AI::GetUniqueInfoList();
|
this->info_list = this->show_all ? AI::GetInfoList() : AI::GetUniqueInfoList();
|
||||||
@ -84,8 +84,8 @@ struct ScriptListWindow : public Window {
|
|||||||
this->vscroll->SetCount(this->info_list->size() + 1);
|
this->vscroll->SetCount(this->info_list->size() + 1);
|
||||||
|
|
||||||
/* Try if we can find the currently selected AI */
|
/* Try if we can find the currently selected AI */
|
||||||
if (GetConfig(slot)->HasScript()) {
|
if (GetConfig(this->slot)->HasScript()) {
|
||||||
ScriptInfo *info = GetConfig(slot)->GetInfo();
|
ScriptInfo *info = GetConfig(this->slot)->GetInfo();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &item : *this->info_list) {
|
for (const auto &item : *this->info_list) {
|
||||||
if (item.second == info) {
|
if (item.second == info) {
|
||||||
@ -168,25 +168,25 @@ struct ScriptListWindow : public Window {
|
|||||||
void ChangeScript()
|
void ChangeScript()
|
||||||
{
|
{
|
||||||
if (this->selected == -1) {
|
if (this->selected == -1) {
|
||||||
GetConfig(slot)->Change(std::nullopt);
|
GetConfig(this->slot)->Change(std::nullopt);
|
||||||
} else {
|
} else {
|
||||||
ScriptInfoList::const_iterator it = this->info_list->cbegin();
|
ScriptInfoList::const_iterator it = this->info_list->cbegin();
|
||||||
std::advance(it, this->selected);
|
std::advance(it, this->selected);
|
||||||
GetConfig(slot)->Change(it->second->GetName(), it->second->GetVersion());
|
GetConfig(this->slot)->Change(it->second->GetName(), it->second->GetVersion());
|
||||||
}
|
}
|
||||||
if (_game_mode == GM_EDITOR) {
|
if (_game_mode == GM_EDITOR) {
|
||||||
if (slot == OWNER_DEITY) {
|
if (this->slot == OWNER_DEITY) {
|
||||||
if (Game::GetInstance() != nullptr) Game::ResetInstance();
|
if (Game::GetInstance() != nullptr) Game::ResetInstance();
|
||||||
Game::StartNew();
|
Game::StartNew();
|
||||||
} else {
|
} else {
|
||||||
Company *c = Company::GetIfValid(slot);
|
Company *c = Company::GetIfValid(this->slot);
|
||||||
if (c != nullptr && c->ai_instance != nullptr) {
|
if (c != nullptr && c->ai_instance != nullptr) {
|
||||||
c->ai_instance.reset();
|
c->ai_instance.reset();
|
||||||
AI::StartNew(slot);
|
AI::StartNew(this->slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InvalidateWindowData(WC_GAME_OPTIONS, slot == OWNER_DEITY ? WN_GAME_OPTIONS_GS : WN_GAME_OPTIONS_AI);
|
InvalidateWindowData(WC_GAME_OPTIONS, this->slot == OWNER_DEITY ? WN_GAME_OPTIONS_GS : WN_GAME_OPTIONS_AI);
|
||||||
InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);
|
InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);
|
||||||
InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1);
|
InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1);
|
||||||
CloseWindowByClass(WC_QUERY_STRING);
|
CloseWindowByClass(WC_QUERY_STRING);
|
||||||
@ -198,7 +198,7 @@ struct ScriptListWindow : public Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_SCRL_LIST: { // Select one of the Scripts
|
case WID_SCRL_LIST: { // Select one of the Scripts
|
||||||
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCRL_LIST) - 1;
|
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCRL_LIST) - 1;
|
||||||
if (sel < (int)this->info_list->size()) {
|
if (sel < static_cast<int>(this->info_list->size())) {
|
||||||
this->selected = sel;
|
this->selected = sel;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
if (click_count > 1) {
|
if (click_count > 1) {
|
||||||
@ -307,7 +307,7 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
{
|
{
|
||||||
this->CreateNestedTree();
|
this->CreateNestedTree();
|
||||||
this->vscroll = this->GetScrollbar(WID_SCRS_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_SCRS_SCROLLBAR);
|
||||||
this->FinishInitNested(slot); // Initializes 'this->line_height' as side effect.
|
this->FinishInitNested(this->slot); // Initializes 'this->line_height' as side effect.
|
||||||
|
|
||||||
this->OnInvalidateData();
|
this->OnInvalidateData();
|
||||||
}
|
}
|
||||||
@ -319,12 +319,12 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
*/
|
*/
|
||||||
void RebuildVisibleSettings()
|
void RebuildVisibleSettings()
|
||||||
{
|
{
|
||||||
visible_settings.clear();
|
this->visible_settings.clear();
|
||||||
|
|
||||||
for (const auto &item : *this->script_config->GetConfigList()) {
|
for (const auto &item : *this->script_config->GetConfigList()) {
|
||||||
bool no_hide = !item.flags.Test(ScriptConfigFlag::Developer);
|
bool no_hide = !item.flags.Test(ScriptConfigFlag::Developer);
|
||||||
if (no_hide || _settings_client.gui.ai_developer_tools) {
|
if (no_hide || _settings_client.gui.ai_developer_tools) {
|
||||||
visible_settings.push_back(&item);
|
this->visible_settings.push_back(&item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
} else {
|
} else {
|
||||||
int i = static_cast<int>(std::distance(std::begin(this->visible_settings), it));
|
int i = static_cast<int>(std::distance(std::begin(this->visible_settings), it));
|
||||||
if (config_item.complete_labels) {
|
if (config_item.complete_labels) {
|
||||||
DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
|
DrawDropDownButton(br.left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, editable);
|
||||||
} else {
|
} else {
|
||||||
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
||||||
}
|
}
|
||||||
@ -488,14 +488,14 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
if (!str.has_value()) return;
|
if (!str.has_value()) return;
|
||||||
auto value = ParseInteger<int32_t>(*str, 10, true);
|
auto value = ParseInteger<int32_t>(*str, 10, true);
|
||||||
if (!value.has_value()) return;
|
if (!value.has_value()) return;
|
||||||
SetValue(*value);
|
this->SetValue(*value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDropdownSelect(WidgetID widget, int index, int) override
|
void OnDropdownSelect(WidgetID widget, int index, int) override
|
||||||
{
|
{
|
||||||
if (widget != WID_SCRS_SETTING_DROPDOWN) return;
|
if (widget != WID_SCRS_SETTING_DROPDOWN) return;
|
||||||
assert(this->clicked_dropdown);
|
assert(this->clicked_dropdown);
|
||||||
SetValue(index);
|
this->SetValue(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDropdownClose(Point, WidgetID widget, int, int, bool) override
|
void OnDropdownClose(Point, WidgetID widget, int, int, bool) override
|
||||||
@ -606,7 +606,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
|||||||
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_TF_CAPTION) {
|
if (widget == WID_TF_CAPTION) {
|
||||||
return GetString(stringid, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI, GetConfig(slot)->GetInfo()->GetName());
|
return GetString(stringid, (this->slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI, GetConfig(this->slot)->GetInfo()->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->Window::GetWidgetString(widget, stringid);
|
return this->Window::GetWidgetString(widget, stringid);
|
||||||
@ -614,11 +614,11 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
|||||||
|
|
||||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
auto textfile = GetConfig(slot)->GetTextfile(file_type, slot);
|
auto textfile = GetConfig(this->slot)->GetTextfile(file_type, this->slot);
|
||||||
if (!textfile.has_value()) {
|
if (!textfile.has_value()) {
|
||||||
this->Close();
|
this->Close();
|
||||||
} else {
|
} else {
|
||||||
this->LoadTextfile(textfile.value(), (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
this->LoadTextfile(textfile.value(), (this->slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -732,13 +732,13 @@ struct ScriptDebugWindow : public Window {
|
|||||||
|
|
||||||
for (const Company *c : Company::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
if (c->is_ai) {
|
if (c->is_ai) {
|
||||||
ChangeToScript(c->index);
|
this->ChangeToScript(c->index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no AI is available, see if there is a game script. */
|
/* If no AI is available, see if there is a game script. */
|
||||||
if (Game::GetInstance() != nullptr) ChangeToScript(OWNER_DEITY);
|
if (Game::GetInstance() != nullptr) this->ChangeToScript(OWNER_DEITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -844,7 +844,7 @@ struct ScriptDebugWindow : public Window {
|
|||||||
void DrawWidgetCompanyButton(const Rect &r, WidgetID widget, int start) const
|
void DrawWidgetCompanyButton(const Rect &r, WidgetID widget, int start) const
|
||||||
{
|
{
|
||||||
if (this->IsWidgetDisabled(widget)) return;
|
if (this->IsWidgetDisabled(widget)) return;
|
||||||
CompanyID cid = (CompanyID)(widget - start);
|
CompanyID cid = static_cast<CompanyID>(widget - start);
|
||||||
Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
|
Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||||
DrawCompanyIcon(cid, CentreBounds(r.left, r.right, sprite_size.width), CentreBounds(r.top, r.bottom, sprite_size.height));
|
DrawCompanyIcon(cid, CentreBounds(r.left, r.right, sprite_size.width), CentreBounds(r.top, r.bottom, sprite_size.height));
|
||||||
}
|
}
|
||||||
@ -909,7 +909,7 @@ struct ScriptDebugWindow : public Window {
|
|||||||
|
|
||||||
ScriptLogTypes::LogData &log = this->GetLogData();
|
ScriptLogTypes::LogData &log = this->GetLogData();
|
||||||
|
|
||||||
int scroll_count = (int)log.size();
|
int scroll_count = static_cast<int>(log.size());
|
||||||
if (this->vscroll->GetCount() != scroll_count) {
|
if (this->vscroll->GetCount() != scroll_count) {
|
||||||
this->vscroll->SetCount(scroll_count);
|
this->vscroll->SetCount(scroll_count);
|
||||||
|
|
||||||
@ -921,10 +921,10 @@ struct ScriptDebugWindow : public Window {
|
|||||||
|
|
||||||
/* Detect when the user scrolls the window. Enable autoscroll when the bottom-most line becomes visible. */
|
/* Detect when the user scrolls the window. Enable autoscroll when the bottom-most line becomes visible. */
|
||||||
if (this->last_vscroll_pos != this->vscroll->GetPosition()) {
|
if (this->last_vscroll_pos != this->vscroll->GetPosition()) {
|
||||||
this->autoscroll = this->vscroll->GetPosition() + this->vscroll->GetCapacity() >= (int)log.size();
|
this->autoscroll = this->vscroll->GetPosition() + this->vscroll->GetCapacity() >= static_cast<int>(log.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->autoscroll && this->vscroll->SetPosition((int)log.size())) {
|
if (this->autoscroll && this->vscroll->SetPosition(static_cast<int>(log.size()))) {
|
||||||
/* We need a repaint */
|
/* We need a repaint */
|
||||||
this->SetWidgetDirty(WID_SCRD_VSCROLLBAR);
|
this->SetWidgetDirty(WID_SCRD_VSCROLLBAR);
|
||||||
this->SetWidgetDirty(WID_SCRD_LOG_PANEL);
|
this->SetWidgetDirty(WID_SCRD_LOG_PANEL);
|
||||||
@ -1003,12 +1003,12 @@ struct ScriptDebugWindow : public Window {
|
|||||||
|
|
||||||
/* Check which button is clicked */
|
/* Check which button is clicked */
|
||||||
if (IsInsideMM(widget, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END + 1)) {
|
if (IsInsideMM(widget, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END + 1)) {
|
||||||
ChangeToScript((CompanyID)(widget - WID_SCRD_COMPANY_BUTTON_START), _ctrl_pressed);
|
this->ChangeToScript(static_cast<CompanyID>(widget - WID_SCRD_COMPANY_BUTTON_START), _ctrl_pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_SCRD_SCRIPT_GAME:
|
case WID_SCRD_SCRIPT_GAME:
|
||||||
ChangeToScript(OWNER_DEITY, _ctrl_pressed);
|
this->ChangeToScript(OWNER_DEITY, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_SCRD_RELOAD_TOGGLE:
|
case WID_SCRD_RELOAD_TOGGLE:
|
||||||
@ -1111,7 +1111,7 @@ struct ScriptDebugWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Highlight row that matched */
|
/* Highlight row that matched */
|
||||||
this->highlight_row = (int)(log.size() - 1);
|
this->highlight_row = static_cast<int>(log.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user