diff --git a/Scenes/Play.tscn b/Scenes/Play.tscn index 2684237..49ff1c4 100644 --- a/Scenes/Play.tscn +++ b/Scenes/Play.tscn @@ -65,7 +65,7 @@ uv1_offset = Vector3(0, -0.001, 0) [sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"] viewport_path = NodePath("Mask") -[sub_resource type="ShaderMaterial" id="ShaderMaterial_exkdy"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_5k3bq"] resource_local_to_scene = true shader = ExtResource("3_rjbyl") shader_parameter/mask = SubResource("ViewportTexture_w20vk") @@ -163,7 +163,7 @@ anchor_mode = 0 editor_draw_screen = false [node name="Background" parent="2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")] -material = SubResource("ShaderMaterial_exkdy") +material = SubResource("ShaderMaterial_5k3bq") layout_mode = 1 offset_top = -1920.0 offset_right = 1920.0 diff --git a/Scripts/Things/TunnelObjects/THNoteHold.cs b/Scripts/Things/TunnelObjects/THNoteHold.cs index 4667a59..f947ebb 100644 --- a/Scripts/Things/TunnelObjects/THNoteHold.cs +++ b/Scripts/Things/TunnelObjects/THNoteHold.cs @@ -65,52 +65,29 @@ namespace WacK.Things.TunnelObjects var length = Play.ScrollPxPerSec * (float)(destination.time - origin.time); var verts = new Vector2[4]; - int originPos; - int originSize; - int destPos; - int destSize; - if (3 <= origin.size && origin.size <= 59) - { - originPos = ((int)origin.pos + 1)%60; - originSize = (int)origin.size - 2; - } - else - { - originPos = (int)origin.pos; - originSize = (int)origin.size; - } + int correctedDestPos = Util.NearestMinute((int) origin.pos, (int) destination.pos); + var (originPosPx, originSizePx) = Util.PixelizeNote((int)origin.pos, (int)origin.size); + var (destPosPx, destSizePx) = Util.PixelizeNote(correctedDestPos, (int)destination.size); - if (3 <= destination.size && destination.size <= 59) - { - destPos = ((int)destination.pos + 1)%60; - destSize = (int)destination.size - 2; - } - else - { - destPos = (int)destination.pos; - destSize = (int)destination.size; - } - - destPos = (int)Util.NearestMinute(originPos, destPos); - verts[0] = new Vector2(originPos * minuteSize, 0); - verts[1] = new Vector2(verts[0].X + originSize * minuteSize, 0); - verts[2] = new Vector2(minuteSize * (destPos + destSize), -length); - verts[3] = new Vector2(minuteSize * destPos, -length); + verts[0] = new Vector2(originPosPx, 0); + verts[1] = new Vector2(verts[0].X + originSizePx, 0); + verts[2] = new Vector2(destPosPx + destSizePx, -length); + verts[3] = new Vector2(destPosPx, -length); var segment = new Polygon2D() { Polygon = verts, Antialiased = true }; // draw overflow - var originFinalPos = originPos + originSize; - var destinationFinalPos = destPos + destSize; + var originFinalPos = origin.pos + origin.size; + var destinationFinalPos = correctedDestPos + destination.size; if (originFinalPos > 60 || destinationFinalPos > 60) { var subSegment = new Polygon2D() { Polygon = verts, Antialiased = true }; - subSegment.Translate(new Vector2(-60 * minuteSize, 0)); + subSegment.Translate(new Vector2(-Constants.BASE_2D_RESOLUTION, 0)); segment.AddChild(subSegment); } if (originFinalPos < 60 || destinationFinalPos < 60) { var subSegment = new Polygon2D() { Polygon = verts, Antialiased = true }; - subSegment.Translate(new Vector2(60 * minuteSize, 0)); + subSegment.Translate(new Vector2(Constants.BASE_2D_RESOLUTION, 0)); segment.AddChild(subSegment); } segment.Modulate = new Color("#FFFFFFD0"); diff --git a/Scripts/Things/TunnelObjects/THNotePlay.cs b/Scripts/Things/TunnelObjects/THNotePlay.cs index 996b7dd..e280007 100644 --- a/Scripts/Things/TunnelObjects/THNotePlay.cs +++ b/Scripts/Things/TunnelObjects/THNotePlay.cs @@ -1,3 +1,4 @@ +using Microsoft.VisualBasic.CompilerServices; using Godot; using WacK.Data.Chart; @@ -24,32 +25,11 @@ namespace WacK.Things.TunnelObjects public void SetPosSize(int pos, int size) { - float pxPerMinute = Constants.BASE_2D_RESOLUTION / 60; + var (posPx, sizePx) = Util.PixelizeNote(pos, size); - float posPx = 0; - float sizePx = 0; - - if (size <= 59) - { - if (size >= 3) - { - posPx = (pos + 1) * pxPerMinute; - sizePx = (size - 2) * pxPerMinute; - } - else // 2 or smaller - { - posPx = pos * pxPerMinute; - sizePx = size * pxPerMinute; - } - // end-caps - posPx -= 12; - sizePx += 24; - } - else // size is 60 or greater + if (size >= 60) { size = 60; - sizePx = Constants.BASE_2D_RESOLUTION; - // remove end-caps noteBase.RegionRect = new Rect2(12, 0, new Vector2(488, 36)); noteBase.PatchMarginLeft = 0; noteBase.PatchMarginRight = 0; diff --git a/Scripts/Util.cs b/Scripts/Util.cs index 8a3675b..6fe9d7f 100644 --- a/Scripts/Util.cs +++ b/Scripts/Util.cs @@ -56,7 +56,7 @@ namespace WacK } // Return an equivalent minute that's closest to the origin. - public static float NearestMinute(int origin, int destination) + public static int NearestMinute(int origin, int destination) { int result = destination % 60; @@ -73,6 +73,37 @@ namespace WacK return result; } + public static (float, float) PixelizeNote(int pos, int size, int endCapPx = 12) + { + float pxPerMinute = Constants.BASE_2D_RESOLUTION / 60; + + float posPx = 0; + float sizePx = 0; + + if (size <= 59) + { + if (size >= 3) + { + posPx = (pos + 1) * pxPerMinute; + sizePx = (size - 2) * pxPerMinute; + } + else // 2 or smaller + { + posPx = pos * pxPerMinute; + sizePx = size * pxPerMinute; + } + // end-caps + posPx -= endCapPx; + sizePx += 2*endCapPx; + } + else // size is 60 or greater + { + size = 60; + sizePx = Constants.BASE_2D_RESOLUTION; + } + return (posPx, sizePx); + } + public static float ScreenPixelToRad(Vector2 pos) { var resolution = DisplayServer.WindowGetSize(); diff --git a/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn b/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn index a589059..ae9771a 100644 --- a/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn +++ b/Things/TunnelObjects/Notes/NoteSwipeCCW.tscn @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://cmaq66vbi80ug" path="res://_Assets/Textures/Notes/SlideArrow_Texture.png" id="4_rv322"] [ext_resource type="Texture2D" uid="uid://kjoqem41xatr" path="res://_Assets/Textures/Notes/SlideArrow_Mask.png" id="6_o3u8k"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_gys6q"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_6l1er"] resource_local_to_scene = true shader = ExtResource("3_k16x0") shader_parameter/ArrowColor = Color(0, 1, 0, 1) @@ -39,7 +39,7 @@ patch_margin_left = 12 patch_margin_right = 12 [node name="SwipeArrow" parent="." instance=ExtResource("3_smdjm")] -material = SubResource("ShaderMaterial_gys6q") +material = SubResource("ShaderMaterial_6l1er") layout_mode = 0 offset_top = -35.0 offset_bottom = 733.0 diff --git a/Things/TunnelObjects/Notes/NoteSwipeCW.tscn b/Things/TunnelObjects/Notes/NoteSwipeCW.tscn index 7f272cf..5267365 100644 --- a/Things/TunnelObjects/Notes/NoteSwipeCW.tscn +++ b/Things/TunnelObjects/Notes/NoteSwipeCW.tscn @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://cmaq66vbi80ug" path="res://_Assets/Textures/Notes/SlideArrow_Texture.png" id="4_v0t51"] [ext_resource type="Texture2D" uid="uid://kjoqem41xatr" path="res://_Assets/Textures/Notes/SlideArrow_Mask.png" id="5_dafyh"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_y8jlc"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_k510k"] resource_local_to_scene = true shader = ExtResource("3_de2t7") shader_parameter/ArrowColor = Color(0, 1, 0, 1) @@ -40,7 +40,7 @@ patch_margin_left = 12 patch_margin_right = 12 [node name="SwipeArrow" parent="." instance=ExtResource("3_b1dle")] -material = SubResource("ShaderMaterial_y8jlc") +material = SubResource("ShaderMaterial_k510k") layout_mode = 0 offset_top = -35.0 offset_bottom = 733.0