Fix #12395: Ensure president name widget is tall enough. (#12419)

This commit is contained in:
Peter Nelson 2024-04-04 17:56:16 +01:00 committed by GitHub
parent 338def1b06
commit 197fb00d31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -1182,6 +1182,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
}
}
InvalidateWindowClassesData(WC_COMPANY, 1);
MarkWholeScreenDirty();
CompanyAdminUpdate(c);
}

View File

@ -2452,6 +2452,14 @@ struct CompanyWindow : Window
}
}
void OnResize() override
{
NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_C_FACE_TITLE);
SetDParam(0, this->owner);
int y = GetStringHeight(STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE, wid->current_x);
if (wid->UpdateVerticalSize(y)) this->ReInit(0, 0);
}
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
{
switch (widget) {
@ -2587,6 +2595,14 @@ struct CompanyWindow : Window
break;
}
}
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
{
if (gui_scope && data == 1) {
/* Manually call OnResize to adjust minimum height of president name widget. */
OnResize();
}
}
};
static WindowDesc _company_desc(