From 81ea6f0258895e9087e0cb89cbd8bd30346974e2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Wed, 13 May 2020 11:38:05 +0300 Subject: ped attractor: start --- src/render/2dEffect.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h index 2a71a8d5..33b553bd 100644 --- a/src/render/2dEffect.h +++ b/src/render/2dEffect.h @@ -3,7 +3,8 @@ enum { EFFECT_LIGHT, EFFECT_PARTICLE, - EFFECT_ATTRACTOR + EFFECT_ATTRACTOR, + EFFECT_PED_ATTRACTOR }; enum { @@ -63,6 +64,11 @@ public: uint8 flags; uint8 probability; }; + struct PedAttractor { + CVector useDir; + CVector queueDir; + int8 type; + }; CVector pos; CRGBA col; @@ -71,6 +77,7 @@ public: Light light; Particle particle; Attractor attractor; + PedAttractor pedattr; }; C2dEffect(void) {} -- cgit v1.2.3 From 08b2138c7e59ce3350d333832ceca5c24799a34c Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 16 May 2020 01:49:30 +0300 Subject: ped attractors done --- src/render/2dEffect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h index 33b553bd..ed5ce5ba 100644 --- a/src/render/2dEffect.h +++ b/src/render/2dEffect.h @@ -65,8 +65,8 @@ public: uint8 probability; }; struct PedAttractor { - CVector useDir; CVector queueDir; + CVector useDir; int8 type; }; -- cgit v1.2.3 From ec1b91e5270b1c91885a5e8000a5ff8286aee140 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 16 May 2020 05:06:51 +0300 Subject: Remove unused audio enum --- src/render/Glass.cpp | 11 ++++++----- src/render/Particle.cpp | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/render') diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index 6f17013c..ac892ddb 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -13,6 +13,7 @@ #include "Shadows.h" #include "ModelIndices.h" #include "main.h" +#include "soundlist.h" uint32 CGlass::NumGlassEntities; @@ -101,7 +102,7 @@ CFallingGlassPane::Update(void) pos = CVector(GetPosition().x, GetPosition().y, m_fGroundZ); - PlayOneShotScriptObject(_SCRSOUND_GLASS_SHARD, pos); + PlayOneShotScriptObject(SCRIPT_SOUND_GLASS_LIGHT_BREAK, pos); RwRGBA color = { 255, 255, 255, 255 }; @@ -627,7 +628,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, if ( amount > 300.0f ) { - PlayOneShotScriptObject(_SCRSOUND_GLASS_SMASH_1, object->GetPosition()); + PlayOneShotScriptObject(SCRIPT_SOUND_GLASS_BREAK_L, object->GetPosition()); GeneratePanesForWindow(0, CVector(minx, miny, minz), @@ -637,7 +638,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, } else { - PlayOneShotScriptObject(_SCRSOUND_GLASS_SMASH_2, object->GetPosition()); + PlayOneShotScriptObject(SCRIPT_SOUND_GLASS_BREAK_S, object->GetPosition()); GeneratePanesForWindow(1, CVector(minx, miny, minz), @@ -659,7 +660,7 @@ CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount) if ( amount > 50.0f && !object->bGlassCracked ) { - PlayOneShotScriptObject(_SCRSOUND_GLASS_CRACK, object->GetPosition()); + PlayOneShotScriptObject(SCRIPT_SOUND_GLASS_CRACK, object->GetPosition()); object->bGlassCracked = true; } } @@ -675,7 +676,7 @@ CGlass::WasGlassHitByBullet(CEntity *entity, CVector point) { if ( !object->bGlassCracked ) { - PlayOneShotScriptObject(_SCRSOUND_GLASS_CRACK, object->GetPosition()); + PlayOneShotScriptObject(SCRIPT_SOUND_GLASS_CRACK, object->GetPosition()); object->bGlassCracked = true; } else diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index 4223ac10..a867ae13 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -11,6 +11,7 @@ #include "AudioScriptObject.h" #include "ParticleObject.h" #include "Particle.h" +#include "soundlist.h" #define MAX_PARTICLES_ON_SCREEN (1000) @@ -1268,7 +1269,7 @@ void CParticle::Update() nil, particle->m_fSize, color, particle->m_nRotationStep, 0, 0, 0); - PlayOneShotScriptObject(_SCRSOUND_BULLET_SHELL_HIT_GROUND_1, particle->m_vecPosition); + PlayOneShotScriptObject(SCRIPT_SOUND_GUNSHELL_DROP, particle->m_vecPosition); } break; @@ -1287,7 +1288,7 @@ void CParticle::Update() nil, particle->m_fSize, color, 0, 0, 0, 0); - PlayOneShotScriptObject(_SCRSOUND_BULLET_SHELL_HIT_GROUND_2, particle->m_vecPosition); + PlayOneShotScriptObject(SCRIPT_SOUND_GUNSHELL_DROP_SOFT, particle->m_vecPosition); } break; -- cgit v1.2.3 From 4defd8b75c80341ecccbfe2a0d3a6baf34c4f02e Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 16 May 2020 13:31:23 +0300 Subject: minimal weather stuff + multiple bugfixes --- src/render/Renderer.cpp | 3 +- src/render/Weather.cpp | 182 ++++++++++++++++++++++++++++++------------------ src/render/Weather.h | 28 +++----- 3 files changed, 129 insertions(+), 84 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 406edc9f..803f4cc1 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -143,7 +143,8 @@ CRenderer::RenderOneNonRoad(CEntity *e) resetLights = e->SetupLighting(); if(e->IsVehicle()){ - CVisibilityPlugins::SetupVehicleVariables(e->GetClump()); + // unfortunately can't use GetClump here + CVisibilityPlugins::SetupVehicleVariables((RpClump*)e->m_rwObject); CVisibilityPlugins::InitAlphaAtomicList(); } diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index 25e67281..fc3e0d61 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -8,6 +8,7 @@ #include "DMAudio.h" #include "General.h" #include "Pad.h" +#include "PlayerPed.h" #include "Particle.h" #include "RenderBuffer.h" #include "Stats.h" @@ -40,41 +41,60 @@ float CWeather::Rain; float CWeather::InterpolationValue; float CWeather::WetRoads; float CWeather::Rainbow; +float CWeather::SunGlare; +float CWeather::WindClipped; +float CWeather::TrafficLightBrightness; bool CWeather::bScriptsForceRain; -bool CWeather::Stored_StateStored; - -float CWeather::Stored_InterpolationValue; -int16 CWeather::Stored_OldWeatherType; -int16 CWeather::Stored_NewWeatherType; -float CWeather::Stored_Rain; tRainStreak Streaks[NUM_RAIN_STREAKS]; const int16 WeatherTypesList[] = { + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, + WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_CLOUDY, WEATHER_CLOUDY, WEATHER_RAINY, WEATHER_RAINY, + WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_CLOUDY, + WEATHER_RAINY, WEATHER_RAINY, WEATHER_RAINY, WEATHER_RAINY, WEATHER_CLOUDY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_CLOUDY, WEATHER_FOGGY, WEATHER_FOGGY, WEATHER_CLOUDY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_CLOUDY, WEATHER_CLOUDY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_CLOUDY, WEATHER_CLOUDY, WEATHER_RAINY, WEATHER_RAINY, - WEATHER_CLOUDY, WEATHER_RAINY, WEATHER_CLOUDY, WEATHER_SUNNY, + WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY +}; + +const int16 WeatherTypesList_WithHurricanes[] = { + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, + WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_CLOUDY, + WEATHER_HURRICANE, WEATHER_HURRICANE, WEATHER_CLOUDY, WEATHER_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_FOGGY, WEATHER_FOGGY, WEATHER_SUNNY, - WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_RAINY, WEATHER_CLOUDY, + WEATHER_CLOUDY, WEATHER_HURRICANE, WEATHER_HURRICANE, WEATHER_HURRICANE, + WEATHER_CLOUDY, WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_SUNNY, + WEATHER_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, + WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY }; const float Windiness[] = { - 0.0f, // WEATHER_SUNNY + 0.25f,// WEATHER_SUNNY 0.7f, // WEATHER_CLOUDY 1.0f, // WEATHER_RAINY - 0.5f // WEATHER_FOGGY + 0.0f, // WEATHER_FOGGY + 0.0f, // WEATHER_EXTRA_SUNNY + 2.0f, // WEATHER_HURRICANE + 0.0f }; #define MIN_TIME_BETWEEN_LIGHTNING_FLASH_CHANGES (50) @@ -105,10 +125,9 @@ const float Windiness[] = { void CWeather::Init(void) { - NewWeatherType = WEATHER_SUNNY; + NewWeatherType = WEATHER_EXTRA_SUNNY; bScriptsForceRain = false; - OldWeatherType = WEATHER_CLOUDY; - Stored_StateStored = false; + OldWeatherType = WEATHER_EXTRA_SUNNY; InterpolationValue = 0.0f; WhenToPlayLightningSound = 0; WeatherTypeInList = 0; @@ -128,16 +147,8 @@ void CWeather::Update(void) NewWeatherType = ForcedWeatherType; else { WeatherTypeInList = (WeatherTypeInList + 1) % ARRAY_SIZE(WeatherTypesList); - NewWeatherType = WeatherTypesList[WeatherTypeInList]; -#ifdef FIX_BUGS - } - if (NewWeatherType == WEATHER_RAINY) - CStats::mmRain += CGeneral::GetRandomNumber() & 7; -#else - if (NewWeatherType == WEATHER_RAINY) - CStats::mmRain += CGeneral::GetRandomNumber() & 7; + NewWeatherType = CStats::NoMoreHurricanes ? WeatherTypesList[WeatherTypeInList] : WeatherTypesList_WithHurricanes[WeatherTypeInList]; } -#endif } InterpolationValue = fNewInterpolation; if (CPad::GetPad(1)->GetRightShockJustDown()) { @@ -189,14 +200,14 @@ void CWeather::Update(void) } // Wet roads - if (OldWeatherType == WEATHER_RAINY) { - if (NewWeatherType == WEATHER_RAINY) + if (OldWeatherType == WEATHER_RAINY || OldWeatherType == WEATHER_HURRICANE) { + if (NewWeatherType == WEATHER_RAINY || NewWeatherType == WEATHER_HURRICANE) WetRoads = 1.0f; else WetRoads = 1.0f - InterpolationValue; } else { - if (NewWeatherType == WEATHER_RAINY) + if (NewWeatherType == WEATHER_RAINY || NewWeatherType == WEATHER_HURRICANE) WetRoads = InterpolationValue; else WetRoads = 0.0f; @@ -204,10 +215,10 @@ void CWeather::Update(void) // Rain float fNewRain; - if (NewWeatherType == WEATHER_RAINY) { + if (NewWeatherType == WEATHER_RAINY || NewWeatherType == WEATHER_HURRICANE) { // if raining for >1 hour, values: 0, 0.33, 0.66, 0.99, switching every ~16.5s fNewRain = ((uint16)CTimer::GetTimeInMilliseconds() >> 14) * 0.33f; - if (OldWeatherType != WEATHER_RAINY) { + if (OldWeatherType != WEATHER_RAINY && OldWeatherType != WEATHER_HURRICANE) { if (InterpolationValue < 0.4f) // if rain has just started (<24 minutes), always 0.5 fNewRain = 0.5f; @@ -218,19 +229,14 @@ void CWeather::Update(void) } else fNewRain = 0.0f; - if (Rain != fNewRain) { // ok to use comparasion - if (Rain < fNewRain) - Rain = Min(fNewRain, Rain + RAIN_CHANGE_SPEED * CTimer::GetTimeStep()); - else - Rain = Max(fNewRain, Rain - RAIN_CHANGE_SPEED * CTimer::GetTimeStep()); - } + Rain = fNewRain; // Clouds - if (OldWeatherType != WEATHER_SUNNY) + if (OldWeatherType != WEATHER_SUNNY && OldWeatherType != WEATHER_EXTRA_SUNNY) CloudCoverage = 1.0f - InterpolationValue; else CloudCoverage = 0.0f; - if (NewWeatherType != WEATHER_SUNNY) + if (NewWeatherType != WEATHER_SUNNY && OldWeatherType != WEATHER_EXTRA_SUNNY) CloudCoverage += InterpolationValue; // Fog @@ -240,12 +246,76 @@ void CWeather::Update(void) Foggyness = 0.0f; if (NewWeatherType == WEATHER_FOGGY) Foggyness += InterpolationValue; - if (OldWeatherType == WEATHER_RAINY && NewWeatherType == WEATHER_SUNNY && InterpolationValue < 0.5f && CClock::GetHours() > 6 && CClock::GetHours() < 21) + + // Extra Sunnyness + if (OldWeatherType == WEATHER_EXTRA_SUNNY) + ExtraSunnyness = 1.0f - InterpolationValue; + else + ExtraSunnyness = 0.0f; + if (NewWeatherType == WEATHER_EXTRA_SUNNY) + ExtraSunnyness += InterpolationValue; + + // Rainbow + if (OldWeatherType == WEATHER_RAINY && (NewWeatherType == WEATHER_SUNNY || NewWeatherType == WEATHER_EXTRA_SUNNY) && + InterpolationValue < 0.5f && CClock::GetHours() > 6 && CClock::GetHours() < 21) Rainbow = 1.0f - 4.0f * Abs(InterpolationValue - 0.25f) / 4.0f; else Rainbow = 0.0f; + + // Sun Glare + if (OldWeatherType == WEATHER_EXTRA_SUNNY) + SunGlare = 1.0f - InterpolationValue; + else + SunGlare = 0.0f; + if (NewWeatherType == WEATHER_EXTRA_SUNNY) + SunGlare += InterpolationValue; + + if (SunGlare > 0.0f) { + SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunPosition().z); + SunGlare = clamp(SunGlare, 0.0f, 1.0f); + // TODO(MIAMI): if (CSpecialFX::bSnapShotActive)... + } + Wind = InterpolationValue * Windiness[NewWeatherType] + (1.0f - InterpolationValue) * Windiness[OldWeatherType]; + WindClipped = Max(1.0f, Wind); + + if (CClock::GetHours() == 20) + TrafficLightBrightness = CClock::GetMinutes() / 60.0f; + else if (CClock::GetHours() > 6 && CClock::GetHours() < 20) + TrafficLightBrightness = 0.0f; + else if (CClock::GetHours() == 6) + TrafficLightBrightness = 1.0f - CClock::GetMinutes() / 60.0f; + else + TrafficLightBrightness = 1.0f; + TrafficLightBrightness = Max(WetRoads, TrafficLightBrightness); + TrafficLightBrightness = Max(Rain, TrafficLightBrightness); + AddRain(); + + if ((NewWeatherType == WEATHER_SUNNY || NewWeatherType == WEATHER_EXTRA_SUNNY) && + !CGame::IsInInterior() && !CCutsceneMgr::IsRunning() && (CTimer::GetFrameCounter() & 7) == 0) { +#ifdef FIX_BUGS + if (FindPlayerPed() && (!FindPlayerPed()->CheckIfInTheAir() || FindPlayerPed()->CheckIfInTheAir() && FindPlayerPed()->GetPosition().z < 7.5f && + CClock::GetHours() > 6 && CClock::GetHours() < 18)) +#else + if (!FindPlayerPed()->CheckIfInTheAir() || FindPlayerPed()->CheckIfInTheAir() && FindPlayerPed()->GetPosition().z < 7.5f && + CClock::GetHours() > 6 && CClock::GetHours() < 18) +#endif + AddHeatHaze(); + } + + if ((NewWeatherType == WEATHER_SUNNY || NewWeatherType == WEATHER_EXTRA_SUNNY) && !CGame::IsInInterior() && !CCutsceneMgr::IsRunning()) + AddBeastie(); +} + +void CWeather::AddHeatHaze() +{ + /* TODO(MIAMI) */ +} + +void CWeather::AddBeastie() +{ + /* TODO(MIAMI) */ } void CWeather::ForceWeather(int16 weather) @@ -511,23 +581,3 @@ void CWeather::RenderRainStreaks(void) TempBufferVerticesStored = 0; TempBufferIndicesStored = 0; } - -void CWeather::StoreWeatherState() -{ - Stored_StateStored = true; - Stored_InterpolationValue = InterpolationValue; - Stored_Rain = Rain; - Stored_NewWeatherType = NewWeatherType; - Stored_OldWeatherType = OldWeatherType; -} - -void CWeather::RestoreWeatherState() -{ -#ifdef FIX_BUGS // it's not used anyway though - Stored_StateStored = false; -#endif - InterpolationValue = Stored_InterpolationValue; - Rain = Stored_Rain; - NewWeatherType = Stored_NewWeatherType; - OldWeatherType = Stored_OldWeatherType; -} diff --git a/src/render/Weather.h b/src/render/Weather.h index 4bf2fd8f..bd9b9603 100644 --- a/src/render/Weather.h +++ b/src/render/Weather.h @@ -1,21 +1,17 @@ enum { - WEATHER_SUNNY, + WEATHER_RANDOM = -1, + WEATHER_SUNNY = 0, WEATHER_CLOUDY, WEATHER_RAINY, - WEATHER_FOGGY + WEATHER_FOGGY, + WEATHER_EXTRA_SUNNY, + WEATHER_HURRICANE, + WEATHER_TOTAL }; class CWeather { public: - enum { - WEATHER_RANDOM = -1, - WEATHER_SUNNY = 0, - WEATHER_CLOUDY = 1, - WEATHER_RAINY = 2, - WEATHER_FOGGY = 3, - WEATHER_TOTAL = 4 - }; static int32 SoundHandle; static int32 WeatherTypeInList; @@ -38,13 +34,11 @@ public: static float InterpolationValue; static float WetRoads; static float Rainbow; + static float SunGlare; + static float WindClipped; + static float TrafficLightBrightness; static bool bScriptsForceRain; - static bool Stored_StateStored; - static float Stored_InterpolationValue; - static int16 Stored_OldWeatherType; - static int16 Stored_NewWeatherType; - static float Stored_Rain; static void RenderRainStreaks(void); static void Update(void); @@ -53,9 +47,9 @@ public: static void ReleaseWeather(); static void ForceWeather(int16); static void ForceWeatherNow(int16); - static void StoreWeatherState(); - static void RestoreWeatherState(); static void AddRain(); + static void AddHeatHaze(); + static void AddBeastie(); }; enum { -- cgit v1.2.3 From 3f2bdc096dcc6c4593e2825b64a47a9682927bfa Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 17 May 2020 15:33:44 +0200 Subject: some HUD colors --- src/render/Hud.cpp | 67 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index e06cc143..6a8e6f9a 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -21,6 +21,28 @@ #include "User.h" #include "World.h" +// Game has colors inlined in code. +// For easier modification we collect them here: +CRGBA MONEY_COLOR(0, 207, 133, 255); +CRGBA AMMO_COLOR(255, 150, 225, 255); +CRGBA HEALTH_COLOR(255, 150, 225, 255); +CRGBA ARMOUR_COLOR(185, 185, 185, 255); +CRGBA NOTWANTED_COLOR(27, 89, 130, 255); +CRGBA WANTED_COLOR_FLASH(62, 141, 181, 255); +CRGBA WANTED_COLOR(97, 194, 247, 255); +CRGBA ZONE_COLOR(45, 155, 90, 255); +CRGBA VEHICLE_COLOR(97, 194, 247, 255); +CRGBA CLOCK_COLOR(97, 194, 247, 255); +CRGBA TIMER_COLOR(97, 194, 247, 255); +CRGBA COUNTER_COLOR(97, 194, 247, 255); +CRGBA PAGER_COLOR(32, 162, 66, 205); +CRGBA RADARDISC_COLOR(255, 255, 255, 255); +CRGBA BIGMESSAGE_COLOR(85, 119, 133, 255); +CRGBA WASTEDBUSTED_COLOR(170, 123, 87, 255); +CRGBA ODDJOB_COLOR(89, 115, 150, 255); +CRGBA ODDJOB2_COLOR(156, 91, 40, 255); +CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); + wchar CHud::m_HelpMessage[256]; wchar CHud::m_LastHelpMessage[256]; uint32 CHud::m_HelpMessageState; @@ -252,7 +274,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(43.0f + 2.0f), sPrint); - CFont::SetColor(CRGBA(89, 115, 150, 255)); + CFont::SetColor(MONEY_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); /* @@ -335,7 +357,7 @@ void CHud::Draw() if (!CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); - CFont::SetColor(CRGBA(255, 150, 225, 255)); + CFont::SetColor(AMMO_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint); CFont::SetDropShadowPosition(0); } @@ -373,7 +395,7 @@ void CHud::Draw() if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(164.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); } - CFont::SetColor(CRGBA(186, 101, 50, 255)); + CFont::SetColor(HEALTH_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint); @@ -404,7 +426,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(234.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); } - CFont::SetColor(CRGBA(124, 140, 95, 255)); + CFont::SetColor(ARMOUR_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); @@ -434,7 +456,10 @@ void CHud::Draw() && (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange + 2000 || CTimer::GetFrameCounter() & 4)) { - CFont::SetColor(CRGBA(193, 164, 120, 255)); + CFont::SetColor(WANTED_COLOR); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + }else{ + CFont::SetColor(NOTWANTED_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); } } @@ -528,7 +553,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, fZoneAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); - CFont::SetColor(CRGBA(152, 154, 82, fZoneAlpha)); + CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f), m_ZoneToPrint); } } @@ -622,7 +647,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, fVehicleAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); - CFont::SetColor(CRGBA(194, 165, 120, fVehicleAlpha)); + CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f), m_pVehicleNameToPrint); } } @@ -654,7 +679,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), sPrint); - CFont::SetColor(CRGBA(194, 165, 120, 255)); + CFont::SetColor(CLOCK_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f), SCREEN_SCALE_Y(22.0f), sPrint); /* @@ -698,7 +723,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); - CFont::SetColor(CRGBA(186, 101, 50, 255)); + CFont::SetColor(TIMER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText[0]) { @@ -707,7 +732,7 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(0.64f), SCREEN_SCALE_Y(1.35f)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); - CFont::SetColor(CRGBA(186, 101, 50, 255)); + CFont::SetColor(TIMER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); } } @@ -742,7 +767,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer); - CFont::SetColor(CRGBA(0, 106, 164, 255)); + CFont::SetColor(COUNTER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer); } else { int counter = atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer); @@ -759,7 +784,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); - CFont::SetColor(CRGBA(0, 106, 164, 255)); + CFont::SetColor(COUNTER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); } } @@ -806,7 +831,7 @@ void CHud::Draw() CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.84f), SCREEN_SCALE_Y(1.0f)); - CFont::SetColor(CRGBA(32, 162, 66, 205)); + CFont::SetColor(PAGER_COLOR); CFont::SetRightJustifyOff(); CFont::SetBackgroundOff(); CFont::SetCentreOff(); @@ -828,7 +853,7 @@ void CHud::Draw() rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); #endif rect.Grow(4.0f); - Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255)); + Sprites[HUD_RADARDISC].Draw(rect, RADARDISC_COLOR); CRadar::DrawBlips(); } } @@ -983,7 +1008,7 @@ void CHud::Draw() 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::SetColor(CRGBA(BIGMESSAGE_COLOR.r, BIGMESSAGE_COLOR.g, BIGMESSAGE_COLOR.b, BigMessageAlpha[0])); CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]); } else { @@ -1018,7 +1043,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]); - CFont::SetColor(CRGBA(170, 123, 87, BigMessageAlpha[2])); + CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(82.0f), m_BigMessage[2]); } else { @@ -1210,7 +1235,7 @@ void CHud::DrawAfterFade() CFont::SetColor(CRGBA(0, 0, 0, 255)); 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::SetColor(ODDJOB_COLOR); CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[3]); } @@ -1226,7 +1251,7 @@ void CHud::DrawAfterFade() 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[4]); - CFont::SetColor(CRGBA(89, 115, 150, 255)); + CFont::SetColor(ODDJOB_COLOR); CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[4]); } @@ -1284,12 +1309,12 @@ void CHud::DrawAfterFade() #ifdef BETA_SLIDING_TEXT CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - CFont::SetColor(CRGBA(156, 91, 40, 255)); + CFont::SetColor(ODDJOB2_COLOR); CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #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[5]); - CFont::SetColor(CRGBA(156, 91, 40, 255)); + CFont::SetColor(ODDJOB2_COLOR); CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #endif } @@ -1334,7 +1359,7 @@ void CHud::DrawAfterFade() CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[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::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); } else { -- cgit v1.2.3 From 68f1c03a85833a0efedf5df52160bca02786ccac Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 18 May 2020 16:43:40 +0200 Subject: fixes for braking and cloud rotation at high fps --- src/render/Clouds.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/render') diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 9cd3b5d2..05210c77 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -64,6 +64,13 @@ CClouds::Update(void) float s = Sin(TheCamera.Orientation - 0.85f); CloudRotation += CWeather::Wind*s*0.001f; IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f) * 60.0f; +#ifdef FIX_BUGS + CloudRotation += CWeather::Wind*s*0.001f*CTimer::GetTimeStepFix(); + IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f*CTimer::GetTimeStepFix()) * 60.0f; +#else + CloudRotation += CWeather::Wind*s*0.001f; + IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f) * 60.0f; +#endif } void -- cgit v1.2.3 From 62db8cd9b0030f042403e996b20c3ceca5cd4f7a Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 19 May 2020 10:23:08 +0200 Subject: finished CFileLoader; some COcclusion stubs --- src/render/Occlusion.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/render/Occlusion.h | 19 +++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'src/render') diff --git a/src/render/Occlusion.cpp b/src/render/Occlusion.cpp index b33b1d01..1c4e4266 100644 --- a/src/render/Occlusion.cpp +++ b/src/render/Occlusion.cpp @@ -2,6 +2,42 @@ #include "Occlusion.h" +int32 COcclusion::NumOccludersOnMap; +int16 COcclusion::FarAwayList; +int16 COcclusion::NearbyList; +int16 COcclusion::ListWalkThroughFA; +int16 COcclusion::PreviousListWalkThroughFA; +COccluder COcclusion::aOccluders[NUMOCCLUSIONVOLUMES]; + +void +COcclusion::Init(void) +{ + NumOccludersOnMap = 0; + FarAwayList = -1; + NearbyList = -1; + ListWalkThroughFA = -1; + PreviousListWalkThroughFA = -1; +} + +void +COcclusion::AddOne(float x, float y, float z, float width, float length, float height, float angle) +{ + if(NumOccludersOnMap >= NUMOCCLUSIONVOLUMES) + return; + + aOccluders[NumOccludersOnMap].x = x; + aOccluders[NumOccludersOnMap].y = y; + aOccluders[NumOccludersOnMap].z = z; + aOccluders[NumOccludersOnMap].width = width; + aOccluders[NumOccludersOnMap].length = length; + aOccluders[NumOccludersOnMap].height = height; + while(angle < 0.0f) angle += 360.0f; + while(angle > 360.0f) angle -= 360.0f; + aOccluders[NumOccludersOnMap].angle = angle * UINT16_MAX/360.0f; + aOccluders[NumOccludersOnMap].listIndex = FarAwayList; + FarAwayList = NumOccludersOnMap++; +} + void COcclusion::ProcessBeforeRendering(void) { diff --git a/src/render/Occlusion.h b/src/render/Occlusion.h index 977649b8..ac0ede5e 100644 --- a/src/render/Occlusion.h +++ b/src/render/Occlusion.h @@ -1,7 +1,26 @@ #pragma once +class COccluder +{ +public: + int16 width, length, height; + int16 x, y, z; + uint16 angle; + int16 listIndex; +}; + class COcclusion { public: + static int32 NumOccludersOnMap; + static int16 FarAwayList; + static int16 NearbyList; + static int16 ListWalkThroughFA; + static int16 PreviousListWalkThroughFA; + + static COccluder aOccluders[NUMOCCLUSIONVOLUMES]; + + static void Init(void); + static void AddOne(float x, float y, float z, float width, float length, float height, float angle); static void ProcessBeforeRendering(void); }; -- cgit v1.2.3 From 00ee82aba676c9889761cd3efcb47f78773b6ea8 Mon Sep 17 00:00:00 2001 From: Xinerki Date: Tue, 19 May 2020 11:36:08 +0300 Subject: Zone and Vehicle text slant --- src/render/Hud.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 6a8e6f9a..6a0b7eea 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -546,15 +546,20 @@ void CHud::Draw() else CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); + CFont::SetSlantRefPoint(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f)); + CFont::SetSlant(0.15f); + CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); CFont::SetBackGroundOnlyTextOff(); CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(0, 0, 0, fZoneAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f), m_ZoneToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(128.0f), m_ZoneToPrint); + + CFont::SetSlant(0.f); } } } @@ -640,15 +645,20 @@ void CHud::Draw() else CFont::SetScale(SCREEN_SCALE_X(1.2f * 0.85f), SCREEN_SCALE_Y(1.2f)); + CFont::SetSlantRefPoint(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f)); + CFont::SetSlant(0.15f); + CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); CFont::SetBackGroundOnlyTextOff(); CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(0, 0, 0, fVehicleAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(105.f) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f), m_pVehicleNameToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f), m_pVehicleNameToPrint); + + CFont::SetSlant(0.f); } } } -- cgit v1.2.3 From a6972714b7ce5b7834e55a3b23acf28cf51a78ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Tue, 19 May 2020 17:39:19 +0300 Subject: Melee weapons(half-working), Ped and Hud bits --- src/render/Hud.cpp | 296 ++++++++++++++++++++++++++++++++++++++++++----------- src/render/Hud.h | 39 +++++++ 2 files changed, 277 insertions(+), 58 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 6a8e6f9a..3844953a 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -88,6 +88,21 @@ float CHud::PagerXOffset; int16 CHud::PagerTimer; int16 CHud::PagerOn; +uint32 CHud::m_WantedFadeTimer; +uint32 CHud::m_WantedState; +uint32 CHud::m_WantedTimer; +uint32 CHud::m_EnergyLostFadeTimer; +uint32 CHud::m_EnergyLostState; +uint32 CHud::m_EnergyLostTimer; +uint32 CHud::m_DisplayScoreFadeTimer; +uint32 CHud::m_DisplayScoreState; +uint32 CHud::m_DisplayScoreTimer; +uint32 CHud::m_WeaponFadeTimer; +uint32 CHud::m_WeaponState; +uint32 CHud::m_WeaponTimer; + +uint32 CHud::m_LastDisplayScore; + CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; struct @@ -125,6 +140,10 @@ RwTexture *gpRocketSightTex; void CHud::Draw() { + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + // disable hud via second controller if (CPad::GetPad(1)->GetStartJustDown()) m_Wants_To_Draw_Hud = !m_Wants_To_Draw_Hud; @@ -136,22 +155,29 @@ void CHud::Draw() bool DrawCrossHair = 0; bool DrawCrossHairPC = 0; - int32 WeaponType = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_eWeaponType; + CPlayerPed *playerPed = FindPlayerPed(); + eWeaponType WeaponType = playerPed->GetWeapon()->m_eWeaponType; int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode; - if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON) - DrawCrossHair = 1; - if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT) - DrawCrossHairPC = 1; + // TODO(Miami): New cam mode + if ((Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON/* || Mode == 46*/) + && playerPed && !playerPed->GetWeapon()->IsTypeMelee()) + DrawCrossHair = true; - /* - Draw Crosshairs - */ - if (TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam() && - (!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage) || Mode == CCam::MODE_1STPERSON_RUNABOUT) { - if (FindPlayerPed() && !FindPlayerPed()->EnteringCar()) { - if ((WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_M16) || WeaponType == WEAPONTYPE_FLAMETHROWER) - DrawCrossHairPC = 1; + if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT) + DrawCrossHairPC = true; + if (TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam() && (!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage) + || Mode == CCam::MODE_1STPERSON_RUNABOUT) { + if (playerPed) { + if (playerPed->m_nPedState != PED_ENTER_CAR && playerPed->m_nPedState != PED_CARJACK) { + + // TODO(Miami): Uncomment + if (WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_AK47 + /*|| WeaponType == WEAPONTYPE_M60 || || WeaponType == WEAPONTYPE_MINIGUN */ + || WeaponType == WEAPONTYPE_FLAMETHROWER) { + DrawCrossHairPC = 1; + } + } } } @@ -171,7 +197,8 @@ void CHud::Draw() #ifdef ASPECT_RATIO_SCALE f3rdY -= SCREEN_SCALE_Y(2.0f); #endif - if (FindPlayerPed() && WeaponType == WEAPONTYPE_M16) { + // TODO(Miami): M60 + if (playerPed && (WeaponType == WEAPONTYPE_M16 || WeaponType == WEAPONTYPE_AK47/* || WeaponType == WEAPONTYPE_M60*/)) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f); @@ -187,8 +214,7 @@ void CHud::Draw() Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); } - } - else { + } else { if (Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_HELICANNON_1STPERSON) { @@ -215,8 +241,11 @@ void CHud::Draw() RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRocketSightTex)); CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); } else { + + // TODO(Miami) // Sniper rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); @@ -243,9 +272,9 @@ void CHud::Draw() Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); } } - RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); } else { SpriteBrightness = 0; @@ -254,34 +283,48 @@ void CHud::Draw() /* DrawMoneyCounter */ + wchar sPrint[16]; wchar sPrintIcon[16]; char sTemp[16]; + float alpha; - sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney); - AsciiToUnicode(sTemp, sPrint); - - CFont::SetPropOff(); - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); - CFont::SetCentreOff(); - CFont::SetRightJustifyOn(); - CFont::SetRightJustifyWrap(0.0f); - CFont::SetBackGroundOnlyTextOff(); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetPropOff(); - CFont::SetColor(CRGBA(0, 0, 0, 255)); - - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(43.0f + 2.0f), sPrint); + if (m_LastDisplayScore == CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney) { + alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 0); + } else { + alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 1); + m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; + } + if (m_DisplayScoreState != FADED_OUT) { + sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney); + AsciiToUnicode(sTemp, sPrint); - CFont::SetColor(MONEY_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); + CFont::SetPropOff(); + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); + CFont::SetCentreOff(); + CFont::SetRightJustifyOn(); + CFont::SetRightJustifyWrap(0.0f); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetPropOff(); + CFont::SetDropShadowPosition(2); + CFont::SetDropColor(CRGBA(0, 0, 0, alpha)); + MONEY_COLOR.a = alpha; + CFont::SetColor(MONEY_COLOR); + + // TODO(Miami): m_nHudMode + //if (CMenuManager.m_nHudMode) + { + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); + } + } /* DrawAmmo */ CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType); - CWeapon *weapon = FindPlayerPed()->GetWeapon(); + CWeapon *weapon = playerPed->GetWeapon(); uint32 AmmoAmount = weaponInfo->m_nAmountofAmmunition; uint32 AmmoInClip = weapon->m_nAmmoInClip; uint32 TotalAmmo = weapon->m_nAmmoTotal; @@ -347,14 +390,15 @@ void CHud::Draw() } CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); + CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.8f)); CFont::SetJustifyOff(); CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); CFont::SetPropOn(); + CFont::SetDropShadowPosition(0); CFont::SetFontStyle(FONT_BANK); - if (!CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { + if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(AMMO_COLOR); @@ -366,7 +410,7 @@ void CHud::Draw() DrawHealth */ CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetJustifyOff(); CFont::SetCentreOff(); CFont::SetRightJustifyWrap(0.0f); @@ -376,16 +420,16 @@ void CHud::Draw() if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_HEALTH - || FindPlayerPed()->m_fHealth < 10 + || playerPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { - if (FindPlayerPed()->m_fHealth >= 10 - || FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { + if (playerPed->m_fHealth >= 10 + || playerPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { AsciiToUnicode("{", sPrintIcon); #ifdef FIX_BUGS - sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fHealth + 0.5f)); + sprintf(sTemp, "%03d", int32(playerPed->m_fHealth + 0.5f)); #else - sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth); + sprintf(sTemp, "%03d", (int32)playerPed->m_fHealth); #endif AsciiToUnicode(sTemp, sPrint); @@ -409,13 +453,13 @@ void CHud::Draw() DrawArmour */ if (m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_ARMOUR) { - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); - if (FindPlayerPed()->m_fArmour > 1.0f) { + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); + if (playerPed->m_fArmour > 1.0f) { AsciiToUnicode("[", sPrintIcon); #ifdef FIX_BUGS - sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fArmour + 0.5f)); + sprintf(sTemp, "%03d", int32(playerPed->m_fArmour + 0.5f)); #else - sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fArmour); + sprintf(sTemp, "%03d", (int32)playerPed->m_fArmour); #endif AsciiToUnicode(sTemp, sPrint); @@ -440,30 +484,33 @@ void CHud::Draw() DrawWantedLevel */ CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(1.25f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetJustifyOff(); CFont::SetCentreOff(); CFont::SetRightJustifyOn(); CFont::SetPropOn(); CFont::SetFontStyle(FONT_HEADING); + CFont::SetDropShadowPosition(2); // TODO(Miami): Remove that, VC keeps that open above AsciiToUnicode("]", sPrintIcon); for (int i = 0; i < 6; i++) { - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(2.0f + SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f + 2.0f), sPrintIcon); - if (FindPlayerPed()->m_pWanted->m_nWantedLevel > i - && (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange + if (playerPed->m_pWanted->m_nWantedLevel > i + && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange + 2000 || CTimer::GetFrameCounter() & 4)) { CFont::SetColor(WANTED_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); - }else{ + + // TODO(Miami): There is one more condition in here + }else if (playerPed->m_pWanted->m_nWantedLevel <= i) { CFont::SetColor(NOTWANTED_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); } } + CFont::SetDropShadowPosition(0); // TODO(Miami): Remove that, VC keeps that open + /* DrawZoneName */ @@ -665,7 +712,7 @@ void CHud::Draw() CFont::SetJustifyOff(); CFont::SetCentreOff(); CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetBackGroundOnlyTextOff(); CFont::SetPropOff(); CFont::SetFontStyle(FONT_HEADING); @@ -714,7 +761,7 @@ void CHud::Draw() AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer); CFont::SetPropOn(); CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); @@ -722,7 +769,7 @@ void CHud::Draw() CFont::SetBackGroundOnlyTextOn(); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetColor(TIMER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); @@ -754,7 +801,7 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetCentreOff(); CFont::SetRightJustifyOn(); CFont::SetRightJustifyWrap(0.0f); @@ -780,7 +827,7 @@ void CHud::Draw() if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) { CFont::SetPropOn(); - CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); @@ -1446,6 +1493,21 @@ void CHud::Initialise() PagerSoundPlayed = 0; PagerXOffset = 150.0f; + m_WantedFadeTimer = 0; + m_WantedState = FADE_DISABLED; + m_WantedTimer = 0; + m_EnergyLostFadeTimer = 0; + m_EnergyLostState = FADE_DISABLED; + m_EnergyLostTimer = 0; + m_DisplayScoreFadeTimer = 0; + m_DisplayScoreState = FADE_DISABLED; + m_DisplayScoreTimer = 0; + m_WeaponFadeTimer = 0; + m_WeaponState = FADE_DISABLED; + m_WeaponTimer = 0; + + m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; + CTxdStore::PopCurrentTxd(); } @@ -1469,6 +1531,21 @@ void CHud::ReInitialise() { PagerTimer = 0; PagerSoundPlayed = 0; PagerXOffset = 150.0f; + + m_WantedFadeTimer = 0; + m_WantedState = FADE_DISABLED; + m_WantedTimer = 0; + m_EnergyLostFadeTimer = 0; + m_EnergyLostState = FADE_DISABLED; + m_EnergyLostTimer = 0; + m_DisplayScoreFadeTimer = 0; + m_DisplayScoreState = FADE_DISABLED; + m_DisplayScoreTimer = 0; + m_WeaponFadeTimer = 0; + m_WeaponState = FADE_DISABLED; + m_WeaponTimer = 0; + + m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; } wchar LastBigMessage[6][128]; @@ -1565,3 +1642,106 @@ void CHud::Shutdown() int HudTXD = CTxdStore::FindTxdSlot("hud"); CTxdStore::RemoveTxdSlot(HudTXD); } + +float CHud::DrawFadeState(DRAW_FADE_STATE fadingElement, int forceFadingIn) +{ + float alpha = 255.0f; + uint32 operation, timer; + int32 fadeTimer; + + switch (fadingElement) { + case HUD_WANTED_FADING: + fadeTimer = m_WantedFadeTimer; + operation = m_WantedState; + timer = m_WantedTimer; + break; + case HUD_ENERGY_FADING: + fadeTimer = m_EnergyLostFadeTimer; + operation = m_EnergyLostState; + timer = m_EnergyLostTimer; + break; + case HUD_SCORE_FADING: + fadeTimer = m_DisplayScoreFadeTimer; + operation = m_DisplayScoreState; + timer = m_DisplayScoreTimer; + break; + case HUD_WEAPON_FADING: + fadeTimer = m_WeaponFadeTimer; + operation = m_WeaponState; + timer = m_WeaponTimer; + break; + default: + break; + } + if (forceFadingIn) { + switch (operation) { + case FADED_OUT: + fadeTimer = 0; + case START_FADE_OUT: + case FADING_OUT: + timer = 5; + operation = FADING_IN; + break; + default: + break; + } + } + if (operation != FADED_OUT && operation != FADE_DISABLED) { + switch (operation) { + case START_FADE_OUT: + fadeTimer = 1000; + alpha = 255.0f; + if (timer > 10000) { + fadeTimer = 3000; + operation = FADING_OUT; + } + break; + case FADING_IN: + fadeTimer += CTimer::GetTimeStepInMilliseconds(); + if (fadeTimer > 1000.0f) { + operation = START_FADE_OUT; + fadeTimer = 1000; + } + alpha = fadeTimer / 1000.0f * 255.0f; + break; + case FADING_OUT: + fadeTimer -= CTimer::GetTimeStepInMilliseconds(); + if (fadeTimer < 0.0f) { + fadeTimer = 0; + operation = FADED_OUT; + } + alpha = fadeTimer / 1000.0f * 255.0f; + break; + default: + break; + } + timer += CTimer::GetTimeStepInMilliseconds(); + } + + switch (fadingElement) { + case HUD_WANTED_FADING: + m_WantedFadeTimer = fadeTimer; + m_WantedState = operation; + m_WantedTimer = timer; + break; + case HUD_ENERGY_FADING: + m_EnergyLostFadeTimer = fadeTimer; + m_EnergyLostState = operation; + m_EnergyLostTimer = timer; + break; + case HUD_SCORE_FADING: + m_DisplayScoreFadeTimer = fadeTimer; + m_DisplayScoreState = operation; + m_DisplayScoreTimer = timer; + break; + case HUD_WEAPON_FADING: + m_WeaponFadeTimer = fadeTimer; + m_WeaponState = operation; + m_WeaponTimer = timer; + break; + default: + break; + } + + return clamp(alpha, 0.0f, 255.0f); +} diff --git a/src/render/Hud.h b/src/render/Hud.h index 701e47e2..bae19ee4 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -9,6 +9,25 @@ enum eItems ITEM_RADAR = 8 }; +// Thanks for vague name, R* +enum DRAW_FADE_STATE +{ + HUD_WANTED_FADING = 0, + HUD_ENERGY_FADING, + HUD_SCORE_FADING, + HUD_WEAPON_FADING, +}; + +// My name +enum eFadeOperation +{ + FADED_OUT = 0, + START_FADE_OUT, + FADING_IN, + FADING_OUT, + FADE_DISABLED = 5, +}; + enum eSprites { HUD_FIST, @@ -32,6 +51,10 @@ enum eSprites NUM_HUD_SPRITES, }; +// TODO(Miami): Make those 0.7f - 1.25f once fonts have been ported +#define HUD_TEXT_SCALE_X 0.8f +#define HUD_TEXT_SCALE_Y 1.35f + class CHud { public: @@ -82,6 +105,21 @@ public: static int16 PagerTimer; static int16 PagerOn; + static uint32 m_WantedFadeTimer; + static uint32 m_WantedState; + static uint32 m_WantedTimer; + static uint32 m_EnergyLostFadeTimer; + static uint32 m_EnergyLostState; + static uint32 m_EnergyLostTimer; + static uint32 m_DisplayScoreFadeTimer; + static uint32 m_DisplayScoreState; + static uint32 m_DisplayScoreTimer; + static uint32 m_WeaponFadeTimer; + static uint32 m_WeaponState; + static uint32 m_WeaponTimer; + + static uint32 m_LastDisplayScore; + public: static void Draw(); static void DrawAfterFade(); @@ -95,4 +133,5 @@ public: static void SetVehicleName(wchar *name); static void SetZoneName(wchar *name); static void Shutdown(); + static float DrawFadeState(DRAW_FADE_STATE, int); }; -- cgit v1.2.3 From bdbe5d1080066073f063d653e80df6dbf4b326a2 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 19 May 2020 20:56:42 +0200 Subject: CEntity and friends --- src/render/2dEffect.h | 5 ++++- src/render/Clouds.cpp | 2 -- src/render/Coronas.cpp | 11 +++++++---- src/render/Coronas.h | 6 ++++-- src/render/Renderer.cpp | 12 +++++++----- src/render/WindModifiers.cpp | 8 ++++++++ src/render/WindModifiers.h | 7 +++++++ 7 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 src/render/WindModifiers.cpp create mode 100644 src/render/WindModifiers.h (limited to 'src/render') diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h index ed5ce5ba..504824c5 100644 --- a/src/render/2dEffect.h +++ b/src/render/2dEffect.h @@ -4,7 +4,8 @@ enum { EFFECT_LIGHT, EFFECT_PARTICLE, EFFECT_ATTRACTOR, - EFFECT_PED_ATTRACTOR + EFFECT_PED_ATTRACTOR, + EFFECT_SUNGLARE }; enum { @@ -35,6 +36,8 @@ enum { // same order as CPointLights flags, must start at 2 LIGHTFLAG_FOG_NORMAL = 2, // can have light and fog LIGHTFLAG_FOG_ALWAYS = 4, // fog only + LIGHTFLAG_HIDE_OBJECT = 8, // hide the object instead of rendering light (???) + LIGHTFLAG_LONG_DIST = 16, LIGHTFLAG_FOG = (LIGHTFLAG_FOG_NORMAL|LIGHTFLAG_FOG_ALWAYS) }; diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 05210c77..c6ba0f10 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -62,8 +62,6 @@ void CClouds::Update(void) { float s = Sin(TheCamera.Orientation - 0.85f); - CloudRotation += CWeather::Wind*s*0.001f; - IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f) * 60.0f; #ifdef FIX_BUGS CloudRotation += CWeather::Wind*s*0.001f*CTimer::GetTimeStepFix(); IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f*CTimer::GetTimeStepFix()) * 60.0f; diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index e36bdf3d..8e832ab1 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -129,7 +129,8 @@ CCoronas::Update(void) void CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, RwTexture *tex, - int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle) + int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, + bool longDist, float nearDist) { int i; @@ -192,11 +193,13 @@ CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 al void CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, - const CVector &coors, float size, float drawDist, uint8 type, - int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle) + const CVector &coors, float size, float drawDist, uint8 type, + int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, + bool longDist, float nearDist) { RegisterCorona(id, red, green, blue, alpha, coors, size, drawDist, - gpCoronaTexture[type], flareType, reflection, LOScheck, drawStreak, someAngle); + gpCoronaTexture[type], flareType, reflection, LOScheck, drawStreak, someAngle, + longDist, nearDist); } void diff --git a/src/render/Coronas.h b/src/render/Coronas.h index 70e9ccd5..cb4e8583 100644 --- a/src/render/Coronas.h +++ b/src/render/Coronas.h @@ -90,10 +90,12 @@ public: static void Update(void); static void RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, RwTexture *tex, - int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle); + int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, + bool longDist = false, float nearClip = 1.5f); static void RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, uint8 type, - int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle); + int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, + bool longDist = false, float nearClip = 1.5f); static void UpdateCoronaCoors(uint32 id, const CVector &coors, float drawDist, float someAngle); static void Render(void); static void RenderReflections(void); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 803f4cc1..f149c6fb 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1245,9 +1245,11 @@ CRenderer::ShouldModelBeStreamed(CEntity *ent, const CVector &campos) void CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset) { - if(ent->bRenderScorched) - return; - CPointLights::RemoveLightsAffectingObject(); - if(reset) - ReSetAmbientAndDirectionalColours(); + if(!ent->bRenderScorched){ + CPointLights::RemoveLightsAffectingObject(); + if(reset) + ReSetAmbientAndDirectionalColours(); + } + SetAmbientColours(); + DeActivateDirectional(); } diff --git a/src/render/WindModifiers.cpp b/src/render/WindModifiers.cpp new file mode 100644 index 00000000..d7405c7a --- /dev/null +++ b/src/render/WindModifiers.cpp @@ -0,0 +1,8 @@ +#include "common.h" +#include "WindModifiers.h" + +int32 +CWindModifiers::FindWindModifier(CVector pos, float *x, float *y) +{ + return 0; +} diff --git a/src/render/WindModifiers.h b/src/render/WindModifiers.h new file mode 100644 index 00000000..b4024343 --- /dev/null +++ b/src/render/WindModifiers.h @@ -0,0 +1,7 @@ +#pragma once + +class CWindModifiers +{ +public: + static int32 FindWindModifier(CVector pos, float *x, float *y); +}; -- cgit v1.2.3 From 7e5342e9f0b27d69eaf0e3c6e1d14333ab5c4083 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 21 May 2020 11:22:25 +0300 Subject: script revision --- src/render/Shadows.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 69f9dce0..c512f35c 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -18,6 +18,7 @@ #endif #include "PointLights.h" #include "SpecialFX.h" +#include "Script.h" #include "Shadows.h" #ifdef DEBUGMENU @@ -1766,6 +1767,6 @@ CShadows::RenderIndicatorShadow(uint32 nID, uint8 ShadowType, RwTexture *pTextur ASSERT(pPosn != NULL); C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, Max(fFrontX, -fSideY), - 0, 128, 255, 128, - 2048, 0.2f, 0); + SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, + SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, 0.2f, 0); } -- cgit v1.2.3 From 3e75de970988fde8ebf2fd05a81399c2e7ba763b Mon Sep 17 00:00:00 2001 From: Xinerki Date: Thu, 21 May 2020 15:46:53 +0300 Subject: radardisc shadow thank tomasak --- src/render/Hud.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 7289d70c..7c33ea5b 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -909,7 +909,17 @@ void CHud::Draw() #else rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); #endif - rect.Grow(4.0f); + + // shadow, might not be exactly accurate numbers + rect.Translate(0.f, 4.f); + rect.Grow(6.0f); + rect.top += 2.f; + rect.bottom -= 2.f; + Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255)); + + rect.Translate(0.f, -4.f); + rect.top -= 2.f; + rect.bottom += 2.f; Sprites[HUD_RADARDISC].Draw(rect, RADARDISC_COLOR); CRadar::DrawBlips(); } -- cgit v1.2.3 From 46c6b0d29d218fdbea82a85939c6cef9f56437c6 Mon Sep 17 00:00:00 2001 From: Xinerki Date: Thu, 21 May 2020 16:25:46 +0300 Subject: fancy HUD.TXD reloader TODO: make optional with defines, also add more reload options --- src/render/Hud.cpp | 22 ++++++++++++++++++++++ src/render/Hud.h | 1 + 2 files changed, 23 insertions(+) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 7c33ea5b..a2eed48b 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -1476,6 +1476,28 @@ void CHud::GetRidOfAllHudMessages() } } +void CHud::ReloadTXD() +{ + for (int i = 0; i < NUM_HUD_SPRITES; ++i) { + Sprites[i].Delete(); + } + + int HudTXD = CTxdStore::FindTxdSlot("hud"); + CTxdStore::RemoveTxdSlot(HudTXD); + + debug("Reloading HUD.TXD...\n"); + + HudTXD = CTxdStore::AddTxdSlot("hud"); + CTxdStore::LoadTxd(HudTXD, "MODELS/HUD.TXD"); + CTxdStore::AddRef(HudTXD); + CTxdStore::PopCurrentTxd(); + CTxdStore::SetCurrentTxd(HudTXD); + + for (int i = 0; i < NUM_HUD_SPRITES; i++) { + Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); + } +} + void CHud::Initialise() { m_Wants_To_Draw_Hud = true; diff --git a/src/render/Hud.h b/src/render/Hud.h index bae19ee4..3f4b218e 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -124,6 +124,7 @@ public: static void Draw(); static void DrawAfterFade(); static void GetRidOfAllHudMessages(); + static void ReloadTXD(); static void Initialise(); static void ReInitialise(); static void SetBigMessage(wchar *message, int16 style); -- cgit v1.2.3 From 6692f5b2aa11e5cac51a61b41164316030152b16 Mon Sep 17 00:00:00 2001 From: Xinerki Date: Thu, 21 May 2020 16:47:48 +0300 Subject: make reloadables optional --- src/render/Hud.cpp | 2 ++ src/render/Hud.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index a2eed48b..4e12ceb5 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -1476,6 +1476,7 @@ void CHud::GetRidOfAllHudMessages() } } +#ifdef RELOADABLES void CHud::ReloadTXD() { for (int i = 0; i < NUM_HUD_SPRITES; ++i) { @@ -1497,6 +1498,7 @@ void CHud::ReloadTXD() Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); } } +#endif void CHud::Initialise() { diff --git a/src/render/Hud.h b/src/render/Hud.h index 3f4b218e..9d2c5f8b 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -124,7 +124,9 @@ public: static void Draw(); static void DrawAfterFade(); static void GetRidOfAllHudMessages(); +#ifdef RELOADABLES static void ReloadTXD(); +#endif static void Initialise(); static void ReInitialise(); static void SetBigMessage(wchar *message, int16 style); -- cgit v1.2.3 From e0345732c02ecaf329d13ac7dd005bcac7596bf7 Mon Sep 17 00:00:00 2001 From: Xinerki Date: Thu, 21 May 2020 17:50:08 +0300 Subject: wasted/busted text color how did nobody change it yet --- src/render/Hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 4e12ceb5..ff2af2d7 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -38,7 +38,7 @@ CRGBA COUNTER_COLOR(97, 194, 247, 255); CRGBA PAGER_COLOR(32, 162, 66, 205); CRGBA RADARDISC_COLOR(255, 255, 255, 255); CRGBA BIGMESSAGE_COLOR(85, 119, 133, 255); -CRGBA WASTEDBUSTED_COLOR(170, 123, 87, 255); +CRGBA WASTEDBUSTED_COLOR(255, 150, 225, 255); CRGBA ODDJOB_COLOR(89, 115, 150, 255); CRGBA ODDJOB2_COLOR(156, 91, 40, 255); CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); -- cgit v1.2.3 From a5f23a03424cf312add998edce6ef4122c0a29d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 22 May 2020 02:44:01 +0300 Subject: VC CMenuManager struct, ctor etc. --- src/render/Credits.cpp | 56 ++++++++++++++++---------------- src/render/Fluff.cpp | 4 +-- src/render/Hud.cpp | 88 +++++++++++++++++++++++++++++++++----------------- src/render/Hud.h | 1 + 4 files changed, 90 insertions(+), 59 deletions(-) (limited to 'src/render') diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index dc0b0252..60e69583 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -128,12 +128,12 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED040"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED041"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.5, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED042"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED043"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.5, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED044"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); @@ -176,7 +176,7 @@ CCredits::Render(void) PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED061"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.5, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED062"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); @@ -191,7 +191,7 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED068"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED069"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.5, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED070"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); @@ -220,7 +220,7 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED262"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED085"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.5, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED086"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); @@ -265,76 +265,76 @@ CCredits::Render(void) PrintCreditText(1.0, 1.0, TheText.Get("CRED108"), lineoffset, scrolloffset); PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED109"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED110"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED111"), lineoffset, scrolloffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED112"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED113"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED114"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED115"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED116"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED117"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED118"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED119"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED120"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED121"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED122"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED123"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED124"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED125"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED126"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED127"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED128"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED129"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED130"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED131"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED132"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED133"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) + if(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_ITALIAN) PrintCreditSpace(1.0, lineoffset); PrintCreditText(1.0, 1.0, TheText.Get("CRED134"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 59ac1652..1056d6ff 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -382,7 +382,7 @@ void CScrollBar::Update() m_pMessage = FindTimeMessage(); break; case 6: - if (CMenuManager::m_PrefsLanguage == LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == LANGUAGE_GERMAN) + if (FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_FRENCH || FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_GERMAN) m_pMessage = FindTimeMessage(); else m_pMessage = "WWW.GRANDTHEFTAUTO3.COM "; @@ -602,7 +602,7 @@ void CScrollBar::Update() m_pMessage = "FREE FLUFFY DICE WITH ALL PURCHASES. . ."; break; case 9: - if (CMenuManager::m_PrefsLanguage == LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == LANGUAGE_GERMAN) + if (FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_FRENCH || FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_GERMAN) m_pMessage = "QUICK, TAKE A LOOK AT OUR CURRENT STOCK )CAUSE THESE AUTOS ARE MOVIN) FAST . . . "; else m_pMessage = "HTTP:((ROCKSTARGAMES.COM(GRANDTHEFTAUTO3(CAPITALAUTOS "; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 7289d70c..96149573 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -102,6 +102,7 @@ uint32 CHud::m_WeaponState; uint32 CHud::m_WeaponTimer; uint32 CHud::m_LastDisplayScore; +uint32 CHud::m_LastWanted; CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; @@ -483,33 +484,46 @@ void CHud::Draw() /* DrawWantedLevel */ - CFont::SetBackgroundOff(); - CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); - CFont::SetJustifyOff(); - CFont::SetCentreOff(); - CFont::SetRightJustifyOn(); - CFont::SetPropOn(); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetDropShadowPosition(2); // TODO(Miami): Remove that, VC keeps that open above + if (m_LastWanted == playerPed->m_pWanted->m_nWantedLevel) + alpha = CHud::DrawFadeState(HUD_WANTED_FADING, 0); + else { + alpha = CHud::DrawFadeState(HUD_WANTED_FADING, 1); + m_LastWanted = playerPed->m_pWanted->m_nWantedLevel; + } - AsciiToUnicode("]", sPrintIcon); + if (m_WantedState != FADED_OUT) { + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); + CFont::SetJustifyOff(); + CFont::SetCentreOff(); + CFont::SetRightJustifyOn(); + CFont::SetPropOn(); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetDropShadowPosition(2); // TODO(Miami): Remove that, VC keeps that open above + CFont::SetDropColor(CRGBA(0,0,0,alpha)); // TODO(Miami): Remove that, VC keeps that open above - for (int i = 0; i < 6; i++) { - if (playerPed->m_pWanted->m_nWantedLevel > i - && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange - + 2000 || CTimer::GetFrameCounter() & 4)) { + AsciiToUnicode("]", sPrintIcon); - CFont::SetColor(WANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + for (int i = 0; i < 6; i++) { + if (playerPed->m_pWanted->m_nWantedLevel > i + && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange + + 2000 || CTimer::GetFrameCounter() & 4)) { - // TODO(Miami): There is one more condition in here - }else if (playerPed->m_pWanted->m_nWantedLevel <= i) { - CFont::SetColor(NOTWANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + WANTED_COLOR.a = alpha; + CFont::SetColor(WANTED_COLOR); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + + // TODO(Miami): There is one more condition in here + } + else if (playerPed->m_pWanted->m_nWantedLevel <= i) { + NOTWANTED_COLOR.a = alpha; + CFont::SetColor(NOTWANTED_COLOR); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + } } - } - CFont::SetDropShadowPosition(0); // TODO(Miami): Remove that, VC keeps that open + CFont::SetDropShadowPosition(0); // TODO(Miami): Remove that, VC keeps that open + } /* DrawZoneName @@ -1503,20 +1517,28 @@ void CHud::Initialise() PagerSoundPlayed = 0; PagerXOffset = 150.0f; - m_WantedFadeTimer = 0; +#ifdef HUD_AUTO_FADE + m_EnergyLostState = START_FADE_OUT; + m_WantedState = START_FADE_OUT; + m_DisplayScoreState = START_FADE_OUT; + m_WeaponState = START_FADE_OUT; +#else + m_EnergyLostState = FADE_DISABLED; m_WantedState = FADE_DISABLED; + m_DisplayScoreState = FADE_DISABLED; + m_WeaponState = FADE_DISABLED; +#endif + m_WantedFadeTimer = 0; m_WantedTimer = 0; m_EnergyLostFadeTimer = 0; - m_EnergyLostState = FADE_DISABLED; m_EnergyLostTimer = 0; m_DisplayScoreFadeTimer = 0; - m_DisplayScoreState = FADE_DISABLED; m_DisplayScoreTimer = 0; m_WeaponFadeTimer = 0; - m_WeaponState = FADE_DISABLED; m_WeaponTimer = 0; m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; + m_LastWanted = 0; CTxdStore::PopCurrentTxd(); } @@ -1542,20 +1564,28 @@ void CHud::ReInitialise() { PagerSoundPlayed = 0; PagerXOffset = 150.0f; - m_WantedFadeTimer = 0; +#ifdef HUD_AUTO_FADE + m_EnergyLostState = START_FADE_OUT; + m_WantedState = START_FADE_OUT; + m_DisplayScoreState = START_FADE_OUT; + m_WeaponState = START_FADE_OUT; +#else + m_EnergyLostState = FADE_DISABLED; m_WantedState = FADE_DISABLED; + m_DisplayScoreState = FADE_DISABLED; + m_WeaponState = FADE_DISABLED; +#endif + m_WantedFadeTimer = 0; m_WantedTimer = 0; m_EnergyLostFadeTimer = 0; - m_EnergyLostState = FADE_DISABLED; m_EnergyLostTimer = 0; m_DisplayScoreFadeTimer = 0; - m_DisplayScoreState = FADE_DISABLED; m_DisplayScoreTimer = 0; m_WeaponFadeTimer = 0; - m_WeaponState = FADE_DISABLED; m_WeaponTimer = 0; m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; + m_LastWanted = 0; } wchar LastBigMessage[6][128]; diff --git a/src/render/Hud.h b/src/render/Hud.h index bae19ee4..4c02827b 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -119,6 +119,7 @@ public: static uint32 m_WeaponTimer; static uint32 m_LastDisplayScore; + static uint32 m_LastWanted; public: static void Draw(); -- cgit v1.2.3 From a53ca58e566ffceb058451bc49bcc5810c26cb37 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 22 May 2020 14:27:16 +0200 Subject: CPhysical --- src/render/Timecycle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Timecycle.h b/src/render/Timecycle.h index dc52d493..2d873e6d 100644 --- a/src/render/Timecycle.h +++ b/src/render/Timecycle.h @@ -155,7 +155,7 @@ public: static float GetSpriteSize(void) { return m_fCurrentSpriteSize; } static int GetShadowStrength(void) { return m_nCurrentShadowStrength; } static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; } - static int GetLightOnGroundBrightness(void) { return m_fCurrentLightsOnGroundBrightness; } + static float GetLightOnGroundBrightness(void) { return m_fCurrentLightsOnGroundBrightness; } static float GetFarClip(void) { return m_fCurrentFarClip; } static float GetFogStart(void) { return m_fCurrentFogStart; } -- cgit v1.2.3 From 5357957fe124afb8e9a5f737510fe4c96a7dc327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 23 May 2020 16:53:20 +0300 Subject: Compatibility with VC weapon.dat + new shotguns --- src/render/Hud.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 00d5b5c7..5d1542ef 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -172,9 +172,8 @@ void CHud::Draw() if (playerPed) { if (playerPed->m_nPedState != PED_ENTER_CAR && playerPed->m_nPedState != PED_CARJACK) { - // TODO(Miami): Uncomment - if (WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_AK47 - /*|| WeaponType == WEAPONTYPE_M60 || || WeaponType == WEAPONTYPE_MINIGUN */ + if (WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_RUGER + || WeaponType == WEAPONTYPE_M60 || WeaponType == WEAPONTYPE_MINIGUN || WeaponType == WEAPONTYPE_FLAMETHROWER) { DrawCrossHairPC = 1; } @@ -198,8 +197,7 @@ void CHud::Draw() #ifdef ASPECT_RATIO_SCALE f3rdY -= SCREEN_SCALE_Y(2.0f); #endif - // TODO(Miami): M60 - if (playerPed && (WeaponType == WEAPONTYPE_M16 || WeaponType == WEAPONTYPE_AK47/* || WeaponType == WEAPONTYPE_M60*/)) { + if (playerPed && (WeaponType == WEAPONTYPE_M4 || WeaponType == WEAPONTYPE_RUGER || WeaponType == WEAPONTYPE_M60)) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f); @@ -314,9 +312,7 @@ void CHud::Draw() MONEY_COLOR.a = alpha; CFont::SetColor(MONEY_COLOR); - // TODO(Miami): m_nHudMode - //if (CMenuManager.m_nHudMode) - { + if (FrontEndMenuManager.m_PrefsShowHud) { CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); } } @@ -505,20 +501,21 @@ void CHud::Draw() AsciiToUnicode("]", sPrintIcon); for (int i = 0; i < 6; i++) { - if (playerPed->m_pWanted->m_nWantedLevel > i - && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange - + 2000 || CTimer::GetFrameCounter() & 4)) { - - WANTED_COLOR.a = alpha; - CFont::SetColor(WANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); - - // TODO(Miami): There is one more condition in here - } - else if (playerPed->m_pWanted->m_nWantedLevel <= i) { - NOTWANTED_COLOR.a = alpha; - CFont::SetColor(NOTWANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + if (FrontEndMenuManager.m_PrefsShowHud) { + if (playerPed->m_pWanted->m_nWantedLevel > i + && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange + + 2000 || CTimer::GetFrameCounter() & 4)) { + + WANTED_COLOR.a = alpha; + CFont::SetColor(WANTED_COLOR); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + + // TODO(Miami): There is one more condition in here + } else if (playerPed->m_pWanted->m_nWantedLevel <= i) { + NOTWANTED_COLOR.a = alpha; + CFont::SetColor(NOTWANTED_COLOR); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + } } } -- cgit v1.2.3 From 4870d9a31be6302037eb7ddcf0b99ea25ebccabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 24 May 2020 02:59:30 +0300 Subject: Menu borders and weapon fixes --- src/render/Draw.cpp | 29 ++++++++++++++--------------- src/render/Draw.h | 6 ++---- src/render/Font.h | 2 +- src/render/Sprite2d.cpp | 15 +++++++-------- 4 files changed, 24 insertions(+), 28 deletions(-) (limited to 'src/render') diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index b31cc624..e2dfc8d9 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -19,24 +19,23 @@ uint8 CDraw::FadeGreen; uint8 CDraw::FadeBlue; float -CDraw::FindAspectRatio(void) +CDraw::CalculateAspectRatio(void) { -#ifndef ASPECT_RATIO_SCALE - if(FrontEndMenuManager.m_PrefsUseWideScreen) - return 16.0f/9.0f; - else - return 4.0f/3.0f; + if (FrontEndMenuManager.m_PrefsUseWideScreen) { + if (TheCamera.m_WideScreenOn) + CDraw::ms_fAspectRatio = 5.f / 3.f; // It's used on theatrical showings according to Wiki + else +#ifdef ASPECT_RATIO_SCALE + CDraw::ms_fAspectRatio = FrontEndMenuManager.m_PrefsUseWideScreen == AR_AUTO ? SCREEN_WIDTH / SCREEN_HEIGHT : 16.f / 9.f; #else - switch (FrontEndMenuManager.m_PrefsUseWideScreen) { - case AR_AUTO: - return SCREEN_WIDTH / SCREEN_HEIGHT; - default: - case AR_4_3: - return 4.0f / 3.0f; - case AR_16_9: - return 16.0f / 9.0f; - }; + CDraw::ms_fAspectRatio = 16.f / 9.f; #endif + } else if (TheCamera.m_WideScreenOn) { + CDraw::ms_fAspectRatio = 5.f/4.f; + } else { + CDraw::ms_fAspectRatio = 4.f/3.f; + } + return CDraw::ms_fAspectRatio; } #ifdef ASPECT_RATIO_SCALE diff --git a/src/render/Draw.h b/src/render/Draw.h index 55958a2a..46e85e49 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -38,12 +38,10 @@ public: static void SetFOV(float fov); static float GetFOV(void) { return ms_fFOV; } - static float FindAspectRatio(void); + static float CalculateAspectRatio(void); #ifdef ASPECT_RATIO_SCALE static float ConvertFOV(float fov); +#endif static float GetAspectRatio(void) { return ms_fAspectRatio; } static void SetAspectRatio(float ratio) { ms_fAspectRatio = ratio; } -#else - static float GetAspectRatio(void) { return FindAspectRatio(); } -#endif }; diff --git a/src/render/Font.h b/src/render/Font.h index 9b4e7132..48f5703d 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -68,8 +68,8 @@ class CFont static int16 Size[MAX_FONTS][193]; #endif static int16 NewLine; - static CSprite2d Sprite[MAX_FONTS]; public: + static CSprite2d Sprite[MAX_FONTS]; static CFontDetails Details; static void Initialise(void); diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 189c9797..2675c95f 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -4,11 +4,11 @@ #include "Draw.h" #include "Camera.h" #include "Sprite2d.h" +#include "Font.h" RwIm2DVertex CSprite2d::maVertices[8]; float CSprite2d::RecipNearClip; int32 CSprite2d::mCurrentBank; -RwTexture *CSprite2d::mpBankTextures[10]; int32 CSprite2d::mCurrentSprite[10]; int32 CSprite2d::mBankStart[10]; RwIm2DVertex CSprite2d::maBankVertices[500]; @@ -16,7 +16,7 @@ RwIm2DVertex CSprite2d::maBankVertices[500]; void CSprite2d::SetRecipNearClip(void) { - RecipNearClip = 1.0f / RwCameraGetNearClipPlane(Scene.camera); + // Used but empty in VC, instead they set in InitPerFrame. Isn't that great? } void @@ -24,17 +24,15 @@ CSprite2d::InitPerFrame(void) { int i; + RecipNearClip = 1.0f / RwCameraGetNearClipPlane(Scene.camera); mCurrentBank = 0; for(i = 0; i < 10; i++) mCurrentSprite[i] = 0; - for(i = 0; i < 10; i++) - mpBankTextures[i] = nil; } int32 CSprite2d::GetBank(int32 n, RwTexture *tex) { - mpBankTextures[mCurrentBank] = tex; mCurrentSprite[mCurrentBank] = 0; mBankStart[mCurrentBank+1] = mBankStart[mCurrentBank] + n; return mCurrentBank++; @@ -59,13 +57,14 @@ CSprite2d::DrawBank(int32 bank) { if(mCurrentSprite[bank] == 0) return; - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, - mpBankTextures[bank] ? RwTextureGetRaster(mpBankTextures[bank]) : nil); + + // This is hacked III function to make it work with VC frontend. + CFont::Sprite[bank].SetRenderState(); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwIm2DRenderPrimitive(rwPRIMTYPETRILIST, &maBankVertices[6*mBankStart[bank]], 6*mCurrentSprite[bank]); mCurrentSprite[bank] = 0; - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + //RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); } -- cgit v1.2.3 From d59862eb5e9b56fe5b9fb0b2332e07b5266dcd22 Mon Sep 17 00:00:00 2001 From: nrb Date: Sun, 24 May 2020 17:27:12 +0200 Subject: fixed compiler errors --- src/render/Timecycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index c120c003..8846fdf0 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -175,7 +175,7 @@ CTimeCycle::Initialise(void) bi++; bi++; } - while(work_buff[bi] != '\n') + while(work_buff[bi] != '\n' || work_buff[bi] != '\0') line[li++] = work_buff[bi++]; line[li] = '\0'; bi++; -- cgit v1.2.3 From 7bf833785411955c2bcf35ed55e9d206facbc575 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 24 May 2020 15:14:27 +0200 Subject: CVehicle --- src/render/Coronas.cpp | 6 +++--- src/render/Shadows.cpp | 8 ++++---- src/render/Skidmarks.cpp | 4 ++-- src/render/SpecialFX.cpp | 1 + src/render/SpecialFX.h | 2 ++ src/render/Timecycle.cpp | 2 +- src/render/Timecycle.h | 2 +- src/render/Weather.cpp | 6 ++++-- 8 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/render') diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 8e832ab1..efe486fe 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -509,18 +509,18 @@ CCoronas::DoSunAndMoon(void) { // yeah, moon is done somewhere else.... - CVector sunCoors = CTimeCycle::GetSunPosition(); + CVector sunCoors = CTimeCycle::GetSunDirection(); sunCoors *= 150.0f; sunCoors += TheCamera.GetPosition(); - if(CTimeCycle::GetSunPosition().z > -0.2f){ + if(CTimeCycle::GetSunDirection().z > -0.2f){ float size = ((CGeneral::GetRandomNumber()&0xFF) * 0.005f + 10.0f) * CTimeCycle::GetSunSize(); RegisterCorona(SUN_CORE, CTimeCycle::GetSunCoreRed(), CTimeCycle::GetSunCoreGreen(), CTimeCycle::GetSunCoreBlue(), 255, sunCoors, size, 999999.88f, TYPE_STAR, FLARE_NONE, REFLECTION_OFF, LOSCHECK_OFF, STREAK_OFF, 0.0f); - if(CTimeCycle::GetSunPosition().z > 0.0f) + if(CTimeCycle::GetSunDirection().z > 0.0f) RegisterCorona(SUN_CORONA, CTimeCycle::GetSunCoronaRed(), CTimeCycle::GetSunCoronaGreen(), CTimeCycle::GetSunCoronaBlue(), 255, sunCoors, 25.0f * CTimeCycle::GetSunSize(), diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index c512f35c..fac35aeb 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -643,12 +643,12 @@ CShadows::StoreShadowForPole(CEntity *pPole, float fOffsetX, float fOffsetY, flo PolePos.y += fOffsetX * pPole->GetRight().y + fOffsetY * pPole->GetForward().y; PolePos.z += fOffsetZ; - PolePos.x += -CTimeCycle::GetSunPosition().x * (fPoleHeight / 2); - PolePos.y += -CTimeCycle::GetSunPosition().y * (fPoleHeight / 2); + PolePos.x += -CTimeCycle::GetSunDirection().x * (fPoleHeight / 2); + PolePos.y += -CTimeCycle::GetSunDirection().y * (fPoleHeight / 2); StoreStaticShadow((uintptr)pPole + nID + _TODOCONST(51), SHADOWTYPE_DARK, gpPostShadowTex, &PolePos, - -CTimeCycle::GetSunPosition().x * (fPoleHeight / 2), - -CTimeCycle::GetSunPosition().y * (fPoleHeight / 2), + -CTimeCycle::GetSunDirection().x * (fPoleHeight / 2), + -CTimeCycle::GetSunDirection().y * (fPoleHeight / 2), CTimeCycle::GetShadowSideX() * fPoleWidth, CTimeCycle::GetShadowSideY() * fPoleWidth, 2 * (int32)((pPole->GetUp().z - 0.5f) * CTimeCycle::GetShadowStrength() * 2.0f) / 3, diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index 7f057319..961c38a6 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -199,8 +199,8 @@ CSkidmarks::RegisterOne(uintptr id, CVector pos, float fwdX, float fwdY, bool *i aSkidmarks[i].m_pos[aSkidmarks[i].m_last] = pos; CVector2D dist = aSkidmarks[i].m_pos[aSkidmarks[i].m_last] - aSkidmarks[i].m_pos[aSkidmarks[i].m_last-1]; - dist.NormaliseSafe(); - fwd.NormaliseSafe(); + dist.Normalise(); + fwd.Normalise(); CVector2D right(dist.y, -dist.x); float turn = DotProduct2D(fwd, right); turn = Abs(turn) + 1.0f; diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 7e08fbad..79ae21a5 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -28,6 +28,7 @@ RwImVertexIndex StreakIndexList[12]; RwIm3DVertex TraceVertices[6]; RwImVertexIndex TraceIndexList[12]; +bool CSpecialFX::bSnapShotActive; void CSpecialFX::Init(void) diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 2d9f18b1..7bc3750a 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -3,6 +3,8 @@ class CSpecialFX { public: + static bool bSnapShotActive; + static void Render(void); static void Update(void); static void Init(void); diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index c120c003..ab94f874 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -350,7 +350,7 @@ CTimeCycle::Update(void) m_CurrentStoredValue = (m_CurrentStoredValue+1)&0xF; float sunAngle = 2*PI*(CClock::GetSeconds()/60.0f + CClock::GetMinutes() + CClock::GetHours()*60)/(24*60); - CVector &sunPos = GetSunPosition(); + CVector &sunPos = GetSunDirection(); sunPos.x = Sin(sunAngle); sunPos.y = 1.0f; sunPos.z = 0.2f - Cos(sunAngle); diff --git a/src/render/Timecycle.h b/src/render/Timecycle.h index 2d873e6d..60c9e29f 100644 --- a/src/render/Timecycle.h +++ b/src/render/Timecycle.h @@ -180,7 +180,7 @@ public: static void Initialise(void); static void Update(void); - static CVector &GetSunPosition(void) { return m_VectorToSun[m_CurrentStoredValue]; } + static CVector &GetSunDirection(void) { return m_VectorToSun[m_CurrentStoredValue]; } static float GetShadowFrontX(void) { return m_fShadowFrontX[m_CurrentStoredValue]; } static float GetShadowFrontY(void) { return m_fShadowFrontY[m_CurrentStoredValue]; } static float GetShadowSideX(void) { return m_fShadowSideX[m_CurrentStoredValue]; } diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index fc3e0d61..324c63ea 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -18,6 +18,7 @@ #include "Vehicle.h" #include "World.h" #include "ZoneCull.h" +#include "SpecialFX.h" int32 CWeather::SoundHandle = -1; @@ -271,9 +272,10 @@ void CWeather::Update(void) SunGlare += InterpolationValue; if (SunGlare > 0.0f) { - SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunPosition().z); + SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunDirection().z); SunGlare = clamp(SunGlare, 0.0f, 1.0f); - // TODO(MIAMI): if (CSpecialFX::bSnapShotActive)... + if (!CSpecialFX::bSnapShotActive) + SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f); } Wind = InterpolationValue * Windiness[NewWeatherType] + (1.0f - InterpolationValue) * Windiness[OldWeatherType]; -- cgit v1.2.3 From dfa95002aa1813f1d2f68172f32f748d83b47d2c Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 26 May 2020 12:10:08 +0200 Subject: fix --- src/render/Timecycle.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index 28156c7e..bf55d7bc 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -175,7 +175,11 @@ CTimeCycle::Initialise(void) bi++; bi++; } - while(work_buff[bi] != '\n' || work_buff[bi] != '\0') + while(work_buff[bi] != '\n' +#ifdef FIX_BUGS + && work_buff[bi] != '\0' +#endif + ) line[li++] = work_buff[bi++]; line[li] = '\0'; bi++; -- cgit v1.2.3 From 7f60be9814894fc5c6e9fbc9d52be492c8c92a11 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 26 May 2020 18:50:11 +0200 Subject: fix UB shit --- src/render/Sprite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 9631aced..a6d2db7b 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -22,8 +22,8 @@ CSprite::CalcHorizonCoors(void) bool CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh, bool farclip) { - CVector viewvec = TheCamera.m_viewMatrix * *(CVector*)∈ - *out = *(RwV3d*)&viewvec; + CVector viewvec = TheCamera.m_viewMatrix * in; + *out = viewvec; if(out->z <= CDraw::GetNearClipZ() + 1.0f) return false; if(out->z >= CDraw::GetFarClipZ() && farclip) return false; float recip = 1.0f/out->z; -- cgit v1.2.3