OpenTTD Source 20241224-master-gf74b0cf984
|
Functionality related to the company manager's face. More...
#include "core/random_func.hpp"
#include "core/bitmath_func.hpp"
#include "table/sprites.h"
#include "company_type.h"
Go to the source code of this file.
Data Structures | |
struct | CompanyManagerFaceBitsInfo |
Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw. More... | |
Enumerations | |
enum | GenderEthnicity { GENDER_FEMALE = 0 , ETHNICITY_BLACK = 1 , GE_WM = 0 , GE_WF = 1 << GENDER_FEMALE , GE_BM = 1 << ETHNICITY_BLACK , GE_BF = 1 << ETHNICITY_BLACK | 1 << GENDER_FEMALE , GE_END } |
The gender/race combinations that we have faces for. More... | |
enum | CompanyManagerFaceVariable { CMFV_GENDER , CMFV_ETHNICITY , CMFV_GEN_ETHN , CMFV_HAS_MOUSTACHE , CMFV_HAS_TIE_EARRING , CMFV_HAS_GLASSES , CMFV_EYE_COLOUR , CMFV_CHEEKS , CMFV_CHIN , CMFV_EYEBROWS , CMFV_MOUSTACHE , CMFV_LIPS , CMFV_NOSE , CMFV_HAIR , CMFV_JACKET , CMFV_COLLAR , CMFV_TIE_EARRING , CMFV_GLASSES , CMFV_END } |
Bitgroups of the CompanyManagerFace variable. More... | |
Functions | |
uint | GetCompanyManagerFaceBits (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Make sure the table's size is right. | |
void | SetCompanyManagerFaceBits (CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) |
Sets the company manager's face bits for the given company manager's face variable. | |
void | IncreaseCompanyManagerFaceBits (CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount) |
Increase/Decrease the company manager's face variable by the given amount. | |
bool | AreCompanyManagerFaceBitsValid (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Checks whether the company manager's face bits have a valid range. | |
uint | ScaleCompanyManagerFaceValue (CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) |
Scales a company manager's face bits variable to the correct scope. | |
void | ScaleAllCompanyManagerFaceBits (CompanyManagerFace &cmf) |
Scales all company manager's face bits to the correct scope. | |
void | RandomCompanyManagerFaceBits (CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer) |
Make a random new face. | |
SpriteID | GetCompanyManagerFaceSprite (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Gets the sprite to draw for the given company manager's face variable. | |
void | DrawCompanyManagerFace (CompanyManagerFace face, Colours colour, const Rect &r) |
Draws the face of a company manager's face. | |
Variables | |
static const CompanyManagerFaceBitsInfo | _cmf_info [] |
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites. | |
Functionality related to the company manager's face.
Definition in file company_manager_face.h.
Bitgroups of the CompanyManagerFace variable.
Definition at line 32 of file company_manager_face.h.
enum GenderEthnicity |
The gender/race combinations that we have faces for.
Definition at line 19 of file company_manager_face.h.
|
inline |
Checks whether the company manager's face bits have a valid range.
cmf | the face to extract the bits from |
cmfv | the face variable to get the data of |
ge | the gender and ethnicity of the face |
Definition at line 151 of file company_manager_face.h.
References _cmf_info, GB(), and CompanyManagerFaceBitsInfo::valid_values.
Referenced by IsValidCompanyManagerFace().
void DrawCompanyManagerFace | ( | CompanyManagerFace | cmf, |
Colours | colour, | ||
const Rect & | r | ||
) |
Draws the face of a company manager's face.
cmf | the company manager's face |
colour | the (background) colour of the gradient |
r | position to draw the face |
Definition at line 1126 of file company_gui.cpp.
References _cmf_info, CenterBounds(), DrawSprite(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), GetCompanyManagerFaceSprite(), GetSpriteSize(), and HasBit().
Referenced by SelectCompanyManagerFaceWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), and NewsWindow::DrawWidget().
|
inline |
Make sure the table's size is right.
Gets the company manager's face bits for the given company manager's face variable
cmf | the face to extract the bits from |
cmfv | the face variable to get the data of |
ge | the gender and ethnicity of the face |
Definition at line 96 of file company_manager_face.h.
References _cmf_info, and GB().
Referenced by DrawCompanyManagerFace(), IncreaseCompanyManagerFaceBits(), IsValidCompanyManagerFace(), SelectCompanyManagerFaceWindow::OnClick(), SelectCompanyManagerFaceWindow::OnPaint(), ScaleAllCompanyManagerFaceBits(), and SelectCompanyManagerFaceWindow::SetStringParameters().
|
inline |
Gets the sprite to draw for the given company manager's face variable.
cmf | the face to extract the data from |
cmfv | the face variable to get the sprite of |
ge | the gender and ethnicity of the face |
Definition at line 232 of file company_manager_face.h.
References _cmf_info, CompanyManagerFaceBitsInfo::first_sprite, and GB().
Referenced by DrawCompanyManagerFace().
|
inline |
Increase/Decrease the company manager's face variable by the given amount.
If the new value greater than the max value for this variable it will be set to 0. Or is it negative (< 0) it will be set to max value.
cmf | the company manager face to write the bits to |
cmfv | the company manager face variable to write the data of |
ge | the gender and ethnicity of the company manager's face |
amount | the amount which change the value |
Definition at line 130 of file company_manager_face.h.
References _cmf_info, GetCompanyManagerFaceBits(), SetCompanyManagerFaceBits(), and CompanyManagerFaceBitsInfo::valid_values.
Referenced by SelectCompanyManagerFaceWindow::OnClick(), and ScaleAllCompanyManagerFaceBits().
|
inline |
Make a random new face.
If it is for the advanced company manager's face window then the new face have the same gender and ethnicity as the old one, else the gender is equal and the ethnicity is random.
cmf | the company manager's face to write the bits to |
ge | the gender and ethnicity of the old company manager's face |
adv | if it for the advanced company manager's face window |
randomizer | the source of random to use for creating the manager face |
Definition at line 206 of file company_manager_face.h.
References GENDER_FEMALE, HasBit(), Randomizer::Next(), ScaleAllCompanyManagerFaceBits(), and SetCompanyManagerFaceBits().
Referenced by DoStartupNewCompany(), and SelectCompanyManagerFaceWindow::OnClick().
|
inline |
Scales all company manager's face bits to the correct scope.
cmf | the company manager's face to write the bits to |
Definition at line 176 of file company_manager_face.h.
References _cmf_info, GB(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), HasBit(), and IncreaseCompanyManagerFaceBits().
Referenced by SelectCompanyManagerFaceWindow::OnClick(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), and RandomCompanyManagerFaceBits().
|
inline |
Scales a company manager's face bits variable to the correct scope.
cmfv | the face variable to write the data of |
ge | the gender and ethnicity of the face |
val | the to value to scale |
Definition at line 164 of file company_manager_face.h.
References _cmf_info, and CompanyManagerFaceBitsInfo::length.
Referenced by ConvertFromOldCompanyManagerFace().
|
inline |
Sets the company manager's face bits for the given company manager's face variable.
cmf | the face to write the bits to |
cmfv | the face variable to write the data of |
ge | the gender and ethnicity of the face |
val | the new value |
Definition at line 111 of file company_manager_face.h.
References _cmf_info, and SB().
Referenced by ConvertFromOldCompanyManagerFace(), IncreaseCompanyManagerFaceBits(), SelectCompanyManagerFaceWindow::OnClick(), and RandomCompanyManagerFaceBits().
|
static |
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
Definition at line 64 of file company_manager_face.h.
Referenced by AreCompanyManagerFaceBitsValid(), DrawCompanyManagerFace(), GetCompanyManagerFaceBits(), GetCompanyManagerFaceSprite(), IncreaseCompanyManagerFaceBits(), SelectCompanyManagerFaceWindow::OnPaint(), ScaleAllCompanyManagerFaceBits(), ScaleCompanyManagerFaceValue(), and SetCompanyManagerFaceBits().