From 095b8b1e74e7d2454bfb92e22811e06702e3ae46 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 13:16:28 +0300 Subject: CMoneyMessages --- src/render/MoneyMessages.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++ src/render/MoneyMessages.h | 24 +++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/render/MoneyMessages.cpp create mode 100644 src/render/MoneyMessages.h (limited to 'src/render') diff --git a/src/render/MoneyMessages.cpp b/src/render/MoneyMessages.cpp new file mode 100644 index 00000000..c18c7a8a --- /dev/null +++ b/src/render/MoneyMessages.cpp @@ -0,0 +1,86 @@ +#include "common.h" +#include "patcher.h" +#include "MoneyMessages.h" +#include "Timer.h" +#include "Sprite.h" +#include "Font.h" +#include "Text.h" + +#define MONEY_MESSAGE_LIFETIME_MS 2000 + +CMoneyMessage CMoneyMessages::aMoneyMessages[NUMMONEYMESSAGES]; + +void +CMoneyMessage::Render() +{ + const float MAX_SCALE = 4.0f; + uint32 dwLifeTime = CTimer::GetTimeInMilliseconds() - m_nTimeRegistered; + if (dwLifeTime >= MONEY_MESSAGE_LIFETIME_MS) m_nTimeRegistered = 0; + else { + float fLifeTime = (float)dwLifeTime / MONEY_MESSAGE_LIFETIME_MS; + RwV3d vecOut; + float fDistX, fDistY; + if (CSprite::CalcScreenCoors(m_vecPosition + CVector(0.0f, 0.0f, fLifeTime), &vecOut, &fDistX, &fDistY, true)) { + fDistX *= (0.7 * fLifeTime + 2.0) * m_fSize; + fDistY *= (0.7 * fLifeTime + 2.0) * m_fSize; + CFont::SetPropOn(); + CFont::SetBackgroundOff(); + + float fScaleY = fDistY / 100.0f; + if (fScaleY > MAX_SCALE) fScaleY = MAX_SCALE; + + float fScaleX = fDistX / 100.0f; + if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE; + + CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here? + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity)); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetFontStyle(FONT_BANK); + CFont::PrintString(vecOut.x, vecOut.y, m_aText); + } + } +} + +void +CMoneyMessages::Init() +{ + for (int32 i = 0; i < NUMMONEYMESSAGES; i++) + aMoneyMessages[i].m_nTimeRegistered = 0; +} + +void +CMoneyMessages::Render() +{ + for (int32 i = 0; i < NUMMONEYMESSAGES; i++) { + if (aMoneyMessages[i].m_nTimeRegistered) + aMoneyMessages[i].Render(); + } +} + +void +CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity) +{ + uint32 nIndex = 0; + while (aMoneyMessages[nIndex].m_nTimeRegistered != 0) { + if (++nIndex >= NUMMONEYMESSAGES) return; + } + + // Add data of this money message to the array + AsciiToUnicode(pText, aMoneyMessages[nIndex].m_aText); + + aMoneyMessages[nIndex].m_nTimeRegistered = CTimer::GetTimeInMilliseconds(); + aMoneyMessages[nIndex].m_vecPosition = vecPos; + aMoneyMessages[nIndex].m_Colour.red = bRed; + aMoneyMessages[nIndex].m_Colour.green = bGreen; + aMoneyMessages[nIndex].m_Colour.blue = bBlue; + aMoneyMessages[nIndex].m_fSize = fSize; + aMoneyMessages[nIndex].m_fOpacity = fOpacity; +} + +STARTPATCHES + InjectHook(0x51AF70, CMoneyMessages::Init, PATCH_JUMP); + InjectHook(0x51B030, CMoneyMessages::Render, PATCH_JUMP); +ENDPATCHES diff --git a/src/render/MoneyMessages.h b/src/render/MoneyMessages.h new file mode 100644 index 00000000..f0a48a84 --- /dev/null +++ b/src/render/MoneyMessages.h @@ -0,0 +1,24 @@ +#pragma once + +class CMoneyMessage +{ + friend class CMoneyMessages; + + uint32 m_nTimeRegistered; + CVector m_vecPosition; + wchar m_aText[16]; + CRGBA m_Colour; + float m_fSize; + float m_fOpacity; +public: + void Render(); +}; + +class CMoneyMessages +{ + static CMoneyMessage aMoneyMessages[NUMMONEYMESSAGES]; +public: + static void Init(); + static void Render(); + static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); +}; \ No newline at end of file -- cgit v1.2.3 From 6bed421ce86a83709fde4e90f6101ad2b3314053 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 13:31:31 +0300 Subject: No dw --- src/render/MoneyMessages.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/render') diff --git a/src/render/MoneyMessages.cpp b/src/render/MoneyMessages.cpp index c18c7a8a..d80be276 100644 --- a/src/render/MoneyMessages.cpp +++ b/src/render/MoneyMessages.cpp @@ -14,10 +14,10 @@ void CMoneyMessage::Render() { const float MAX_SCALE = 4.0f; - uint32 dwLifeTime = CTimer::GetTimeInMilliseconds() - m_nTimeRegistered; - if (dwLifeTime >= MONEY_MESSAGE_LIFETIME_MS) m_nTimeRegistered = 0; + uint32 nLifeTime = CTimer::GetTimeInMilliseconds() - m_nTimeRegistered; + if (nLifeTime >= MONEY_MESSAGE_LIFETIME_MS) m_nTimeRegistered = 0; else { - float fLifeTime = (float)dwLifeTime / MONEY_MESSAGE_LIFETIME_MS; + float fLifeTime = (float)nLifeTime / MONEY_MESSAGE_LIFETIME_MS; RwV3d vecOut; float fDistX, fDistY; if (CSprite::CalcScreenCoors(m_vecPosition + CVector(0.0f, 0.0f, fLifeTime), &vecOut, &fDistX, &fDistY, true)) { -- cgit v1.2.3 From 47e6cbe65e1715d11d81cbe3dc85b01f894e70c1 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 23:35:09 +0300 Subject: Fix formatting mistakes --- src/render/MoneyMessages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/MoneyMessages.cpp b/src/render/MoneyMessages.cpp index d80be276..53d6db58 100644 --- a/src/render/MoneyMessages.cpp +++ b/src/render/MoneyMessages.cpp @@ -55,7 +55,7 @@ void CMoneyMessages::Render() { for (int32 i = 0; i < NUMMONEYMESSAGES; i++) { - if (aMoneyMessages[i].m_nTimeRegistered) + if (aMoneyMessages[i].m_nTimeRegistered != 0) aMoneyMessages[i].Render(); } } -- cgit v1.2.3 From 5e1538a2757dc495d0c15f72a71583b4b8f2610d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 4 Oct 2019 00:49:11 +0300 Subject: Fixed disappearing ammo count --- src/render/Hud.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 2dae7551..ae0d4eb3 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -336,23 +336,6 @@ void CHud::Draw() AsciiToUnicode(sTemp, sPrint); - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); - CFont::SetJustifyOff(); - CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); - CFont::SetPropOn(); - CFont::SetFontStyle(FONT_BANK); - - if (!CDarkel::FrenzyOnGoing()) { - if (WeaponType) { - if (WeaponType != WEAPONTYPE_BASEBALLBAT) { - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(73.0f), sPrint); - } - } - } - /* DrawWeaponIcon */ @@ -368,6 +351,19 @@ void CHud::Draw() 1.0f, 1.0f); + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); + CFont::SetJustifyOff(); + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); + CFont::SetPropOn(); + CFont::SetFontStyle(FONT_BANK); + + if (!CDarkel::FrenzyOnGoing() && WeaponType != WEAPONTYPE_UNARMED && WeaponType != WEAPONTYPE_BASEBALLBAT) { + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(73.0f), sPrint); + } + /* DrawHealth */ -- cgit v1.2.3 From cc621ba0995f659c32dee4b7d7870902ef50c9eb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Oct 2019 16:04:27 +0300 Subject: Corona widescreen fix --- src/render/Coronas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 1a6cfea3..89a85e92 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -324,7 +324,7 @@ CCoronas::Render(void) CSprite::RenderOneXLUSprite(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * aCoronas[i].size * wscale, - spriteh * aCoronas[i].size * fogscale * hscale, + spriteh * SCREEN_SCALE_AR2(aCoronas[i].size * fogscale * hscale), CCoronas::aCoronas[i].red / fogscale, CCoronas::aCoronas[i].green / fogscale, CCoronas::aCoronas[i].blue / fogscale, @@ -335,7 +335,7 @@ CCoronas::Render(void) CSprite::RenderOneXLUSprite_Rotate_Aspect( spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * aCoronas[i].size * fogscale, - spriteh * aCoronas[i].size * fogscale, + spriteh * SCREEN_SCALE_AR2(aCoronas[i].size * fogscale), CCoronas::aCoronas[i].red / fogscale, CCoronas::aCoronas[i].green / fogscale, CCoronas::aCoronas[i].blue / fogscale, -- cgit v1.2.3 From 365f9e9caff6f61ef08ca67526fd85f9a010d965 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Oct 2019 17:32:01 +0300 Subject: Triangular radar blips --- src/render/Sprite2d.cpp | 14 ++++++++++++++ src/render/Sprite2d.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'src/render') diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 4ed27fa1..c4dbcdaa 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -457,6 +457,20 @@ CSprite2d::DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); } +void CSprite2d::Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color) +{ + SetVertices(x1, y1, x2, y2, x3, y3, x4, y4, color, color, color, color); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, 0); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(color.a != 255)); + RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD); +} + STARTPATCHES #define C4 const CRGBA&, const CRGBA&, const CRGBA&, const CRGBA& #define F8 float, float, float, float, float, float, float, float diff --git a/src/render/Sprite2d.h b/src/render/Sprite2d.h index e0f19ef1..268c7d2b 100644 --- a/src/render/Sprite2d.h +++ b/src/render/Sprite2d.h @@ -47,5 +47,7 @@ public: static void DrawRect(const CRect &r, const CRGBA &col); static void DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); + static void Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color); + static RwIm2DVertex* GetVertices() { return maVertices; }; }; -- cgit v1.2.3 From dd99edd339a22f0309ae0917ee77c6df31c2525b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Oct 2019 22:26:29 +0300 Subject: Fixed a bunch of calculation mistakes in CHud --- src/render/Font.cpp | 8 +- src/render/Hud.cpp | 280 ++++++++++++++++++++++++++++------------------------ src/render/Hud.h | 2 +- 3 files changed, 158 insertions(+), 132 deletions(-) (limited to 'src/render') diff --git a/src/render/Font.cpp b/src/render/Font.cpp index 59023960..54243069 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -134,10 +134,10 @@ CFont::PrintChar(float x, float y, uint16 c) if(Details.style == 0 || Details.style == 2){ if(Details.dropShadowPosition != 0){ CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank - CRect(x + Details.dropShadowPosition, - y + Details.dropShadowPosition, - x + Details.dropShadowPosition + 32.0f * Details.scaleX * 1.0f, - y + Details.dropShadowPosition + 40.0f * Details.scaleY * 0.5f), + CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition), + y + SCREEN_SCALE_Y(Details.dropShadowPosition), + x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f, + y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY * 0.5f), Details.dropColor, xoff/16.0f, yoff/12.8f, (xoff+1.0f)/16.0f - 0.001f, yoff/12.8f, diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index ae0d4eb3..d98ec1ea 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -46,7 +46,7 @@ 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; +wchar(&CHud::m_BigMessage)[6][128] = *(wchar(*)[6][128])*(uintptr*)0x664CE0; int16 &CHud::m_ItemToFlash = *(int16*)0x95CC82; // These aren't really in CHud @@ -68,53 +68,35 @@ int16 &CHud::PagerTimer = *(int16*)0x95CC3A; int16 &CHud::PagerOn = *(int16*)0x95CCA0; CSprite2d *CHud::Sprites = (CSprite2d*)0x95CB9C; -char *WeaponFilenames[] = { - "fist", - "fistm", - "bat", - "batm", - "pistol", - "pistolm", - "uzi", - "uzim", - "shotgun", - "shotgunm", - "ak47", - "ak47m", - "m16", - "m16m", - "sniper", - "sniperm", - "rocket", - "rocketm", - "flame", - "flamem", - "molotov", - "molotovm", - "grenade", - "grenadem", - "detonator", - "detonator_mask", - "", - "", - "", - "", - "radardisc", - "radardiscm", - "pager", - "pagerm", - "", - "", - "", - "", - "bleeder", - "", - "sitesniper", - "sitesniperm", - "siteM16", - "siteM16m", - "siterocket", - "siterocketm" + +struct +{ + const char *name; + const char *mask; +} WeaponFilenames[] = { + {"fist", "fistm"}, + {"bat", "batm"}, + {"pistol", "pistolm" }, + {"uzi", "uzim"}, + {"shotgun", "shotgunm"}, + {"ak47", "ak47m"}, + {"m16", "m16m"}, + {"sniper", "sniperm"}, + {"rocket", "rocketm"}, + {"flame", "flamem"}, + {"molotov", "molotovm"}, + {"grenade", "grenadem"}, + {"detonator", "detonator_mask"}, + {"", ""}, + {"", ""}, + {"radardisc", "radardiscm"}, + {"pager", "pagerm"}, + {"", ""}, + {"", ""}, + {"bleeder", ""}, + {"sitesniper", "sitesniperm"}, + {"siteM16", "siteM16m"}, + {"siterocket", "siterocketm"} }; RwTexture *&gpSniperSightTex = *(RwTexture**)0x8F5834; @@ -892,15 +874,17 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetFontStyle(FONT_BANK); - if (TheCamera.m_WideScreenOn) - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(120.0f)); - else - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(280.0f)); + float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f); + float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX; + CFont::SetCentreSize(center); - CFont::SetDropShadowPosition(1); + const int16 shadow = 1; + CFont::SetDropShadowPosition(shadow); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(235, 235, 235, 255)); - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(64.0f), m_Message); + + // I'm not sure shadow substaction was intentional here, might be a leftover if CFont::PrintString was used for a shadow draw call + CFont::PrintString(center / 2.0f + offsetX - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(68.0f) - SCREEN_SCALE_Y(shadow), m_Message); CFont::SetDropShadowPosition(0); } @@ -920,11 +904,11 @@ void CHud::Draw() CFont::SetFontStyle(FONT_HEADING); if (BigMessageX[0] >= (SCREEN_WIDTH - 20)) { - BigMessageInUse[0] += (CTimer::GetTimeStepInSeconds() * 120.0f); + BigMessageInUse[0] += CTimer::GetTimeStep(); if (BigMessageInUse[0] >= 120.0f) { BigMessageInUse[0] = 120.0; - BigMessageAlpha[0] += (CTimer::GetTimeStepInSeconds() * -255.0f); + BigMessageAlpha[0] -= (CTimer::GetTimeStepInMilliseconds() * 0.3f); } if (BigMessageAlpha[0] <= 0.0f) { @@ -933,18 +917,22 @@ void CHud::Draw() } } else { - BigMessageX[0] += (CTimer::GetTimeStepInSeconds() * 255.0f); - BigMessageAlpha[0] += (CTimer::GetTimeStepInSeconds() * 255.0f); + BigMessageX[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); + BigMessageAlpha[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); 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) - SCREEN_SCALE_Y(20.0f - 2.0f), m_BigMessage[0]); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); +#else + CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); +#endif CFont::SetColor(CRGBA(85, 119, 133, BigMessageAlpha[0])); - CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f), m_BigMessage[0]); + CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]); } else { BigMessageAlpha[0] = 0.0f; @@ -1099,7 +1087,7 @@ void CHud::DrawAfterFade() DrawBigMessage2 */ // Oddjob - if (m_BigMessage[4][0]) { + if (m_BigMessage[3][0]) { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); @@ -1109,70 +1097,90 @@ void CHud::DrawAfterFade() CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_X(2.0f) + (SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[4]); + CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); + + CFont::SetColor(CRGBA(89, 115, 150, 255)); + CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[3]); + } + + if (!m_BigMessage[1][0] && m_BigMessage[4][0]) { + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); + CFont::SetCentreOn(); + CFont::SetPropOn(); + CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::SetFontStyle(FONT_BANK); + + CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); CFont::SetColor(CRGBA(89, 115, 150, 255)); - CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[4]); + CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[3]); } // Oddjob result if (OddJob2OffTimer > 0) - OddJob2OffTimer = OddJob2OffTimer - CTimer::GetTimeStepInMilliseconds(); + OddJob2OffTimer -= CTimer::GetTimeStepInMilliseconds(); static float fStep; - if (!m_BigMessage[1][0] && m_BigMessage[4][0] && m_BigMessage[5][0] && OddJob2OffTimer <= 0.0f) { - switch (OddJob2On) { - case 0: - OddJob2On = 1; - OddJob2XOffset = 380.0f; - break; - case 1: - if (OddJob2XOffset <= 2.0f) { - OddJob2Timer = 0; - OddJob2On = 2; - } - else { - fStep = 40.0f; - if ((OddJob2XOffset * 0.16667f) <= 40.0f) - fStep = OddJob2XOffset * 0.16667f; - OddJob2XOffset = OddJob2XOffset - fStep; - } - break; - case 2: - OddJob2Timer += (20.0f * CTimer::GetTimeStep()); - if (OddJob2Timer > 1500) { - OddJob2On = 3; - } - break; - case 3: - fStep = 30.0f; - if ((OddJob2XOffset * 0.2f) >= 30.0f) - fStep = OddJob2XOffset * 0.2f; + if (m_BigMessage[5][0] && OddJob2OffTimer <= 0.0f) { + if (OddJob2On <= 3) { + switch (OddJob2On) { + case 0: + OddJob2On = 1; + OddJob2XOffset = 380.0f; + break; + case 1: + if (OddJob2XOffset <= 2.0f) { + OddJob2Timer = 0; + OddJob2On = 2; + } + else { + fStep = 40.0f; + if ((OddJob2XOffset / 6.0f) <= 40.0f) + fStep = OddJob2XOffset / 6.0f; + OddJob2XOffset = OddJob2XOffset - fStep; + } + break; + case 2: + OddJob2Timer += (20.0f * CTimer::GetTimeStep()); + if (OddJob2Timer > 1500) { + OddJob2On = 3; + } + break; + case 3: + fStep = 30.0f; + if ((OddJob2XOffset / 5.0f) >= 30.0f) + fStep = OddJob2XOffset / 5.0f; - OddJob2XOffset = OddJob2XOffset - fStep; + OddJob2XOffset = OddJob2XOffset - fStep; - if (OddJob2XOffset < -380.0f) { - OddJob2OffTimer = 5000.0f; - OddJob2On = 0; + if (OddJob2XOffset < -380.0f) { + OddJob2OffTimer = 5000.0f; + OddJob2On = 0; + } + break; + default: + break; } - break; - default: - break; } - CFont::SetJustifyOff(); - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.2f)); - CFont::SetCentreOn(); - CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); - CFont::SetFontStyle(FONT_BANK); + if (!m_BigMessage[1][0]) { + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.2f)); + CFont::SetCentreOn(); + CFont::SetPropOn(); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::SetFontStyle(FONT_BANK); - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_X(2.0f) + (SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f + 2.0f), m_BigMessage[5]); + CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - CFont::SetColor(CRGBA(156, 91, 40, 255)); - CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f + 2.0f), m_BigMessage[5]); + CFont::SetColor(CRGBA(156, 91, 40, 255)); + CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); + } } /* @@ -1189,15 +1197,15 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f)); CFont::SetPropOn(); - CFont::SetRightJustifyWrap(-500); + CFont::SetRightJustifyWrap(-500.0f); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); if (BigMessageX[1] >= (SCREEN_WIDTH - 20)) { - BigMessageInUse[1] += (CTimer::GetTimeStepInSeconds() * 120.0f); + BigMessageInUse[1] += CTimer::GetTimeStep(); if (BigMessageInUse[1] >= 120.0f) { BigMessageInUse[1] = 120.0; - BigMessageAlpha[1] += (CTimer::GetTimeStepInSeconds() * -255.0f); + BigMessageAlpha[1] -= (CTimer::GetTimeStepInMilliseconds() * 0.3f); } if (BigMessageAlpha[1] <= 0) { m_BigMessage[1][0] = 0; @@ -1205,15 +1213,15 @@ void CHud::DrawAfterFade() } } else { - BigMessageX[1] += (CTimer::GetTimeStepInSeconds() * 255.0f); - BigMessageAlpha[1] += (CTimer::GetTimeStepInSeconds() * 255.0f); + BigMessageX[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); + BigMessageAlpha[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); if (BigMessageAlpha[1] >= 255.0f) BigMessageAlpha[1] = 255.0f; } CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1])); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); CFont::SetColor(CRGBA(220, 172, 2, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); @@ -1272,9 +1280,8 @@ void CHud::GetRidOfAllHudMessages() void CHud::Initialise() { - debug("Init CHud"); - - ReInitialise(); + m_Wants_To_Draw_Hud = true; + m_Wants_To_Draw_3dMarkers = true; int HudTXD = CTxdStore::AddTxdSlot("hud"); CTxdStore::LoadTxd(HudTXD, "MODELS/HUD.TXD"); @@ -1282,12 +1289,31 @@ void CHud::Initialise() CTxdStore::PopCurrentTxd(); CTxdStore::SetCurrentTxd(HudTXD); - for (int i = 0; i < ARRAY_SIZE(WeaponFilenames) / 2; i++) { - Sprites[i].SetTexture(WeaponFilenames[i * 2]); + for (int i = 0; i < ARRAY_SIZE(WeaponFilenames); i++) { + Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); } - gpSniperSightTex = RwTextureRead("sitesniper", nil); - gpRocketSightTex = RwTextureRead("siterocket", nil); + GetRidOfAllHudMessages(); + + if (gpSniperSightTex == nil) + gpSniperSightTex = RwTextureRead("sitesniper", nil); + if (gpRocketSightTex == nil) + gpRocketSightTex = RwTextureRead("siterocket", nil); + + CounterOnLastFrame = 0; + m_ItemToFlash = ITEM_NONE; + OddJob2Timer = 0; + OddJob2OffTimer = 0.0f; + OddJob2On = 0; + OddJob2XOffset = 0.0f; + CounterFlashTimer = 0; + TimerOnLastFrame = 0; + TimerFlashTimer = 0; + SpriteBrightness = 0; + PagerOn = 0; + PagerTimer = 0; + PagerSoundPlayed = 0; + PagerXOffset = 150.0f; CTxdStore::PopCurrentTxd(); } @@ -1324,7 +1350,7 @@ WRAPPER void CHud::SetBigMessage(wchar *message, int16 style) { EAXJMP(0x50A250) #else void CHud::SetBigMessage(wchar *message, int16 style) { - int i; + int i = 0; if (style == 5) { for (i = 0; i < 128; i++) { @@ -1375,7 +1401,7 @@ WRAPPER void CHud::SetMessage(wchar *message) { EAXJMP(0x50A210); } #else void CHud::SetMessage(wchar *message) { - int i; + int i = 0; for (i = 0; i < 256; i++) { if (message[i] == 0) break; @@ -1391,7 +1417,7 @@ WRAPPER void CHud::SetPagerMessage(wchar *message) { EAXJMP(0x50A320); } #else void CHud::SetPagerMessage(wchar *message) { - int i; + int i = 0; for (i = 0; i < 256; i++) { if (message[i] == 0) break; @@ -1424,7 +1450,7 @@ void CHud::Shutdown() { debug("Shutdown CHud"); - for (int i = 0; i < ARRAY_SIZE(WeaponFilenames) / 2; ++i) { + for (int i = 0; i < ARRAY_SIZE(WeaponFilenames); ++i) { Sprites[i].Delete(); } diff --git a/src/render/Hud.h b/src/render/Hud.h index 1567abdc..d3482ae6 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -61,7 +61,7 @@ public: static wchar *m_PagerMessage; static bool &m_Wants_To_Draw_Hud; static bool &m_Wants_To_Draw_3dMarkers; - static wchar(*m_BigMessage)[128]; + static wchar(&m_BigMessage)[6][128]; static int16 &m_ItemToFlash; // These aren't really in CHud -- cgit v1.2.3