Merge pull request #20 from gennariarmando/master

Update HUD stuff, bug and format fixes.
This commit is contained in:
aap 2019-06-17 07:29:52 +02:00 committed by GitHub
commit fcc6a8bc55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 291 additions and 190 deletions

View File

@ -177,3 +177,10 @@ but here are some observations:
* do *not* use `dw` for `DWORD` or so, we're not programming win32
* Generally, try to make the code look as if R* could have written it
# Environment Variables
Here you can find a list of variables that you might need to set in windows:
```
"GTA_III_RE_DIR" * path to "gta3_re" game folder usually where this plugin run.
"GTA_III_DIR)" * path to "GTAIII" game folder.
```

View File

@ -42,9 +42,9 @@ project "re3"
defines { "DEBUG" }
staticruntime "on"
symbols "On"
debugdir "C:/Users/aap/games/gta3_re"
debugcommand "C:/Users/aap/games/gta3_re/gta3.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gta3_re\\plugins\\re3.dll\""
debugdir "$(GTA_III_RE_DIR)"
debugcommand "$(GTA_III_RE_DIR)/gta3.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_III_RE_DIR)\\plugins\\re3.dll\""
filter "configurations:Release"
defines { "NDEBUG" }
@ -52,16 +52,16 @@ project "re3"
staticruntime "on"
debugdir "C:/Users/aap/games/gta3_re"
debugcommand "C:/Users/aap/games/gta3_re/gta3.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gta3_re\\plugins\\re3.dll\""
postbuildcommands "copy /y \"$(TargetPath)\" \"$(GTA_III_RE_DIR)\\plugins\\re3.dll\""
filter "configurations:ReleaseFH"
defines { "NDEBUG" }
symbols "Full"
optimize "off"
staticruntime "on"
debugdir "F:/Rockstar Games/GTAIII"
debugcommand "F:/Rockstar Games/GTAIII/gta3.exe"
debugdir "$(GTA_III_DIR)"
debugcommand "$(GTA_III_DIR)/gta3.exe"
targetextension ".asi"
targetdir "F:/Rockstar Games/GTAIII/scripts"
targetdir "$(GTA_III_DIR)/scripts"
filter "configurations:DebugCI"
defines { "DEBUG" }
symbols "On"

View File

