Files

54 lines
1.3 KiB
C#
Raw Permalink Normal View History

using Microsoft.VisualBasic.CompilerServices;
2023-09-16 00:40:36 -07:00
using Godot;
using WacK.Data.Chart;
namespace WacK.Things.TunnelObjects
{
public partial class THNotePlay : Control
{
2023-09-29 17:58:32 -07:00
[Export]
private NinePatchRect noteBase;
2023-09-16 00:40:36 -07:00
public NotePlay noteData;
public void Init(NotePlay noteData)
2023-09-16 00:40:36 -07:00
{
this.noteData = noteData;
2023-10-09 01:22:41 -07:00
SetPosSize((int)noteData.pos, (int)noteData.size);
2023-09-16 00:40:36 -07:00
}
2023-10-09 01:22:41 -07:00
public void SetPosSize(int pos, int size)
2023-09-16 00:40:36 -07:00
{
var (posPx, sizePx) = Util.PixelizeNote(pos, size);
if (size >= 60)
2023-09-17 23:51:50 -07:00
{
size = 60;
2023-09-29 17:58:32 -07:00
noteBase.RegionRect = new Rect2(12, 0, new Vector2(488, 36));
noteBase.PatchMarginLeft = 0;
noteBase.PatchMarginRight = 0;
2023-09-17 23:51:50 -07:00
}
2023-10-09 01:22:41 -07:00
var nPos = noteBase.Position;
nPos.X = posPx;
noteBase.SetDeferred("position", nPos);
2023-09-16 00:40:36 -07:00
2023-10-09 01:22:41 -07:00
var nSize = noteBase.Size;
nSize.X = sizePx;
noteBase.SetDeferred("size", nSize);
2023-10-09 01:22:41 -07:00
2023-10-11 02:57:24 -07:00
// handle swipe arrow
2023-10-09 01:22:41 -07:00
if (noteData.type == NotePlayType.SwipeCW || noteData.type == NotePlayType.SwipeCCW)
{
var n = (SwipeArrow) FindChild("SwipeArrow");
2023-10-11 02:57:24 -07:00
n.CallDeferred("Init", pos, size, noteData.type == NotePlayType.SwipeCW);
2023-10-11 02:47:31 -07:00
}
2023-10-11 02:57:24 -07:00
// handle snap arrow
2023-10-11 02:47:31 -07:00
if (noteData.type == NotePlayType.SnapIn || noteData.type == NotePlayType.SnapOut)
{
var n = (SnapArrows)FindChild("SnapArrows");
n.CallDeferred("Init", pos, size, noteData.type == NotePlayType.SnapIn);
2023-10-09 01:22:41 -07:00
}
2023-09-16 00:40:36 -07:00
}
}
}