Skip to content

Commit 5ea0e0f

Browse files
authored
HUD Customization (PR #3836)
1 parent 7ad96e2 commit 5ea0e0f

23 files changed

+1885
-11
lines changed

Client/game_sa/CAERadioTrackManagerSA.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ void CAERadioTrackManagerSA::StartRadio(BYTE bStationID, BYTE bUnknown)
107107
call dwFunc
108108
}
109109
}
110+
111+
bool CAERadioTrackManagerSA::IsStationLoading() const
112+
{
113+
CAERadioTrackManagerSAInterface* trackInterface = GetInterface();
114+
return (trackInterface->stationsListed || trackInterface->stationsListDown);
115+
}

Client/game_sa/CAERadioTrackManagerSA.h

+87
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,101 @@
2323

2424
#define CLASS_CAERadioTrackManager 0x8CB6F8
2525

26+
enum class eRadioTrackMode
27+
{
28+
RADIO_STARTING,
29+
RADIO_WAITING_TO_PLAY,
30+
RADIO_PLAYING,
31+
RADIO_STOPPING,
32+
RADIO_STOPPING_SILENCED,
33+
RADIO_STOPPING_CHANNELS_STOPPED,
34+
RADIO_WAITING_TO_STOP,
35+
RADIO_STOPPED
36+
};
37+
38+
struct tRadioSettings
39+
{
40+
std::int32_t djIndex[4];
41+
std::int32_t currentTrackId;
42+
std::int32_t prevTrackId;
43+
std::int32_t trackPlayTime;
44+
std::int32_t trackLengthInMS;
45+
std::uint8_t trackFlags[2];
46+
std::uint8_t currentRadioStation;
47+
std::uint8_t field_27;
48+
std::uint8_t bassSet;
49+
float bassGain;
50+
std::uint8_t trackTypes[4];
51+
std::uint8_t currentTrackType;
52+
std::uint8_t prevTrackType;
53+
std::int8_t trackIndexes[10];
54+
};
55+
static_assert(sizeof(tRadioSettings) == 0x3C, "Invalid size of tRadioSettings struct!");
56+
57+
struct tRadioState
58+
{
59+
std::int32_t elapsed[3];
60+
std::int32_t timeInPauseModeInMS;
61+
std::int32_t timeInMS;
62+
std::int32_t trackPlayTime;
63+
std::int32_t trackQueue[3];
64+
std::uint8_t trackTypes[3];
65+
std::uint8_t gameMonthDay;
66+
std::uint8_t gameClockHours;
67+
};
68+
static_assert(sizeof(tRadioState) == 0x2C, "Invalid size of tRadioState struct!");
69+
70+
class CAERadioTrackManagerSAInterface
71+
{
72+
public:
73+
bool isInitialised;
74+
bool displayStationName;
75+
std::uint8_t field_2;
76+
bool enableInPauseMode;
77+
bool bassEnhance;
78+
bool pauseMode;
79+
bool retuneJustStarted;
80+
bool autoSelect;
81+
std::uint8_t tracksInARow[14];
82+
std::uint8_t gameMonthDay;
83+
std::uint8_t gameClockHours;
84+
std::int32_t listenItems[14];
85+
std::uint32_t timeRadioStationReturned;
86+
std::uint32_t timeToDisplayRadioName;
87+
std::uint32_t savedTimeInMS;
88+
std::uint32_t retuneStartedTime;
89+
std::uint8_t field_60[4];
90+
std::int32_t hwClientHandle;
91+
eRadioTrackMode trackMode;
92+
std::int32_t stationsListed;
93+
std::int32_t stationsListDown;
94+
std::int32_t savedRadioStationId;
95+
std::int32_t radioStationMenuRequest;
96+
std::int32_t radioStationScriptRequest;
97+
float volume1;
98+
float volume2;
99+
tRadioSettings requestedSettings;
100+
tRadioSettings activeSettings;
101+
tRadioState radioState[13];
102+
std::uint8_t field_33C[12];
103+
std::uint8_t field_348[32];
104+
std::uint32_t field_368;
105+
std::uint8_t userTrackPlayMode;
106+
std::uint8_t field_36D[3];
107+
};
108+
static_assert(sizeof(CAERadioTrackManagerSAInterface) == 0x370, "Invalid size of CAERadioTrackManagerSAInterface class!");
109+
26110
class CAERadioTrackManagerSA : public CAERadioTrackManager
27111
{
28112
public:
113+
CAERadioTrackManagerSAInterface* GetInterface() const noexcept { return reinterpret_cast<CAERadioTrackManagerSAInterface*>(CLASS_CAERadioTrackManager); }
114+
29115
BYTE GetCurrentRadioStationID();
30116
BYTE IsVehicleRadioActive();
31117
char* GetRadioStationName(BYTE bStationID);
32118
bool IsRadioOn();
33119
void SetBassSetting(DWORD dwBass);
34120
void Reset();
35121
void StartRadio(BYTE bStationID, BYTE bUnknown);
122+
bool IsStationLoading() const;
36123
};

Client/game_sa/CFontSA.cpp

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: game_sa/CFontSA.cpp
6+
* PURPOSE: Font class layer
7+
*
8+
* Multi Theft Auto is available from https://www.multitheftauto.com/
9+
*
10+
*****************************************************************************/
11+
12+
#include "StdInc.h"
13+
#include "CFontSA.h"
14+
15+
void CFontSA::PrintChar(float x, float y, char character)
16+
{
17+
// Call CFont::PrintChar
18+
((void(_cdecl*)(float, float, char))0x718A10)(x, y, character);
19+
}
20+
21+
void CFontSA::PrintString(float x, float y, const char* text)
22+
{
23+
// Call CFont::PrintString
24+
((void(__cdecl*)(float, float, const char*))0x71A700)(x, y, text);
25+
}
26+
27+
void CFontSA::PrintStringFromBottom(float x, float y, const char* text)
28+
{
29+
// Call CFont::PrintStringFromBottom
30+
((void(__cdecl*)(float, float, const char*))0x71A820)(x, y, text);
31+
}
32+
33+
void CFontSA::SetScale(float w, float h)
34+
{
35+
// Call CFont::SetScale
36+
((void(__cdecl*)(float, float))0x719380)(w, h);
37+
}
38+
39+
void CFontSA::SetScale(const CVector2D& scale)
40+
{
41+
SetScale(scale.fX, scale.fY);
42+
}
43+
44+
void CFontSA::SetScaleForCurrentLanguage(float w, float h)
45+
{
46+
// Call CFont::SetScaleForCurrentLanguage
47+
((void(__cdecl*)(float, float))0x7193A0)(w, h);
48+
}
49+
50+
void CFontSA::SetSlantRefPoint(float x, float y)
51+
{
52+
// Call CFont::SetSlantRefPoint
53+
((void(__cdecl*)(float, float))0x719400)(x, y);
54+
}
55+
56+
void CFontSA::SetSlant(float slant)
57+
{
58+
// Call CFont::SetSlant
59+
((void(__cdecl*)(float))0x719420)(slant);
60+
}
61+
62+
void CFontSA::SetColor(const RwColor& color)
63+
{
64+
// Call CFont::SetColor
65+
((void(__cdecl*)(RwColor))0x719430)(color);
66+
}
67+
68+
void CFontSA::SetDropColor(const RwColor& color)
69+
{
70+
// Call CFont::SetDropColor
71+
((void(__cdecl*)(RwColor))0x719510)(color);
72+
}
73+
74+
void CFontSA::SetFontStyle(const eFontStyle& style)
75+
{
76+
// Call CFont::SetFontStyle
77+
((void(__cdecl*)(eFontStyle))0x719490)(style);
78+
}
79+
80+
void CFontSA::SetWrapX(float wrapx)
81+
{
82+
// Call CFont::SetWrapx
83+
((void(__cdecl*)(float))0x7194D0)(wrapx);
84+
}
85+
86+
void CFontSA::SetRightJustifyWrap(float wrap)
87+
{
88+
// Call CFont::SetRightJustifyWrap
89+
((void(__cdecl*)(float))0x7194F0)(wrap);
90+
}
91+
92+
void CFontSA::SetCentreSize(float size)
93+
{
94+
// Call CFont::SetCentreSize
95+
((void(__cdecl*)(float))0x7194E0)(size);
96+
}
97+
98+
void CFontSA::SetDropShadowPosition(std::int16_t offset)
99+
{
100+
// Call CFont::SetDropShadowPosition
101+
((void(__cdecl*)(std::int16_t))0x719570)(offset);
102+
}
103+
104+
void CFontSA::SetEdge(std::int16_t edgeSize)
105+
{
106+
// Call CFont::SetEdge
107+
((void(__cdecl*)(std::int16_t))0x719590)(edgeSize);
108+
}
109+
110+
void CFontSA::SetProportional(bool enable)
111+
{
112+
// Call CFont::SetProportional
113+
((void(__cdecl*)(bool))0x7195B0)(enable);
114+
}
115+
116+
void CFontSA::SetBackground(bool enable, bool includeWrap)
117+
{
118+
// Call CFont::SetBackground
119+
((void(__cdecl*)(bool, bool))0x7195C0)(enable, includeWrap);
120+
}
121+
122+
void CFontSA::SetBackgroundColor(const RwColor& color)
123+
{
124+
// Call CFont::SetBackgroundColor
125+
((void(__cdecl*)(RwColor))0x7195E0)(color);
126+
}
127+
128+
void CFontSA::SetJustify(bool enable)
129+
{
130+
// Call CFont::SetJustify
131+
((void(__cdecl*)(bool))0x719600)(enable);
132+
}
133+
134+
void CFontSA::SetOrientation(const eFontAlignment& alignment)
135+
{
136+
// Call CFont::SetOrientation
137+
((void(__cdecl*)(eFontAlignment))0x719610)(alignment);
138+
}
139+
140+
float CFontSA::GetStringWidth(const char* string, bool spaces, bool scriptValues)
141+
{
142+
// Call CFont::GetStringWidth
143+
return ((float(__cdecl*)(const char*, bool, bool))0x71A0E0)(string, spaces, scriptValues);
144+
}
145+
146+
std::int16_t CFontSA::GetNumberLines(float x, float y, const char* text)
147+
{
148+
// Call CFont::GetNumberLines
149+
return ((std::int16_t(__cdecl*)(float, float, const char*))0x71A5E0)(x, y, text);
150+
}
151+
152+
float CFontSA::GetFontHeight(float scaleY)
153+
{
154+
return scaleY * 16.0f + scaleY * 2.0f;
155+
}
156+
157+
eFontAlignment CFontSA::GetOrientation()
158+
{
159+
bool centerAlign = *reinterpret_cast<bool*>(VAR_CFont_CenterAlign);
160+
bool rightAlign = *reinterpret_cast<bool*>(VAR_CFont_RightAlign);
161+
162+
if (centerAlign)
163+
return eFontAlignment::ALIGN_CENTER;
164+
else if (rightAlign)
165+
return eFontAlignment::ALIGN_RIGHT;
166+
167+
return eFontAlignment::ALIGN_LEFT;
168+
}
169+
170+
eFontStyle CFontSA::GetFontStyle()
171+
{
172+
std::uint8_t style = *reinterpret_cast<std::uint8_t*>(VAR_CFont_FontStyle);
173+
174+
switch (style)
175+
{
176+
case 0:
177+
return *reinterpret_cast<eFontStyle*>(VAR_CFont_TextureID);
178+
case 1:
179+
return eFontStyle::FONT_PRICEDOWN;
180+
case 2:
181+
return eFontStyle::FONT_MENU;
182+
}
183+
}

0 commit comments

Comments
 (0)