finish snap notes

This commit is contained in:
msk
2023-10-11 02:47:31 -07:00
parent 033ec8ab30
commit b282dd21cd
5 changed files with 237 additions and 55 deletions
+44 -2
View File
@@ -1,15 +1,57 @@
using Godot; using Godot;
using System; using System;
using System.Linq;
using WacK;
public partial class SnapArrows : HBoxContainer public partial class SnapArrows : HBoxContainer
{ {
private TextureRect[] arrows = new TextureRect[20];
// Called when the node enters the scene tree for the first time. // Called when the node enters the scene tree for the first time.
public override void _Ready() 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. /// <summary>
public override void _Process(double delta) /// Make sure to run as CallDeferred if constructing!
/// </summary>
/// <param name="pos"></param>
/// <param name="size"></param>
/// <param name="isIn"></param>
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;
} }
} }
+13 -3
View File
@@ -19,7 +19,8 @@ namespace WacK.Things.TunnelObjects
if (noteData.type == NotePlayType.SwipeCW) if (noteData.type == NotePlayType.SwipeCW)
{ {
var n = (SwipeArrow) FindChild("SwipeArrow"); 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; nSize.X = sizePx;
noteBase.SetDeferred("size", nSize); noteBase.SetDeferred("size", nSize);
// handle swipe arrow size // handle swipe arrow pos & size
if (noteData.type == NotePlayType.SwipeCW || noteData.type == NotePlayType.SwipeCCW) if (noteData.type == NotePlayType.SwipeCW || noteData.type == NotePlayType.SwipeCCW)
{ {
var n = (SwipeArrow) FindChild("SwipeArrow"); 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);
} }
} }
} }
+6 -3
View File
@@ -26,11 +26,14 @@ texture = ExtResource("2_ipqj7")
patch_margin_left = 12 patch_margin_left = 12
patch_margin_right = 12 patch_margin_right = 12
[node name="HBoxContainer" parent="." instance=ExtResource("3_tg2n4")] [node name="SnapArrows" parent="." instance=ExtResource("3_tg2n4")]
layout_mode = 0 layout_mode = 0
anchors_preset = 0 anchors_preset = 0
anchor_top = 0.0 anchor_top = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
offset_top = -205.0 offset_left = -20.0
offset_bottom = -65.0 offset_top = -176.0
offset_right = 52.0
offset_bottom = -36.0
grow_vertical = 1 grow_vertical = 1
rotation = -0.000788897
+14 -1
View File
@@ -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="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="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")] [node name="NoteSnapOut" type="Control" node_paths=PackedStringArray("noteBase")]
layout_mode = 3 layout_mode = 3
@@ -23,3 +24,15 @@ grow_vertical = 2
texture = ExtResource("2_6llgl") texture = ExtResource("2_6llgl")
patch_margin_left = 12 patch_margin_left = 12
patch_margin_right = 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
+160 -46
View File
@@ -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="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"] [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 = ExtResource("1_dxmi1")
shader_parameter/isIn = true shader_parameter/isIn = false
shader_parameter/arrow = ExtResource("2_dipvr") shader_parameter/arrow = ExtResource("2_dipvr")
[sub_resource type="Gradient" id="Gradient_46guk"] [sub_resource type="Gradient" id="Gradient_46guk"]
@@ -17,6 +18,120 @@ colors = PackedColorArray(0, 0, 0, 1)
gradient = SubResource("Gradient_46guk") gradient = SubResource("Gradient_46guk")
width = 1 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"] [node name="SnapArrows" type="HBoxContainer"]
anchors_preset = 2 anchors_preset = 2
anchor_top = 1.0 anchor_top = 1.0
@@ -25,147 +140,146 @@ offset_top = -1080.0
offset_right = 1920.0 offset_right = 1920.0
offset_bottom = -940.0 offset_bottom = -940.0
grow_vertical = 0 grow_vertical = 0
theme_override_constants/separation = 0 theme_override_constants/separation = 24
alignment = 1 alignment = 1
script = ExtResource("1_dqasq") script = ExtResource("1_dqasq")
theme_override_constants/separation = 0
[node name="Arrow TextureRect1" type="TextureRect" parent="."] [node name="Arrow TextureRect1" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_273qb")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect2" type="TextureRect" parent="."] [node name="Arrow TextureRect2" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_3ee2l")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect3" type="TextureRect" parent="."] [node name="Arrow TextureRect3" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_l7jji")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect4" type="TextureRect" parent="."] [node name="Arrow TextureRect4" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_14tmo")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect5" type="TextureRect" parent="."] [node name="Arrow TextureRect5" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_sema3")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect6" type="TextureRect" parent="."] [node name="Arrow TextureRect6" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_lfe7p")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect7" type="TextureRect" parent="."] [node name="Arrow TextureRect7" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_s1e0l")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect8" type="TextureRect" parent="."] [node name="Arrow TextureRect8" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_y4npm")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect9" type="TextureRect" parent="."] [node name="Arrow TextureRect9" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_atogq")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect10" type="TextureRect" parent="."] [node name="Arrow TextureRect10" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_0gmc4")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect11" type="TextureRect" parent="."] [node name="Arrow TextureRect11" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_p5ssm")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect12" type="TextureRect" parent="."] [node name="Arrow TextureRect12" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_h3bnn")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect13" type="TextureRect" parent="."] [node name="Arrow TextureRect13" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_pt4h5")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect14" type="TextureRect" parent="."] [node name="Arrow TextureRect14" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_wokwc")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect15" type="TextureRect" parent="."] [node name="Arrow TextureRect15" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_3lmnb")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect16" type="TextureRect" parent="."] [node name="Arrow TextureRect16" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_y3hru")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect17" type="TextureRect" parent="."] [node name="Arrow TextureRect17" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_b75kp")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect18" type="TextureRect" parent="."] [node name="Arrow TextureRect18" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_cjd55")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect19" type="TextureRect" parent="."] [node name="Arrow TextureRect19" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_fsfxn")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4
[node name="Arrow TextureRect20" type="TextureRect" parent="."] [node name="Arrow TextureRect20" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_a2kww") material = SubResource("ShaderMaterial_7hjys")
custom_minimum_size = Vector2(96, 140) custom_minimum_size = Vector2(72, 140)
layout_mode = 2 layout_mode = 2
texture = SubResource("GradientTexture1D_oc0to") texture = SubResource("GradientTexture1D_oc0to")
expand_mode = 4 expand_mode = 4