mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Centre company face in scaled widget. (#10688)
This commit is contained in:
parent
6b077ce25c
commit
018f0f63a6
|
@ -1182,13 +1182,17 @@ void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
|
|||
* Draws the face of a company manager's face.
|
||||
* @param cmf the company manager's face
|
||||
* @param colour the (background) colour of the gradient
|
||||
* @param x x-position to draw the face
|
||||
* @param y y-position to draw the face
|
||||
* @param r position to draw the face
|
||||
*/
|
||||
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
|
||||
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, const Rect &r)
|
||||
{
|
||||
GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
|
||||
|
||||
/* Determine offset from centre of drawing rect. */
|
||||
Dimension d = GetSpriteSize(SPR_GRADIENT);
|
||||
int x = CenterBounds(r.left, r.right, d.width);
|
||||
int y = CenterBounds(r.top, r.bottom, d.height);
|
||||
|
||||
bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
|
||||
bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
|
||||
bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
|
||||
|
@ -1491,7 +1495,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_SCMF_FACE: {
|
||||
Dimension face_size = GetSpriteSize(SPR_GRADIENT);
|
||||
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
|
||||
size->width = std::max(size->width, face_size.width);
|
||||
size->height = std::max(size->height, face_size.height);
|
||||
break;
|
||||
|
@ -1643,7 +1647,7 @@ public:
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_SCMF_FACE:
|
||||
DrawCompanyManagerFace(this->face, Company::Get((CompanyID)this->window_number)->colour, r.left, r.top);
|
||||
DrawCompanyManagerFace(this->face, Company::Get((CompanyID)this->window_number)->colour, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2385,7 +2389,7 @@ struct CompanyWindow : Window
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_C_FACE: {
|
||||
Dimension face_size = GetSpriteSize(SPR_GRADIENT);
|
||||
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
|
||||
size->width = std::max(size->width, face_size.width);
|
||||
size->height = std::max(size->height, face_size.height);
|
||||
break;
|
||||
|
@ -2523,7 +2527,7 @@ struct CompanyWindow : Window
|
|||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
switch (widget) {
|
||||
case WID_C_FACE:
|
||||
DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
|
||||
DrawCompanyManagerFace(c->face, c->colour, r);
|
||||
break;
|
||||
|
||||
case WID_C_FACE_TITLE:
|
||||
|
@ -2800,7 +2804,7 @@ struct BuyCompanyWindow : Window {
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_BC_FACE:
|
||||
*size = GetSpriteSize(SPR_GRADIENT);
|
||||
*size = GetScaledSpriteSize(SPR_GRADIENT);
|
||||
break;
|
||||
|
||||
case WID_BC_QUESTION:
|
||||
|
@ -2827,7 +2831,7 @@ struct BuyCompanyWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_BC_FACE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
|
||||
DrawCompanyManagerFace(c->face, c->colour, r);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,6 @@ static inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, Compa
|
|||
return _cmf_info[cmfv].first_sprite[ge] + GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
|
||||
}
|
||||
|
||||
void DrawCompanyManagerFace(CompanyManagerFace face, int colour, int x, int y);
|
||||
void DrawCompanyManagerFace(CompanyManagerFace face, int colour, const Rect &r);
|
||||
|
||||
#endif /* COMPANY_MANAGER_FACE_H */
|
||||
|
|
|
@ -227,7 +227,7 @@ public:
|
|||
break;
|
||||
}
|
||||
case WID_EM_FACE: {
|
||||
Dimension face_size = GetSpriteSize(SPR_GRADIENT);
|
||||
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
|
||||
size->width = std::max(size->width, face_size.width);
|
||||
size->height = std::max(size->height, face_size.height);
|
||||
break;
|
||||
|
@ -287,7 +287,7 @@ public:
|
|||
switch (widget) {
|
||||
case WID_EM_FACE: {
|
||||
const Company *c = Company::Get(this->face);
|
||||
DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
|
||||
DrawCompanyManagerFace(c->face, c->colour, r);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ struct NewsWindow : Window {
|
|||
}
|
||||
|
||||
case WID_N_MGR_FACE:
|
||||
*size = maxdim(*size, GetSpriteSize(SPR_GRADIENT));
|
||||
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT));
|
||||
break;
|
||||
|
||||
case WID_N_MGR_NAME:
|
||||
|
@ -435,7 +435,7 @@ struct NewsWindow : Window {
|
|||
|
||||
case WID_N_MGR_FACE: {
|
||||
const CompanyNewsInformation *cni = static_cast<const CompanyNewsInformation*>(this->ni->data.get());
|
||||
DrawCompanyManagerFace(cni->face, cni->colour, r.left, r.top);
|
||||
DrawCompanyManagerFace(cni->face, cni->colour, r);
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, PALETTE_NEWSPAPER, FILLRECT_RECOLOUR);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue