|
Mario Kart 64
|
#include <Text.h>
Data Structures | |
| struct | CharacterList |
Public Types | |
| enum | TextMode : int16_t { STATIONARY , FOLLOW_PLAYER } |
| enum | FadeMode : int16_t { NO_FADE , FADE_IN , FADE_OUT } |
| enum | DistanceProps : int16_t { TOO_CLOSE , ACTIVE , TOO_FAR } |
Public Member Functions | |
| AText (const SpawnParams ¶ms) | |
| virtual | ~AText () override=default |
| virtual void | Tick () override |
| virtual void | Draw (Camera *camera) override |
| virtual void | SetSpawnParams (SpawnParams ¶ms) override |
| virtual bool | IsMod () override |
| virtual void | DrawEditorProperties () override |
| void | DrawColourEditor (bool *updated) |
| void | FollowPlayer () |
| void | SetText (std::string text) |
| std::string | ValidateString (const std::string_view &text) |
| void | Refresh () |
| void | Print3D (char *text, s32 tracking, s32 mode) |
| void | PrintLetter3D (MenuTexture *glyphTexture, f32 column, f32 row, s32 mode) |
| void | SetupVtx () |
| void | DrawText3D (Camera *camera) |
| void | AnimateColour (Vtx *vtx) |
| void | FadeIn (Vtx *vtx) |
| void | FadeOut (Vtx *vtx) |
| uint8_t | FloatToU8 (float v) |
Public Member Functions inherited from AActor | |
| virtual | ~AActor ()=default |
| AActor () | |
| AActor (SpawnParams params) | |
| virtual void | BeginPlay () |
| virtual void | Collision (Player *player, AActor *actor) |
| virtual void | VehicleCollision (s32 playerId, Player *player) |
| void | SetLocation (FVector pos) |
| virtual void | Destroy () |
| FVector | GetLocation () const |
| IRotator | GetRotation () const |
| FVector | GetScale () const |
| void | Translate (FVector pos) |
| void | Rotate (IRotator rot) |
| void | SetScale (FVector scale) |
Static Public Member Functions | |
| static AText * | Spawn (std::string text, FVector pos, FVector scale, AText::TextMode textMode, int16_t playerIndex) |
Data Fields | |
| DistanceProps | Dist = ACTIVE |
| DistanceProps | PrevState = ACTIVE |
| FadeMode | FadeState = NO_FADE |
| std::vector< CharacterList > | TextureList |
| std::string | Text |
| TextMode | Mode |
| uint32_t | PlayerIndex |
| float | WidthOffset = 0.0f |
| float | HeightOffset = 8.0f |
| f32 | ScaleX = 1.0f |
| f32 | LetterSpacing = 1.0f |
| f32 | Far = 14000.0f |
| f32 | Close = 350.0f |
| bool | FaceCamera = true |
| bool | Animate = false |
| bool | SingleColour = true |
| RGBA8 | TextColour [4] |
| Vtx | myVtx [12] |
Data Fields inherited from AActor | |
| s16 | Type = 0 |
| s16 | Flags |
| s16 | Unk_04 |
| s16 | State |
| f32 | Unk_08 |
| f32 | BoundingBoxSize |
| Vec3s | Rot = {0, 0, 0} |
| s16 | Unk_16 |
| Vec3f | Pos |
| Vec3f | Velocity = {0, 0, 0} |
| Collision | Unk30 |
| const char * | Model = "" |
| uint8_t | uuid [16] |
| const char * | Name = "" |
| const char * | ResourceName = "" |
| FVector | SpawnPos = {0.0f, 0.0f, 0.0f} |
| IRotator | SpawnRot = {0, 0, 0} |
| FVector | SpawnScale = {1.0f, 1.0f, 1.0f} |
| FVector | Scale = {1, 1, 1} |
| float | Speed = 0.0f |
| std::vector< Triangle > | Triangles |
| bool | bPendingDestroy = false |
| enum AText::DistanceProps : int16_t |
| enum AText::FadeMode : int16_t |
| enum AText::TextMode : int16_t |
| AText::AText | ( | const SpawnParams & | params | ) |
|
overridevirtualdefault |
| void AText::AnimateColour | ( | Vtx * | vtx | ) |
|
overridevirtual |
| void AText::DrawColourEditor | ( | bool * | updated | ) |
|
overridevirtual |
| void AText::DrawText3D | ( | Camera * | camera | ) |
| void AText::FadeIn | ( | Vtx * | vtx | ) |
| void AText::FadeOut | ( | Vtx * | vtx | ) |
|
inline |
| void AText::FollowPlayer | ( | ) |
|
overridevirtual |
Reimplemented from AActor.
| void AText::Print3D | ( | char * | text, |
| s32 | tracking, | ||
| s32 | mode ) |
These have been refactored for efficiency purposes. The new method uses 1 matrix to display the whole string And then setting vertex data is done during the setup/constructor phase, instead of during rendering This requires a refresh if the data ever changes
This method is more efficient because the original version does all this work during the render phase. Now it's done during the actor spawn phase with the exception if any changes are made at runtime.
FAKE:
| void AText::PrintLetter3D | ( | MenuTexture * | glyphTexture, |
| f32 | column, | ||
| f32 | row, | ||
| s32 | mode ) |
| void AText::Refresh | ( | ) |
|
overridevirtual |
Make sure you call this in derived classes! Usage: MyActor::SetSpawnParams(SetSpawnParams& params) { AActor::SetSpawnParams(params); // Calls default implementation }
Reimplemented from AActor.
| void AText::SetText | ( | std::string | text | ) |
| void AText::SetupVtx | ( | ) |
|
inlinestatic |
This is simply a helper function to keep Spawning code clean Main parameters usage:
PlayerIndex is only used if textMode is FOLLOW_PLAYER
Other available options:
TextColour<RGBA8> - Colour of the text (1 colour for each vertex) ScaleX<float> - Font scale Y LetterSpacing<float> - Space between letters HeightOffset<float> - Height above player when in FOLLOW_PLAYER mode WidthOffset<float> - Left/right offset of the text when in FOLLOW_PLAYER mode Far<float> - Skip rendering if camera is too far away Close<float> - Skip rendering if too close to the camera Animate<bool> - Cycle colours similar to the grand prix title text
Other options usage:
AText* text = AText::Spawn("Hello World", FVector(0, 0, 0), etc.); text->Animate = true; text->Far = 14000.0f; text->ScaleX = 0.1f; // Recommend in the range of 0-2.0f. Default 1.0f text->LetterSpacing = 1.0f; // Default 1.0f
For one single colour, set all vertices to the same colour. text->TextColour[0] = {255, 0, 0, 255}; // Red text->TextColour[1] = {0, 255, 0, 255}; // Green text->TextColour[2] = {0, 0, 255, 255}; // Blue text->TextColour[3] = {255, 255, 0, 255}; // Yellow
The above will result in a gradient between red, green, blue, and yellow For transparency {0, 0, 0, 100} <– alpha value of 100 will render semi-transparent black text.
|
overridevirtual |
| std::string AText::ValidateString | ( | const std::string_view & | s | ) |
Filters out bad characters (allows a-z, A-Z, 0-9, space) Returns "Blank Text" for blank input Returns "Invalid" if no valid input found Limits str to 20 characters
The font does support some symbols and other language characters But these need to be checked thoroughly before white-listing.
| bool AText::Animate = false |
| f32 AText::Close = 350.0f |
| DistanceProps AText::Dist = ACTIVE |
| bool AText::FaceCamera = true |
| f32 AText::Far = 14000.0f |
| float AText::HeightOffset = 8.0f |
| f32 AText::LetterSpacing = 1.0f |
| TextMode AText::Mode |
| Vtx AText::myVtx[12] |
| uint32_t AText::PlayerIndex |
| DistanceProps AText::PrevState = ACTIVE |
| f32 AText::ScaleX = 1.0f |
| bool AText::SingleColour = true |
| std::string AText::Text |
| RGBA8 AText::TextColour[4] |
| std::vector<CharacterList> AText::TextureList |
| float AText::WidthOffset = 0.0f |