fix chart reading, scroll chart notes!

This commit is contained in:
muskit
2023-09-16 00:40:36 -07:00
parent 6a98acce67
commit c8bd5c16c8
9 changed files with 126 additions and 29 deletions
+27 -14
View File
@@ -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)
-4
View File
@@ -13,7 +13,6 @@ namespace WacK.Data.Chart
/// </summary>
public class Chart
{
public static bool doneLoading { get; private set; } = false;
// Key of dictionaries are in milliseconds
// List is for chords
public SortedList<float, List<NotePlay>> 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
+46 -2
View File
@@ -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<PackedScene>("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();
}
/// <summary>
/// Instantiates necessary notes onto the noteDisplay for the player to see.
/// </summary>
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<THNotePlay>();
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;
}
@@ -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;
}
}
}
@@ -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;
}
}
}
+9 -9
View File
@@ -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")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB