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... | |
Functions | |
DECLARE_ENUM_AS_BIT_SET (GenderEthnicity) enum CompanyManagerFaceVariable | |
Bitgroups of the CompanyManagerFace variable. | |
assert_compile (lengthof(_cmf_info)==CMFV_END) | |
Make sure the table's size is right. | |
static uint | GetCompanyManagerFaceBits (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Gets the company manager's face bits for the given company manager's face variable. | |
static 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. | |
static void | IncreaseCompanyManagerFaceBits (CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount) |
Increase/Decrease the company manager's face variable by the given amount. | |
static bool | AreCompanyManagerFaceBitsValid (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Checks whether the company manager's face bits have a valid range. | |
static uint | ScaleCompanyManagerFaceValue (CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) |
Scales a company manager's face bits variable to the correct scope. | |
static void | ScaleAllCompanyManagerFaceBits (CompanyManagerFace &cmf) |
Scales all company manager's face bits to the correct scope. | |
static void | RandomCompanyManagerFaceBits (CompanyManagerFace &cmf, GenderEthnicity ge, bool adv) |
Make a random new face. | |
static SpriteID | GetCompanyManagerFaceSprite (CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) |
Gets the sprite to draw for the given company manager's face variable. | |
bool | IsValidCompanyManagerFace (CompanyManagerFace cmf) |
Checks whether a company manager's face is a valid encoding. | |
void | DrawCompanyManagerFace (CompanyManagerFace face, int colour, int x, int y) |
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.
enum GenderEthnicity |
The gender/race combinations that we have faces for.
Definition at line 21 of file company_manager_face.h.
static bool AreCompanyManagerFaceBitsValid | ( | CompanyManagerFace | cmf, | |
CompanyManagerFaceVariable | cmfv, | |||
GenderEthnicity | ge | |||
) | [inline, static] |
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 153 of file company_manager_face.h.
References GB(), and CompanyManagerFaceBitsInfo::valid_values.
Referenced by IsValidCompanyManagerFace().
assert_compile | ( | lengthof(_cmf_info) | = =CMFV_END |
) |
Make sure the table's size is right.
void DrawCompanyManagerFace | ( | CompanyManagerFace | cmf, | |
int | colour, | |||
int | x, | |||
int | y | |||
) |
Draws the face of a company manager's face.
cmf | the company manager's face | |
colour | the (background) colour of the gradient | |
x | x-position to draw the face | |
y | y-position to draw the face |
Definition at line 880 of file company_gui.cpp.
References _cmf_info, DrawSprite(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), GetCompanyManagerFaceSprite(), and HasBit().
Referenced by NewsWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), CompanyWindow::DrawWidget(), and SelectCompanyManagerFaceWindow::DrawWidget().
static uint GetCompanyManagerFaceBits | ( | CompanyManagerFace | cmf, | |
CompanyManagerFaceVariable | cmfv, | |||
GenderEthnicity | ge | |||
) | [inline, static] |
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 98 of file company_manager_face.h.
References GB().
Referenced by DrawCompanyManagerFace(), SelectCompanyManagerFaceWindow::DrawWidget(), AICompany::GetPresidentGender(), IncreaseCompanyManagerFaceBits(), IsValidCompanyManagerFace(), SelectCompanyManagerFaceWindow::OnClick(), SelectCompanyManagerFaceWindow::OnPaint(), and ScaleAllCompanyManagerFaceBits().
static SpriteID GetCompanyManagerFaceSprite | ( | CompanyManagerFace | cmf, | |
CompanyManagerFaceVariable | cmfv, | |||
GenderEthnicity | ge | |||
) | [inline, static] |
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 233 of file company_manager_face.h.
References CompanyManagerFaceBitsInfo::first_sprite, and GB().
Referenced by DrawCompanyManagerFace().
static void IncreaseCompanyManagerFaceBits | ( | CompanyManagerFace & | cmf, | |
CompanyManagerFaceVariable | cmfv, | |||
GenderEthnicity | ge, | |||
int8 | amount | |||
) | [inline, static] |
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 negativ (< 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 132 of file company_manager_face.h.
References GetCompanyManagerFaceBits(), SetCompanyManagerFaceBits(), and CompanyManagerFaceBitsInfo::valid_values.
Referenced by SelectCompanyManagerFaceWindow::OnClick(), and ScaleAllCompanyManagerFaceBits().
bool IsValidCompanyManagerFace | ( | CompanyManagerFace | cmf | ) |
Checks whether a company manager's face is a valid encoding.
Unused bits are not enforced to be 0.
cmf | the fact to check |
Definition at line 149 of file company_cmd.cpp.
References AreCompanyManagerFaceBitsValid(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), and HasBit().
Referenced by CmdSetCompanyManagerFace(), and SetCompanyProfile().
static void RandomCompanyManagerFaceBits | ( | CompanyManagerFace & | cmf, | |
GenderEthnicity | ge, | |||
bool | adv | |||
) | [inline, static] |
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 |
Definition at line 207 of file company_manager_face.h.
References GENDER_FEMALE, HasBit(), ScaleAllCompanyManagerFaceBits(), and SetCompanyManagerFaceBits().
Referenced by DoStartupNewCompany(), SelectCompanyManagerFaceWindow::OnClick(), and AICompany::SetPresidentGender().
static void ScaleAllCompanyManagerFaceBits | ( | CompanyManagerFace & | cmf | ) | [inline, static] |
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 178 of file company_manager_face.h.
References GB(), GE_WM, GENDER_FEMALE, GetCompanyManagerFaceBits(), HasBit(), and IncreaseCompanyManagerFaceBits().
Referenced by SelectCompanyManagerFaceWindow::OnClick(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), and RandomCompanyManagerFaceBits().
static uint ScaleCompanyManagerFaceValue | ( | CompanyManagerFaceVariable | cmfv, | |
GenderEthnicity | ge, | |||
uint | val | |||
) | [inline, static] |
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 166 of file company_manager_face.h.
References CompanyManagerFaceBitsInfo::length.
Referenced by ConvertFromOldCompanyManagerFace().
static void SetCompanyManagerFaceBits | ( | CompanyManagerFace & | cmf, | |
CompanyManagerFaceVariable | cmfv, | |||
GenderEthnicity | ge, | |||
uint | val | |||
) | [inline, static] |
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 113 of file company_manager_face.h.
References SB().
Referenced by ConvertFromOldCompanyManagerFace(), IncreaseCompanyManagerFaceBits(), SelectCompanyManagerFaceWindow::OnClick(), and RandomCompanyManagerFaceBits().
const CompanyManagerFaceBitsInfo _cmf_info[] [static] |
{ { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } }, { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } }, { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } }, { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } }, { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } }, { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } }, { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } }, { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } }, { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } }, { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } }, { 20, 4, { 9, 5, 5, 4 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } }, { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } }, { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } }, { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } }, { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } }
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
Definition at line 66 of file company_manager_face.h.
Referenced by DrawCompanyManagerFace(), and SelectCompanyManagerFaceWindow::OnPaint().