summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-03-31 16:15:09 +0200
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-04-24 17:40:11 +0200
commita64bd6e22c747f082f6167926b50e5eb16f4fdf0 (patch)
tree5a3b9db73889b96c344504477ca9f97b28ba3f17
parent08284e005d129ffefa7e6f54a44b514a541e288d (diff)
downloadopenttd-a64bd6e22c747f082f6167926b50e5eb16f4fdf0.tar.xz
Fix: Also breaking for warning text in set company password
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/network/network_gui.cpp26
2 files changed, 22 insertions, 6 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 702d5b7ec..0566fffc3 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -977,8 +977,6 @@ struct QueryStringWindow : public Window
void UpdateWarningStringSize()
{
- NWidgetBase *text_wid = this->GetWidget<NWidgetBase>(WID_QS_WARNING);
-
if (this->flags & QSF_PASSWORD) {
assert(this->nested_root->smallest_x > 0);
this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 42fea015c..d39b61dbf 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -2162,10 +2162,12 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
struct NetworkCompanyPasswordWindow : public Window {
QueryString password_editbox; ///< Password editbox.
+ Dimension warning_size; ///< How much space to use for the warning text
NetworkCompanyPasswordWindow(WindowDesc *desc, Window *parent) : Window(desc), password_editbox(lengthof(_settings_client.network.default_company_pass))
{
this->InitNested(0);
+ this->UpdateWarningStringSize();
this->parent = parent;
this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox;
@@ -2174,11 +2176,29 @@ struct NetworkCompanyPasswordWindow : public Window {
this->SetFocusedWidget(WID_NCP_PASSWORD);
}
+ void UpdateWarningStringSize()
+ {
+ assert(this->nested_root->smallest_x > 0);
+ this->warning_size.width = this->nested_root->current_x - (WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
+ this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
+ this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
+
+ this->ReInit();
+ }
+
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
+ {
+ if (widget == WID_NCP_WARNING) {
+ *size = this->warning_size;
+ }
+ }
+
virtual void DrawWidget(const Rect &r, int widget) const
{
if (widget != WID_NCP_WARNING) return;
- DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
+ DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT,
+ r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
}
@@ -2228,9 +2248,7 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = {
EndContainer(),
EndContainer(),
EndContainer(),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING),
- NWidget(WWT_LABEL, COLOUR_GREY), SetFill(0, 1), SetPadding(2, 2, 2, 2), SetDataTip(STR_WARNING_PASSWORD_SECURITY, STR_NULL),
- EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING), EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),