From bb5470617c6d5847083b2e0cb25b8d51c7920df3 Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Fri, 16 Apr 2021 23:08:56 +1000 Subject: [PATCH 1/6] Use separate function to calculate console rotation offset --- bin/skins/Default/scripts/gameplay.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/skins/Default/scripts/gameplay.lua b/bin/skins/Default/scripts/gameplay.lua index 3d3cdbe7f..a6b6a8e66 100644 --- a/bin/skins/Default/scripts/gameplay.lua +++ b/bin/skins/Default/scripts/gameplay.lua @@ -453,11 +453,18 @@ end -- -------------------------------------------------------------------------- -- -- GetCritLineCenteringOffset: -- -- Utility function which returns the magnitude of an offset to center the -- --- crit line on the screen based on its position and rotation. -- +-- crit line on the screen based on its rotation. -- function GetCritLineCenteringOffset() return gameplay.critLine.xOffset * 10 end -- -------------------------------------------------------------------------- -- +-- GetConsoleCenteringOffset: -- +-- Utility function which returns the magnitude of an offset to center the -- +-- console on the screen based on its position and rotation. -- +function GetConsoleCenteringOffset() + return resx / 2 - gameplay.critLine.x +end +-- -------------------------------------------------------------------------- -- -- render_crit_base: -- -- Called after rendering the highway and playable objects, but before -- -- the built-in hit effects. -- @@ -594,7 +601,7 @@ function render_crit_overlay(deltaTime) -- Figure out how to offset the center of the crit line to remain -- centered on the players screen. - local xOffset = resx / 2 - gameplay.critLine.x + local xOffset = GetConsoleCenteringOffset() -- When in portrait, we can draw the console at the bottom if portrait then From eb179485cd7dea3855d89210863ad4c714b683c8 Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Fri, 16 Apr 2021 23:10:07 +1000 Subject: [PATCH 2/6] Fix white spacing --- bin/skins/Default/scripts/gameplay.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/skins/Default/scripts/gameplay.lua b/bin/skins/Default/scripts/gameplay.lua index a6b6a8e66..e1dfd3696 100644 --- a/bin/skins/Default/scripts/gameplay.lua +++ b/bin/skins/Default/scripts/gameplay.lua @@ -460,7 +460,7 @@ end -- -------------------------------------------------------------------------- -- -- GetConsoleCenteringOffset: -- -- Utility function which returns the magnitude of an offset to center the -- --- console on the screen based on its position and rotation. -- +-- console on the screen based on its position and rotation. -- function GetConsoleCenteringOffset() return resx / 2 - gameplay.critLine.x end From 8f0fe93ab3ac42a7b3b6ff4740d569cc3cf6c792 Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Sat, 17 Apr 2021 14:30:15 +1000 Subject: [PATCH 3/6] Fix hit effect turning into a crit when a hold object crosses the crit line --- Main/include/Scoring.hpp | 3 +-- Main/src/Scoring.cpp | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Main/include/Scoring.hpp b/Main/include/Scoring.hpp index 5b91c0614..7e8cb7ef9 100644 --- a/Main/include/Scoring.hpp +++ b/Main/include/Scoring.hpp @@ -316,7 +316,7 @@ class Scoring : public Unique MapTime m_buttonGuardTime[6] = { 0, 0, 0, 0, 0, 0 }; // Offet to use for calculating judge (ms) - uint32 m_inputOffset = 0; + int32 m_inputOffset = 0; int32 m_bounceGuard = 0; float m_drainMultiplier = 1.0f; MapTime m_endTime = 180000; @@ -347,4 +347,3 @@ class Scoring : public Unique // shall be put on the score screen. Vector m_gaugeStack; }; - diff --git a/Main/src/Scoring.cpp b/Main/src/Scoring.cpp index aa59595b8..fd52b9c57 100755 --- a/Main/src/Scoring.cpp +++ b/Main/src/Scoring.cpp @@ -817,14 +817,14 @@ ObjectState* Scoring::m_ConsumeTick(uint32 buttonCode) ObjectState* hitObject = tick->object; if (tick->HasFlag(TickFlags::Laser)) { - // Ignore laser and hold ticks + // Ignore laser ticks return nullptr; } if (tick->HasFlag(TickFlags::Hold)) { HoldObjectState* hos = (HoldObjectState*)hitObject; hos = hos->GetRoot(); - if (hos->time - hitWindow.hold <= currentTime) + if (hos->time - currentTime <= hitWindow.hold) m_SetHoldObject(hitObject, buttonCode); return nullptr; } @@ -849,6 +849,7 @@ void Scoring::m_OnTickProcessed(ScoreTick* tick, uint32 index) OnScoreChanged.Call(); } } + void Scoring::m_TickHit(ScoreTick* tick, uint32 index, MapTime delta /*= 0*/) { HitStat* stat = m_AddOrUpdateHitStat(tick->object); From e2337907da126ef8c81329b0817c54990858c5e6 Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Sun, 18 Apr 2021 00:35:14 +1000 Subject: [PATCH 4/6] Fix hit effects not decaying in the calibration screen --- Main/include/Track.hpp | 8 ++-- Main/src/Game.cpp | 15 +++---- Main/src/Track.cpp | 98 ++++++++++++++++++++---------------------- 3 files changed, 58 insertions(+), 63 deletions(-) diff --git a/Main/include/Track.hpp b/Main/include/Track.hpp index e835a93c7..d168630f3 100644 --- a/Main/include/Track.hpp +++ b/Main/include/Track.hpp @@ -34,10 +34,10 @@ struct ButtonHitEffect : TimedEffect uint32 buttonCode; // Only used for Draw Color color; - float delayFadeDuration; + float delayFadeDuration = 0; bool held = false; float hitEffectDuration; - float alphaScale; + float alphaScale = 1; }; // Button hit rating effect @@ -203,8 +203,8 @@ class Track : Unique, public IAsyncLoadable // Track Origin position Transform trackOrigin; - bool hitEffectAutoplay; - float scrollSpeed; + bool hitEffectAutoplay = false; + float scrollSpeed = 0; private: // Laser track generators diff --git a/Main/src/Game.cpp b/Main/src/Game.cpp index 022504040..04aa55657 100755 --- a/Main/src/Game.cpp +++ b/Main/src/Game.cpp @@ -479,14 +479,13 @@ class Game_Impl : public Game m_track->distantButtonScale = g_gameConfig.GetFloat(GameConfigKeys::DistantButtonScale); m_showCover = g_gameConfig.GetBool(GameConfigKeys::ShowCover); - - g_input.OnButtonReleased.Add(m_track, &Track::OnButtonReleased); - if (m_delayedHitEffects) - { - m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter); - if (m_scoring.autoplayInfo.IsAutoplayButtons()) - m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased); - } + + if (m_delayedHitEffects) + { + m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter); + if (m_scoring.autoplayInfo.IsAutoplayButtons()) + m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased); + } #ifdef EMBEDDED basicParticleTexture = Ref(); diff --git a/Main/src/Track.cpp b/Main/src/Track.cpp index e6a35d11c..06720b2ab 100644 --- a/Main/src/Track.cpp +++ b/Main/src/Track.cpp @@ -24,20 +24,13 @@ Track::Track() Track::~Track() { - if(loader) - delete loader; + delete loader; - for(uint32 i = 0; i < 2; i++) - { - if(m_laserTrackBuilder[i]) - delete m_laserTrackBuilder[i]; - } - for(auto it = m_hitEffects.begin(); it != m_hitEffects.end(); it++) - { - delete *it; - } - if(timedHitEffect) - delete timedHitEffect; + for (auto & i : m_laserTrackBuilder) + delete i; + for (auto & m_hitEffect : m_hitEffects) + delete m_hitEffect; + delete timedHitEffect; } bool Track::AsyncLoad() @@ -49,35 +42,6 @@ bool Track::AsyncLoad() laserHues[0] = g_gameConfig.GetFloat(GameConfigKeys::Laser0Color); laserHues[1] = g_gameConfig.GetFloat(GameConfigKeys::Laser1Color); m_btOverFxScale = Math::Clamp(g_gameConfig.GetFloat(GameConfigKeys::BTOverFXScale), 0.01f, 1.0f); - bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects); - - for (int i = 0; i < 6; ++i) - { - ButtonHitEffect& bfx = m_buttonHitEffects[i]; - if (delayedHitEffects) - { - if (i < 4) - { - bfx.delayFadeDuration = BT_DELAY_FADE_DURATION; - bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION; - bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed - } - else - { - bfx.delayFadeDuration = FX_DELAY_FADE_DURATION; - bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION; - bfx.alphaScale = 0.45f; - } - } - else - { - bfx.delayFadeDuration = 0; - bfx.hitEffectDuration = 7 / 60.f; - bfx.alphaScale = 1; - } - bfx.buttonCode = i; - bfx.track = this; - } for (uint32 i = 0; i < 2; i++) laserColors[i] = Color::FromHSV(laserHues[i],1.0,1.0); @@ -131,6 +95,7 @@ bool Track::AsyncLoad() return loader->Load(); } + bool Track::AsyncFinalize() { // Finalizer loading textures/material/etc. @@ -173,18 +138,18 @@ bool Track::AsyncFinalize() holdButtonMaterial->opaque = false; - for (uint32 i = 0; i < 2; i++) + for (auto &laserTexture : laserTextures) { - laserTextures[i]->SetMipmaps(true); - laserTextures[i]->SetFilter(true, true, 16.0f); - laserTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat); + laserTexture->SetMipmaps(true); + laserTexture->SetFilter(true, true, 16.0f); + laserTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat); } - for(uint32 i = 0; i < 4; i++) + for (auto &laserTailTexture : laserTailTextures) { - laserTailTextures[i]->SetMipmaps(true); - laserTailTextures[i]->SetFilter(true, true, 16.0f); - laserTailTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp); + laserTailTexture->SetMipmaps(true); + laserTailTexture->SetFilter(true, true, 16.0f); + laserTailTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp); } // Track and sprite material (all transparent) @@ -255,11 +220,42 @@ bool Track::AsyncFinalize() whiteTexture = TextureRes::Create(g_gl); whiteTexture->SetData({ 1,1 }, (void*)whiteData); - timedHitEffect = new TimedHitEffect(false); timedHitEffect->time = 0; timedHitEffect->track = this; + g_input.OnButtonReleased.Add(this, &Track::OnButtonReleased); + + bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects); + + for (int i = 0; i < 6; ++i) + { + ButtonHitEffect& bfx = m_buttonHitEffects[i]; + if (delayedHitEffects) + { + if (i < 4) + { + bfx.delayFadeDuration = BT_DELAY_FADE_DURATION; + bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION; + bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed + } + else + { + bfx.delayFadeDuration = FX_DELAY_FADE_DURATION; + bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION; + bfx.alphaScale = 0.45f; + } + } + else + { + bfx.delayFadeDuration = 0; + bfx.hitEffectDuration = 7 / 60.f; + bfx.alphaScale = 1; + } + bfx.buttonCode = i; + bfx.track = this; + } + return success; } void Track::Tick(class BeatmapPlayback& playback, float deltaTime) From 11f9e736c26d731cfda9ef26e527377879d77cba Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Sun, 18 Apr 2021 01:26:20 +1000 Subject: [PATCH 5/6] Fix hit effects not working properly in practice mode --- Main/src/Game.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Main/src/Game.cpp b/Main/src/Game.cpp index 04aa55657..95f64cc93 100755 --- a/Main/src/Game.cpp +++ b/Main/src/Game.cpp @@ -2583,6 +2583,9 @@ class Game_Impl : public Game m_isPracticeSetup = true; m_scoring.autoplayInfo.autoplay = true; + m_track->hitEffectAutoplay = true; + m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased); + m_playOptions.range = { 0, 0 }; m_playOnDialogClose = true; @@ -2619,6 +2622,9 @@ class Game_Impl : public Game m_isPracticeSetup = false; m_scoring.autoplayInfo.autoplay = false; + m_track->hitEffectAutoplay = false; + m_scoring.OnHoldLeave.Remove(m_track, &Track::OnButtonReleased); + m_paused = false; m_triggerPause = false; From 5d229eb53f35c8a7186abd94a483014b31a30527 Mon Sep 17 00:00:00 2001 From: ASleepyCat Date: Tue, 20 Apr 2021 18:37:49 +1000 Subject: [PATCH 6/6] Update console offset value --- bin/skins/Default/scripts/gameplay.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/skins/Default/scripts/gameplay.lua b/bin/skins/Default/scripts/gameplay.lua index e1dfd3696..5d56803fa 100644 --- a/bin/skins/Default/scripts/gameplay.lua +++ b/bin/skins/Default/scripts/gameplay.lua @@ -462,7 +462,7 @@ end -- Utility function which returns the magnitude of an offset to center the -- -- console on the screen based on its position and rotation. -- function GetConsoleCenteringOffset() - return resx / 2 - gameplay.critLine.x + return (resx / 2 - gameplay.critLine.x) * (5 / 6) end -- -------------------------------------------------------------------------- -- -- render_crit_base: -- @@ -607,7 +607,7 @@ function render_crit_overlay(deltaTime) if portrait then -- We're going to make temporary modifications to the transform gfx.Save() - gfx.Translate(xOffset * 0.85, 0) + gfx.Translate(xOffset, 0) local bfw, bfh = gfx.ImageSize(bottomFill)