From b282dd21cdff5bea269eb2fa65902190c885f545 Mon Sep 17 00:00:00 2001 From: msk <15199219+muskit@users.noreply.github.com> Date: Wed, 11 Oct 2023 02:47:31 -0700 Subject: [PATCH] finish snap notes --- Scripts/Things/TunnelObjects/SnapArrows.cs | 46 ++++- Scripts/Things/TunnelObjects/THNotePlay.cs | 16 +- Things/TunnelObjects/Notes/NoteSnapIn.tscn | 9 +- Things/TunnelObjects/Notes/NoteSnapOut.tscn | 15 +- Things/TunnelObjects/Notes/SnapArrows.tscn | 206 +++++++++++++++----- 5 files changed, 237 insertions(+), 55 deletions(-) diff --git a/Scripts/Things/TunnelObjects/SnapArrows.cs b/Scripts/Things/TunnelObjects/SnapArrows.cs index 6eb9180..6405ad7 100644 --- a/Scripts/Things/TunnelObjects/SnapArrows.cs +++ b/Scripts/Things/TunnelObjects/SnapArrows.cs @@ -1,15 +1,57 @@ using Godot; using System; +using System.Linq; +using WacK; public partial class SnapArrows : HBoxContainer { + private TextureRect[] arrows = new TextureRect[20]; + // Called when the node enters the scene tree for the first time. public override void _Ready() { + var c = GetChildren(); + for(int i = 0; i < 20; ++i) + { + arrows[i] = (TextureRect) c[i]; + } } - // Called every frame. 'delta' is the elapsed time since the previous frame. - public override void _Process(double delta) + /// + /// Make sure to run as CallDeferred if constructing! + /// + /// + /// + /// + public void Init(int pos, int size, bool isIn) { + var nVis = Math.Clamp(size / 3, 1, 20); + + for(int i = 0; i < arrows.Count(); ++i) + { + if (i < nVis) + { + arrows[i].Visible = true; + ((ShaderMaterial)arrows[i].Material) + .SetShaderParameter("isIn", isIn); + } + else + { + arrows[i].Visible = false; + } + } + + // shrink + var s = Size; + s.X = 0; + Size = s; + + var (posPx, sizePx) = Util.PixelizeNote(pos, size); + var noteCtrPos = posPx + sizePx / 2; + + // reposition + var p = Position; + p.X = -Size.X / 2 + noteCtrPos; + Position = p; } } diff --git a/Scripts/Things/TunnelObjects/THNotePlay.cs b/Scripts/Things/TunnelObjects/THNotePlay.cs index e280007..1f4c29a 100644 --- a/Scripts/Things/TunnelObjects/THNotePlay.cs +++ b/Scripts/Things/TunnelObjects/THNotePlay.cs @@ -19,7 +19,8 @@ namespace WacK.Things.TunnelObjects if (noteData.type == NotePlayType.SwipeCW) { var n = (SwipeArrow) FindChild("SwipeArrow"); - n.SetCW(noteData.type == NotePlayType.SwipeCW); + // n.SetCW(noteData.type == NotePlayType.SwipeCW); + n.CallDeferred("SetCW", noteData.type == NotePlayType.SwipeCW); } } @@ -43,11 +44,20 @@ namespace WacK.Things.TunnelObjects nSize.X = sizePx; noteBase.SetDeferred("size", nSize); - // handle swipe arrow size + // handle swipe arrow pos & size if (noteData.type == NotePlayType.SwipeCW || noteData.type == NotePlayType.SwipeCCW) { var n = (SwipeArrow) FindChild("SwipeArrow"); - n.SetPosSize(pos, size); + // 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); } } } diff --git a/Things/TunnelObjects/Notes/NoteSnapIn.tscn b/Things/TunnelObjects/Notes/NoteSnapIn.tscn index ed6fc26..3fca088 100644 --- a/Things/TunnelObjects/Notes/NoteSnapIn.tscn +++ b/Things/TunnelObjects/Notes/NoteSnapIn.tscn @@ -26,11 +26,14 @@ texture = ExtResource("2_ipqj7") patch_margin_left = 12 patch_margin_right = 12 -[node name="HBoxContainer" parent="." instance=ExtResource("3_tg2n4")] +[node name="SnapArrows" parent="." instance=ExtResource("3_tg2n4")] layout_mode = 0 anchors_preset = 0 anchor_top = 0.0 anchor_bottom = 0.0 -offset_top = -205.0 -offset_bottom = -65.0 +offset_left = -20.0 +offset_top = -176.0 +offset_right = 52.0 +offset_bottom = -36.0 grow_vertical = 1 +rotation = -0.000788897 diff --git a/Things/TunnelObjects/Notes/NoteSnapOut.tscn b/Things/TunnelObjects/Notes/NoteSnapOut.tscn index 8a0b1a8..38f3280 100644 --- a/Things/TunnelObjects/Notes/NoteSnapOut.tscn +++ b/Things/TunnelObjects/Notes/NoteSnapOut.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://dqw7av6ummhib"] +[gd_scene load_steps=4 format=3 uid="uid://dqw7av6ummhib"] [ext_resource type="Script" path="res://Scripts/Things/TunnelObjects/THNotePlay.cs" id="1_mhn02"] [ext_resource type="Texture2D" uid="uid://cdui66l8fg6rg" path="res://_Assets/Textures/Notes/SnapOut.png" id="2_6llgl"] +[ext_resource type="PackedScene" uid="uid://digltkd2gj66n" path="res://Things/TunnelObjects/Notes/SnapArrows.tscn" id="3_khdro"] [node name="NoteSnapOut" type="Control" node_paths=PackedStringArray("noteBase")] layout_mode = 3 @@ -23,3 +24,15 @@ grow_vertical = 2 texture = ExtResource("2_6llgl") patch_margin_left = 12 patch_margin_right = 12 + +[node name="SnapArrows" parent="." instance=ExtResource("3_khdro")] +layout_mode = 0 +anchors_preset = 0 +anchor_top = 0.0 +anchor_bottom = 0.0 +offset_left = -20.0 +offset_top = -176.0 +offset_right = 52.0 +offset_bottom = -36.0 +grow_vertical = 1 +rotation = -0.000788897 diff --git a/Things/TunnelObjects/Notes/SnapArrows.tscn b/Things/TunnelObjects/Notes/SnapArrows.tscn index fc28df2..17e6529 100644 --- a/Things/TunnelObjects/Notes/SnapArrows.tscn +++ b/Things/TunnelObjects/Notes/SnapArrows.tscn @@ -1,12 +1,13 @@ -[gd_scene load_steps=7 format=3 uid="uid://digltkd2gj66n"] +[gd_scene load_steps=26 format=3 uid="uid://digltkd2gj66n"] -[ext_resource type="Script" path="res://Things/TunnelObjects/Notes/SnapArrows.cs" id="1_dqasq"] +[ext_resource type="Script" path="res://Scripts/Things/TunnelObjects/SnapArrows.cs" id="1_dqasq"] [ext_resource type="Shader" uid="uid://b1yf18ux4edj2" path="res://Shaders/SnapArrow.tres" id="1_dxmi1"] [ext_resource type="Texture2D" uid="uid://cedfe12weahhb" path="res://_Assets/Textures/Notes/SnapArrow.png" id="2_dipvr"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_a2kww"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_273qb"] +resource_local_to_scene = true shader = ExtResource("1_dxmi1") -shader_parameter/isIn = true +shader_parameter/isIn = false shader_parameter/arrow = ExtResource("2_dipvr") [sub_resource type="Gradient" id="Gradient_46guk"] @@ -17,6 +18,120 @@ colors = PackedColorArray(0, 0, 0, 1) gradient = SubResource("Gradient_46guk") width = 1 +[sub_resource type="ShaderMaterial" id="ShaderMaterial_3ee2l"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_l7jji"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_14tmo"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_sema3"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_lfe7p"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_s1e0l"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_y4npm"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_atogq"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0gmc4"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_p5ssm"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_h3bnn"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_pt4h5"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_wokwc"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_3lmnb"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_y3hru"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_b75kp"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_cjd55"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_fsfxn"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_7hjys"] +resource_local_to_scene = true +shader = ExtResource("1_dxmi1") +shader_parameter/isIn = false +shader_parameter/arrow = ExtResource("2_dipvr") + [node name="SnapArrows" type="HBoxContainer"] anchors_preset = 2 anchor_top = 1.0 @@ -25,147 +140,146 @@ offset_top = -1080.0 offset_right = 1920.0 offset_bottom = -940.0 grow_vertical = 0 -theme_override_constants/separation = 0 +theme_override_constants/separation = 24 alignment = 1 script = ExtResource("1_dqasq") -theme_override_constants/separation = 0 [node name="Arrow TextureRect1" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_273qb") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect2" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_3ee2l") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect3" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_l7jji") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect4" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_14tmo") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect5" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_sema3") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect6" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_lfe7p") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect7" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_s1e0l") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect8" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_y4npm") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect9" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_atogq") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect10" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_0gmc4") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect11" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_p5ssm") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect12" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_h3bnn") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect13" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_pt4h5") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect14" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_wokwc") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect15" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_3lmnb") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect16" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_y3hru") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect17" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_b75kp") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect18" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_cjd55") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect19" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_fsfxn") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4 [node name="Arrow TextureRect20" type="TextureRect" parent="."] -material = SubResource("ShaderMaterial_a2kww") -custom_minimum_size = Vector2(96, 140) +material = SubResource("ShaderMaterial_7hjys") +custom_minimum_size = Vector2(72, 140) layout_mode = 2 texture = SubResource("GradientTexture1D_oc0to") expand_mode = 4