Update to 12.0-beta1
This commit is contained in:
@@ -182,7 +182,7 @@ struct AIListWindow : public Window {
|
||||
}
|
||||
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_AI);
|
||||
InvalidateWindowClassesData(WC_AI_SETTINGS);
|
||||
DeleteWindowByClass(WC_QUERY_STRING);
|
||||
CloseWindowByClass(WC_QUERY_STRING);
|
||||
InvalidateWindowClassesData(WC_TEXTFILE);
|
||||
}
|
||||
|
||||
@@ -190,13 +190,13 @@ struct AIListWindow : public Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_AIL_LIST: { // Select one of the AIs
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST, 0, this->line_height) - 1;
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST) - 1;
|
||||
if (sel < (int)this->info_list->size()) {
|
||||
this->selected = sel;
|
||||
this->SetDirty();
|
||||
if (click_count > 1) {
|
||||
this->ChangeAI();
|
||||
delete this;
|
||||
this->Close();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -204,12 +204,12 @@ struct AIListWindow : public Window {
|
||||
|
||||
case WID_AIL_ACCEPT: {
|
||||
this->ChangeAI();
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_AIL_CANCEL:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ struct AIListWindow : public Window {
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ static WindowDesc _ai_list_desc(
|
||||
*/
|
||||
static void ShowAIListWindow(CompanyID slot)
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
new AIListWindow(&_ai_list_desc, slot);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ struct AISettingsWindow : public Window {
|
||||
if (!this->IsEditableItem(config_item)) return;
|
||||
|
||||
if (this->clicked_row != num) {
|
||||
DeleteChildWindows(WC_QUERY_STRING);
|
||||
this->CloseChildWindows(WC_QUERY_STRING);
|
||||
HideDropDownMenu(this);
|
||||
this->clicked_row = num;
|
||||
this->clicked_dropdown = false;
|
||||
@@ -518,7 +518,7 @@ struct AISettingsWindow : public Window {
|
||||
}
|
||||
|
||||
case WID_AIS_ACCEPT:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_AIS_RESET:
|
||||
@@ -584,7 +584,7 @@ struct AISettingsWindow : public Window {
|
||||
{
|
||||
this->RebuildVisibleSettings();
|
||||
HideDropDownMenu(this);
|
||||
DeleteChildWindows(WC_QUERY_STRING);
|
||||
this->CloseChildWindows(WC_QUERY_STRING);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -628,8 +628,8 @@ static WindowDesc _ai_settings_desc(
|
||||
*/
|
||||
static void ShowAISettingsWindow(CompanyID slot)
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
new AISettingsWindow(&_ai_settings_desc, slot);
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
||||
{
|
||||
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
|
||||
if (textfile == nullptr) {
|
||||
delete this;
|
||||
this->Close();
|
||||
} else {
|
||||
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
||||
}
|
||||
@@ -669,7 +669,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
||||
*/
|
||||
void ShowScriptTextfileWindow(TextfileType file_type, CompanyID slot)
|
||||
{
|
||||
DeleteWindowById(WC_TEXTFILE, file_type);
|
||||
CloseWindowById(WC_TEXTFILE, file_type);
|
||||
new ScriptTextfileWindow(file_type, slot);
|
||||
}
|
||||
|
||||
@@ -744,10 +744,11 @@ struct AIConfigWindow : public Window {
|
||||
this->OnInvalidateData(0);
|
||||
}
|
||||
|
||||
~AIConfigWindow()
|
||||
void Close() override
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
@@ -784,6 +785,7 @@ struct AIConfigWindow : public Window {
|
||||
|
||||
case WID_AIC_LIST:
|
||||
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
|
||||
resize->height = this->line_height;
|
||||
size->height = 8 * this->line_height;
|
||||
break;
|
||||
|
||||
@@ -895,7 +897,7 @@ struct AIConfigWindow : public Window {
|
||||
}
|
||||
|
||||
case WID_AIC_LIST: { // Select a slot
|
||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
|
||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
||||
this->InvalidateData();
|
||||
if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
|
||||
break;
|
||||
@@ -928,7 +930,7 @@ struct AIConfigWindow : public Window {
|
||||
break;
|
||||
|
||||
case WID_AIC_CLOSE:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_AIC_CONTENT_DOWNLOAD:
|
||||
@@ -970,7 +972,7 @@ struct AIConfigWindow : public Window {
|
||||
/** Open the AI config window. */
|
||||
void ShowAIConfigWindow()
|
||||
{
|
||||
DeleteWindowByClass(WC_GAME_OPTIONS);
|
||||
CloseWindowByClass(WC_GAME_OPTIONS);
|
||||
new AIConfigWindow();
|
||||
}
|
||||
|
||||
@@ -1262,7 +1264,7 @@ struct AIDebugWindow : public Window {
|
||||
this->highlight_row = -1; // The highlight of one AI make little sense for another AI.
|
||||
|
||||
/* Close AI settings window to prevent confusion */
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
|
||||
this->InvalidateData(-1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user