diff --git a/Scenes/Play.tscn b/Scenes/Play.tscn index 92911a6..dc917f8 100644 --- a/Scenes/Play.tscn +++ b/Scenes/Play.tscn @@ -66,8 +66,9 @@ width = 2048 [sub_resource type="LabelSettings" id="LabelSettings_dj3ei"] font_size = 271 -[node name="Play" type="Node"] +[node name="Play" type="Node" node_paths=PackedStringArray("noteDisplay")] script = ExtResource("1_d6iv3") +noteDisplay = NodePath("SubViewportContainer/2D Viewport/Viewport Control/Notes") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_nefjb") @@ -113,7 +114,7 @@ msaa_2d = 1 size = Vector2i(1920, 1920) render_target_update_mode = 4 -[node name="Node2D" type="Control" parent="SubViewportContainer/2D Viewport"] +[node name="Viewport Control" type="Control" parent="SubViewportContainer/2D Viewport"] clip_contents = true layout_mode = 3 anchors_preset = 15 @@ -122,12 +123,12 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="Camera2D" type="Camera2D" parent="SubViewportContainer/2D Viewport/Node2D"] +[node name="Camera2D" type="Camera2D" parent="SubViewportContainer/2D Viewport/Viewport Control"] position = Vector2(0, -1920) anchor_mode = 0 enabled = false -[node name="Shadow" type="TextureRect" parent="SubViewportContainer/2D Viewport/Node2D"] +[node name="Shadow" type="TextureRect" parent="SubViewportContainer/2D Viewport/Viewport Control"] layout_mode = 2 offset_top = 1920.0 offset_right = 100.0 @@ -136,9 +137,9 @@ rotation = -1.5708 texture = SubResource("GradientTexture1D_vv2ac") expand_mode = 1 -[node name="HitLine_Reverse" type="Node2D" parent="SubViewportContainer/2D Viewport/Node2D"] +[node name="HitLine_Reverse" type="Node2D" parent="SubViewportContainer/2D Viewport/Viewport Control"] -[node name="Line" type="TextureRect" parent="SubViewportContainer/2D Viewport/Node2D/HitLine_Reverse"] +[node name="Line" type="TextureRect" parent="SubViewportContainer/2D Viewport/Viewport Control/HitLine_Reverse"] anchors_preset = 7 anchor_left = 0.5 anchor_top = 1.0 @@ -152,7 +153,7 @@ grow_vertical = 0 texture = ExtResource("2_kpt0a") expand_mode = 1 -[node name="Line2" type="TextureRect" parent="SubViewportContainer/2D Viewport/Node2D/HitLine_Reverse"] +[node name="Line2" type="TextureRect" parent="SubViewportContainer/2D Viewport/Viewport Control/HitLine_Reverse"] anchors_preset = 7 anchor_left = 0.5 anchor_top = 1.0 @@ -167,7 +168,7 @@ grow_vertical = 0 texture = ExtResource("2_kpt0a") expand_mode = 1 -[node name="Label" type="Label" parent="SubViewportContainer/2D Viewport/Node2D"] +[node name="Label" type="Label" parent="SubViewportContainer/2D Viewport/Viewport Control"] visible = false layout_mode = 1 anchors_preset = 2 @@ -188,10 +189,22 @@ label_settings = SubResource("LabelSettings_dj3ei") horizontal_alignment = 1 vertical_alignment = 2 -[node name="Notes" type="Node2D" parent="SubViewportContainer/2D Viewport/Node2D"] +[node name="Notes" type="Control" parent="SubViewportContainer/2D Viewport/Viewport Control"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +grow_vertical = 0 -[node name="NoteTouch" parent="SubViewportContainer/2D Viewport/Node2D/Notes" instance=ExtResource("3_qp71m")] -offset_left = 1500.0 -offset_top = 1800.0 -offset_right = 1690.0 -offset_bottom = 1824.0 +[node name="NoteTouch" parent="SubViewportContainer/2D Viewport/Viewport Control/Notes" instance=ExtResource("3_qp71m")] +visible = false +layout_mode = 1 +offset_left = 400.0 +offset_top = -120.0 +offset_right = 1100.0 +offset_bottom = -96.0 + +[node name="HoldTest" type="Polygon2D" parent="SubViewportContainer/2D Viewport/Viewport Control/Notes"] +visible = false +color = Color(1, 0.917647, 0.2, 0.890196) +polygon = PackedVector2Array(0, 0, 300, 0, 1100, -1920, 800, -1920) diff --git a/Scripts/Data/Chart/Chart.cs b/Scripts/Data/Chart/Chart.cs index 93c9436..33ca94b 100644 --- a/Scripts/Data/Chart/Chart.cs +++ b/Scripts/Data/Chart/Chart.cs @@ -13,7 +13,6 @@ namespace WacK.Data.Chart /// public class Chart { - public static bool doneLoading { get; private set; } = false; // Key of dictionaries are in milliseconds // List is for chords public SortedList> playNotes { get; private set; } @@ -23,7 +22,6 @@ namespace WacK.Data.Chart public Chart(string chartPath) { - doneLoading = false; var file = FileAccess.Open(chartPath, FileAccess.ModeFlags.Read); if (file == null) { @@ -35,8 +33,6 @@ namespace WacK.Data.Chart var mer = new Mer.Mer(str); Load(mer); - - doneLoading = true; } // place notes and events relative to the previous diff --git a/Scripts/Scenes/Play.cs b/Scripts/Scenes/Play.cs index b563838..0825e9a 100644 --- a/Scripts/Scenes/Play.cs +++ b/Scripts/Scenes/Play.cs @@ -1,6 +1,8 @@ +using System.Reflection.PortableExecutable; using Godot; using WacK.Data.Chart; using WacK.Data.Mer; +using WacK.Things.TunnelObjects; namespace WacK.Scenes { @@ -24,13 +26,55 @@ namespace WacK.Scenes // initialized by another scene, BEFORE loading this one! public static PlayParameters playParams; + // TunnelObjects we can instantiate + public static PackedScene notePlay = GD.Load("res://Things/TunnelObjects/Notes/NoteTouch.tscn"); + + [Export] + public Control noteDisplay; + private Chart chart; public override void _Ready() { + // parse mer and create chart for current play chart = new(playParams.chartPath); - } - private void OnDestroy() + RealizeChart(); + } + + /// + /// Instantiates necessary notes onto the noteDisplay for the player to see. + /// + private void RealizeChart() + { + foreach (var msNote in chart.playNotes) + { + GD.Print(msNote.Key); + foreach (var note in msNote.Value) + { + THNotePlay nNote; + switch (note) + { + default: // tap note + nNote = notePlay.Instantiate(); + break; + } + nNote.Init(note); + var nPos = nNote.Position; + nPos.Y = msNote.Key * -1000; + nNote.Position = nPos; + noteDisplay.AddChild(nNote); + } + } + } + + public override void _Process(double delta) + { + var nPos = noteDisplay.Position; + nPos.Y += (float)delta * 1000; + noteDisplay.Position = nPos; + } + + private void OnDestroy() { playParams = null; } diff --git a/Scripts/Things/TunnelObjects/THNoteHold.cs b/Scripts/Things/TunnelObjects/THNoteHold.cs new file mode 100644 index 0000000..995adba --- /dev/null +++ b/Scripts/Things/TunnelObjects/THNoteHold.cs @@ -0,0 +1,16 @@ +using Godot; +using WacK.Data.Chart; + +namespace WacK.Things.TunnelObjects +{ + public partial class THNoteHold : THNotePlay + { + public new NoteHold noteData; + + public void Init(NoteHold noteData) + { + base.Init(noteData); + this.noteData = noteData; + } + } +} \ No newline at end of file diff --git a/Scripts/Things/TunnelObjects/THNotePlay.cs b/Scripts/Things/TunnelObjects/THNotePlay.cs new file mode 100644 index 0000000..f9713ca --- /dev/null +++ b/Scripts/Things/TunnelObjects/THNotePlay.cs @@ -0,0 +1,28 @@ +using Godot; +using WacK.Data.Chart; + +namespace WacK.Things.TunnelObjects +{ + public partial class THNotePlay : Control + { + public NotePlay noteData; + + public void Init(NotePlay noteData) + { + this.noteData = noteData; + SetSizePos((int)noteData.position, (int)noteData.size); + } + + public void SetSizePos(int pos, int size) + { + // TODO: pos + size >= 60 + var nPos = Position; + nPos.X = pos * (1920f/60) - 12; + Position = nPos; + + var nSize = Size; + nSize.X = size * (1920f/60) + 24; + Size = nSize; + } + } +} \ No newline at end of file diff --git a/Things/TunnelObjects/Notes/NoteTouch.tscn b/Things/TunnelObjects/Notes/NoteTouch.tscn index cb8bef5..10ed9d2 100644 --- a/Things/TunnelObjects/Notes/NoteTouch.tscn +++ b/Things/TunnelObjects/Notes/NoteTouch.tscn @@ -1,22 +1,22 @@ -[gd_scene load_steps=2 format=3 uid="uid://cyopljug0duaa"] +[gd_scene load_steps=3 format=3 uid="uid://cyopljug0duaa"] [ext_resource type="Texture2D" uid="uid://cnsbqiharp0jh" path="res://_Assets/Textures/Notes/Touch.png" id="1_hnm2k"] +[ext_resource type="Script" path="res://Scripts/Things/TunnelObjects/THNotePlay.cs" id="1_p334j"] [node name="NoteTouch" type="Control"] layout_mode = 3 -anchors_preset = 2 -anchor_top = 1.0 -anchor_bottom = 1.0 -offset_top = -1920.0 -offset_right = 1920.0 -offset_bottom = -1884.0 -grow_vertical = 0 +anchors_preset = 0 +offset_right = 200.0 +offset_bottom = 24.0 +script = ExtResource("1_p334j") [node name="NinePatchRect" type="NinePatchRect" parent="."] layout_mode = 1 -anchors_preset = 15 +anchors_preset = -1 anchor_right = 1.0 anchor_bottom = 1.0 +offset_top = -36.0 +offset_bottom = -24.0 grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("1_hnm2k") diff --git a/_Assets/Textures/Notes/Hold.png b/_Assets/Textures/Notes/Hold.png index c8edfbf..83e5f89 100644 Binary files a/_Assets/Textures/Notes/Hold.png and b/_Assets/Textures/Notes/Hold.png differ diff --git a/_Assets/Textures/Notes/Touch.xcf b/_Assets/Textures/Notes/Notes.xcf similarity index 99% rename from _Assets/Textures/Notes/Touch.xcf rename to _Assets/Textures/Notes/Notes.xcf index 968d6e4..b112096 100644 Binary files a/_Assets/Textures/Notes/Touch.xcf and b/_Assets/Textures/Notes/Notes.xcf differ diff --git a/_Assets/Textures/Notes/Touch.png b/_Assets/Textures/Notes/Touch.png index 38b6eac..8738bf4 100644 Binary files a/_Assets/Textures/Notes/Touch.png and b/_Assets/Textures/Notes/Touch.png differ