Skip to content

Commit

Permalink
Add more comprehensive inline comment
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 7, 2022
1 parent d63f196 commit e1e12f4
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions osu.Game.Rulesets.Mania/UI/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ public Column(int index, bool isSpecial)
[BackgroundDependencyLoader]
private void load(GameHost host)
{
SkinnableDrawable keyArea;

skin.SourceChanged += onSourceChanged;
onSourceChanged();

Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{
RelativeSizeAxes = Axes.Both,
// This is pretty dodgy (and will cause weirdness when pausing gameplay) but is better than completely broken rewind.
Clock = host.UpdateThread.Clock,
ProcessCustomClock = false,
};

InternalChildren = new[]
Expand All @@ -89,25 +88,37 @@ private void load(GameHost host)
// For input purposes, the background is added at the highest depth, but is then proxied back below all other elements
background.CreateProxy(),
HitObjectArea,
new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
keyArea = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.KeyArea), _ => new DefaultKeyArea())
{
RelativeSizeAxes = Axes.Both,
// This is pretty dodgy (and will cause weirdness when pausing gameplay) but is better than completely broken rewind.
Clock = host.UpdateThread.Clock,
ProcessCustomClock = false,
},
background,
TopLevelContainer,
new ColumnTouchInputArea(this)
};

applyGameWideClock(background);
applyGameWideClock(keyArea);

TopLevelContainer.Add(HitObjectArea.Explosions.CreateProxy());

RegisterPool<Note, DrawableNote>(10, 50);
RegisterPool<HoldNote, DrawableHoldNote>(10, 50);
RegisterPool<HeadNote, DrawableHoldNoteHead>(10, 50);
RegisterPool<TailNote, DrawableHoldNoteTail>(10, 50);
RegisterPool<HoldNoteTick, DrawableHoldNoteTick>(50, 250);

// Some elements don't handle rewind correctly and fixing them is non-trivial.
// In the future we need a better solution to this, but as a temporary work-around, give these components the game-wide
// clock so they don't need to worry about rewind.
// This only works because they handle OnPressed/OnReleased which results in a correct state while rewinding.
//
// This is kinda dodgy (and will cause weirdness when pausing gameplay) but is better than completely broken rewind.
void applyGameWideClock(Drawable drawable)
{
drawable.Clock = host.UpdateThread.Clock;
drawable.ProcessCustomClock = false;
}
}

private void onSourceChanged()
Expand Down

0 comments on commit e1e12f4

Please sign in to comment.