Skip to content

Commit

Permalink
Final update
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Dec 26, 2024
1 parent 7231404 commit e38e5c6
Show file tree
Hide file tree
Showing 12 changed files with 654 additions and 93 deletions.
6 changes: 6 additions & 0 deletions Client/game_sa/CAERadioTrackManagerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,9 @@ void CAERadioTrackManagerSA::StartRadio(BYTE bStationID, BYTE bUnknown)
call dwFunc
}
}

bool CAERadioTrackManagerSA::IsStationLoading() const
{
CAERadioTrackManagerSAInterface* trackInterface = GetInterface();
return (trackInterface->stationsListed || trackInterface->stationsListDown);
}
87 changes: 87 additions & 0 deletions Client/game_sa/CAERadioTrackManagerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,101 @@

#define CLASS_CAERadioTrackManager 0x8CB6F8

enum class eRadioTrackMode
{
RADIO_STARTING,
RADIO_WAITING_TO_PLAY,
RADIO_PLAYING,
RADIO_STOPPING,
RADIO_STOPPING_SILENCED,
RADIO_STOPPING_CHANNELS_STOPPED,
RADIO_WAITING_TO_STOP,
RADIO_STOPPED
};

struct tRadioSettings
{
std::int32_t djIndex[4];
std::int32_t currentTrackId;
std::int32_t prevTrackId;
std::int32_t trackPlayTime;
std::int32_t trackLengthInMS;
std::uint8_t trackFlags[2];
std::uint8_t currentRadioStation;
std::uint8_t field_27;
std::uint8_t bassSet;
float bassGain;
std::uint8_t trackTypes[4];
std::uint8_t currentTrackType;
std::uint8_t prevTrackType;
std::int8_t trackIndexes[10];
};
static_assert(sizeof(tRadioSettings) == 0x3C, "Invalid size of tRadioSettings struct!");

struct tRadioState
{
std::int32_t elapsed[3];
std::int32_t timeInPauseModeInMS;
std::int32_t timeInMS;
std::int32_t trackPlayTime;
std::int32_t trackQueue[3];
std::uint8_t trackTypes[3];
std::uint8_t gameMonthDay;
std::uint8_t gameClockHours;
};
static_assert(sizeof(tRadioState) == 0x2C, "Invalid size of tRadioState struct!");

class CAERadioTrackManagerSAInterface
{
public:
bool isInitialised;
bool displayStationName;
std::uint8_t field_2;
bool enableInPauseMode;
bool bassEnhance;
bool pauseMode;
bool retuneJustStarted;
bool autoSelect;
std::uint8_t tracksInARow[14];
std::uint8_t gameMonthDay;
std::uint8_t gameClockHours;
std::int32_t listenItems[14];
std::uint32_t timeRadioStationReturned;
std::uint32_t timeToDisplayRadioName;
std::uint32_t savedTimeInMS;
std::uint32_t retuneStartedTime;
std::uint8_t field_60[4];
std::int32_t hwClientHandle;
eRadioTrackMode trackMode;
std::int32_t stationsListed;
std::int32_t stationsListDown;
std::int32_t savedRadioStationId;
std::int32_t radioStationMenuRequest;
std::int32_t radioStationScriptRequest;
float volume1;
float volume2;
tRadioSettings requestedSettings;
tRadioSettings activeSettings;
tRadioState radioState[13];
std::uint8_t field_33C[12];
std::uint8_t field_348[32];
std::uint32_t field_368;
std::uint8_t userTrackPlayMode;
std::uint8_t field_36D[3];
};
static_assert(sizeof(CAERadioTrackManagerSAInterface) == 0x370, "Invalid size of CAERadioTrackManagerSAInterface class!");

class CAERadioTrackManagerSA : public CAERadioTrackManager
{
public:
CAERadioTrackManagerSAInterface* GetInterface() const noexcept { return reinterpret_cast<CAERadioTrackManagerSAInterface*>(CLASS_CAERadioTrackManager); }

BYTE GetCurrentRadioStationID();
BYTE IsVehicleRadioActive();
char* GetRadioStationName(BYTE bStationID);
bool IsRadioOn();
void SetBassSetting(DWORD dwBass);
void Reset();
void StartRadio(BYTE bStationID, BYTE bUnknown);
bool IsStationLoading() const;
};
13 changes: 12 additions & 1 deletion Client/game_sa/CFontSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ void CFontSA::SetScale(const CVector2D& scale)
SetScale(scale.fX, scale.fY);
}

void CFontSA::SetScaleForCurrentLanguage(float w, float h)
{
// Call CFont::SetScaleForCurrentLanguage
((void(__cdecl*)(float, float))FUNC_CFont_SetScaleForCurrentLanguage)(w, h);
}

void CFontSA::SetSlantRefPoint(float x, float y)
{
// Call CFont::SetSlantRefPoint
Expand Down Expand Up @@ -68,7 +74,7 @@ void CFontSA::SetDropColor(const RwColor& color)
void CFontSA::SetFontStyle(const eFontStyle& style)
{
// Call CFont::SetFontStyle
((void(__cdecl*)(std::uint16_t))FUNC_CFont_SetStyle)(static_cast<std::uint16_t>(style));
((void(__cdecl*)(eFontStyle))FUNC_CFont_SetStyle)(style);
}

void CFontSA::SetWrapX(float wrapx)
Expand Down Expand Up @@ -143,6 +149,11 @@ std::int16_t CFontSA::GetNumberLines(float x, float y, const char* text)
return ((std::int16_t(__cdecl*)(float, float, const char*))FUNC_CFont_GetNumberLines)(x, y, text);
}

float CFontSA::GetFontHeight(float scaleY)
{
return scaleY * 16.0f + scaleY * 2.0f;
}

eFontAlignment CFontSA::GetOrientation()
{
bool centerAlign = *reinterpret_cast<bool*>(VAR_CFont_CenterAlign);
Expand Down
10 changes: 8 additions & 2 deletions Client/game_sa/CFontSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define FUNC_CFont_PrintStringFromBottom 0x71A820

#define FUNC_CFont_SetScale 0x719380
#define FUNC_CFont_SetScaleForCurrentLanguage 0x7193A0

#define FUNC_CFont_SetSlantRefPoint 0x719400
#define FUNC_CFont_SetSlant 0x719420
Expand Down Expand Up @@ -82,6 +83,7 @@ class CFontSA

static void SetScale(float w, float h);
static void SetScale(const CVector2D& scale);
static void SetScaleForCurrentLanguage(float w, float h);

static void SetSlantRefPoint(float x, float y);
static void SetSlant(float slant);
Expand All @@ -108,9 +110,11 @@ class CFontSA

static float GetStringWidth(const char* string, bool spaces, bool scriptValues = false);
static std::int16_t GetNumberLines(float x, float y, const char* text);
static float GetFontHeight(float scaleY);

static CVector2D GetScale() { return *reinterpret_cast<CVector2D*>(VAR_CFont_Scale); }
static RwColor GetColor() { return *reinterpret_cast<RwColor*>(VAR_CFont_Color); }
static RwColor GetDropColor() { return *reinterpret_cast<RwColor*>(VAR_CFont_DropColor); }

static float GetSlant() { return *reinterpret_cast<float*>(VAR_CFont_Slant); }
static CVector2D GetSlantRefPoint() { return *reinterpret_cast<CVector2D*>(VAR_CFont_SlantRefPoint); }
Expand All @@ -130,6 +134,8 @@ class CFontSA

static eFontStyle GetFontStyle();

static float GetEdge() { return *reinterpret_cast<float*>(VAR_CFont_Edge); }
static float GetDropdownShadow() { return *reinterpret_cast<float*>(VAR_CFont_Shadow); }
static float GetEdge() { return static_cast<float>(*reinterpret_cast<std::uint8_t*>(VAR_CFont_Edge)); }
static float GetDropdownShadow() { return static_cast<float>(*reinterpret_cast<std::uint8_t*>(VAR_CFont_Shadow)); }

static bool GetProportional() { return *reinterpret_cast<bool*>(VAR_CFont_Proportional); }
};
Loading

0 comments on commit e38e5c6

Please sign in to comment.