@ -1249,7 +1249,8 @@ CCam::FixCamWhenObscuredByVehicle(const CVector &TargetCoors)
Source.z += HeightFixerCarsObscuring;
}
bool CCam::Using3rdPersonMouseCam() {
bool CCam::Using3rdPersonMouseCam()
{
return CCamera::m_bUseMouse3rdPerson &&
(Mode == MODE_FOLLOWPED ||
TheCamera.m_bPlayerIsInGarage &&

View File

@ -37,15 +37,15 @@ WRAPPER void CMenuManager::LoadSettings(void) { EAXJMP(0x488EE0); }
WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); }
int CMenuManager::FadeIn(int alpha) {
if (FrontEndMenuManager.m_nCurrScreen == MENU_LOADING_IN_PROGRESS ||
FrontEndMenuManager.m_nCurrScreen == MENU_SAVING_IN_PROGRESS ||
FrontEndMenuManager.m_nCurrScreen == MENU_DELETING)
if (m_nCurrScreen == MENU_LOADING_IN_PROGRESS ||
m_nCurrScreen == MENU_SAVING_IN_PROGRESS ||
m_nCurrScreen == MENU_DELETING)
return alpha;
if (FrontEndMenuManager.m_nMenuFadeAlpha >= alpha)
if (m_nMenuFadeAlpha >= alpha)
return alpha;
return FrontEndMenuManager.m_nMenuFadeAlpha;
return m_nMenuFadeAlpha;
}
STARTPATCHES

View File

@ -15,7 +15,8 @@ WRAPPER void CRadar::DrawRadarMap() { EAXJMP(0x4A6C20); }
float &CRadar::m_RadarRange = *(float*)0x8E281C;
CVector2D &CRadar::vec2DRadarOrigin = *(CVector2D*)0x6299B8;
void CRadar::DrawMap() {
void CRadar::DrawMap()
{
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
if (FindPlayerVehicle()) {
if (FindPlayerVehicle()->GetSpeed().Magnitude() > 0.3f) {
@ -24,24 +25,24 @@ void CRadar::DrawMap() {
else
CRadar::m_RadarRange = (FindPlayerVehicle()->GetSpeed().Magnitude() + 0.3f) * 200.0f;
}
else {
else
CRadar::m_RadarRange = 120.0f;
}
}
else {
else
CRadar::m_RadarRange = 120.0f;
}
vec2DRadarOrigin.x = FindPlayerCentreOfWorld_NoSniperShift().x;
vec2DRadarOrigin.y = FindPlayerCentreOfWorld_NoSniperShift().y;
CRadar::DrawRadarMap();
}
}
void CRadar::TransformRadarPointToScreenSpace(CVector2D *out, CVector2D *in) {
void CRadar::TransformRadarPointToScreenSpace(CVector2D *out, CVector2D *in)
{
out->x = in->x * HUD_STRETCH_X(47.0f) + HUD_STRETCH_X(47.0f + 20.0f);
out->y = (HUD_STRETCH_Y(76.0f)) * 0.5f + SCREEN_HEIGHT - (HUD_STRETCH_Y(123.0f)) - in->y * (HUD_STRETCH_Y(76.0f)) * 0.5f;
out->y = (HUD_STRETCH_Y(76.0f)) * 0.5f + SCREEN_HEIGHT - (HUD_STRETCH_Y(123.0f)) - in->y * (HUD_STRETCH_Y(76.0f)) * 0.5f;
}
STARTPATCHES
InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP);
ENDPATCHES
ENDPATCHES

View File

@ -2,7 +2,8 @@
#include "Entity.h"
#include "math/Vector.h"
enum eCrimeType {
enum eCrimeType
{
CRIME_NONE,
CRIME_SHOT_FIRED,
CRIME_PED_FIGHT,
@ -22,7 +23,8 @@ enum eCrimeType {
CRIME_DESTROYED_CESSNA,
};
enum eCopType {
enum eCopType
{
COP_STREET = 0,
COP_FBI = 1,
COP_SWAT = 2,

View File

@ -16,7 +16,8 @@ int &gRetuneCounter = *(int*)0x650B84;
//WRAPPER void cMusicManager::DisplayRadioStationName(void) { EAXJMP(0x57E6D0); }
bool cMusicManager::PlayerInCar() {
bool cMusicManager::PlayerInCar()
{
if (!FindPlayerVehicle())
return false;
else {
@ -25,7 +26,6 @@ bool cMusicManager::PlayerInCar() {
if (State == PED_DRAG_FROM_CAR || State == PED_EXIT_CAR || State == PED_ARRESTED)
return false;
int16 Model = FindPlayerVehicle()->m_modelIndex;
switch (FindPlayerVehicle()->m_modelIndex) {
case MI_FIRETRUCK:
case MI_AMBULAN:
@ -42,8 +42,9 @@ bool cMusicManager::PlayerInCar() {
}
}
void cMusicManager::DisplayRadioStationName() {
wchar* RadioName = nullptr;
void cMusicManager::DisplayRadioStationName()
{
wchar *RadioName = nullptr;
uint32 RadioStation = gNumRetunePresses + MusicManager.m_nCurrentStreamedSound;
switch (RadioStation) {
@ -84,11 +85,11 @@ void cMusicManager::DisplayRadioStationName() {
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_STRETCH_X(0.8f), SCREEN_STRETCH_Y(1.35f));
CFont::SetScale(HUD_STRETCH_X(0.8f), HUD_STRETCH_Y(1.35f));
CFont::SetPropOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_STRETCH_X(640.0f));;
CFont::SetCentreSize(HUD_STRETCH_X(640.0f));;
static int32 nTime = 0;
if (!CTimer::GetIsPaused() && !TheCamera.m_WideScreenOn && MusicManager.PlayerInCar()) {
@ -105,33 +106,36 @@ void cMusicManager::DisplayRadioStationName() {
else {
if (RadioStation > HEAD_RADIO) {
if (cSampleManager.IsMP3RadioChannelAvailable()) {
if (RadioStation > USERTRACK)
if (RadioStation > USERTRACK) {
RadioStation = RADIO_OFF;
return;
}
}
else {
if (RadioStation > CHATTERBOX)
if (RadioStation > CHATTERBOX) {
RadioStation = RADIO_OFF;
return;
}
}
}
else {
else
RadioStation = RADIO_OFF;
}
}
}
if (RadioName) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_STRETCH_Y(23.0f), RadioName);
CFont::PrintString(SCREEN_WIDTH / 2, HUD_STRETCH_Y(23.0f), RadioName);
if (gNumRetunePresses)
CFont::SetColor(CRGBA(102, 133, 143, 255));
else
CFont::SetColor(CRGBA(147, 196, 211, 255));
CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_STRETCH_Y(22.0f), RadioName);
CFont::PrintString(SCREEN_WIDTH / 2, HUD_STRETCH_Y(22.0f), RadioName);
CFont::DrawFonts();
}
}
}
}
}

View File

@ -1,6 +1,7 @@
#pragma once
enum eRadioStation {
enum eRadioStation
{
HEAD_RADIO,
DOUBLE_CLEF,
JAH_RADIO,
@ -15,7 +16,8 @@ enum eRadioStation {
RADIO_OFF,
};
enum eStreamedSounds {
enum eStreamedSounds
{
STREAMED_SOUND_RADIO_HEAD = 0,
STREAMED_SOUND_RADIO_CLASSIC = 1,
STREAMED_SOUND_RADIO_KJAH = 2,
@ -216,7 +218,8 @@ enum eStreamedSounds {
NO_STREAMED_SOUND = 197,
};
class tMP3Sample {
class tMP3Sample
{
public:
uint32 m_nLength;
uint32 m_nPosition;

View File

@ -138,6 +138,7 @@ void mysrand(unsigned int seed);
extern uint8 work_buff[55000];
extern char gString[256];
extern wchar *gUString;
void re3_debug(char *format, ...);
void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...);

View File

@ -6,6 +6,7 @@ WRAPPER void CDarkel::DrawMessages(void) { EAXJMP(0x420920); }
bool CDarkel::Status = *(bool*)0x95CCB4;
bool CDarkel::FrenzyOnGoing() {
bool CDarkel::FrenzyOnGoing()
{
return Status;
}

View File

@ -2,8 +2,29 @@
#include "patcher.h"
#include "ModelIndices.h"
#include "Garages.h"
#include "Timer.h"
#include "Font.h"
#include "Messages.h"
#include "Text.h"
WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
//WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
bool &CGarages::RespraysAreFree = *(bool *)0x95CD1D;
int32 &CGarages::CarsCollected = *(int32 *)0x880E18;
int32 &CGarages::CarTypesCollected = *(int32 *)0x8E286C;
int32 &CGarages::CrushedCarId = *(int32 *)0x943060;
uint32 &CGarages::LastTimeHelpMessage = *(uint32 *)0x8F1B58;
int32 &CGarages::MessageNumberInString = *(int32 *)0x885BA8;
const char *CGarages::MessageIDString = (const char *)0x878358;
int32 &CGarages::MessageNumberInString2 = *(int32 *)0x8E2C14;
uint32 &CGarages::MessageStartTime = *(uint32 *)0x8F2530;
uint32 &CGarages::MessageEndTime = *(uint32 *)0x8F597C;
uint32 &CGarages::NumGarages = *(uint32 *)0x8F29F4;
bool &CGarages::PlayerInGarage = *(bool *)0x95CD83;
int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444;
uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570;
bool
CGarages::IsModelIndexADoor(uint32 id)
@ -42,3 +63,44 @@ CGarages::IsModelIndexADoor(uint32 id)
id == MI_CRUSHERBODY ||
id == MI_CRUSHERLID;
}
void CGarages::PrintMessages()
{
if (CTimer::GetTimeInMilliseconds() > CGarages::MessageStartTime && CTimer::GetTimeInMilliseconds() < CGarages::MessageEndTime) {
CFont::SetScale(HUD_STRETCH_X(1.2f / 2), HUD_STRETCH_Y(1.5f / 2)); // BUG: game doesn't use macro here.
CFont::SetPropOn();
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetCentreSize(HUD_FROM_RIGHT(50.0f));
CFont::SetCentreOn();
CFont::SetFontStyle(FONT_BANK);
if (CGarages::MessageNumberInString2 < 0) {
if (CGarages::MessageNumberInString < 0) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH/ 2) + HUD_STRETCH_X(2.0f), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f), TheText.Get(CGarages::MessageIDString));
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f), TheText.Get(CGarages::MessageIDString));
}
else {
CMessages::InsertNumberInString(TheText.Get(CGarages::MessageIDString), CGarages::MessageNumberInString, -1, -1, -1, -1, -1, gUString);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + HUD_STRETCH_X(2.0f), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f + 2.0 - 40.0f), gUString);
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f - 40.0f), gUString);
}
}
else {
CMessages::InsertNumberInString(TheText.Get(CGarages::MessageIDString), CGarages::MessageNumberInString2, -1, -1, -1, -1, -1, gUString);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + HUD_STRETCH_X(2.0f), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f + 2.0 - 40.0f), gUString);
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + HUD_STRETCH_Y(-84.0f - 40.0f), gUString);
}
}
}

