2023-10-09 21:52:23 -07:00
|
|
|
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;
|
|
|
|
|
|
2023-10-09 20:58:33 -07:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// handle swipe arrow color
|
|
|
|
|
if (noteData.type == NotePlayType.SwipeCW)
|
|
|
|
|
{
|
|
|
|
|
var n = (SwipeArrow) FindChild("SwipeArrow");
|
2023-10-11 02:47:31 -07:00
|
|
|
// n.SetCW(noteData.type == NotePlayType.SwipeCW);
|
|
|
|
|
n.CallDeferred("SetCW", noteData.type == NotePlayType.SwipeCW);
|
2023-10-09 01:22:41 -07:00
|
|
|
}
|
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
|
|
|
{
|
2023-10-09 21:52:23 -07:00
|
|
|
var (posPx, sizePx) = Util.PixelizeNote(pos, size);
|
2023-10-09 20:58:33 -07:00
|
|
|
|
2023-10-09 21:52:23 -07:00
|
|
|
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-09-17 23:09:19 -07:00
|
|
|
|
2023-10-09 01:22:41 -07:00
|
|
|
var nPos = noteBase.Position;
|
2023-10-09 20:58:33 -07:00
|
|
|
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;
|
2023-10-09 20:58:33 -07:00
|
|
|
nSize.X = sizePx;
|
|
|
|
|
noteBase.SetDeferred("size", nSize);
|
2023-10-09 01:22:41 -07:00
|
|
|
|
2023-10-11 02:47:31 -07:00
|
|
|
// handle swipe arrow pos & size
|
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:47:31 -07:00
|
|
|
// n.SetPosSize(pos, size);
|
|
|
|
|
n.CallDeferred("SetPosSize", pos, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// handle snap arrow pos & size
|
|
|
|
|
if (noteData.type == NotePlayType.SnapIn || noteData.type == NotePlayType.SnapOut)
|
|
|
|
|
{
|
|
|
|
|
var n = (SnapArrows)FindChild("SnapArrows");
|
|
|
|
|
// n.SetPosSize(pos, size);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|