Skip to content

Commit

Permalink
Refactor syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudicito committed Sep 24, 2024
1 parent 9c2cbbd commit eccc759
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 154 deletions.
31 changes: 15 additions & 16 deletions osu.Game.Rulesets.Gitaroo/Beatmaps/GitarooBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Gitaroo.Objects;

namespace osu.Game.Rulesets.Gitaroo.Beatmaps
namespace osu.Game.Rulesets.Gitaroo.Beatmaps;

public class GitarooBeatmapConverter : BeatmapConverter<GitarooHitObject>
{
public class GitarooBeatmapConverter : BeatmapConverter<GitarooHitObject>
public GitarooBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
: base(beatmap, ruleset)
{
public GitarooBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
: base(beatmap, ruleset)
{
}
}

// todo: Check for conversion types that should be supported (ie. Beatmap.HitObjects.Any(h => h is IHasXPosition))
// https://github.com/ppy/osu/tree/master/osu.Game/Rulesets/Objects/Types
public override bool CanConvert() => true;
// todo: Check for conversion types that should be supported (ie. Beatmap.HitObjects.Any(h => h is IHasXPosition))
// https://github.com/ppy/osu/tree/master/osu.Game/Rulesets/Objects/Types
public override bool CanConvert() => true;

protected override IEnumerable<GitarooHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken)
protected override IEnumerable<GitarooHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken)
{
yield return new GitarooHitObject
{
yield return new GitarooHitObject
{
Samples = original.Samples,
StartTime = original.StartTime,
};
}
Samples = original.Samples,
StartTime = original.StartTime,
};
}
}
25 changes: 12 additions & 13 deletions osu.Game.Rulesets.Gitaroo/GitarooDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;

namespace osu.Game.Rulesets.Gitaroo
namespace osu.Game.Rulesets.Gitaroo;

public class GitarooDifficultyCalculator : DifficultyCalculator
{
public class GitarooDifficultyCalculator : DifficultyCalculator
public GitarooDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
public GitarooDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
}
}

protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
return new DifficultyAttributes(mods, 0);
}
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
return new DifficultyAttributes(mods, 0);
}

protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) => Enumerable.Empty<DifficultyHitObject>();
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) => Enumerable.Empty<DifficultyHitObject>();

protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate) => Array.Empty<Skill>();
}
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate) => Array.Empty<Skill>();
}
25 changes: 12 additions & 13 deletions osu.Game.Rulesets.Gitaroo/GitarooInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Gitaroo
namespace osu.Game.Rulesets.Gitaroo;

public partial class GitarooInputManager : RulesetInputManager<GitarooAction>
{
public partial class GitarooInputManager : RulesetInputManager<GitarooAction>
public GitarooInputManager(RulesetInfo ruleset)
: base(ruleset, 0, SimultaneousBindingMode.Unique)
{
public GitarooInputManager(RulesetInfo ruleset)
: base(ruleset, 0, SimultaneousBindingMode.Unique)
{
}
}
}

public enum GitarooAction
{
[Description("Left button")]
LeftButton,
public enum GitarooAction
{
[Description("Left button")]
LeftButton,

[Description("Right button")]
RightButton,
}
[Description("Right button")]
RightButton,
}
11 changes: 5 additions & 6 deletions osu.Game.Rulesets.Gitaroo/Mods/GitarooModAutoplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
using osu.Game.Rulesets.Gitaroo.Replays;
using osu.Game.Rulesets.Mods;

namespace osu.Game.Rulesets.Gitaroo.Mods
namespace osu.Game.Rulesets.Gitaroo.Mods;

