Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into timing
  • Loading branch information
ASleepyCat committed Apr 23, 2021
2 parents abc0a34 + b72ae68 commit 0376ba8
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 70 deletions.
3 changes: 1 addition & 2 deletions Main/include/Scoring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -347,4 +347,3 @@ class Scoring : public Unique
// shall be put on the score screen.
Vector<class Gauge*> m_gaugeStack;
};

8 changes: 4 additions & 4 deletions Main/include/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions Main/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextureRes>();
Expand Down Expand Up @@ -2584,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;

Expand Down Expand Up @@ -2620,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;

Expand Down
5 changes: 3 additions & 2 deletions Main/src/Scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
98 changes: 47 additions & 51 deletions Main/src/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down Expand Up @@ -131,6 +95,7 @@ bool Track::AsyncLoad()

return loader->Load();
}

bool Track::AsyncFinalize()
{
// Finalizer loading textures/material/etc.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions bin/skins/Default/scripts/gameplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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) * (5 / 6)
end
-- -------------------------------------------------------------------------- --
-- render_crit_base: --
-- Called after rendering the highway and playable objects, but before --
-- the built-in hit effects. --
Expand Down Expand Up @@ -594,13 +601,13 @@ 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
-- 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)

Expand Down

0 comments on commit 0376ba8

Please sign in to comment.