mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00: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.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class ApproachCircle : Container
|
||||
{
|
||||
private readonly Sprite approachCircle;
|
||||
|
||||
public ApproachCircle()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
approachCircle = new Sprite()
|
||||
};
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
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
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Skinning;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class CirclePiece : Container, IKeyBindingHandler<OsuAction>
|
||||
{
|
||||
private readonly Sprite disc;
|
||||
|
||||
public Func<bool> Hit;
|
||||
|
||||
public CirclePiece()
|
||||
@ -27,26 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
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");
|
||||
InternalChild = new SkinnableDrawable("Play/osu/hitcircle", _ => new DefaultCirclePiece());
|
||||
}
|
||||
|
||||
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.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class GlowPiece : Container
|
||||
{
|
||||
private readonly Sprite layer;
|
||||
|
||||
public GlowPiece()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
layer = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Blending = BlendingMode.Additive,
|
||||
Alpha = 0.5f
|
||||
}
|
||||
};
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
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 OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CircularContainer
|
||||
new SkinnableDrawable("Play/osu/number-glow", name => new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
Origin = Anchor.Centre,
|
||||
@ -38,11 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
Radius = 60,
|
||||
Colour = Color4.White.Opacity(0.5f),
|
||||
},
|
||||
Children = new[]
|
||||
{
|
||||
new Box()
|
||||
}
|
||||
},
|
||||
Child = new Box()
|
||||
}, false),
|
||||
number = new OsuSpriteText
|
||||
{
|
||||
Text = @"1",
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
@ -15,24 +16,26 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
Size = new Vector2(128);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = Size.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
BorderThickness = 10;
|
||||
BorderColour = Color4.White;
|
||||
|
||||
Children = new Drawable[]
|
||||
InternalChild = new SkinnableDrawable("Play/osu/hitcircleoverlay", _ => new Container
|
||||
{
|
||||
new Box
|
||||
Masking = true,
|
||||
CornerRadius = Size.X / 2,
|
||||
BorderThickness = 10,
|
||||
BorderColour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
new Box
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@
|
||||
<Compile Include="Objects\Drawables\IRequireTracking.cs" />
|
||||
<Compile Include="Objects\Drawables\ITrackSnaking.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\CirclePiece.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\SkinInfo.cs" />
|
||||
<Compile Include="Skinning\SkinManager.cs" />
|
||||
<Compile Include="Skinning\SkinnableDrawable.cs" />
|
||||
<Compile Include="Skinning\SkinStore.cs" />
|
||||
<Compile Include="Storyboards\CommandLoop.cs" />
|
||||
<Compile Include="Storyboards\CommandTimeline.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user