public class GitarooModAutoplay : ModAutoplay
{
public class GitarooModAutoplay : ModAutoplay
{
public override ModReplayData CreateReplayData(IBeatmap beatmap, IReadOnlyList<Mod> mods)
=> new ModReplayData(new GitarooAutoGenerator(beatmap).Generate(), new ModCreatedUser { Username = "sample" });
}
public override ModReplayData CreateReplayData(IBeatmap beatmap, IReadOnlyList<Mod> mods)
=> new ModReplayData(new GitarooAutoGenerator(beatmap).Generate(), new ModCreatedUser { Username = "sample" });
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,41 @@
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Gitaroo.Objects.Drawables
namespace osu.Game.Rulesets.Gitaroo.Objects.Drawables;

public partial class DrawableGitarooHitObject : DrawableHitObject<GitarooHitObject>
{
public partial class DrawableGitarooHitObject : DrawableHitObject<GitarooHitObject>
public DrawableGitarooHitObject(GitarooHitObject hitObject)
: base(hitObject)
{
public DrawableGitarooHitObject(GitarooHitObject hitObject)
: base(hitObject)
{
Size = new Vector2(40);
Origin = Anchor.Centre;
Size = new Vector2(40);
Origin = Anchor.Centre;

// todo: add visuals.
}
// todo: add visuals.
}

protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (timeOffset >= 0)
// todo: implement judgement logic
ApplyMaxResult();
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (timeOffset >= 0)
// todo: implement judgement logic
ApplyMaxResult();
}

protected override void UpdateHitStateTransforms(ArmedState state)
{
const double duration = 1000;
protected override void UpdateHitStateTransforms(ArmedState state)
{
const double duration = 1000;

switch (state)
{
case ArmedState.Hit:
this.FadeOut(duration, Easing.OutQuint).Expire();
break;
switch (state)
{
case ArmedState.Hit:
this.FadeOut(duration, Easing.OutQuint).Expire();
break;

case ArmedState.Miss:
case ArmedState.Miss:

this.FadeColour(Color4.Red, duration);
this.FadeOut(duration, Easing.InQuint).Expire();
break;
}
this.FadeColour(Color4.Red, duration);
this.FadeOut(duration, Easing.InQuint).Expire();
break;
}
}
}
11 changes: 5 additions & 6 deletions osu.Game.Rulesets.Gitaroo/Objects/GitarooHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Gitaroo.Objects
namespace osu.Game.Rulesets.Gitaroo.Objects;

public class GitarooHitObject : HitObject
{
public class GitarooHitObject : HitObject
{
public override Judgement CreateJudgement() => new GitarooJudgement();
public override Judgement CreateJudgement() => new GitarooJudgement();

protected override HitWindows CreateHitWindows() => new GitarooHitWindows();
}
protected override HitWindows CreateHitWindows() => new GitarooHitWindows();
}
33 changes: 16 additions & 17 deletions osu.Game.Rulesets.Gitaroo/Replays/GitarooAutoGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@
using osu.Game.Rulesets.Gitaroo.Objects;
using osu.Game.Rulesets.Replays;

namespace osu.Game.Rulesets.Gitaroo.Replays
namespace osu.Game.Rulesets.Gitaroo.Replays;

public class GitarooAutoGenerator : AutoGenerator<GitarooReplayFrame>
{
public class GitarooAutoGenerator : AutoGenerator<GitarooReplayFrame>
public new Beatmap<GitarooHitObject> Beatmap => (Beatmap<GitarooHitObject>)base.Beatmap;

public GitarooAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
public new Beatmap<GitarooHitObject> Beatmap => (Beatmap<GitarooHitObject>)base.Beatmap;
}

public GitarooAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
}
protected override void GenerateFrames()
{
Frames.Add(new GitarooReplayFrame());

protected override void GenerateFrames()
foreach (GitarooHitObject hitObject in Beatmap.HitObjects)
{
Frames.Add(new GitarooReplayFrame());

foreach (GitarooHitObject hitObject in Beatmap.HitObjects)
Frames.Add(new GitarooReplayFrame
{
Frames.Add(new GitarooReplayFrame
{
Time = hitObject.StartTime
// todo: add required inputs and extra frames.
});
}
Time = hitObject.StartTime
// todo: add required inputs and extra frames.
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;

namespace osu.Game.Rulesets.Gitaroo.Replays
namespace osu.Game.Rulesets.Gitaroo.Replays;

public class GitarooFramedReplayInputHandler : FramedReplayInputHandler<GitarooReplayFrame>
{
public class GitarooFramedReplayInputHandler : FramedReplayInputHandler<GitarooReplayFrame>
public GitarooFramedReplayInputHandler(Replay replay)
: base(replay)
{
public GitarooFramedReplayInputHandler(Replay replay)
: base(replay)
{
}
}

protected override bool IsImportant(GitarooReplayFrame frame) => frame.Actions.Any();
protected override bool IsImportant(GitarooReplayFrame frame) => frame.Actions.Any();

protected override void CollectReplayInputs(List<IInput> inputs)
protected override void CollectReplayInputs(List<IInput> inputs)
{
inputs.Add(new ReplayState<GitarooAction>
{
inputs.Add(new ReplayState<GitarooAction>
{
PressedActions = CurrentFrame?.Actions ?? new List<GitarooAction>(),
});
}
PressedActions = CurrentFrame?.Actions ?? new List<GitarooAction>(),
});
}
}
17 changes: 8 additions & 9 deletions osu.Game.Rulesets.Gitaroo/Replays/GitarooReplayFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
using System.Collections.Generic;
using osu.Game.Rulesets.Replays;

namespace osu.Game.Rulesets.Gitaroo.Replays
namespace osu.Game.Rulesets.Gitaroo.Replays;

public class GitarooReplayFrame : ReplayFrame
{
public class GitarooReplayFrame : ReplayFrame
{
public List<GitarooAction> Actions = new List<GitarooAction>();
public List<GitarooAction> Actions = new List<GitarooAction>();

public GitarooReplayFrame(GitarooAction? button = null)
{
if (button.HasValue)
Actions.Add(button.Value);
}
public GitarooReplayFrame(GitarooAction? button = null)
{
if (button.HasValue)
Actions.Add(button.Value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public CenterCircleContainer()
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

InternalChildren = new Container[]
{
InternalChildren =
[
new FanShaped(),
new CenterCircle()
};
];
}
}
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Gitaroo/UI/CenterCircle/FanShaped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public FanShaped()
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
InternalChildren = new[]
{
InternalChildren =
[
rotatingContainer = new Container
{
AutoSizeAxes = Axes.Both,
Expand Down Expand Up @@ -76,7 +76,7 @@ public FanShaped()
}
}
}
};
];
}

private float fan_shaped_get_x(float angle)
Expand Down
27 changes: 13 additions & 14 deletions osu.Game.Rulesets.Gitaroo/UI/DrawableGitarooRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;

namespace osu.Game.Rulesets.Gitaroo.UI
namespace osu.Game.Rulesets.Gitaroo.UI;

[Cached]
public partial class DrawableGitarooRuleset : DrawableScrollingRuleset<GitarooHitObject>
{
[Cached]
public partial class DrawableGitarooRuleset : DrawableScrollingRuleset<GitarooHitObject>
public DrawableGitarooRuleset(GitarooRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
{
public DrawableGitarooRuleset(GitarooRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
{
Direction.Value = ScrollingDirection.Left;
TimeRange.Value = 6000;
}
Direction.Value = ScrollingDirection.Left;
TimeRange.Value = 6000;
}

protected override Playfield CreatePlayfield() => new GitarooPlayfield();
protected override Playfield CreatePlayfield() => new GitarooPlayfield();

protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new GitarooFramedReplayInputHandler(replay);
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new GitarooFramedReplayInputHandler(replay);

public override DrawableHitObject<GitarooHitObject> CreateDrawableRepresentation(GitarooHitObject h) => new DrawableGitarooHitObject(h);
public override DrawableHitObject<GitarooHitObject> CreateDrawableRepresentation(GitarooHitObject h) => new DrawableGitarooHitObject(h);

protected override PassThroughInputManager CreateInputManager() => new GitarooInputManager(Ruleset?.RulesetInfo);
}
protected override PassThroughInputManager CreateInputManager() => new GitarooInputManager(Ruleset?.RulesetInfo);
}
Loading

0 comments on commit eccc759

Please sign in to comment.