Changeset - r28636:848679c154d6
[Not reviewed]
master
0 1 0
Loïc Guilloux - 3 months ago 2024-02-02 13:34:49
glx22@users.noreply.github.com
Change: Improve AIConfig window (#11949)
1 file changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -181,8 +181,16 @@ struct AIConfigWindow : public Window {
 
					} else {
 
						text = STR_AI_CONFIG_RANDOM_AI;
 
					}
 
					DrawString(tr, text,
 
							(this->selected_slot == i) ? TC_WHITE : (IsEditable((CompanyID)i) ? TC_ORANGE : TC_SILVER));
 

	
 
					TextColour tc = TC_SILVER;
 
					if (this->selected_slot == i) {
 
						tc = TC_WHITE;
 
					} else if (IsEditable((CompanyID)i)) {
 
						tc = TC_ORANGE;
 
					} else if (Company::IsValidAiID(i)) {
 
						tc = TC_GREEN;
 
					}
 
					DrawString(tr, text, tc);
 
					tr.top += this->line_height;
 
				}
 
				break;
 
@@ -229,7 +237,7 @@ struct AIConfigWindow : public Window {
 
			case WID_AIC_LIST: { // Select a slot
 
				this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
 
				this->InvalidateData();
 
				if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
 
				if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
 
				break;
 
			}
 

	
 
@@ -259,7 +267,7 @@ struct AIConfigWindow : public Window {
 
			}
 

	
 
			case WID_AIC_CHANGE:  // choose other AI
 
				ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
 
				if (IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
 
				break;
 

	
 
			case WID_AIC_CONFIGURE: // change the settings for an AI
 
@@ -283,7 +291,7 @@ struct AIConfigWindow : public Window {
 
	 */
 
	void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
 
	{
 
		if (!IsEditable(this->selected_slot)) {
 
		if (!IsEditable(this->selected_slot) && !Company::IsValidAiID(this->selected_slot)) {
 
			this->selected_slot = INVALID_COMPANY;
 
		}
 

	
 
@@ -295,10 +303,10 @@ struct AIConfigWindow : public Window {
 
		this->SetWidgetDisabledState(WID_AIC_INCREASE_NUMBER, GetGameSettings().difficulty.max_no_competitors == MAX_COMPANIES - 1);
 
		this->SetWidgetDisabledState(WID_AIC_DECREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MIN_COMPETITORS_INTERVAL);
 
		this->SetWidgetDisabledState(WID_AIC_INCREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MAX_COMPETITORS_INTERVAL);
 
		this->SetWidgetDisabledState(WID_AIC_CHANGE, this->selected_slot == INVALID_COMPANY);
 
		this->SetWidgetDisabledState(WID_AIC_CHANGE, !IsEditable(this->selected_slot));
 
		this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == INVALID_COMPANY || config->GetConfigList()->empty());
 
		this->SetWidgetDisabledState(WID_AIC_MOVE_UP, this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot - 1)));
 
		this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot + 1)));
 
		this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable((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_OPEN_URL, this->selected_slot == INVALID_COMPANY || config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
 
		for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
0 comments (0 inline, 0 general)