Changeset - r23644:5bb815004e8b
[Not reviewed]
master
0 2 0
Niels Martin Hansen - 6 years ago 2019-03-31 14:15:09
nielsm@indvikleren.dk
Fix: Also breaking for warning text in set company password
2 files changed with 22 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -974,14 +974,12 @@ struct QueryStringWindow : public Window
 

	
 
		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 {
src/network/network_gui.cpp
Show inline comments
 
@@ -2159,29 +2159,49 @@ void ShowNetworkNeedPassword(NetworkPass
 
	}
 
	ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_PASSWORD);
 
}
 

	
 
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;
 
		this->password_editbox.cancel_button = WID_NCP_CANCEL;
 
		this->password_editbox.ok_button = WID_NCP_OK;
 
		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);
 
	}
 

	
 
	void OnOk()
 
	{
 
		if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
 
@@ -2225,15 +2245,13 @@ static const NWidgetPart _nested_network
 
				NWidget(NWID_SPACER), SetFill(1, 0),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_NCP_SAVE_AS_DEFAULT_PASSWORD), SetMinimalSize(194, 12),
 
											SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
 
			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),
 
	EndContainer(),
 
};
 

	
0 comments (0 inline, 0 general)