mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 00:02:56 +08:00
Add basic hitcircle skinning
This commit is contained in:
parent
3726db53b5
commit
84b707f4f8
@ -6,30 +6,24 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
public class ApproachCircle : Container
|
public class ApproachCircle : Container
|
||||||
{
|
{
|
||||||
private readonly Sprite approachCircle;
|
|
||||||
|
|
||||||
public ApproachCircle()
|
public ApproachCircle()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
approachCircle = new Sprite()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
approachCircle.Texture = textures.Get(@"Play/osu/approachcircle");
|
Child = new SkinnableDrawable("Play/osu/approachcircle", name => new Sprite { Texture = textures.Get(name) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,16 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
public class CirclePiece : Container, IKeyBindingHandler<OsuAction>
|
public class CirclePiece : Container, IKeyBindingHandler<OsuAction>
|
||||||
{
|
{
|
||||||
private readonly Sprite disc;
|
|
||||||
|
|
||||||
public Func<bool> Hit;
|
public Func<bool> Hit;
|
||||||
|
|
||||||
public CirclePiece()
|
public CirclePiece()
|
||||||
@ -27,26 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
Children = new Drawable[]
|
InternalChild = new SkinnableDrawable("Play/osu/hitcircle", _ => new DefaultCirclePiece());
|
||||||
{
|
|
||||||
disc = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre
|
|
||||||
},
|
|
||||||
new TrianglesPiece
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Blending = BlendingMode.Additive,
|
|
||||||
Alpha = 0.5f,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(TextureStore textures)
|
|
||||||
{
|
|
||||||
disc.Texture = textures.Get(@"Play/osu/disc");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(OsuAction action)
|
public bool OnPressed(OsuAction action)
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
|
{
|
||||||
|
public class DefaultCirclePiece : Container
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Sprite
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Texture = textures.Get(@"Play/osu/disc"),
|
||||||
|
},
|
||||||
|
new TrianglesPiece
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Blending = BlendingMode.Additive,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,34 +6,30 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
public class GlowPiece : Container
|
public class GlowPiece : Container
|
||||||
{
|
{
|
||||||
private readonly Sprite layer;
|
|
||||||
|
|
||||||
public GlowPiece()
|
public GlowPiece()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
layer = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Blending = BlendingMode.Additive,
|
|
||||||
Alpha = 0.5f
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
layer.Texture = textures.Get(@"Play/osu/ring-glow");
|
Child = new SkinnableDrawable("Play/osu/ring-glow", name => new Sprite
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Texture = textures.Get(name),
|
||||||
|
Blending = BlendingMode.Additive,
|
||||||
|
Alpha = 0.5f
|
||||||
|
}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new CircularContainer
|
new SkinnableDrawable("Play/osu/number-glow", name => new CircularContainer
|
||||||
{
|
{
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -38,11 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Radius = 60,
|
Radius = 60,
|
||||||
Colour = Color4.White.Opacity(0.5f),
|
Colour = Color4.White.Opacity(0.5f),
|
||||||
},
|
},
|
||||||
Children = new[]
|
Child = new Box()
|
||||||
{
|
}, false),
|
||||||
new Box()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
number = new OsuSpriteText
|
number = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = @"1",
|
Text = @"1",
|
||||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
@ -15,24 +16,26 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
{
|
{
|
||||||
Size = new Vector2(128);
|
Size = new Vector2(128);
|
||||||
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = Size.X / 2;
|
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
BorderThickness = 10;
|
InternalChild = new SkinnableDrawable("Play/osu/hitcircleoverlay", _ => new Container
|
||||||
BorderColour = Color4.White;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new Box
|
Masking = true,
|
||||||
|
CornerRadius = Size.X / 2,
|
||||||
|
BorderThickness = 10,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
AlwaysPresent = true,
|
new Box
|
||||||
Alpha = 0,
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
AlwaysPresent = true,
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
<Compile Include="Objects\Drawables\IRequireTracking.cs" />
|
<Compile Include="Objects\Drawables\IRequireTracking.cs" />
|
||||||
<Compile Include="Objects\Drawables\ITrackSnaking.cs" />
|
<Compile Include="Objects\Drawables\ITrackSnaking.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
|
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
|
||||||
|
<Compile Include="Objects\Drawables\Pieces\DefaultCirclePiece.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SpinnerBackground.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SpinnerBackground.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
|
<Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
|
||||||
<Compile Include="Objects\Drawables\DrawableSlider.cs" />
|
<Compile Include="Objects\Drawables\DrawableSlider.cs" />
|
||||||
|
58
osu.Game/Skinning/SkinnableDrawable.cs
Normal file
58
osu.Game/Skinning/SkinnableDrawable.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public class SkinnableDrawable : SkinnableDrawable<Drawable>
|
||||||
|
{
|
||||||
|
public SkinnableDrawable(string name, Func<string, Drawable> defaultImplementation, bool fallback = true)
|
||||||
|
: base(name, defaultImplementation, fallback)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SkinnableDrawable<T> : CompositeDrawable
|
||||||
|
where T : Drawable
|
||||||
|
{
|
||||||
|
private Bindable<Skin> skin;
|
||||||
|
protected Func<string, T> CreateDefault;
|
||||||
|
|
||||||
|
public string ComponentName { get; set; }
|
||||||
|
|
||||||
|
public readonly bool DefaultFallback;
|
||||||
|
|
||||||
|
public SkinnableDrawable(string name, Func<string, T> defaultImplementation, bool fallback = true)
|
||||||
|
{
|
||||||
|
DefaultFallback = fallback;
|
||||||
|
ComponentName = name;
|
||||||
|
CreateDefault = defaultImplementation;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(SkinManager skinManager)
|
||||||
|
{
|
||||||
|
skin = skinManager.CurrentSkin.GetBoundCopy();
|
||||||
|
skin.ValueChanged += updateComponent;
|
||||||
|
skin.TriggerChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateComponent(Skin skin)
|
||||||
|
{
|
||||||
|
var drawable = skin.GetDrawableComponent(ComponentName);
|
||||||
|
if (drawable == null && (DefaultFallback || skin.SkinInfo == SkinInfo.Default))
|
||||||
|
drawable = CreateDefault(ComponentName);
|
||||||
|
|
||||||
|
if (drawable != null)
|
||||||
|
InternalChild = drawable;
|
||||||
|
else
|
||||||
|
ClearInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -860,6 +860,7 @@
|
|||||||
<Compile Include="Skinning\SkinFileInfo.cs" />
|
<Compile Include="Skinning\SkinFileInfo.cs" />
|
||||||
<Compile Include="Skinning\SkinInfo.cs" />
|
<Compile Include="Skinning\SkinInfo.cs" />
|
||||||
<Compile Include="Skinning\SkinManager.cs" />
|
<Compile Include="Skinning\SkinManager.cs" />
|
||||||
|
<Compile Include="Skinning\SkinnableDrawable.cs" />
|
||||||
<Compile Include="Skinning\SkinStore.cs" />
|
<Compile Include="Skinning\SkinStore.cs" />
|
||||||
<Compile Include="Storyboards\CommandLoop.cs" />
|
<Compile Include="Storyboards\CommandLoop.cs" />
|
||||||
<Compile Include="Storyboards\CommandTimeline.cs" />
|
<Compile Include="Storyboards\CommandTimeline.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user