Skip to content

Commit

Permalink
show hitline in skin editor
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Jun 29, 2024
1 parent 99fe7ac commit d445e7b
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions fluXis.Game/Screens/Skinning/SkinEditorPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ public partial class SkinEditorPlayfield : Container
public int KeyMode { get; set; }

private Container stageContainer;
private Drawable hitline;
private FillFlowContainer receptorContainer;
private Container hitObjectContainer;

[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
Masking = true;
RelativeSizeAxes = Axes.Y;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

addContent();
}
Expand All @@ -37,7 +39,7 @@ private void addContent()
{
stageContainer = new Container
{
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
Expand All @@ -49,17 +51,22 @@ private void addContent()
},
receptorContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre
},
hitObjectContainer = new Container
{
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
},
hitline = SkinManager.GetHitLine().With(line =>
{
line.Width = 1;
line.RelativeSizeAxes = Axes.X;
})
};

for (int i = 0; i < KeyMode; i++)
Expand All @@ -77,10 +84,10 @@ private void addContent()

protected override void Update()
{
var width = SkinJson.GetKeymode(KeyMode).ColumnWidth * KeyMode;
stageContainer.Width = width;
receptorContainer.Width = width;
hitObjectContainer.Width = width;
Width = SkinJson.GetKeymode(KeyMode).ColumnWidth * KeyMode;

var hitpos = SkinJson.GetKeymode(KeyMode).HitPosition;
hitline.Y = -hitpos;

foreach (var drawable in hitObjectContainer)
{
Expand All @@ -90,7 +97,7 @@ protected override void Update()
drawable.X = index * SkinJson.GetKeymode(KeyMode).ColumnWidth;

float time = index * 100;
drawable.Y = -SkinJson.GetKeymode(KeyMode).HitPosition - .5f * (time * 3);
drawable.Y = -hitpos - .5f * (time * 3);
}
}
}

0 comments on commit d445e7b

Please sign in to comment.