diff options
-rw-r--r-- | src/company_gui.cpp | 2 | ||||
-rw-r--r-- | src/lang/english.txt | 2 | ||||
-rw-r--r-- | src/misc_gui.cpp | 36 | ||||
-rw-r--r-- | src/script/api/game/game_window.hpp.sq | 1 | ||||
-rw-r--r-- | src/script/api/script_window.hpp | 1 | ||||
-rw-r--r-- | src/widgets/misc_widget.h | 1 |
6 files changed, 27 insertions, 16 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 8891393e6..b36ab959e 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2602,7 +2602,7 @@ struct CompanyWindow : Window MarkWholeScreenDirty(); } else if (NetworkCompanyIsPassworded(company)) { /* ask for the password */ - ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_NONE); + ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_PASSWORD); } else { /* just send the join command */ NetworkClientRequestMove(company); diff --git a/src/lang/english.txt b/src/lang/english.txt index 4f648a482..fc5071169 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -265,7 +265,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}By enabl STR_BUTTON_DEFAULT :{BLACK}Default STR_BUTTON_CANCEL :{BLACK}Cancel STR_BUTTON_OK :{BLACK}OK -STR_WARNING_PASSWORD_SECURITY :{YELLOW}Warning: Server administrators may be{}able to read any text entered here. +STR_WARNING_PASSWORD_SECURITY :{YELLOW}Warning: Server administrators may be able to read any text entered here. # On screen keyboard window STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ . diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 8a86f0c57..702d5b7ec 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -941,6 +941,7 @@ struct QueryStringWindow : public Window { QueryString editbox; ///< Editbox. QueryStringFlags flags; ///< Flags controlling behaviour of the window. + Dimension warning_size; ///< How much space to use for the warning text QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : Window(desc), editbox(max_bytes, max_chars) @@ -967,12 +968,29 @@ struct QueryStringWindow : public Window this->flags = flags; this->InitNested(WN_QUERY_STRING); + this->UpdateWarningStringSize(); this->parent = parent; this->SetFocusedWidget(WID_QS_TEXT); } + 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); + 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; + } else { + this->warning_size = Dimension{ 0, 0 }; + } + + this->ReInit(); + } + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { @@ -982,14 +1000,8 @@ struct QueryStringWindow : public Window size->width = 0; } - if (widget == WID_QS_WARNINGBOX && (this->flags & QSF_PASSWORD) == 0) { - /* We don't want this widget to show! */ - fill->width = 0; - resize->width = 0; - size->width = 0; - } if (widget == WID_QS_WARNING) { - *size = GetStringBoundingBox(STR_WARNING_PASSWORD_SECURITY); + *size = this->warning_size; } } @@ -997,7 +1009,11 @@ struct QueryStringWindow : public Window { if (widget != WID_QS_WARNING) return; - DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER); + if (this->flags & QSF_PASSWORD) { + DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT - WD_FRAMERECT_RIGHT, + r.top + WD_FRAMERECT_TOP + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMERECT_BOTTOM - WD_FRAMETEXT_BOTTOM, + STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER); + } } void SetStringParameters(int widget) const override @@ -1054,9 +1070,7 @@ static const NWidgetPart _nested_query_string_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY), NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2), EndContainer(), - NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNINGBOX), - NWidget(WWT_LABEL, COLOUR_GREY, WID_QS_WARNING), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), SetFill(0, 1), - EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNING), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq index 90fd2f5ac..162c0bf0c 100644 --- a/src/script/api/game/game_window.hpp.sq +++ b/src/script/api/game/game_window.hpp.sq @@ -637,7 +637,6 @@ void SQGSWindow_Register(Squirrel *engine) SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION, "WID_QS_CAPTION"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT, "WID_QS_TEXT"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING, "WID_QS_WARNING"); - SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNINGBOX, "WID_QS_WARNINGBOX"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_DEFAULT, "WID_QS_DEFAULT"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CANCEL, "WID_QS_CANCEL"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_OK, "WID_QS_OK"); diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp index 4275fba54..a56307cb0 100644 --- a/src/script/api/script_window.hpp +++ b/src/script/api/script_window.hpp @@ -1599,7 +1599,6 @@ public: WID_QS_CAPTION = ::WID_QS_CAPTION, ///< Caption of the window. WID_QS_TEXT = ::WID_QS_TEXT, ///< Text of the query. WID_QS_WARNING = ::WID_QS_WARNING, ///< Warning label about password security - WID_QS_WARNINGBOX = ::WID_QS_WARNINGBOX, ///< Container for warning label WID_QS_DEFAULT = ::WID_QS_DEFAULT, ///< Default button. WID_QS_CANCEL = ::WID_QS_CANCEL, ///< Cancel button. WID_QS_OK = ::WID_QS_OK, ///< OK button. diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h index 9fbd9f2f1..9f6a7e5f5 100644 --- a/src/widgets/misc_widget.h +++ b/src/widgets/misc_widget.h @@ -33,7 +33,6 @@ enum QueryStringWidgets { WID_QS_CAPTION, ///< Caption of the window. WID_QS_TEXT, ///< Text of the query. WID_QS_WARNING, ///< Warning label about password security - WID_QS_WARNINGBOX, ///< Container for warning label WID_QS_DEFAULT, ///< Default button. WID_QS_CANCEL, ///< Cancel button. WID_QS_OK, ///< OK button. |