Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Implementation #43

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Ignore Visual Studio temporary files, build results, and
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
Expand Down Expand Up @@ -327,4 +327,4 @@ ASALocalRun/
*.nvuser

# MFractors (Xamarin productivity tool) working folder
.mfractor/
.mfractor/
15 changes: 15 additions & 0 deletions osu.Game.Rulesets.tau.Tests/TestSceneTauEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using osu.Game.Tests.Visual;
using System;
using System.Collections.Generic;
using System.Text;

namespace osu.Game.Rulesets.Tau.Tests
{
public class TestSceneTauEditor : EditorTestScene
{
public TestSceneTauEditor()
: base(new TauRuleset())
{
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.tau/Beatmaps/tauBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected override IEnumerable<TauHitObject> ConvertHitObject(HitObject original
{
Samples = original is IHasCurve ? ((IHasCurve)original).NodeSamples[0] : original.Samples,
StartTime = original.StartTime,
PositionToEnd = position,
Position = position,
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
}.Yield();
Expand Down
19 changes: 19 additions & 0 deletions osu.Game.Rulesets.tau/Edit/Blueprints/BlueprintPiece.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Tau.Objects;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints
{
/// <summary>
/// A piece of a selection or placement blueprint which visualises an <see cref="BlueprintPiece"/>.
/// </summary>
/// <typeparam name="T">The type of <see cref="BlueprintPiece"/> which this <see cref="BlueprintPiece{T}"/> visualises.</typeparam>
public abstract class BlueprintPiece<T> : CompositeDrawable
where T : TauHitObject
{
/// <summary>
/// Updates this <see cref="BlueprintPiece{T}"/> using the properties of a <see cref="BlueprintPiece"/>.
/// </summary>
/// <param name="hitObject">The <see cref="BlueprintPiece"/> to reference properties from.</param>
public virtual void UpdateFrom(T hitObject) => Position = hitObject.Position;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using osu.Game.Rulesets.Tau.Objects;
using osuTK;
using osu.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Game.Rulesets.Tau.Objects.Drawables.Pieces;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints.Tap.Components
{
public class TauHitPiece : BlueprintPiece<TauHitObject>
{
public TauHitPiece()
{
Origin = Anchor.Centre;

Size = new Vector2(TauHitObject.SIZE);

CornerRadius = Size.X / 2;
CornerExponent = 2;

InternalChild = new SquarePiece();
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Yellow;
}

public override void UpdateFrom(TauHitObject hitObject)
{
base.UpdateFrom(hitObject);

Scale = new Vector2(TauHitObject.SIZE);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Tau.Edit.Blueprints.Tap.Components;
using osu.Game.Rulesets.Tau.Objects;
using osuTK;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints.Tap
{
public class TauHitObjectPlacementBlueprint : PlacementBlueprint
{
public new TauHitObject TauHit => (TauHitObject)HitObject;

private readonly TauHitPiece hitPiece;

//TODO: All instances of TauHitObject needs to be changed to the BeatObject once HitObject is abstracted.
public TauHitObjectPlacementBlueprint()
: base(new TauHitObject())
{
InternalChild = hitPiece = new TauHitPiece();
}

protected override void Update()
{
base.Update();

hitPiece.UpdateFrom(TauHit);
}

protected override bool OnClick(ClickEvent e)
{
EndPlacement(true);
return true;
}

public override void UpdatePosition(Vector2 screenSpacePosition)
{
BeginPlacement();
TauHit.Position = ToLocalSpace(screenSpacePosition); // Need to fix this up
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Tau.Edit.Blueprints.Tap.Components;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osuTK;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints.Tap
{
public class TauHitObjectSelectionBlueprint : TauSelectionBlueprint<TauHitObject>
{
protected new DrawabletauHitObject DrawableObject => (DrawabletauHitObject) base.DrawableObject;

protected readonly TauHitPiece TauHitPiece;

public TauHitObjectSelectionBlueprint(DrawabletauHitObject drawabletauHit)
: base(drawabletauHit)
{
InternalChild = TauHitPiece = new TauHitPiece();
}

protected override void Update()
{
base.Update();

TauHitPiece.UpdateFrom(HitObject);
}

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);

public override Quad SelectionQuad => DrawableObject.ScreenSpaceDrawQuad;
}
}
30 changes: 30 additions & 0 deletions osu.Game.Rulesets.tau/Edit/Blueprints/TauBlueprintContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Screens.Edit.Compose.Components;
using System.Collections.Generic;
using osu.Game.Rulesets.Tau.Edit.Blueprints.Tap;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints
{
public class TauBlueprintContainer : ComposeBlueprintContainer
{
public TauBlueprintContainer(IEnumerable<DrawableHitObject> drawableHitObjects)
: base(drawableHitObjects)
{
}

protected override SelectionHandler CreateSelectionHandler() => new TauSelectionHandler();

public override OverlaySelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
{
switch (hitObject)
{
case DrawabletauHitObject tap:
return new TauHitObjectSelectionBlueprint(tap);
}

return base.CreateBlueprintFor(hitObject);
}
}
}
20 changes: 20 additions & 0 deletions osu.Game.Rulesets.tau/Edit/Blueprints/TauSelectionBlueprint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using System;
using System.Collections.Generic;
using System.Text;

namespace osu.Game.Rulesets.Tau.Edit.Blueprints
{
public abstract class TauSelectionBlueprint<T> : OverlaySelectionBlueprint
where T : TauHitObject
{
protected new T HitObject => (T) DrawableObject.HitObject;

protected TauSelectionBlueprint(DrawabletauHitObject drawableObject)
: base(drawableObject)
{
}
}
}
85 changes: 85 additions & 0 deletions osu.Game.Rulesets.tau/Edit/DrawableTauEditRuleset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Lines;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Rulesets.Tau.UI;
using osu.Game.Rulesets.UI;
using osuTK.Input;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace osu.Game.Rulesets.Tau.Edit
{
public class DrawableTauEditRuleset : DrawabletauRuleset
{
/// <summary>
/// Hit objects are intentionally made to fade out at a constant slower rate than in gameplay.
/// This allows a mapper to gain better historical context and use recent hitobjects as reference / snap points.
/// </summary>
private const double editor_hit_object_fade_out_extension = 500;

public DrawableTauEditRuleset(TauRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods)
{
}

public override DrawableHitObject<TauHitObject> CreateDrawableRepresentation(TauHitObject h)
=> base.CreateDrawableRepresentation(h)?.With(d => d.ApplyCustomUpdateState += updateState);

private void updateState(DrawableHitObject hitObject, ArmedState state)
{
switch (state)
{
case ArmedState.Miss:
// Get the existing fade out transform
var existing = hitObject.Transforms.LastOrDefault(t => t.TargetMember == nameof(Alpha));
if (existing == null)
return;

hitObject.RemoveTransform(existing);

using (hitObject.BeginAbsoluteSequence(existing.StartTime))
hitObject.FadeOut(editor_hit_object_fade_out_extension).Expire();
break;
}
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.ControlPressed & e.PressedKeys.Contains(Key.S))
{
//Save in temp file for now
string directory = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "@osu");

Directory.CreateDirectory(directory);
var path = System.IO.Path.Combine(directory, "tau.osu");

//using (var sw = new StreamWriter(path))
//{
// var encoder = new TauLegacyBeatmapEncoder();
// sw.WriteLine(encoder.Encode(new Beatmap
// {
// HitObjects = Beatmap.HitObjects.OfType<HitObject>().ToList()
// }));
//}
return true;
}
return base.OnKeyDown(e);
}

protected override Playfield CreatePlayfield() => new TauPlayfieldNoCursor();
public class TauPlayfieldNoCursor : TauPlayfield
{
protected override GameplayCursorContainer CreateCursor() => null;
public override bool ShowVisualizer => false;
}
}
}
39 changes: 39 additions & 0 deletions osu.Game.Rulesets.tau/Edit/TauHitObjectComposer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Tau.Edit.Blueprints;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Compose.Components;
using System.Collections.Generic;
using osu.Game.Rulesets.Tau.Edit.Tools.Big;
using osu.Game.Rulesets.Tau.Edit.Tools.Hard;
using osu.Game.Rulesets.Tau.Edit.Tools.Roll;
using osu.Game.Rulesets.Tau.Edit.Tools.Slider;
using osu.Game.Rulesets.Tau.Edit.Tools.Tap;

namespace osu.Game.Rulesets.Tau.Edit
{
public class TauHitObjectComposer : HitObjectComposer<TauHitObject>
{
public TauHitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
}

protected override DrawableRuleset<TauHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
=> new DrawableTauEditRuleset((TauRuleset)ruleset, beatmap, mods);

protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
{
new TauHitBeatCompositionTool(),
new TauSliderCompositionTool(),
new TauHardBeatCompositionTool(),
new TauBigBeatCompositionTool(),
new TauRollBeatCompositionTool(),
};

protected override ComposeBlueprintContainer CreateBlueprintContainer() => new TauBlueprintContainer(HitObjects);
}
}
11 changes: 11 additions & 0 deletions osu.Game.Rulesets.tau/Edit/TauSelectionHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using osu.Game.Screens.Edit.Compose.Components;
using System;
using System.Collections.Generic;
using System.Text;

namespace osu.Game.Rulesets.Tau.Edit
{
public class TauSelectionHandler : SelectionHandler
{
}
}
17 changes: 17 additions & 0 deletions osu.Game.Rulesets.tau/Edit/Tools/Big/TauBigBeatCompositionTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Tau.Edit.Blueprints.Tap;

namespace osu.Game.Rulesets.Tau.Edit.Tools.Big
{
public class TauBigBeatCompositionTool : HitObjectCompositionTool
{
public TauBigBeatCompositionTool()
: base("Big Beat")
{
}

//TODO: Change blueprint once Big Beats are implemented.
public override PlacementBlueprint CreatePlacementBlueprint() => new TauHitObjectPlacementBlueprint();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Tau.Edit.Blueprints.Tap;

namespace osu.Game.Rulesets.Tau.Edit.Tools.Hard
{
public class TauHardBeatCompositionTool : HitObjectCompositionTool
{
public TauHardBeatCompositionTool()
: base("Hard Beat")
{
}

//TODO: Change blueprint once Hard Beats are implemented.
public override PlacementBlueprint CreatePlacementBlueprint() => new TauHitObjectPlacementBlueprint();
}
}
Loading