From 68f358feeea70a9281f81a24f6d97ab33ab38f3b Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sat, 3 May 2025 07:21:26 +0200 Subject: [PATCH] Add components to disable in Marketplace; update input handling for visibility toggling --- project.godot | 22 ++++++++++++++++++++++ resources/collectables/treasure.tres | 1 + scenes/test.tscn | 3 ++- scripts/marketplace.gd | 11 ++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/project.godot b/project.godot index e8a7092..a4bfa71 100644 --- a/project.godot +++ b/project.godot @@ -68,35 +68,56 @@ theme/default_font_antialiasing=0 [input] +ui_accept={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null) +] +} left={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null) ] } right={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) ] } jump={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) ] } up={ "deadzone": 0.2, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) ] } down={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null) ] } attack={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) , Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(416, 6),"global_position":Vector2(425, 50),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null) ] } unlock_skills={ @@ -107,6 +128,7 @@ unlock_skills={ show_marketplace={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":true,"script":null) ] } diff --git a/resources/collectables/treasure.tres b/resources/collectables/treasure.tres index 15e44d0..3266a6b 100644 --- a/resources/collectables/treasure.tres +++ b/resources/collectables/treasure.tres @@ -5,3 +5,4 @@ [resource] script = ExtResource("1_w50p5") amount = 50 +type = 0 diff --git a/scenes/test.tscn b/scenes/test.tscn index e1fbfd8..be4bf0c 100644 --- a/scenes/test.tscn +++ b/scenes/test.tscn @@ -571,12 +571,13 @@ position = Vector2(873, -577) [node name="HUD" parent="CanvasLayer" instance=ExtResource("1_gbpkv")] -[node name="Marketplace" parent="CanvasLayer" node_paths=PackedStringArray("root", "skill_unlocker") instance=ExtResource("20_ss8k0")] +[node name="Marketplace" parent="CanvasLayer" node_paths=PackedStringArray("root", "skill_unlocker", "components_to_disable") instance=ExtResource("20_ss8k0")] visible = false custom_minimum_size = Vector2(480, 240) offset_top = 16.0 root = NodePath(".") skill_unlocker = NodePath("../../Brick Player/SkillUnlockerComponent") +components_to_disable = [NodePath("../../Brick Player")] [node name="Killzone" parent="." instance=ExtResource("20_8a4vc")] position = Vector2(0, 990) diff --git a/scripts/marketplace.gd b/scripts/marketplace.gd index fbb0a0c..a2d3c42 100644 --- a/scripts/marketplace.gd +++ b/scripts/marketplace.gd @@ -6,9 +6,12 @@ extends Node @export var grid: GridContainer @export var font: Font @export var skill_unlocker: SkillUnlockerComponent +@export var components_to_disable: Array[Node] = [] @onready var game_manager: GM = $"/root/GameManager" +var buttons: Array[Button] = [] + func _ready() -> void: if not skill_unlocker: @@ -29,8 +32,14 @@ func _input(event: InputEvent) -> void: if event.is_action_pressed("show_marketplace"): if root.is_visible(): root.hide() + for component in components_to_disable: + component.process_mode = PROCESS_MODE_INHERIT else: root.show() + for component in components_to_disable: + component.process_mode = PROCESS_MODE_DISABLED + if buttons: + buttons[0].grab_focus() func create_upgrade_button(skill: SkillData): @@ -41,6 +50,7 @@ func create_upgrade_button(skill: SkillData): button.pressed.connect(func () -> void: _on_button_pressed(skill)) + buttons.append(button) grid.add_child(button) grid.queue_sort() @@ -57,6 +67,5 @@ func _on_button_pressed(skill: SkillData) -> void: return if skill_unlocker.try_unlock_skill(skill): - print("Skill unlocked: ", skill.name) remove_button(skill)