mirror of https://github.com/OpenTTD/OpenTTD
Add: Draw network password indicator lock in company drop down list. (#7079)
parent
41d47926b1
commit
c3dbe836b4
|
@ -119,12 +119,14 @@ public:
|
||||||
*/
|
*/
|
||||||
class DropDownListCompanyItem : public DropDownListItem {
|
class DropDownListCompanyItem : public DropDownListItem {
|
||||||
Dimension icon_size;
|
Dimension icon_size;
|
||||||
|
Dimension lock_size;
|
||||||
public:
|
public:
|
||||||
bool greyed;
|
bool greyed;
|
||||||
|
|
||||||
DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed)
|
DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed)
|
||||||
{
|
{
|
||||||
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||||
|
this->lock_size = GetSpriteSize(SPR_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DropDownListCompanyItem() {}
|
virtual ~DropDownListCompanyItem() {}
|
||||||
|
@ -139,12 +141,12 @@ public:
|
||||||
CompanyID company = (CompanyID)this->result;
|
CompanyID company = (CompanyID)this->result;
|
||||||
SetDParam(0, company);
|
SetDParam(0, company);
|
||||||
SetDParam(1, company);
|
SetDParam(1, company);
|
||||||
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + 3;
|
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint Height(uint width) const
|
uint Height(uint width) const
|
||||||
{
|
{
|
||||||
return max(this->icon_size.height + 2U, (uint)FONT_HEIGHT_NORMAL);
|
return max(max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
|
||||||
|
@ -157,8 +159,12 @@ public:
|
||||||
|
|
||||||
int icon_offset = (bottom - top - icon_size.height) / 2;
|
int icon_offset = (bottom - top - icon_size.height) / 2;
|
||||||
int text_offset = (bottom - top - FONT_HEIGHT_NORMAL) / 2;
|
int text_offset = (bottom - top - FONT_HEIGHT_NORMAL) / 2;
|
||||||
|
int lock_offset = (bottom - top - lock_size.height) / 2;
|
||||||
|
|
||||||
DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
|
DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
|
||||||
|
if (NetworkCompanyIsPassworded(company)) {
|
||||||
|
DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
|
||||||
|
}
|
||||||
|
|
||||||
SetDParam(0, company);
|
SetDParam(0, company);
|
||||||
SetDParam(1, company);
|
SetDParam(1, company);
|
||||||
|
@ -168,7 +174,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
col = sel ? TC_WHITE : TC_BLACK;
|
col = sel ? TC_WHITE : TC_BLACK;
|
||||||
}
|
}
|
||||||
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : 3 + this->icon_size.width), right - WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 0), top + text_offset, STR_COMPANY_NAME_COMPANY_NUM, col);
|
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 3 + this->lock_size.width : 3 + this->icon_size.width), right - WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 3 + this->lock_size.width), top + text_offset, STR_COMPANY_NAME_COMPANY_NUM, col);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue