Skip to content

Commit

Permalink
Merge branch 'feature/panelstates_flyingComponent' of https://github.…
Browse files Browse the repository at this point in the history
…com/FileEX/mtasa-blue into feature/panelstates_flyingComponent
  • Loading branch information
FileEX committed Jan 2, 2025
2 parents 0e86499 + 2fac1c4 commit 85dc2e4
Show file tree
Hide file tree
Showing 41 changed files with 2,200 additions and 100 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;
};
183 changes: 183 additions & 0 deletions Client/game_sa/CFontSA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CFontSA.cpp
* PURPOSE: Font class layer
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"
#include "CFontSA.h"

void CFontSA::PrintChar(float x, float y, char character)
{
// Call CFont::PrintChar
((void(_cdecl*)(float, float, char))0x718A10)(x, y, character);
}

void CFontSA::PrintString(float x, float y, const char* text)
{
// Call CFont::PrintString
((void(__cdecl*)(float, float, const char*))0x71A700)(x, y, text);
}

void CFontSA::PrintStringFromBottom(float x, float y, const char* text)
{
// Call CFont::PrintStringFromBottom
((void(__cdecl*)(float, float, const char*))0x71A820)(x, y, text);
}

void CFontSA::SetScale(float w, float h)
{
// Call CFont::SetScale
((void(__cdecl*)(float, float))0x719380)(w, h);
}

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))0x7193A0)(w, h);
}

void CFontSA::SetSlantRefPoint(float x, float y)
{
// Call CFont::SetSlantRefPoint
((void(__cdecl*)(float, float))0x719400)(x, y);
}

void CFontSA::SetSlant(float slant)
{
// Call CFont::SetSlant
((void(__cdecl*)(float))0x719420)(slant);
}

void CFontSA::SetColor(const RwColor& color)
{
// Call CFont::SetColor
((void(__cdecl*)(RwColor))0x719430)(color);
}

void CFontSA::SetDropColor(const RwColor& color)
{
// Call CFont::SetDropColor
((void(__cdecl*)(RwColor))0x719510)(color);
}

void CFontSA::SetFontStyle(const eFontStyle& style)
{
// Call CFont::SetFontStyle
((void(__cdecl*)(eFontStyle))0x719490)(style);
}

void CFontSA::SetWrapX(float wrapx)
{
// Call CFont::SetWrapx
((void(__cdecl*)(float))0x7194D0)(wrapx);
}

void CFontSA::SetRightJustifyWrap(float wrap)
{
// Call CFont::SetRightJustifyWrap
((void(__cdecl*)(float))0x7194F0)(wrap);
}

void CFontSA::SetCentreSize(float size)
{
// Call CFont::SetCentreSize
((void(__cdecl*)(float))0x7194E0)(size);
}

void CFontSA::SetDropShadowPosition(std::int16_t offset)
{
// Call CFont::SetDropShadowPosition
((void(__cdecl*)(std::int16_t))0x719570)(offset);
}

void CFontSA::SetEdge(std::int16_t edgeSize)
{
// Call CFont::SetEdge
((void(__cdecl*)(std::int16_t))0x719590)(edgeSize);
}

void CFontSA::SetProportional(bool enable)
{
// Call CFont::SetProportional
((void(__cdecl*)(bool))0x7195B0)(enable);
}

void CFontSA::SetBackground(bool enable, bool includeWrap)
{
// Call CFont::SetBackground
((void(__cdecl*)(bool, bool))0x7195C0)(enable, includeWrap);
}

void CFontSA::SetBackgroundColor(const RwColor& color)
{
// Call CFont::SetBackgroundColor
((void(__cdecl*)(RwColor))0x7195E0)(color);
}

void CFontSA::SetJustify(bool enable)
{
// Call CFont::SetJustify
((void(__cdecl*)(bool))0x719600)(enable);
}

void CFontSA::SetOrientation(const eFontAlignment& alignment)
{
// Call CFont::SetOrientation
((void(__cdecl*)(eFontAlignment))0x719610)(alignment);
}

float CFontSA::GetStringWidth(const char* string, bool spaces, bool scriptValues)
{
// Call CFont::GetStringWidth
return ((float(__cdecl*)(const char*, bool, bool))0x71A0E0)(string, spaces, scriptValues);
}

std::int16_t CFontSA::GetNumberLines(float x, float y, const char* text)
{
// Call CFont::GetNumberLines
return ((std::int16_t(__cdecl*)(float, float, const char*))0x71A5E0)(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);
bool rightAlign = *reinterpret_cast<bool*>(VAR_CFont_RightAlign);

if (centerAlign)
return eFontAlignment::ALIGN_CENTER;
else if (rightAlign)
return eFontAlignment::ALIGN_RIGHT;

return eFontAlignment::ALIGN_LEFT;
}

eFontStyle CFontSA::GetFontStyle()
{
std::uint8_t style = *reinterpret_cast<std::uint8_t*>(VAR_CFont_FontStyle);

switch (style)
{
case 0:
return *reinterpret_cast<eFontStyle*>(VAR_CFont_TextureID);
case 1:
return eFontStyle::FONT_PRICEDOWN;
case 2:
return eFontStyle::FONT_MENU;
}
}
Loading

0 comments on commit 85dc2e4

Please sign in to comment.