From f90543660fe66293c686019bf23b457d3c99b9fd Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 24 Jan 2021 02:49:08 +1030 Subject: [PATCH] Refactor out single-mode silliness Gotta lay out the scene tree such that Radial and Dance modes can be loaded in and out. Godot's GUI nodes are pretty good we should use them more :) --- RadialGame.tscn | 189 ++++++++++++++++++++++++++++++++++++++++ main.tscn | 155 +++----------------------------- project.godot | 2 +- scripts/Bezel.gd | 2 +- scripts/InputHandler.gd | 82 ++--------------- scripts/Menu.gd | 9 +- scripts/NoteHandler.gd | 6 +- scripts/OptionPanel.gd | 7 -- scripts/ScreenFilter.gd | 9 +- scripts/TouchInput.gd | 76 ++++++++++++++++ scripts/main.gd | 21 ----- singletons/GameTheme.gd | 29 ++++-- 12 files changed, 317 insertions(+), 270 deletions(-) create mode 100644 RadialGame.tscn create mode 100644 scripts/TouchInput.gd delete mode 100644 scripts/main.gd diff --git a/RadialGame.tscn b/RadialGame.tscn new file mode 100644 index 0000000..e43db5c --- /dev/null +++ b/RadialGame.tscn @@ -0,0 +1,189 @@ +[gd_scene load_steps=20 format=2] + +[ext_resource path="res://scripts/InputHandler.gd" type="Script" id=1] +[ext_resource path="res://assets/text-4k.png" type="Texture" id=2] +[ext_resource path="res://scripts/video.gd" type="Script" id=3] +[ext_resource path="res://scripts/ScreenFilter.gd" type="Script" id=4] +[ext_resource path="res://scripts/NoteViewport.gd" type="Script" id=5] +[ext_resource path="res://scripts/NotePainter.gd" type="Script" id=6] +[ext_resource path="res://scripts/NoteHandler.gd" type="Script" id=8] +[ext_resource path="res://scripts/Receptors.gd" type="Script" id=9] +[ext_resource path="res://shaders/notelines.shader" type="Shader" id=10] +[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=11] +[ext_resource path="res://shaders/receptors.shader" type="Shader" id=12] +[ext_resource path="res://scripts/Bezel.gd" type="Script" id=13] +[ext_resource path="res://Menu.tscn" type="PackedScene" id=15] + +[sub_resource type="ShaderMaterial" id=1] +shader = ExtResource( 12 ) +shader_param/num_receptors = 8 +shader_param/receptor_offset = 0.392699 +shader_param/line_color = Color( 0, 0, 1, 1 ) +shader_param/dot_color = Color( 0, 0, 1, 1 ) +shader_param/shadow_color = Color( 0, 0, 0, 0.57 ) +shader_param/line_thickness = 0.00434783 +shader_param/dot_radius = 0.026087 +shader_param/shadow_thickness = 0.0173913 +shader_param/px = 0.00108696 +shader_param/px2 = 0.00217391 +shader_param/alpha = 1.0 + +[sub_resource type="ArrayMesh" id=2] +surfaces/0 = { +"aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ), +"array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ), +"array_index_data": PoolByteArray( ), +"blend_shape_data": [ ], +"format": 359441, +"index_count": 0, +"primitive": 5, +"skeleton_aabb": [ ], +"vertex_count": 74 +} + +[sub_resource type="ShaderMaterial" id=3] +shader = ExtResource( 11 ) +shader_param/bps = null +shader_param/star_color = null +shader_param/held_color = null +shader_param/screen_size = null + +[sub_resource type="ShaderMaterial" id=4] +shader = ExtResource( 10 ) +shader_param/line_color = Color( 0.8, 0.8, 1, 0.8 ) +shader_param/line_color_double = Color( 1, 1, 0.6, 0.9 ) +shader_param/dot_color = Color( 1, 1, 1, 0.8 ) +shader_param/bps = 1.0 +shader_param/line_thickness = 0.012 +shader_param/line_thickness_min = 0.0 +shader_param/dot_thickness = 0.033 +shader_param/dot_fullbright_thickness = 0.013 +shader_param/max_angle = 1.0708 +shader_param/max_dist = 1.25 +shader_param/array_postmul = Vector3( 1, 1, 1 ) +shader_param/array_sidelen = 16 +shader_param/array_size = 256 + +[sub_resource type="CanvasItemMaterial" id=5] +blend_mode = 4 + +[sub_resource type="Curve" id=6] +min_value = -1.0 +_data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ] + +[node name="RadialGame" type="Control"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -540.0 +margin_top = -540.0 +margin_right = 540.0 +margin_bottom = 540.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="music" type="AudioStreamPlayer" parent="."] +bus = "Music" + +[node name="video" type="VideoPlayer" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -540.0 +margin_top = -540.0 +margin_right = 540.0 +margin_bottom = 540.0 +grow_horizontal = 2 +grow_vertical = 2 +rect_pivot_offset = Vector2( 540, 540 ) +mouse_filter = 2 +volume_db = -80.0 +bus = "Music" +script = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ScreenFilter" type="ColorRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +color = Color( 0, 0, 0, 1 ) +script = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Center" type="Control" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Receptors" type="MeshInstance2D" parent="Center"] +material = SubResource( 1 ) +mesh = SubResource( 2 ) +script = ExtResource( 9 ) + +[node name="Tween" type="Tween" parent="Center/Receptors"] + +[node name="NoteHandler" type="Node2D" parent="Center"] +script = ExtResource( 8 ) + +[node name="Viewport" type="Viewport" parent="Center/NoteHandler"] +size = Vector2( 1080, 1080 ) +transparent_bg = true +usage = 1 +render_target_v_flip = true +script = ExtResource( 5 ) + +[node name="Center" type="Node2D" parent="Center/NoteHandler/Viewport"] +position = Vector2( 540, 540 ) + +[node name="SlideTrailHandler" type="Node2D" parent="Center/NoteHandler/Viewport/Center"] + +[node name="JudgeText" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"] +texture = ExtResource( 2 ) + +[node name="meshinstance" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"] +material = SubResource( 3 ) + +[node name="notelines" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"] +material = SubResource( 4 ) + +[node name="Painter" type="Node2D" parent="Center/NoteHandler"] +material = SubResource( 5 ) +script = ExtResource( 6 ) + +[node name="Menu" parent="." instance=ExtResource( 15 )] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 0.0 +margin_top = 0.0 +margin_right = 0.0 +margin_bottom = 0.0 +NoteHandlerPath = NodePath("../Center/NoteHandler") +ease_curve = SubResource( 6 ) + +[node name="Bezel" type="Control" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +script = ExtResource( 13 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="InputHandler" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/main.tscn b/main.tscn index 11aaa81..b182412 100644 --- a/main.tscn +++ b/main.tscn @@ -1,152 +1,25 @@ -[gd_scene load_steps=21 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://scripts/main.gd" type="Script" id=1] -[ext_resource path="res://scripts/video.gd" type="Script" id=2] -[ext_resource path="res://scripts/ScreenFilter.gd" type="Script" id=3] -[ext_resource path="res://shaders/receptors.shader" type="Shader" id=4] -[ext_resource path="res://scripts/Receptors.gd" type="Script" id=5] -[ext_resource path="res://scripts/NoteHandler.gd" type="Script" id=6] -[ext_resource path="res://scripts/NoteViewport.gd" type="Script" id=7] -[ext_resource path="res://assets/text-4k.png" type="Texture" id=8] -[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=9] -[ext_resource path="res://shaders/notelines.shader" type="Shader" id=10] -[ext_resource path="res://scripts/NotePainter.gd" type="Script" id=11] -[ext_resource path="res://Menu.tscn" type="PackedScene" id=12] +[ext_resource path="res://RadialGame.tscn" type="PackedScene" id=1] +[ext_resource path="res://scripts/TouchInput.gd" type="Script" id=2] [ext_resource path="res://OptionPanel.tscn" type="PackedScene" id=13] -[ext_resource path="res://scripts/Bezel.gd" type="Script" id=15] -[ext_resource path="res://scripts/InputHandler.gd" type="Script" id=17] -[sub_resource type="ShaderMaterial" id=1] -shader = ExtResource( 4 ) -shader_param/num_receptors = 8 -shader_param/receptor_offset = 0.392699 -shader_param/line_color = Color( 0, 0, 1, 1 ) -shader_param/dot_color = Color( 0, 0, 1, 1 ) -shader_param/shadow_color = Color( 0, 0, 0, 0.57 ) -shader_param/line_thickness = 0.00434783 -shader_param/dot_radius = 0.026087 -shader_param/shadow_thickness = 0.0173913 -shader_param/px = 0.00108696 -shader_param/px2 = 0.00217391 -shader_param/alpha = 1.0 - -[sub_resource type="ArrayMesh" id=6] -surfaces/0 = { -"aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ), -"array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ), -"array_index_data": PoolByteArray( ), -"blend_shape_data": [ ], -"format": 359441, -"index_count": 0, -"primitive": 5, -"skeleton_aabb": [ ], -"vertex_count": 74 -} - -[sub_resource type="ShaderMaterial" id=3] -shader = ExtResource( 9 ) -shader_param/bps = null -shader_param/star_color = null -shader_param/held_color = null -shader_param/screen_size = null - -[sub_resource type="ShaderMaterial" id=4] -shader = ExtResource( 10 ) -shader_param/line_color = Color( 0.8, 0.8, 1, 0.8 ) -shader_param/line_color_double = Color( 1, 1, 0.6, 0.9 ) -shader_param/dot_color = Color( 1, 1, 1, 0.8 ) -shader_param/bps = 1.0 -shader_param/line_thickness = 0.012 -shader_param/line_thickness_min = 0.0 -shader_param/dot_thickness = 0.033 -shader_param/dot_fullbright_thickness = 0.013 -shader_param/max_angle = 1.0708 -shader_param/max_dist = 1.25 -shader_param/array_postmul = Vector3( 1, 1, 1 ) -shader_param/array_sidelen = 16 -shader_param/array_size = 256 - -[sub_resource type="CanvasItemMaterial" id=5] -blend_mode = 4 - -[node name="main" type="Node2D"] -position = Vector2( 540, 540 ) -script = ExtResource( 1 ) +[node name="main" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 __meta__ = { -"_edit_horizontal_guides_": [ ], -"_edit_vertical_guides_": [ ] +"_edit_use_anchors_": false } -[node name="music" type="AudioStreamPlayer" parent="."] -bus = "Music" +[node name="RadialGame" parent="." instance=ExtResource( 1 )] -[node name="video" type="VideoPlayer" parent="."] -margin_left = -540.0 -margin_top = -540.0 -margin_right = 540.0 -margin_bottom = 540.0 -grow_horizontal = 2 -grow_vertical = 2 -rect_pivot_offset = Vector2( 540, 540 ) -mouse_filter = 2 -volume_db = -80.0 -bus = "Music" +[node name="OptionPanel" parent="." instance=ExtResource( 13 )] + +[node name="TouchInput" type="Control" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +mouse_filter = 1 script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } - -[node name="ScreenFilter" type="Node2D" parent="."] -script = ExtResource( 3 ) - -[node name="Receptors" type="MeshInstance2D" parent="."] -material = SubResource( 1 ) -mesh = SubResource( 6 ) -script = ExtResource( 5 ) - -[node name="Tween" type="Tween" parent="Receptors"] - -[node name="NoteHandler" type="Node2D" parent="."] -script = ExtResource( 6 ) - -[node name="Viewport" type="Viewport" parent="NoteHandler"] -size = Vector2( 1080, 1080 ) -transparent_bg = true -usage = 1 -render_target_v_flip = true -script = ExtResource( 7 ) - -[node name="Center" type="Node2D" parent="NoteHandler/Viewport"] -position = Vector2( 540, 540 ) - -[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler/Viewport/Center"] - -[node name="JudgeText" type="MeshInstance2D" parent="NoteHandler/Viewport/Center"] -texture = ExtResource( 8 ) - -[node name="meshinstance" type="MeshInstance2D" parent="NoteHandler/Viewport/Center"] -material = SubResource( 3 ) - -[node name="notelines" type="MeshInstance2D" parent="NoteHandler/Viewport/Center"] -material = SubResource( 4 ) - -[node name="Painter" type="Node2D" parent="NoteHandler"] -material = SubResource( 5 ) -script = ExtResource( 11 ) - -[node name="Menu" parent="." instance=ExtResource( 12 )] - -[node name="Bezel" type="Node2D" parent="."] -script = ExtResource( 15 ) - -[node name="InputHandler" type="Control" parent="."] -margin_left = -540.0 -margin_top = -540.0 -margin_right = 540.0 -margin_bottom = 540.0 -script = ExtResource( 17 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="OptionPanel" parent="." instance=ExtResource( 13 )] diff --git a/project.godot b/project.godot index c7df40b..512b0ba 100644 --- a/project.godot +++ b/project.godot @@ -49,7 +49,7 @@ window/size/height=1080 window/size/fullscreen=true window/handheld/orientation="sensor" window/stretch/mode="2d" -window/stretch/aspect="keep_height" +window/stretch/aspect="expand" [gdnative] diff --git a/scripts/Bezel.gd b/scripts/Bezel.gd index 8398a6f..efcbaba 100644 --- a/scripts/Bezel.gd +++ b/scripts/Bezel.gd @@ -1,5 +1,5 @@ tool -extends Node2D +extends Control # Draw the bezel for radial gamemode var center := Vector2(0.0, 0.0) diff --git a/scripts/InputHandler.gd b/scripts/InputHandler.gd index 3c5c2a0..8695839 100644 --- a/scripts/InputHandler.gd +++ b/scripts/InputHandler.gd @@ -1,11 +1,5 @@ extends Control -var touch_points = {} # dict containing all points touched on the screen -var touch_positions = [] # array of above -var fingers = 0 setget set_fingers # setter for show fingers number on screen -var txt_ball = preload('res://assets/ball.png') # preload our ball texture -var default_font = preload('res://assets/NotoSans.tres') - var buttons_pressed := PoolByteArray() var touchbuttons_pressed := PoolByteArray() signal button_pressed(index) # Add int type to these once Godot supports typed signals @@ -17,12 +11,8 @@ const TOUCHBUTTON_MAX_DIST := 1.075 const BUTTON_MIN_DIST := 0.925 const BUTTON_MAX_DIST := 1.25 -var swipe_momentum := Vector2.ZERO - -func resize(): - var screen_size = $'/root'.get_visible_rect().size - rect_position = -screen_size*0.5 - rect_size = screen_size +func _ready(): + $'/root/main/TouchInput'.connect('touch_positions_updated', self, '_check_buttons') func _init(): buttons_pressed.resize(Rules.COLS) @@ -31,51 +21,19 @@ func _init(): buttons_pressed[i] = 0 touchbuttons_pressed[i] = 0 -func _ready(): - Input.set_use_accumulated_input(false) # Gotta go fast - set_process_unhandled_input(true) # process user input - set_fingers(0) -# connect('button_pressed', self, 'print_pressed') - resize() - func print_pressed(col: int): print('Pressed %d'%col) -func _draw(): # draw fingers points on screen -# var swipe_origin = Vector2(300, 540) -# draw_line(swipe_origin, swipe_origin+swipe_momentum, Color.red) - - # draw points - for i in touch_points: - var point = touch_points[i] -# if point.pressed: - # DRAW POINTS ################################################ - draw_texture(txt_ball, point.position - Vector2(24, 24)) -# draw_string(default_font, point.position - Vector2(24, 24), str(i)) -# draw_string(default_font, point.position + Vector2(-24, 48), str(point.position)) -# if len(touch_positions) > 1: -# for i in range(len(touch_positions)-1): -# # Draw line -# draw_line(touch_positions[i], touch_positions[i+1], Color(1,1,1,1)) - -func _process(delta): - swipe_momentum *= max(1.0 - 5.0*delta, 0) - if swipe_momentum.length_squared() < 1.0: - swipe_momentum = Vector2.ZERO - update() - -func update_data(): - touch_positions.clear() - for i in touch_points: - touch_positions.push_back(touch_points[i].position - rect_size/2) - +func _check_buttons(touch_positions): var buttons_pressed_temp := [] var touchbuttons_pressed_temp := [] for i in Rules.COLS: buttons_pressed_temp.append(false) touchbuttons_pressed_temp.append(false) + var global_center = rect_global_position + rect_size*0.5 for pos in touch_positions: + pos -= global_center var pol = cartesian2polar(pos.x, pos.y) var dist = pol.x/GameTheme.receptor_ring_radius var angle = rad2deg(pol.y) @@ -93,36 +51,6 @@ func update_data(): set_button_state(i, buttons_pressed_temp[i]) set_touchbutton_state(i, touchbuttons_pressed_temp[i]) - set_fingers(len(touch_positions)) - update() - -########################################################################## -func _input(event): - # Unfortunately event.device does NOT differentiate touchscreen inputs on X11, Godot v3.1.1 - # As such, we'll need to do some fancy mapping for multiple inputs - if (event is InputEventScreenDrag): - Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) - touch_points[event.index] = {pressed = true, position = event.position} - swipe_momentum = event.speed - elif (event is InputEventScreenTouch): - Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) - if event.pressed: - if not touch_points.has(event.index): - touch_points[event.index] = {} - touch_points[event.index].position = event.position # update position -# touch_points[event.index].pressed = event.pressed # update "pressed" flag - else: - if touch_points.has(event.index): - touch_points.erase(event.index) - elif (event is InputEventMouse): - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - update_data() - -########################################################################## -# write how many fingers are tapping the screen -func set_fingers(value): - fingers = max(value, 0) - func set_button_state(index: int, state: bool): var new_state = int(state) match new_state - buttons_pressed[index]: diff --git a/scripts/Menu.gd b/scripts/Menu.gd index 73d5772..89c9f1d 100644 --- a/scripts/Menu.gd +++ b/scripts/Menu.gd @@ -2,8 +2,10 @@ #extends Node2D extends Control -export var NoteHandlerPath := @'/root/main/NoteHandler' +export var NoteHandlerPath := @'../Center/NoteHandler' +export var ReceptorsPath := @'../Center/Receptors' onready var NoteHandler := get_node(NoteHandlerPath) +onready var Receptors := get_node(ReceptorsPath) onready var ScoreText := $ScoreText onready var PVMusic := $PVMusic @@ -435,7 +437,7 @@ func _draw(): ScoreText.show() func set_menu_mode(mode): - $'../Receptors'.fade(mode == MenuMode.GAMEPLAY) + Receptors.fade(mode == MenuMode.GAMEPLAY) if mode == MenuMode.GAMEPLAY: PVMusic.stop() rect_clip_content = false @@ -501,7 +503,8 @@ func finished_song(song_key, score_data): func _input(event): if !visible: return - if (event is InputEventScreenTouch) or (event is InputEventMouseButton): + if (event is InputEventMouseButton): # Add this if we ever manage to be rid of the curse of Touch->Mouse emulation: (event is InputEventScreenTouch) + print(event) if event.pressed: var pos = event.position - get_global_transform_with_canvas().get_origin() match menu_mode: diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index a042d84..28b4107 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -7,9 +7,9 @@ signal finished_song(song_key, score_data) var running := false var song_key = '' -export var MusicPlayerPath := @'/root/main/music' -export var VideoPlayerPath := @'/root/main/video' -export var InputHandlerPath := @'/root/main/InputHandler' +export var MusicPlayerPath := @'../../music' +export var VideoPlayerPath := @'../../video' +export var InputHandlerPath := @'../../InputHandler' onready var MusicPlayer := get_node(MusicPlayerPath) onready var VideoPlayer := get_node(VideoPlayerPath) onready var InputHandler := get_node(InputHandlerPath) diff --git a/scripts/OptionPanel.gd b/scripts/OptionPanel.gd index 6f90205..6872211 100644 --- a/scripts/OptionPanel.gd +++ b/scripts/OptionPanel.gd @@ -1,14 +1,8 @@ extends VBoxContainer -func resize(): - var screen_size = $'/root'.get_visible_rect().size - rect_position = -screen_size*0.5 -# rect_size = screen_size - export var btn_language: NodePath = @"hbox_language/btn_language" onready var BtnLanguage = get_node(btn_language) func _ready() -> void: - $'/root'.connect('size_changed', self, 'resize') $HBoxContainer/btn_vsync.connect('toggled', OS, 'set_use_vsync') $HBoxContainer/btn_wakelock.connect('toggled', OS, 'set_keep_screen_on') # This is waiting on godotengine/godot#35536 to be merged to do anything in Linux :( $sl_screenfilter.connect('value_changed', self, 'update_filter') @@ -19,7 +13,6 @@ func _ready() -> void: BtnLanguage.add_item('Romaji') BtnLanguage.add_item('English') BtnLanguage.connect('item_selected', self, 'update_display_language') - resize() func update_filter(alpha: float): diff --git a/scripts/ScreenFilter.gd b/scripts/ScreenFilter.gd index cbe6fe3..57a460a 100644 --- a/scripts/ScreenFilter.gd +++ b/scripts/ScreenFilter.gd @@ -1,11 +1,6 @@ -extends Node2D +extends ColorRect onready var root := $'/root' -func _draw(): - var screen_size = root.get_visible_rect().size - var screen_height = max(screen_size.x, screen_size.y) - draw_rect(Rect2(-screen_height/2, -screen_height/2, screen_height, screen_height), GameTheme.screen_filter) - func _ready(): - GameTheme.connect('screen_filter_changed', self, 'update') + GameTheme.connect('screen_filter_changed', self, 'set_frame_color') diff --git a/scripts/TouchInput.gd b/scripts/TouchInput.gd new file mode 100644 index 0000000..8d5d1ae --- /dev/null +++ b/scripts/TouchInput.gd @@ -0,0 +1,76 @@ +extends Control + +var touch_points = {} # dict containing all points touched on the screen +var touch_positions = [] # array of above +signal touch_positions_updated(positions) + +var fingers = 0 setget set_fingers # setter for show fingers number on screen +var txt_ball = preload('res://assets/ball.png') # preload our ball texture +var default_font = preload('res://assets/NotoSans.tres') + +var swipe_momentum := Vector2.ZERO + +func _ready(): + Input.set_use_accumulated_input(false) # Gotta go fast + set_process_unhandled_input(true) # process user input + set_fingers(0) +# connect('button_pressed', self, 'print_pressed') + +func print_pressed(col: int): + print('Pressed %d'%col) + +func _draw(): # draw fingers points on screen +# var swipe_origin = Vector2(300, 540) +# draw_line(swipe_origin, swipe_origin+swipe_momentum, Color.red) + + # draw points + for i in touch_points: + var point = touch_points[i] +# if point.pressed: + # DRAW POINTS ################################################ + draw_texture(txt_ball, point.position - Vector2(24, 24)) +# draw_string(default_font, point.position - Vector2(24, 24), str(i)) +# draw_string(default_font, point.position + Vector2(-24, 48), str(point.position)) +# if len(touch_positions) > 1: +# for i in range(len(touch_positions)-1): +# # Draw line +# draw_line(touch_positions[i], touch_positions[i+1], Color(1,1,1,1)) + +func _process(delta): + swipe_momentum *= max(1.0 - 5.0*delta, 0) + if swipe_momentum.length_squared() < 1.0: + swipe_momentum = Vector2.ZERO + update() + +func update_data(): + touch_positions.clear() + for i in touch_points: + touch_positions.push_back(touch_points[i].position) # - rect_size/2) + emit_signal('touch_positions_updated', touch_positions) + set_fingers(len(touch_positions)) + update() + +########################################################################## +func _input(event): + # Unfortunately event.device does NOT differentiate touchscreen inputs on X11, Godot v3.1.1 + # As such, we'll need to do some fancy mapping for multiple inputs + if (event is InputEventScreenDrag): + Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) + touch_points[event.index] = {pressed = true, position = event.position} + swipe_momentum = event.speed + elif (event is InputEventScreenTouch): + Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) + if event.pressed: + if not touch_points.has(event.index): + touch_points[event.index] = {} + touch_points[event.index].position = event.position # update position +# touch_points[event.index].pressed = event.pressed # update "pressed" flag + else: + if touch_points.has(event.index): + touch_points.erase(event.index) + elif (event is InputEventMouse): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + update_data() + +func set_fingers(value): + fingers = max(value, 0) diff --git a/scripts/main.gd b/scripts/main.gd deleted file mode 100644 index cd0fb51..0000000 --- a/scripts/main.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends Node2D - -# member variables -var screen_height := 1080 -var x_margin := 0.0 -var y_margin := 0.0 -var screen_center := Vector2(1920/2, screen_height/2) - -func resize(): - var screen_size = $"/root".get_visible_rect().size - screen_center = screen_size*0.5 - position = screen_center - - screen_height = screen_size.y - x_margin = max((screen_size.x - screen_size.y)/2.0, 0.0) - y_margin = max((screen_size.y - screen_size.x)/2.0, 0.0) - -func _ready(): - $"/root".connect("size_changed", self, "resize") - resize() - diff --git a/singletons/GameTheme.gd b/singletons/GameTheme.gd index ed5bfbf..e487f90 100644 --- a/singletons/GameTheme.gd +++ b/singletons/GameTheme.gd @@ -1,6 +1,8 @@ tool extends Node +signal screen_filter_changed(color) + var tex_notes := preload('res://assets/spritesheet-2048.png') var tex_judgement_text := preload('res://assets/text-4k.png') var tex_slide_arrow := tex_notes @@ -147,9 +149,25 @@ const NORMAL_ARRAY_8 := PoolVector3Array([ var display_language = 'n' -var screen_filter_min_alpha := 0.2 +var screen_filter_min_alpha := 0.2 setget set_screen_filter_min_alpha +var screen_filter_alpha_scale := 1.0 setget set_screen_filter_alpha var screen_filter := Color(0.0, 0.0, 0.0, screen_filter_min_alpha) -signal screen_filter_changed() + +func set_screen_filter_min_alpha(alpha: float): +# if alpha == screen_filter_min_alpha: +# return + screen_filter_min_alpha = alpha + set_screen_filter_alpha(screen_filter_alpha_scale) + +func set_screen_filter_alpha(alpha: float): +# if alpha == screen_filter_alpha_scale: +# return + # Scale to minimum alpha + var new_alpha = lerp(screen_filter_min_alpha, 1.0, alpha) + if new_alpha != screen_filter.a: + screen_filter = Color(screen_filter.r, screen_filter.g, screen_filter.b, new_alpha) + emit_signal("screen_filter_changed", screen_filter) + var receptor_color := Color.blue var bezel_color := Color.black if not Engine.editor_hint else Color.red @@ -158,13 +176,6 @@ var slide_trail_alpha := 0.88 var RADIAL_COL_ANGLES := PoolRealArray() # ideally const var RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const -func set_screen_filter_alpha(alpha: float): - # Scale to minimum alpha - var new_alpha = lerp(screen_filter_min_alpha, 1.0, alpha) - if new_alpha != screen_filter.a: - screen_filter = Color(screen_filter.r, screen_filter.g, screen_filter.b, new_alpha) - emit_signal("screen_filter_changed") - var radial_values_initialized := false func init_radial_values(): for i in range(Rules.COLS):