mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18437) -Fix (r16557): background of disabled button in AI GUI wasn't set back to grey after AI bankrupt
This commit is contained in:
parent
7d33e62d7b
commit
784d6d836d
|
@ -731,35 +731,29 @@ struct AIDebugWindow : public Window {
|
||||||
|
|
||||||
/* Paint the company icons */
|
/* Paint the company icons */
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
||||||
/* Background is grey by default, will be changed to red for dead AIs */
|
NWidgetCore *button = this->GetWidget<NWidgetCore>(i + AID_WIDGET_COMPANY_BUTTON_START);
|
||||||
this->GetWidget<NWidgetCore>(i + AID_WIDGET_COMPANY_BUTTON_START)->colour = COLOUR_GREY;
|
bool dirty = false;
|
||||||
|
|
||||||
const Company *c = Company::GetIfValid(i);
|
bool valid = Company::IsValidAiID(i);
|
||||||
if (c == NULL || !c->is_ai) {
|
bool disabled = !valid;
|
||||||
/* Check if we have the company as an active company */
|
if (button->IsDisabled() != disabled) {
|
||||||
if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
|
/* Invalid/non-AI companies have button disabled */
|
||||||
/* Bah, company gone :( */
|
button->SetDisabled(disabled);
|
||||||
this->DisableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
|
dirty = true;
|
||||||
|
|
||||||
/* We need a repaint */
|
|
||||||
this->SetDirty();
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark dead AIs by red background */
|
bool dead = valid && Company::Get(i)->ai_instance->IsDead();
|
||||||
if (c->ai_instance->IsDead()) {
|
Colours colour = dead ? COLOUR_RED : COLOUR_GREY;
|
||||||
this->GetWidget<NWidgetCore>(i + AID_WIDGET_COMPANY_BUTTON_START)->colour = COLOUR_RED;
|
if (button->colour != colour) {
|
||||||
|
/* Mark dead AIs by red background */
|
||||||
|
button->colour = colour;
|
||||||
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have the company marked as inactive */
|
/* Do we need a repaint? */
|
||||||
if (this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
|
if (dirty) this->SetDirty();
|
||||||
/* New AI! Yippie :p */
|
/* Draw company icon only for valid AI companies */
|
||||||
this->EnableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
|
if (!valid) continue;
|
||||||
|
|
||||||
/* We need a repaint */
|
|
||||||
this->SetDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
byte offset = (i == ai_debug_company) ? 1 : 0;
|
byte offset = (i == ai_debug_company) ? 1 : 0;
|
||||||
DrawCompanyIcon(i, this->GetWidget<NWidgetBase>(AID_WIDGET_COMPANY_BUTTON_START + i)->pos_x + 11 + offset, this->GetWidget<NWidgetBase>(AID_WIDGET_COMPANY_BUTTON_START + i)->pos_y + 2 + offset);
|
DrawCompanyIcon(i, this->GetWidget<NWidgetBase>(AID_WIDGET_COMPANY_BUTTON_START + i)->pos_x + 11 + offset, this->GetWidget<NWidgetBase>(AID_WIDGET_COMPANY_BUTTON_START + i)->pos_y + 2 + offset);
|
||||||
|
|
Loading…
Reference in New Issue