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
 
@@ -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);
src/network/network_gui.cpp
Show inline comments
 
@@ -2162,10 +2162,12 @@ void ShowNetworkNeedPassword(NetworkPass
 

	
 
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 : pu
 
		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
 
			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),
0 comments (0 inline, 0 general)