View File

@ -2,6 +2,24 @@
class CGarages
{
public:
static int32 &BankVansCollected;
static bool &BombsAreFree;
static bool &RespraysAreFree;
static int32 &CarsCollected;
static int32 &CarTypesCollected;
static int32 &CrushedCarId;
static uint32 &LastTimeHelpMessage;
static int32 &MessageNumberInString;
static const char *MessageIDString;
static int32 &MessageNumberInString2;
static uint32 &MessageStartTime;
static uint32 &MessageEndTime;
static uint32 &NumGarages;
static bool &PlayerInGarage;
static int32 &PoliceCarsCollected;
static uint32 &GarageToBeTidied;
public:
static bool IsModelIndexADoor(uint32 id);
static void PrintMessages(void);

View File

@ -2,18 +2,21 @@
#include "Automobile.h"
#include "PlayerPed.h"
enum eWastedBustedState {
WBSTATE_PLAYING = 0x0,
WBSTATE_WASTED = 0x1,
WBSTATE_BUSTED = 0x2,
WBSTATE_FAILED_CRITICAL_MISSION = 0x3,
enum eWastedBustedState
{
WBSTATE_PLAYING,
WBSTATE_WASTED,
WBSTATE_BUSTED,
WBSTATE_FAILED_CRITICAL_MISSION,
};
struct CCivilianPed {
struct CCivilianPed
{
};
class CPlayerInfo {
class CPlayerInfo
{
public:
CPlayerPed *m_pPed;
CVehicle *m_pRemoteVehicle;

View File

@ -3,7 +3,8 @@
#include "Ped.h"
#include "Wanted.h"
class CPlayerPed : public CPed {
class CPlayerPed : public CPed
{
public:
CWanted *m_pWanted;
CCopPed *m_pArrestingCop;

View File

@ -57,6 +57,7 @@
uint8 work_buff[55000];
char gString[256];
wchar *gUString = (wchar*)0x74B018;
bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8;
@ -322,15 +323,16 @@ Render2dStuff(void)
CRGBA black(0, 0, 0, 255);
// top and bottom strips
if(weaponType == WEAPONTYPE_ROCKETLAUNCHER){
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH/2 - SCREEN_STRETCH_Y(180)), black);
CSprite2d::DrawRect(CRect(0.0f, SCREENH/2 + SCREEN_STRETCH_Y(170), SCREENW, SCREENH), black);
}else{
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH/2 - SCREEN_STRETCH_Y(210)), black);
CSprite2d::DrawRect(CRect(0.0f, SCREENH/2 + SCREEN_STRETCH_Y(210), SCREENW, SCREENH), black);
if (weaponType == WEAPONTYPE_ROCKETLAUNCHER) {
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH / 2 - HUD_STRETCH_Y(180)), black);
CSprite2d::DrawRect(CRect(0.0f, SCREENH / 2 + HUD_STRETCH_Y(170), SCREENW, SCREENH), black);
}
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW/2 - SCREEN_STRETCH_X(210), SCREENH), black);
CSprite2d::DrawRect(CRect(SCREENW/2 + SCREEN_STRETCH_X(210), 0.0f, SCREENW, SCREENH), black);
else {
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW, SCREENH / 2 - HUD_STRETCH_Y(210)), black);
CSprite2d::DrawRect(CRect(0.0f, SCREENH / 2 + HUD_STRETCH_Y(210), SCREENW, SCREENH), black);
}
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREENW / 2 - HUD_STRETCH_X(210), SCREENH), black);
CSprite2d::DrawRect(CRect(SCREENW / 2 + HUD_STRETCH_X(210), 0.0f, SCREENW, SCREENH), black);
}
MusicManager.DisplayRadioStationName();

