mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Rewrite input drum measurements to autosize on X axis
This commit is contained in:
@ -20,20 +20,22 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class LegacyInputDrum : Container
|
internal class LegacyInputDrum : Container
|
||||||
{
|
{
|
||||||
|
private Container content;
|
||||||
private LegacyHalfDrum left;
|
private LegacyHalfDrum left;
|
||||||
private LegacyHalfDrum right;
|
private LegacyHalfDrum right;
|
||||||
|
|
||||||
public LegacyInputDrum()
|
public LegacyInputDrum()
|
||||||
{
|
{
|
||||||
Size = new Vector2(180, 200);
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin)
|
private void load(ISkinSource skin)
|
||||||
{
|
{
|
||||||
Child = new Container
|
Child = content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Size = new Vector2(180, 200),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Sprite
|
new Sprite
|
||||||
@ -66,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
const float ratio = 1.6f;
|
const float ratio = 1.6f;
|
||||||
|
|
||||||
// because the right half is flipped, we need to position using width - position to get the true "topleft" origin position
|
// because the right half is flipped, we need to position using width - position to get the true "topleft" origin position
|
||||||
float negativeScaleAdjust = Width / ratio;
|
float negativeScaleAdjust = content.Width / ratio;
|
||||||
|
|
||||||
if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
||||||
{
|
{
|
||||||
@ -90,7 +92,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
|
|
||||||
// Relying on RelativeSizeAxes.Both + FillMode.Fit doesn't work due to the precise pixel layout requirements.
|
// Relying on RelativeSizeAxes.Both + FillMode.Fit doesn't work due to the precise pixel layout requirements.
|
||||||
// This is a bit ugly but makes the non-legacy implementations a lot cleaner to implement.
|
// This is a bit ugly but makes the non-legacy implementations a lot cleaner to implement.
|
||||||
Scale = new Vector2(Parent.DrawHeight / Size.Y);
|
content.Scale = new Vector2(DrawHeight / content.Size.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -24,8 +25,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
private const float middle_split = 0.025f;
|
private const float middle_split = 0.025f;
|
||||||
|
|
||||||
public SkinnableDrawable Skinnable { get; private set; }
|
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private DrumSampleTriggerSource sampleTriggerSource;
|
private DrumSampleTriggerSource sampleTriggerSource;
|
||||||
|
|
||||||
@ -33,7 +32,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.X;
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -41,12 +41,32 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Skinnable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new Container
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
|
||||||
{
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
},
|
||||||
|
sampleTriggerSource
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DefaultInputDrum : AspectContainer
|
||||||
|
{
|
||||||
|
public DefaultInputDrum()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
Scale = new Vector2(0.9f),
|
Scale = new Vector2(0.9f),
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new TaikoHalfDrum(false)
|
new TaikoHalfDrum(false)
|
||||||
{
|
{
|
||||||
@ -71,11 +91,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
CentreAction = TaikoAction.RightCentre
|
CentreAction = TaikoAction.RightCentre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
{
|
|
||||||
CentreComponent = false,
|
|
||||||
},
|
|
||||||
sampleTriggerSource
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,4 +217,5 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
||||||
|
inputDrum = new InputDrum(HitObjectContainer)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
||||||
@ -154,13 +161,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
drumRollHitContainer.CreateProxy(),
|
drumRollHitContainer.CreateProxy(),
|
||||||
inputDrum = new InputDrum(HitObjectContainer)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// to prioritise receiving key presses on input drum before objects, move input drum to the end of the hierarchy...
|
||||||
|
leftArea.Remove(inputDrum);
|
||||||
|
AddInternal(inputDrum);
|
||||||
|
|
||||||
|
// ...and create a proxy to keep the input drum displayed behind the playfield elements.
|
||||||
leftArea.Add(inputDrum.CreateProxy());
|
leftArea.Add(inputDrum.CreateProxy());
|
||||||
|
|
||||||
RegisterPool<Hit, DrawableHit>(50);
|
RegisterPool<Hit, DrawableHit>(50);
|
||||||
@ -207,8 +214,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
// Padding is required to be updated for elements which are based on "absolute" X sized elements.
|
// Padding is required to be updated for elements which are based on "absolute" X sized elements.
|
||||||
// This is basically allowing for correct alignment as relative pieces move around them.
|
// This is basically allowing for correct alignment as relative pieces move around them.
|
||||||
var inputDrumSize = inputDrum.Skinnable.Drawable.ToSpaceOfOtherDrawable(inputDrum.Skinnable.Drawable.DrawSize, this);
|
rightArea.Padding = new MarginPadding { Left = inputDrum.Width };
|
||||||
rightArea.Padding = new MarginPadding { Left = inputDrumSize.X };
|
|
||||||
playfieldContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
playfieldContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||||
playfieldOverlay.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
playfieldOverlay.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user