* Some data on this window has become invalid. * @param data Information about the changed data. * This is the company ID of the AI/GS which wrote a new log message, or -1 in other cases. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */
| 1081 | * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
| 1082 | */ |
| 1083 | void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override |
| 1084 | { |
| 1085 | if (this->show_break_box != _settings_client.gui.ai_developer_tools) this->ReInit(); |
| 1086 | |
| 1087 | /* If the log message is related to the active company tab, check the break string. |
| 1088 | * This needs to be done in gameloop-scope, so the AI is suspended immediately. */ |
| 1089 | if (!gui_scope && data == this->filter.script_debug_company && |
| 1090 | this->IsValidDebugCompany(this->filter.script_debug_company) && |
| 1091 | this->filter.break_check_enabled && !this->break_string_filter.IsEmpty()) { |
| 1092 | /* Get the log instance of the active company */ |
| 1093 | ScriptLogTypes::LogData &log = this->GetLogData(); |
| 1094 | |
| 1095 | if (!log.empty()) { |
| 1096 | this->break_string_filter.ResetState(); |
| 1097 | this->break_string_filter.AddLine(log.back().text); |
| 1098 | if (this->break_string_filter.GetState()) { |
| 1099 | /* Pause execution of script. */ |
| 1100 | if (!this->IsDead()) { |
| 1101 | if (this->filter.script_debug_company == OWNER_DEITY) { |
| 1102 | Game::Pause(); |
| 1103 | } else { |
| 1104 | AI::Pause(this->filter.script_debug_company); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | /* Pause the game. */ |
| 1109 | if (!_pause_mode.Test(PauseMode::Normal)) { |
| 1110 | Command<CMD_PAUSE>::Post(PauseMode::Normal, true); |
| 1111 | } |
| 1112 | |
| 1113 | /* Highlight row that matched */ |
| 1114 | this->highlight_row = static_cast<int>(log.size() - 1); |
| 1115 | } |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | if (!gui_scope) return; |
| 1120 | |
| 1121 | this->SelectValidDebugCompany(); |
| 1122 | |
| 1123 | uint max_width = 0; |
| 1124 | if (this->filter.script_debug_company != CompanyID::Invalid()) { |
| 1125 | for (auto &line : this->GetLogData()) { |
| 1126 | if (line.width == 0 || data == -1) line.width = GetStringBoundingBox(line.text).width; |
| 1127 | max_width = std::max(max_width, line.width); |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | this->vscroll->SetCount(this->filter.script_debug_company != CompanyID::Invalid() ? this->GetLogData().size() : 0); |
| 1132 | this->hscroll->SetCount(max_width + WidgetDimensions::scaled.frametext.Horizontal()); |
| 1133 | |
| 1134 | this->UpdateAIButtonsState(); |
| 1135 | this->UpdateGSButtonState(); |
| 1136 | |
| 1137 | this->SetWidgetLoweredState(WID_SCRD_BREAK_STR_ON_OFF_BTN, this->filter.break_check_enabled); |
| 1138 | this->SetWidgetLoweredState(WID_SCRD_MATCH_CASE_BTN, this->filter.case_sensitive_break_check); |
| 1139 | |
| 1140 | this->SetWidgetDisabledState(WID_SCRD_SETTINGS, this->filter.script_debug_company == CompanyID::Invalid() || |
nothing calls this directly
no test coverage detected