MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateAIButtonsState

Method UpdateAIButtonsState

src/script/script_gui.cpp:939–953  ·  view source on GitHub ↗

* Update state of all Company (AI) buttons. */

Source from the content-addressed store, hash-verified

937 * Update state of all Company (AI) buttons.
938 */
939 void UpdateAIButtonsState()
940 {
941 /* Update company buttons */
942 for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i) {
943 /* Mark dead/paused AIs by setting the background colour. */
944 bool valid = Company::IsValidAiID(i);
945 bool dead = valid && Company::Get(i)->ai_instance->IsDead();
946 bool paused = valid && Company::Get(i)->ai_instance->IsPaused();
947
948 NWidgetCore *button = this->GetWidget<NWidgetCore>(WID_SCRD_COMPANY_BUTTON_START + i);
949 button->SetDisabled(!valid);
950 button->SetLowered(this->filter.script_debug_company == i);
951 SetScriptButtonColour(*button, dead, paused);
952 }
953 }
954
955 /**
956 * Update state of game script button.

Callers 1

OnInvalidateDataMethod · 0.95

Calls 6

BeginFunction · 0.85
SetScriptButtonColourFunction · 0.85
SetDisabledMethod · 0.80
SetLoweredMethod · 0.80
IsDeadMethod · 0.45
IsPausedMethod · 0.45

Tested by

no test coverage detected