diff --git a/src/logic-scenes/card_burner/card_burner.gd b/src/logic-scenes/card_burner/card_burner.gd index 2ee615b..85b19a2 100644 --- a/src/logic-scenes/card_burner/card_burner.gd +++ b/src/logic-scenes/card_burner/card_burner.gd @@ -2,16 +2,19 @@ class_name CardBurner extends CenterContainer var has_stage = false: set(focus): - if not focus == has_stage: - if focus: - process_mode = Node.PROCESS_MODE_INHERIT - self.show() - self.mouse_filter = Control.MOUSE_FILTER_PASS - Input.mouse_mode = Input.MOUSE_MODE_HIDDEN - else: - self.mouse_filter = Control.MOUSE_FILTER_IGNORE - self.hide() - process_mode = Node.PROCESS_MODE_DISABLED + if is_node_ready(): + if not focus == has_stage: + if focus: + process_mode = Node.PROCESS_MODE_INHERIT + self.show() + self.mouse_filter = Control.MOUSE_FILTER_PASS + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + if not PromptManager.icons == InputPrompt.Icons.KEYBOARD or true: + handle_direction_input(Vector2.UP) + else: + self.mouse_filter = Control.MOUSE_FILTER_IGNORE + self.hide() + process_mode = Node.PROCESS_MODE_DISABLED has_stage = focus @onready var cursor: CandleCursor = %CandleCursor @@ -68,17 +71,36 @@ func _input(event: InputEvent) -> void: handle_direction_input(Vector2.LEFT) elif event.is_action_pressed("ui_right"): handle_direction_input(Vector2.RIGHT) + elif event is InputEventMouse: + cursor.gamepad_mode = false + ancors[card_index].get_child(0)._on_mouse_exited() + elif event.is_action_pressed("ui_accept"): + ancors[card_index].get_child(0).burn_state = Card.burned.BURNING + + +var focus_cards: bool = false: + set(focus): + focus_cards = focus + if focus_cards: + cursor.visible = true + %SkipButton.release_focus() + card_index = card_index + else: + cursor.visible = false + %SkipButton.grab_focus() + ancors[card_index].get_child(0)._on_mouse_exited() - - -var focus_cards: bool = true var card_index: int = 0: set(index): ancors[card_index].get_child(0)._on_mouse_exited() card_index = index % 4 handle_hover(ancors[card_index].get_child(0)) func handle_direction_input(direction: Vector2): - cursor.gamepad_mode = true + if not cursor.gamepad_mode: + for ancor in ancors: + ancor.get_child(0)._on_mouse_exited() + cursor.gamepad_mode = true + focus_cards = focus_cards match direction: Vector2.UP: focus_cards = true @@ -91,8 +113,10 @@ func handle_direction_input(direction: Vector2): %SkipButton.grab_focus() ancors[card_index].get_child(0)._on_mouse_exited() Vector2.LEFT: + focus_cards = true card_index -= 1 Vector2.RIGHT: + focus_cards = true card_index += 1 cursor.gamepad_target = ancors[card_index].get_child(0).global_position + Vector2(-120, 150) if not focus_cards: cursor.gamepad_target += Vector2(0, 50) diff --git a/src/logic-scenes/card_burner/cursor_candle.tscn b/src/logic-scenes/card_burner/cursor_candle.tscn index 9d823a4..bbdc996 100644 --- a/src/logic-scenes/card_burner/cursor_candle.tscn +++ b/src/logic-scenes/card_burner/cursor_candle.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://uc6urpgv7n1y"] [ext_resource type="Material" uid="uid://ppu1xnd8b7td" path="res://logic-scenes/card_burner/candle.material" id="1_61aak"] +[ext_resource type="Script" uid="uid://rxt7txuyr3vj" path="res://logic-scenes/card_burner/candle_cursor.tres.gd" id="2_5vmq4"] [sub_resource type="Gradient" id="Gradient_wi77g"] colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1) @@ -15,23 +16,6 @@ interpolation_color_space = 1 offsets = PackedFloat32Array(0, 0.254593, 0.902887, 1) colors = PackedColorArray(0.6, 0.443137, 0, 1, 1, 0.917647, 0.388235, 1, 0.513726, 0.772549, 0.862745, 1, 0.443137, 0.635294, 1, 1) -[sub_resource type="GDScript" id="GDScript_cfpbc"] -script/source = "extends CPUParticles2D - -var noise: = FastNoiseLite.new() -var noise_position:= 0.0 -var noise_offset:= Vector2.ZERO - -func _process(delta: float) -> void: - var diff: Vector2 = position - noise_offset - get_viewport().get_mouse_position() - noise_position += delta * 100 - noise_offset = Vector2(noise.get_noise_1d(noise_position), noise.get_noise_1d(-noise_position))*30.0 - position = get_viewport().get_mouse_position() + noise_offset - rotation = lerp(rotation, clamp(-PI/3, diff.x *.05, PI/3), delta*20.0) - - lifetime = max(0.01, lerp(lifetime, .25 * (1.0/(1.0+diff.length()*.1) - noise_offset.length()*.02), 0.2)) -" - [node name="CursorCandle" type="CPUParticles2D"] material = ExtResource("1_61aak") amount = 256 @@ -46,4 +30,4 @@ gravity = Vector2(0, 800) initial_velocity_min = 500.0 initial_velocity_max = 600.0 color_ramp = SubResource("Gradient_2ph0d") -script = SubResource("GDScript_cfpbc") +script = ExtResource("2_5vmq4")