Skip to content

Commit

Permalink
Fix OpenTTD#12395: Ensure president name widget is tall enough. (Open…
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterN authored and ladysadie committed Apr 10, 2024
1 parent 495aa1c commit 6b240cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/company_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
}
}

InvalidateWindowClassesData(WC_COMPANY, 1);
MarkWholeScreenDirty();
CompanyAdminUpdate(c);
}
Expand Down
16 changes: 16 additions & 0 deletions src/company_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6b240cb

Please sign in to comment.