fix chart reading, scroll chart notes!
This commit is contained in:
+27
-14
@@ -66,8 +66,9 @@ width = 2048
|
|||||||
[sub_resource type="LabelSettings" id="LabelSettings_dj3ei"]
|
[sub_resource type="LabelSettings" id="LabelSettings_dj3ei"]
|
||||||
font_size = 271
|
font_size = 271
|
||||||
|
|
||||||
[node name="Play" type="Node"]
|
[node name="Play" type="Node" node_paths=PackedStringArray("noteDisplay")]
|
||||||
script = ExtResource("1_d6iv3")
|
script = ExtResource("1_d6iv3")
|
||||||
|
noteDisplay = NodePath("SubViewportContainer/2D Viewport/Viewport Control/Notes")
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_nefjb")
|
environment = SubResource("Environment_nefjb")
|
||||||
@@ -113,7 +114,7 @@ msaa_2d = 1
|
|||||||
size = Vector2i(1920, 1920)
|
size = Vector2i(1920, 1920)
|
||||||
render_target_update_mode = 4
|
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
|
clip_contents = true
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
@@ -122,12 +123,12 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 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)
|
position = Vector2(0, -1920)
|
||||||
anchor_mode = 0
|
anchor_mode = 0
|
||||||
enabled = false
|
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
|
layout_mode = 2
|
||||||
offset_top = 1920.0
|
offset_top = 1920.0
|
||||||
offset_right = 100.0
|
offset_right = 100.0
|
||||||
@@ -136,9 +137,9 @@ rotation = -1.5708
|
|||||||
texture = SubResource("GradientTexture1D_vv2ac")
|
texture = SubResource("GradientTexture1D_vv2ac")
|
||||||
expand_mode = 1
|
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
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
@@ -152,7 +153,7 @@ grow_vertical = 0
|
|||||||
texture = ExtResource("2_kpt0a")
|
texture = ExtResource("2_kpt0a")
|
||||||
expand_mode = 1
|
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
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
@@ -167,7 +168,7 @@ grow_vertical = 0
|
|||||||
texture = ExtResource("2_kpt0a")
|
texture = ExtResource("2_kpt0a")
|
||||||
expand_mode = 1
|
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
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 2
|
anchors_preset = 2
|
||||||
@@ -188,10 +189,22 @@ label_settings = SubResource("LabelSettings_dj3ei")
|
|||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 2
|
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")]
|
[node name="NoteTouch" parent="SubViewportContainer/2D Viewport/Viewport Control/Notes" instance=ExtResource("3_qp71m")]
|
||||||
offset_left = 1500.0
|
visible = false
|
||||||
offset_top = 1800.0
|
layout_mode = 1
|
||||||
offset_right = 1690.0
|
offset_left = 400.0
|
||||||
offset_bottom = 1824.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)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace WacK.Data.Chart
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Chart
|
public class Chart
|
||||||
{
|
{
|
||||||
public static bool doneLoading { get; private set; } = false;
|
|
||||||
// Key of dictionaries are in milliseconds
|
// Key of dictionaries are in milliseconds
|
||||||
// List is for chords
|
// List is for chords
|
||||||
public SortedList<float, List<NotePlay>> playNotes { get; private set; }
|
public SortedList<float, List<NotePlay>> playNotes { get; private set; }
|
||||||
@@ -23,7 +22,6 @@ namespace WacK.Data.Chart
|
|||||||
|
|
||||||
public Chart(string chartPath)
|
public Chart(string chartPath)
|
||||||
{
|
{
|
||||||
doneLoading = false;
|
|
||||||
var file = FileAccess.Open(chartPath, FileAccess.ModeFlags.Read);
|
var file = FileAccess.Open(chartPath, FileAccess.ModeFlags.Read);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
@@ -35,8 +33,6 @@ namespace WacK.Data.Chart
|
|||||||
|
|
||||||
var mer = new Mer.Mer(str);
|
var mer = new Mer.Mer(str);
|
||||||
Load(mer);
|
Load(mer);
|
||||||
|
|
||||||
doneLoading = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// place notes and events relative to the previous
|
// place notes and events relative to the previous
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using System.Reflection.PortableExecutable;
|
||||||
using Godot;
|
using Godot;
|
||||||
using WacK.Data.Chart;
|
using WacK.Data.Chart;
|
||||||
using WacK.Data.Mer;
|
using WacK.Data.Mer;
|
||||||
|
using WacK.Things.TunnelObjects;
|
||||||
|
|
||||||
namespace WacK.Scenes
|
namespace WacK.Scenes
|
||||||
{
|
{
|
||||||
@@ -24,12 +26,54 @@ namespace WacK.Scenes
|
|||||||
// initialized by another scene, BEFORE loading this one!
|
// initialized by another scene, BEFORE loading this one!
|
||||||
public static PlayParameters playParams;
|
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;
|
private Chart chart;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
// parse mer and create chart for current play
|
||||||
chart = new(playParams.chartPath);
|
chart = new(playParams.chartPath);
|
||||||
|
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()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
playParams = null;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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="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"]
|
[node name="NoteTouch" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 2
|
anchors_preset = 0
|
||||||
anchor_top = 1.0
|
offset_right = 200.0
|
||||||
anchor_bottom = 1.0
|
offset_bottom = 24.0
|
||||||
offset_top = -1920.0
|
script = ExtResource("1_p334j")
|
||||||
offset_right = 1920.0
|
|
||||||
offset_bottom = -1884.0
|
|
||||||
grow_vertical = 0
|
|
||||||
|
|
||||||
[node name="NinePatchRect" type="NinePatchRect" parent="."]
|
[node name="NinePatchRect" type="NinePatchRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = -1
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -36.0
|
||||||
|
offset_bottom = -24.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = ExtResource("1_hnm2k")
|
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.
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 8.7 KiB |
Reference in New Issue
Block a user