Skip to content

Commit

Permalink
Fix: Missing invalidations on gui.ai_developer_tools change (#11664)
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Dec 31, 2023
1 parent 3e2060f commit f56a2d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/script/script_gui.cpp
Expand Up @@ -785,19 +785,14 @@ struct ScriptDebugWindow : public Window {
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_SCRD_VSCROLLBAR);
this->hscroll = this->GetScrollbar(WID_SCRD_HSCROLLBAR);
this->show_break_box = _settings_client.gui.ai_developer_tools;
this->GetWidget<NWidgetStacked>(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL);
this->FinishInitNested(number);

if (!this->show_break_box) this->filter.break_check_enabled = false;

this->last_vscroll_pos = 0;
this->autoscroll = true;
this->highlight_row = -1;

this->querystrings[WID_SCRD_BREAK_STR_EDIT_BOX] = &this->break_editbox;

SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN);
this->hscroll->SetStepSize(10); // Speed up horizontal scrollbar

/* Restore the break string value from static variable, and enable the filter. */
Expand All @@ -813,6 +808,11 @@ struct ScriptDebugWindow : public Window {

void OnInit() override
{
this->show_break_box = _settings_client.gui.ai_developer_tools;
this->GetWidget<NWidgetStacked>(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL);
if (!this->show_break_box) this->filter.break_check_enabled = false;
SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN);

this->InvalidateData(-1);
}

Expand Down Expand Up @@ -1120,6 +1120,8 @@ struct ScriptDebugWindow : public Window {
*/
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
{
if (this->show_break_box != _settings_client.gui.ai_developer_tools) this->ReInit();

/* If the log message is related to the active company tab, check the break string.
* This needs to be done in gameloop-scope, so the AI is suspended immediately. */
if (!gui_scope && data == this->filter.script_debug_company &&
Expand Down
2 changes: 1 addition & 1 deletion src/table/settings/gui_settings.ini
Expand Up @@ -796,7 +796,7 @@ cat = SC_EXPERT
var = gui.ai_developer_tools
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
def = false
post_cb = [](auto) { InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); }
post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); InvalidateWindowClassesData(WC_SCRIPT_DEBUG); InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); }
cat = SC_EXPERT

[SDTC_BOOL]
Expand Down

0 comments on commit f56a2d0

Please sign in to comment.