|
OpenTTD Source 20251104-master-g3befbdd52f
|
Functionality related to the company manager's face. More...
#include "core/random_func.hpp"#include "core/bitmath_func.hpp"#include "strings_type.h"#include "company_type.h"#include "gfx_type.h"#include "table/strings.h"Go to the source code of this file.
Data Structures | |
| struct | FaceVar |
| Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw. More... | |
| struct | FaceSpec |
Typedefs | |
| using | FaceVars = std::span< const FaceVar > |
Enumerations | |
| enum class | FaceVarType : uint8_t { Sprite , Palette , Toggle } |
Functions | |
| void | ResetFaces () |
| Reset company manager face styles to default. | |
| uint | GetNumCompanyManagerFaceStyles () |
| Get the number of company manager face styles. | |
| std::optional< uint > | FindCompanyManagerFaceLabel (std::string_view label) |
| Find a company manager face style by label. | |
| const FaceSpec * | GetCompanyManagerFaceSpec (uint style_index) |
| Get the definition of a company manager face style. | |
| FaceVars | GetCompanyManagerFaceVars (uint style_index) |
| Get the face variables for a face style. | |
| uint64_t | GetActiveFaceVars (const CompanyManagerFace &cmf, FaceVars vars) |
| Get a bitmask of currently active face variables. | |
| void | ScaleAllCompanyManagerFaceBits (CompanyManagerFace &cmf, FaceVars vars) |
| Scales all company manager's face bits to the correct scope. | |
| void | RandomiseCompanyManagerFaceBits (CompanyManagerFace &cmf, FaceVars vars, Randomizer &randomizer) |
| Make a random new face without changing the face style. | |
| void | SetCompanyManagerFaceStyle (CompanyManagerFace &cmf, uint style) |
| Set a company face style. | |
| void | RandomiseCompanyManagerFace (CompanyManagerFace &cmf, Randomizer &randomizer) |
| Completely randomise a company manager face, including style. | |
| uint32_t | MaskCompanyManagerFaceBits (const CompanyManagerFace &cmf, FaceVars vars) |
| Mask company manager face bits to ensure they are all within range. | |
| std::string | FormatCompanyManagerFaceCode (const CompanyManagerFace &cmf) |
| Get a face code representation of a company manager face. | |
| std::optional< CompanyManagerFace > | ParseCompanyManagerFaceCode (std::string_view str) |
| Parse a face code into a company manager face. | |
| void | DrawCompanyManagerFace (const CompanyManagerFace &cmf, Colours colour, const Rect &r) |
| Draws the face of a company manager's face. | |
Functionality related to the company manager's face.
Definition in file company_manager_face.h.
| using FaceVars = std::span<const FaceVar> |
Definition at line 111 of file company_manager_face.h.
|
strong |
Definition at line 21 of file company_manager_face.h.
| void DrawCompanyManagerFace | ( | const 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 1120 of file company_gui.cpp.
References CentreBounds(), DrawSprite(), GetActiveFaceVars(), GetColourPalette(), GetCompanyManagerFaceVars(), GetSpriteSize(), and CompanyManagerFace::style.
Referenced by SelectCompanyManagerFaceWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), and NewsWindow::DrawWidget().
| std::optional< uint > FindCompanyManagerFaceLabel | ( | std::string_view | label | ) |
Find a company manager face style by label.
| label | Label to find. |
Definition at line 1409 of file company_cmd.cpp.
References _faces.
Referenced by AfterLoadGame(), and ParseCompanyManagerFaceCode().
| std::string FormatCompanyManagerFaceCode | ( | const CompanyManagerFace & | cmf | ) |
Get a face code representation of a company manager face.
| cmf | The company manager face. |
Definition at line 1479 of file company_cmd.cpp.
References GetCompanyManagerFaceVars(), MaskCompanyManagerFaceBits(), CompanyManagerFace::style, and CompanyManagerFace::style_label.
Referenced by SelectCompanyManagerFaceWindow::OnClick().
|
inline |
Get a bitmask of currently active face variables.
Face variables can be inactive due to toggles in the face variables.
| cmf | The company manager face. |
| vars | The face variables of the face. |
Definition at line 140 of file company_manager_face.h.
References CompanyManagerFace::bits, and HasBit().
Referenced by DrawCompanyManagerFace(), IsValidCompanyManagerFace(), MaskCompanyManagerFaceBits(), ScaleAllCompanyManagerFaceBits(), and SelectCompanyManagerFaceWindow::UpdateData().
| const FaceSpec * GetCompanyManagerFaceSpec | ( | uint | style_index | ) |
Get the definition of a company manager face style.
| style_index | Face style to get. |
Definition at line 1398 of file company_cmd.cpp.
References _faces, and GetNumCompanyManagerFaceStyles().
Referenced by ConvertFromOldCompanyManagerFace(), GetCompanyManagerFaceVars(), and SetCompanyManagerFaceStyle().
| FaceVars GetCompanyManagerFaceVars | ( | uint | style | ) |
Get the face variables for a face style.
| style_index | Face style to get variables for. |
Definition at line 1422 of file company_cmd.cpp.
References GetCompanyManagerFaceSpec().
Referenced by DrawCompanyManagerFace(), SelectCompanyManagerFaceWindow::DrawWidget(), FormatCompanyManagerFaceCode(), IsValidCompanyManagerFace(), SelectCompanyManagerFaceWindow::OnClick(), ParseCompanyManagerFaceCode(), RandomiseCompanyManagerFace(), and SelectCompanyManagerFaceWindow::UpdateData().
| uint GetNumCompanyManagerFaceStyles | ( | ) |
Get the number of company manager face styles.
Definition at line 1388 of file company_cmd.cpp.
References _faces.
Referenced by SelectCompanyManagerFaceWindow::DrawWidget(), GetCompanyManagerFaceSpec(), IsValidCompanyManagerFace(), SelectCompanyManagerFaceWindow::OnClick(), and RandomiseCompanyManagerFace().
| uint32_t MaskCompanyManagerFaceBits | ( | const CompanyManagerFace & | cmf, |
| FaceVars | vars | ||
| ) |
Mask company manager face bits to ensure they are all within range.
| cmf | The CompanyManagerFace. |
| style | The face variables. |
Definition at line 1463 of file company_cmd.cpp.
References CompanyManagerFace::bits, and GetActiveFaceVars().
Referenced by FormatCompanyManagerFaceCode(), and ParseCompanyManagerFaceCode().
| std::optional< CompanyManagerFace > ParseCompanyManagerFaceCode | ( | std::string_view | str | ) |
Parse a face code into a company manager face.
| str | Face code to parse. |
Definition at line 1490 of file company_cmd.cpp.
References CompanyManagerFace::bits, FindCompanyManagerFaceLabel(), GB(), GetCompanyManagerFaceVars(), MaskCompanyManagerFaceBits(), StringConsumer::npos, ParseInteger(), StringConsumer::ReadUntilChar(), ScaleAllCompanyManagerFaceBits(), SetCompanyManagerFaceStyle(), StringConsumer::SKIP_ONE_SEPARATOR, and CompanyManagerFace::style.
Referenced by CmdCompanyCtrl(), DoStartupNewCompany(), SelectCompanyManagerFaceWindow::OnClick(), and SelectCompanyManagerFaceWindow::OnQueryTextFinished().
| void RandomiseCompanyManagerFace | ( | CompanyManagerFace & | cmf, |
| Randomizer & | randomizer | ||
| ) |
Completely randomise a company manager face, including style.
| cmf | The CompanyManagerFace to randomise. |
| randomizer | The randomizer to use. |
Definition at line 1450 of file company_cmd.cpp.
References GetCompanyManagerFaceVars(), GetNumCompanyManagerFaceStyles(), Randomizer::Next(), RandomiseCompanyManagerFaceBits(), SetCompanyManagerFaceStyle(), and CompanyManagerFace::style.
Referenced by AfterLoadGame(), DoStartupNewCompany(), and SelectCompanyManagerFaceWindow::OnClick().
|
inline |
Make a random new face without changing the face style.
| cmf | The company manager's face to write the bits to |
| vars | The face variables. |
| randomizer | The source of random to use for creating the manager face |
Definition at line 171 of file company_manager_face.h.
References CompanyManagerFace::bits, Randomizer::Next(), and ScaleAllCompanyManagerFaceBits().
Referenced by RandomiseCompanyManagerFace().
| void ResetFaces | ( | ) |
Reset company manager face styles to default.
Definition at line 1378 of file company_cmd.cpp.
References _faces, and _original_faces.
Referenced by ResetNewGRFData().
|
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 158 of file company_manager_face.h.
References GetActiveFaceVars().
Referenced by ParseCompanyManagerFaceCode(), RandomiseCompanyManagerFaceBits(), and SelectCompanyManagerFaceWindow::UpdateData().
| void SetCompanyManagerFaceStyle | ( | CompanyManagerFace & | cmf, |
| uint | style | ||
| ) |
Set a company face style.
Changes both the style index and the label.
| cmf | The CompanyManagerFace to change. |
| style | The style to set. |
Definition at line 1435 of file company_cmd.cpp.
References GetCompanyManagerFaceSpec(), CompanyManagerFace::style, and CompanyManagerFace::style_label.
Referenced by AfterLoadGame(), CmdSetCompanyManagerFace(), SelectCompanyManagerFaceWindow::OnClick(), ParseCompanyManagerFaceCode(), and RandomiseCompanyManagerFace().