View File

@ -24,10 +24,10 @@
//WRAPPER void CHud::DrawAfterFade(void) { EAXJMP(0x509030); }
WRAPPER void CHud::ReInitialise(void) { EAXJMP(0x504CC0); }
WRAPPER void CHud::GetRidOfAllHudMessages(void) { EAXJMP(0x504F90); }
WRAPPER void CHud::SetHelpMessage(wchar* message, bool quick) { EAXJMP(0x5051E0); }
WRAPPER void CHud::SetMessage(wchar* message) { EAXJMP(0x50A210); }
WRAPPER void CHud::SetBigMessage(wchar* message, int16 style) { EAXJMP(0x50A250); }
WRAPPER void CHud::SetPagerMessage(wchar* message) { EAXJMP(0x50A320); }
WRAPPER void CHud::SetHelpMessage(wchar *message, bool quick) { EAXJMP(0x5051E0); }
WRAPPER void CHud::SetMessage(wchar *message) { EAXJMP(0x50A210); }
WRAPPER void CHud::SetBigMessage(wchar *message, int16 style) { EAXJMP(0x50A250); }
WRAPPER void CHud::SetPagerMessage(wchar *message) { EAXJMP(0x50A320); }
wchar *CHud::m_HelpMessage = (wchar*)0x86B888;
wchar *CHud::m_LastHelpMessage = (wchar*)0x6E8F28;
@ -42,17 +42,17 @@ bool &CHud::m_bHelpMessageQuick = *(bool *)0x95CCF7;
int32 CHud::m_ZoneState = *(int32*)0x8F29AC;
int32 CHud::m_ZoneFadeTimer;
int32 CHud::m_ZoneNameTimer = *(int32*)0x8F1A50;
wchar* &CHud::m_pZoneName = *(wchar **)0x8E2C2C;
wchar* CHud::m_pLastZoneName = (wchar*)0x8F432C;
wchar* CHud::m_ZoneToPrint;
wchar *&CHud::m_pZoneName = *(wchar **)0x8E2C2C;
wchar *CHud::m_pLastZoneName = (wchar*)0x8F432C;
wchar *CHud::m_ZoneToPrint;
int32 CHud::m_VehicleState = *(int32*)0x940560;
int32 CHud::m_VehicleFadeTimer;
int32 CHud::m_VehicleNameTimer = *(int32*)0x8F2A14;
wchar* &CHud::m_pVehicleName = *(wchar **)0x942FB4;
wchar* CHud::m_pLastVehicleName = *(wchar **)0x8E2DD8;
wchar* CHud::m_pVehicleNameToPrint;
wchar* CHud::m_Message = (wchar*)0x72E318;
wchar* CHud::m_PagerMessage = (wchar*)0x878840;
wchar *&CHud::m_pVehicleName = *(wchar **)0x942FB4;
wchar *CHud::m_pLastVehicleName = *(wchar **)0x8E2DD8;
wchar *CHud::m_pVehicleNameToPrint;
wchar *CHud::m_Message = (wchar*)0x72E318;
wchar *CHud::m_PagerMessage = (wchar*)0x878840;
bool &CHud::m_Wants_To_Draw_Hud = *(bool*)0x95CD89;
bool &CHud::m_Wants_To_Draw_3dMarkers = *(bool*)0x95CD62;
wchar(*CHud::m_BigMessage)[128] = (wchar(*)[128])0x664CE0;
@ -82,7 +82,7 @@ char *WeaponFilenames[] = {
"bat",
"batm",
"pistol",
"pistolm",
"pistolm",
"uzi",
"uzim",
"shotgun",
@ -100,14 +100,14 @@ char *WeaponFilenames[] = {
"molotov",
"molotovm",
"grenade",
"grenadem",
"grenadem",
"detonator",
"detonator_mask",
"",
"",
"",
"",
"radardisc",
"radardisc",
"radardiscm",
"pager",
"pagerm",
@ -122,13 +122,14 @@ char *WeaponFilenames[] = {
"siteM16",
"siteM16m",
"siterocket",
"siterocketm"
"siterocketm"
};
RwTexture* gpSniperSightTex = (RwTexture*)0x8F5834;
RwTexture* gpRocketSightTex = (RwTexture*)0x8E2C20;
RwTexture *&gpSniperSightTex = *(RwTexture**)0x8F5834;
RwTexture *&gpRocketSightTex = *(RwTexture**)0x8E2C20;
void CHud::Initialise() {
void CHud::Initialise()
{
ReInitialise();
int HudTXD = CTxdStore::AddTxdSlot("hud");
@ -147,8 +148,9 @@ void CHud::Initialise() {
CTxdStore::PopCurrentTxd();
}
void CHud::Shutdown() {
for (int i = 0; i < 23; ++i) {
void CHud::Shutdown()
{
for (int i = 0; i < ARRAY_SIZE(WeaponFilenames) / 2; ++i) {
Sprites[i].Delete();
}
@ -162,15 +164,18 @@ void CHud::Shutdown() {
CTxdStore::RemoveTxdSlot(HudTXD);
}
void CHud::SetVehicleName(wchar* name) {
void CHud::SetVehicleName(wchar *name)
{
m_pVehicleName = name;
}
void CHud::SetZoneName(wchar* name) {
void CHud::SetZoneName(wchar *name)
{
m_pZoneName = name;
}
void CHud::Draw() {
void CHud::Draw()
{
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
@ -218,7 +223,7 @@ void CHud::Draw() {
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
float fStep = sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127);
float fMultBright = CHud::SpriteBrightness * 0.033333335f * (0.25f * fStep + 0.75f);
float fMultBright = CHud::SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f);
CRect rect;
float fWidescreenOffset[2] = { 0.0f, 0.0f };
@ -420,8 +425,8 @@ void CHud::Draw() {
CFont::SetPropOff();
CFont::SetFontStyle(FONT_HEADING);
if (CHud::m_ItemToFlash == 4 && CTimer::GetFrameCounter() & 8
|| CHud::m_ItemToFlash != 4
if (CHud::m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8
|| CHud::m_ItemToFlash != ITEM_HEALTH
|| CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth < 10
&& CTimer::GetFrameCounter() & 8) {
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth >= 10
@ -450,7 +455,7 @@ void CHud::Draw() {
/*
DrawArmour
*/
if (CHud::m_ItemToFlash == 3 && CTimer::GetFrameCounter() & 8 || CHud::m_ItemToFlash != 3) {
if (CHud::m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || CHud::m_ItemToFlash != ITEM_ARMOUR) {
CFont::SetScale(HUD_STRETCH_X(0.8f), HUD_STRETCH_Y(1.35f));
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon);
@ -488,7 +493,7 @@ void CHud::Draw() {
AsciiToUnicode("]", sPrintIcon);
for (int i = 0; i < 6; i++) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(2.0f + HUD_FROM_RIGHT(60.0f - 2.0f + 23.0f * i), HUD_STRETCH_Y(87.0f + 2.0f), sPrintIcon);
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel > i
&& (CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nLastWantedLevelChange
@ -574,7 +579,7 @@ void CHud::Draw() {
if (CMenuManager::m_PrefsLanguage == 4)
CFont::SetScale(HUD_STRETCH_X(1.2f * 0.8f), HUD_STRETCH_Y(1.2f));
else
CFont::SetScale(HUD_STRETCH_X(1.2f), HUD_STRETCH_Y(1.2f));
CFont::SetScale(HUD_STRETCH_X(1.2f), HUD_STRETCH_Y(1.2f));
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f);
@ -845,7 +850,7 @@ void CHud::Draw() {
/*
DrawRadar
*/
if (CHud::m_ItemToFlash == 8 && CTimer::GetFrameCounter() & 8 || CHud::m_ItemToFlash != 8) {
if (CHud::m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || CHud::m_ItemToFlash != ITEM_RADAR) {
CRadar::DrawMap();
CHud::Sprites[HUD_RADARDISC].Draw(CRect(HUD_STRETCH_X(16.0f), HUD_FROM_BOTTOM(123.0f + 4.0f), HUD_STRETCH_X(94.0f + 20.0f + 5.0f), HUD_FROM_BOTTOM(-76.0f + 123.0f - 6.0f)), CRGBA(0, 0, 0, 255));
CRadar::DrawBlips();
@ -863,87 +868,77 @@ void CHud::Draw() {
DrawScriptText
*/
if (!CTimer::GetIsUserPaused()) {
uint16 CounterA = 0;
uint16 CounterB = 0;
CTextLine* IntroText = CTheScripts::IntroTextLines;
do {
if (CTheScripts::IntroTextLines[CounterB].m_awText[0] && CTheScripts::IntroTextLines[CounterB].field_29) {
CFont::SetScale(HUD_STRETCH_X(CTheScripts::IntroTextLines[CounterB].m_fScaleX), HUD_STRETCH_Y(CTheScripts::IntroTextLines[CounterB].m_fScaleY * 0.5f));
CFont::SetColor(CTheScripts::IntroTextLines[CounterB].m_sColor);
for (int i = 0; i < 2; i++) {
if (CTheScripts::IntroTextLines[i].m_awText[0] && CTheScripts::IntroTextLines[i].field_29) {
CFont::SetScale(HUD_STRETCH_X(CTheScripts::IntroTextLines[i].m_fScaleX), HUD_STRETCH_Y(CTheScripts::IntroTextLines[i].m_fScaleY * 0.5f));
CFont::SetColor(CTheScripts::IntroTextLines[i].m_sColor);
if (CTheScripts::IntroTextLines[CounterB].m_bJustify)
if (CTheScripts::IntroTextLines[i].m_bJustify)
CFont::SetJustifyOn();
else
CFont::SetJustifyOff();
if (CTheScripts::IntroTextLines[CounterB].m_bRightJustify)
if (CTheScripts::IntroTextLines[i].m_bRightJustify)
CFont::SetRightJustifyOn();
else
CFont::SetRightJustifyOff();
if (CTheScripts::IntroTextLines[CounterB].m_bCentered)
if (CTheScripts::IntroTextLines[i].m_bCentered)
CFont::SetCentreOn();
else
CFont::SetCentreOff();
CFont::SetWrapx(HUD_STRETCH_X(CTheScripts::IntroTextLines[CounterB].m_fWrapX));
CFont::SetCentreSize(HUD_STRETCH_X(CTheScripts::IntroTextLines[CounterB].m_fCenterSize));
CFont::SetWrapx(HUD_STRETCH_X(CTheScripts::IntroTextLines[i].m_fWrapX));
CFont::SetCentreSize(HUD_STRETCH_X(CTheScripts::IntroTextLines[i].m_fCenterSize));
if (CTheScripts::IntroTextLines[CounterB].m_bBackground)
if (CTheScripts::IntroTextLines[i].m_bBackground)
CFont::SetBackgroundOn();
else
CFont::SetBackgroundOff();
CFont::SetBackgroundColor(CTheScripts::IntroTextLines[CounterB].m_sBackgroundColor);
CFont::SetBackgroundColor(CTheScripts::IntroTextLines[i].m_sBackgroundColor);
if (CTheScripts::IntroTextLines[CounterB].m_bBackgroundOnly)
if (CTheScripts::IntroTextLines[i].m_bBackgroundOnly)
CFont::SetBackGroundOnlyTextOn();
else
CFont::SetBackGroundOnlyTextOff();
if (CTheScripts::IntroTextLines[CounterB].m_bTextProportional)
if (CTheScripts::IntroTextLines[i].m_bTextProportional)
CFont::SetPropOn();
else
CFont::SetPropOff();
CFont::SetFontStyle(CTheScripts::IntroTextLines[CounterB].m_nFont);
CFont::PrintString(HUD_STRETCH_X(640.0f - CTheScripts::IntroTextLines[CounterB].field_36), HUD_STRETCH_Y(448.0f - CTheScripts::IntroTextLines[CounterB].field_40), IntroText->m_awText);
CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont);
CFont::PrintString(HUD_STRETCH_X(640.0f - CTheScripts::IntroTextLines[i].field_36), HUD_STRETCH_Y(448.0f - CTheScripts::IntroTextLines[i].field_40), IntroText->m_awText);
}
++CounterA;
++CounterB;
++IntroText;
} while (CounterA < 2);
}
uint16 CounterC = 0;
uint16 CounterD = 0;
CScriptRectangle* IntroRect = CTheScripts::IntroRectangles;
do {
if (CTheScripts::IntroRectangles[CounterD].m_bIsUsed && CTheScripts::IntroRectangles[CounterD].m_bIsAntialiased) {
if (CTheScripts::IntroRectangles[CounterD].m_wTextureId >= 0) {
for (int i = 0; i < 16; i++) {
if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bIsAntialiased) {
if (CTheScripts::IntroRectangles[i].m_wTextureId >= 0) {
CRect rect = {
CTheScripts::IntroRectangles[CounterD].m_sRect.left,
CTheScripts::IntroRectangles[CounterD].m_sRect.bottom,
CTheScripts::IntroRectangles[CounterD].m_sRect.right,
CTheScripts::IntroRectangles[CounterD].m_sRect.bottom };
CTheScripts::IntroRectangles[i].m_sRect.left,
CTheScripts::IntroRectangles[i].m_sRect.bottom,
CTheScripts::IntroRectangles[i].m_sRect.right,
CTheScripts::IntroRectangles[i].m_sRect.bottom };
CTheScripts::ScriptSprites[CTheScripts::IntroRectangles[CounterD].m_wTextureId].Draw(rect, IntroRect->m_sColor);
CTheScripts::ScriptSprites[CTheScripts::IntroRectangles[i].m_wTextureId].Draw(rect, IntroRect->m_sColor);
}
else {
CRect rect = {
CTheScripts::IntroRectangles[CounterD].m_sRect.left,
CTheScripts::IntroRectangles[CounterD].m_sRect.bottom,
CTheScripts::IntroRectangles[CounterD].m_sRect.right,
CTheScripts::IntroRectangles[CounterD].m_sRect.bottom };
CTheScripts::IntroRectangles[i].m_sRect.left,
CTheScripts::IntroRectangles[i].m_sRect.bottom,
CTheScripts::IntroRectangles[i].m_sRect.right,
CTheScripts::IntroRectangles[i].m_sRect.bottom };
CSprite2d::DrawRect(rect, IntroRect->m_sColor);
}
}
++CounterC;
++CounterD;
++IntroRect;
} while (CounterC < 16);
}
/*
DrawSubtitles
@ -972,8 +967,9 @@ void CHud::Draw() {
/*
DrawBigMessage
*/
// MissionCompleteFailedText
if (CHud::m_BigMessage[0][0]) {
if (0.0f == BigMessageInUse[0]) {
if (BigMessageInUse[0] == 0.0f) {
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetBackGroundOnlyTextOff();
@ -983,28 +979,23 @@ void CHud::Draw() {
CFont::SetCentreSize(HUD_STRETCH_X(615.0f));
CFont::SetColor(CRGBA(255, 255, 0, 255));
CFont::SetFontStyle(FONT_HEADING);
if ((SCREENW - 20) <= BigMessageX[0]) {
BigMessageInUse[0] = BigMessageInUse[0] + CTimer::GetTimeStep();
if (BigMessageInUse[0] >= 120.0f) {
BigMessageInUse[0] = 120.0;
BigMessageAlpha[0] = BigMessageAlpha[0] - (CTimer::GetTimeStep() * 0.02f * 1000.0f) * 0.30000001f;
}
if (BigMessageX[0] >= (SCREENW - 20)) {
BigMessageAlpha[0] += (CTimer::GetTimeStep() * 0.02f * -255.0f);
if (BigMessageAlpha[0] <= 0.0f) {
CHud::m_BigMessage[0][0] = 0;
BigMessageAlpha[0] = 0.0;
BigMessageAlpha[0] = 0.0f;
BigMessageInUse[0] = 1.0f;
}
}
else {
float fStep = (CTimer::GetTimeStep()
* 0.02f
* 1000.0f)
* 0.30000001f;
BigMessageX[0] = BigMessageX[0] + fStep;
BigMessageAlpha[0] = BigMessageAlpha[0] + fStep;
BigMessageX[0] += (CTimer::GetTimeStep() * 0.02f * 255.0f);
BigMessageAlpha[0] += (CTimer::GetTimeStep() * 0.02f * 255.0f);
if (BigMessageAlpha[0] > 255.0f)
BigMessageAlpha[0] = 255.0;
if (BigMessageAlpha[0] >= 255.0f)
BigMessageAlpha[0] = 255.0f;
}
CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[0]));
CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - HUD_STRETCH_Y(20.0f - 2.0f), m_BigMessage[0]);
@ -1023,14 +1014,12 @@ void CHud::Draw() {
// WastedBustedText
if (CHud::m_BigMessage[2][0]) {
if (0 == BigMessageInUse[2]) {
BigMessageAlpha[2] = (CTimer::GetTimeStep()
* 0.02f
* 1000.0f)
* 0.40000001
+ BigMessageAlpha[2];
if (BigMessageInUse[2] == 0.0f) {
BigMessageAlpha[2] += (CTimer::GetTimeStep() * 0.02f * 1000.0f) * 0.4f;
if (BigMessageAlpha[2] > 255.0f)
BigMessageAlpha[2] = 255.0;
CFont::SetBackgroundOff();
if (CGame::frenchGame || CGame::germanGame)
@ -1060,7 +1049,8 @@ void CHud::Draw() {
}
}
void CHud::DrawAfterFade() {
void CHud::DrawAfterFade()
{
if (CTimer::GetIsUserPaused() || CReplay::Mode == 1)
return;
@ -1179,7 +1169,6 @@ void CHud::DrawAfterFade() {
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - HUD_STRETCH_Y(84.0f), m_BigMessage[4]);
}
// Oddjob result
if (OddJob2OffTimer > 0)
OddJob2OffTimer = OddJob2OffTimer - (CTimer::GetTimeStep() * 0.02f * 1000.0f);
@ -1256,23 +1245,20 @@ void CHud::DrawAfterFade() {
CFont::SetRightJustifyWrap(-500);
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
if ((SCREENW - 20) <= BigMessageX[1]) {
BigMessageInUse[1] = BigMessageInUse[1] + CTimer::GetTimeStep();
if (BigMessageInUse[1] >= 120.0f) {
BigMessageInUse[1] = 120.0;
BigMessageAlpha[1] = BigMessageAlpha[1] - (CTimer::GetTimeStep() * 0.02f * 1000.0f) * 0.3f;
}
if (BigMessageAlpha[1] <= 0) {
m_BigMessage[1][0] = 0;
BigMessageAlpha[1] = 0.0;
if (BigMessageX[1] >= (SCREENW - 20)) {
BigMessageAlpha[1] += (CTimer::GetTimeStep() * 0.02f * -255.0f);
if (BigMessageAlpha[1] <= 0.0f) {
BigMessageAlpha[1] = 0.0f;
BigMessageInUse[1] = 1.0f;
}
}
else {
float fStep = (CTimer::GetTimeStep() * 0.02f * 1000.0f) * 0.3f;
BigMessageX[1] = BigMessageX[1] + fStep;
BigMessageAlpha[1] = BigMessageAlpha[1] + fStep;
if (BigMessageAlpha[1] > 255.0f)
BigMessageAlpha[1] = 255.0;
BigMessageX[1] += (CTimer::GetTimeStep() * 0.02f * 255.0f);
BigMessageAlpha[1] += (CTimer::GetTimeStep() * 0.02f * 255.0f);
if (BigMessageAlpha[1] >= 255.0f)
BigMessageAlpha[1] = 255.0f;
}
CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1]));
CFont::PrintString(HUD_FROM_RIGHT(20.0f - 2.0f), HUD_FROM_BOTTOM(120.0f), m_BigMessage[1]);
@ -1281,13 +1267,13 @@ void CHud::DrawAfterFade() {
CFont::PrintString(HUD_FROM_RIGHT(20.0f), HUD_FROM_BOTTOM(120.0f), m_BigMessage[1]);
}
else {
BigMessageAlpha[1] = 0.0;
BigMessageX[1] = -60.0;
BigMessageInUse[1] = 1.0;
BigMessageAlpha[1] = 0.0f;
BigMessageX[1] = -60.0f;
BigMessageInUse[1] = 1.0f;
}
}
else {
BigMessageInUse[1] = 0.0;
BigMessageInUse[1] = 0.0f;
}
}

View File

@ -1,7 +1,15 @@
#pragma once
#include "Sprite2d.h"
enum eSprites {
enum eItems
{
ITEM_ARMOUR = 3,
ITEM_HEALTH = 4,
ITEM_RADAR = 8
};
enum eSprites
{
HUD_FIST,
HUD_BAT,
HUD_PISTOL,
@ -21,7 +29,8 @@ enum eSprites {
HUD_SITEM16 = 21
};
class CHud {
class CHud
{
public:
static CSprite2d *Sprites;
@ -38,23 +47,23 @@ public:
static int32 m_ZoneState;
static int32 m_ZoneFadeTimer;
static int32 m_ZoneNameTimer;
static wchar* &m_pZoneName;
static wchar* m_pLastZoneName;
static wchar* m_ZoneToPrint;
static wchar* &m_pVehicleName;
static wchar* m_pLastVehicleName;
static wchar* m_pVehicleNameToPrint;
static wchar *&m_pZoneName;
static wchar *m_pLastZoneName;
static wchar *m_ZoneToPrint;
static wchar *&m_pVehicleName;
static wchar *m_pLastVehicleName;
static wchar *m_pVehicleNameToPrint;
static int32 m_VehicleState;
static int32 m_VehicleFadeTimer;
static int32 m_VehicleNameTimer;
static wchar* m_Message;
static wchar* m_PagerMessage;
static wchar *m_Message;
static wchar *m_PagerMessage;
static bool &m_Wants_To_Draw_Hud;
static bool &m_Wants_To_Draw_3dMarkers;
static wchar(*m_BigMessage)[128];
static float* BigMessageInUse;
static float* BigMessageAlpha;
static float* BigMessageX;
static float *BigMessageInUse;
static float *BigMessageAlpha;
static float *BigMessageX;
static float &OddJob2OffTimer;
static int8 &CounterOnLastFrame;
static float &OddJob2XOffset;
@ -75,12 +84,12 @@ public:
static void Shutdown();
static void ReInitialise();
static void GetRidOfAllHudMessages();
static void SetZoneName(wchar* name);
static void SetHelpMessage(wchar* message, bool quick);
static void SetVehicleName(wchar* name);
static void SetZoneName(wchar *name);
static void SetHelpMessage(wchar *message, bool quick);
static void SetVehicleName(wchar *name);
static void Draw();
static void DrawAfterFade();
static void SetMessage(wchar* message);
static void SetBigMessage(wchar* message, int16 style);
static void SetPagerMessage(wchar* message);
};
static void SetMessage(wchar *message);
static void SetBigMessage(wchar *message, int16 style);
static void SetPagerMessage(wchar *message);
};