diff --git a/src/autoload/touch_screen.gd b/src/autoload/touch_screen.gd index c9a52d6..28108e2 100644 --- a/src/autoload/touch_screen.gd +++ b/src/autoload/touch_screen.gd @@ -29,10 +29,6 @@ func show_keys(arg_arrows := true, arg_c := true, arg_x := true, arg_pause := fa top.visible = arg_pause func set_game(arg := false): - var i = "" if arg else "ui_" - set_actions(i + "up", i + "down", i + "left", i + "right") - buttons[0].action = "grab" if arg else "ui_cancel" - buttons[1].action = "jump" if arg else "ui_accept" for h in game_hide: h.visible = !arg @@ -49,11 +45,6 @@ func set_game(arg := false): for f in buttons: f.passby_press = arg -func set_actions(_up, _down, _left, _right): - for i in 4: - btns[i].action = [_right, _down, _left, _up][i] - btns[i].passby_press = !("ui_" in _up) - func margin(x := 20, y := 20): control.margin_left = x control.margin_right = -x diff --git a/src/autoload/touch_screen.tscn b/src/autoload/touch_screen.tscn index f4e405e..7a1c1b5 100644 --- a/src/autoload/touch_screen.tscn +++ b/src/autoload/touch_screen.tscn @@ -82,6 +82,7 @@ margin_bottom = 150.0 [node name="0" type="TouchScreenButton" parent="Control/HBoxLeft/DPad/Buttons"] shape = SubResource( 13 ) shape_centered = false +passby_press = true action = "ui_right" script = ExtResource( 3 ) radius = 500.0 @@ -90,6 +91,7 @@ poly_path = NodePath("Polygon2D") poly_radius = 140.0 poly_points = 7 poly_deadzone = 10.0 +secondary_action = "right" [node name="Polygon2D" type="Polygon2D" parent="Control/HBoxLeft/DPad/Buttons/0"] modulate = Color( 1, 1, 1, 0.5 ) @@ -102,6 +104,7 @@ idle_color = Color( 1, 1, 1, 0.501961 ) [node name="1" type="TouchScreenButton" parent="Control/HBoxLeft/DPad/Buttons"] shape = SubResource( 14 ) shape_centered = false +passby_press = true action = "ui_down" script = ExtResource( 3 ) angle = 90.0 @@ -111,6 +114,7 @@ poly_path = NodePath("Polygon2D") poly_radius = 140.0 poly_points = 7 poly_deadzone = 10.0 +secondary_action = "down" [node name="Polygon2D" type="Polygon2D" parent="Control/HBoxLeft/DPad/Buttons/1"] modulate = Color( 1, 1, 1, 0.5 ) @@ -123,6 +127,7 @@ idle_color = Color( 1, 1, 1, 0.501961 ) [node name="2" type="TouchScreenButton" parent="Control/HBoxLeft/DPad/Buttons"] shape = SubResource( 15 ) shape_centered = false +passby_press = true action = "ui_left" script = ExtResource( 3 ) angle = 180.0 @@ -132,6 +137,7 @@ poly_path = NodePath("Polygon2D") poly_radius = 140.0 poly_points = 7 poly_deadzone = 10.0 +secondary_action = "left" [node name="Polygon2D" type="Polygon2D" parent="Control/HBoxLeft/DPad/Buttons/2"] modulate = Color( 1, 1, 1, 0.5 ) @@ -144,6 +150,7 @@ idle_color = Color( 1, 1, 1, 0.501961 ) [node name="3" type="TouchScreenButton" parent="Control/HBoxLeft/DPad/Buttons"] shape = SubResource( 16 ) shape_centered = false +passby_press = true action = "ui_up" script = ExtResource( 3 ) angle = 270.0 @@ -153,6 +160,7 @@ poly_path = NodePath("Polygon2D") poly_radius = 140.0 poly_points = 7 poly_deadzone = 10.0 +secondary_action = "up" [node name="Polygon2D" type="Polygon2D" parent="Control/HBoxLeft/DPad/Buttons/3"] modulate = Color( 1, 1, 1, 0.5 ) @@ -187,6 +195,7 @@ physics_interpolation_mode = 1 modulate = Color( 1, 1, 1, 0.156863 ) shape = SubResource( 3 ) shape_centered = false +passby_press = true action = "ui_cancel" visibility_mode = 1 script = ExtResource( 4 ) @@ -195,6 +204,7 @@ __meta__ = { } color_path = NodePath("../Poly") idle_color = Color( 1, 1, 1, 0.156863 ) +secondary_action = "grab" [node name="Poly" type="Polygon2D" parent="Control/HBoxRight/C/Control"] modulate = Color( 1, 1, 1, 0.156863 ) @@ -238,6 +248,7 @@ margin_bottom = 75.0 modulate = Color( 1, 1, 1, 0.156863 ) shape = SubResource( 4 ) shape_centered = false +passby_press = true action = "ui_accept" visibility_mode = 1 script = ExtResource( 4 ) @@ -246,6 +257,7 @@ __meta__ = { } color_path = NodePath("../Poly") idle_color = Color( 1, 1, 1, 0.156863 ) +secondary_action = "jump" [node name="Poly" type="Polygon2D" parent="Control/HBoxRight/X/Control"] modulate = Color( 1, 1, 1, 0.156863 ) @@ -295,6 +307,7 @@ physics_interpolation_mode = 1 modulate = Color( 1, 1, 1, 0.156863 ) shape = SubResource( 3 ) shape_centered = false +passby_press = true action = "zoom" visibility_mode = 1 script = ExtResource( 4 ) @@ -345,6 +358,7 @@ margin_bottom = 75.0 modulate = Color( 1, 1, 1, 0.156863 ) shape = SubResource( 5 ) shape_centered = false +passby_press = true action = "ui_pause" visibility_mode = 1 script = ExtResource( 4 ) diff --git a/src/map/worlds/1/6.tscn b/src/map/worlds/1/6.tscn index d7befc7..a7dcb3c 100644 --- a/src/map/worlds/1/6.tscn +++ b/src/map/worlds/1/6.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://src/detail/Rocks.tscn" type="PackedScene" id=1] [ext_resource path="res://src/actor/door/DoorLittle.tscn" type="PackedScene" id=2] @@ -14,6 +14,7 @@ [ext_resource path="res://src/detail/Candle.tscn" type="PackedScene" id=12] [ext_resource path="res://src/detail/Bench.tscn" type="PackedScene" id=13] [ext_resource path="res://src/detail/Lamppost.tscn" type="PackedScene" id=14] +[ext_resource path="res://src/detail/SignZoom.tscn" type="PackedScene" id=15] [node name="Node2D" type="Node2D"] @@ -139,3 +140,7 @@ rotation = -3.14159 [node name="Lamppost" parent="Details" instance=ExtResource( 14 )] position = Vector2( 1000, 400 ) rotation = 1.57079 + +[node name="SignZoom" parent="Details" instance=ExtResource( 15 )] +position = Vector2( 110, 590 ) +rotation = -2.26893 diff --git a/src/menu/button_modulate.gd b/src/menu/button_modulate.gd index 44c7161..40726ca 100644 --- a/src/menu/button_modulate.gd +++ b/src/menu/button_modulate.gd @@ -8,11 +8,12 @@ onready var color_node : CanvasItem = get_node_or_null(color_path) export var press_color := Color(1,0,1, 1.0) export var idle_color := Color(1,1,1, 0.5) +export var secondary_action := "" func _ready(): if is_instance_valid(button): - button.connect("pressed", self, "interact") - button.connect("released", self, "interact") + button.connect("pressed", self, "press") + button.connect("released", self, "release") if is_instance_valid(color_node): color_node.modulate = idle_color @@ -20,3 +21,13 @@ func _ready(): func interact(): if is_instance_valid(button) and is_instance_valid(color_node): color_node.modulate = press_color if button.is_pressed() else idle_color + +func press(): + interact() + if secondary_action != "": + Input.action_press(secondary_action) + +func release(): + interact() + if secondary_action != "": + Input.action_release(secondary_action) diff --git a/src/menu/round_button.gd b/src/menu/round_button.gd index 0aa7cbf..d379992 100644 --- a/src/menu/round_button.gd +++ b/src/menu/round_button.gd @@ -15,6 +15,8 @@ export var poly_points := 5 setget set_poly_points export var poly_deadzone := 3.0 setget set_poly_deadzone export var poly_dead_points := 5 setget set_poly_dead_points +export var secondary_action := "" + func set_radius(arg := radius): radius = arg act() @@ -58,6 +60,16 @@ func set_poly_dead_points(arg := poly_dead_points): func _ready(): act() poly_act() + connect("pressed", self, "press") + connect("released", self, "release") + +func press(): + if secondary_action != "": + Input.action_press(secondary_action) + +func release(): + if secondary_action != "": + Input.action_release(secondary_action) func act(): shape = ConvexPolygonShape2D.new()