refactor: card highlighting is now inherited
This commit is contained in:
parent
c20ce4054a
commit
53ace145aa
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=117 format=4 uid="uid://b3b0gyvklqn50"]
|
||||
[gd_scene load_steps=118 format=4 uid="uid://b3b0gyvklqn50"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bsop46tqngddc" path="res://base-environments/youth_room/youth_room.gd" id="1_aitp0"]
|
||||
[ext_resource type="AudioStream" uid="uid://1h6k2d8q1kw3" path="res://base-environments/youth_room/import/sounds/rain_on_window.mp3" id="2_3haaq"]
|
||||
|
|
@ -851,6 +851,10 @@ _surfaces = [{
|
|||
blend_shape_mode = 0
|
||||
shadow_mesh = SubResource("ArrayMesh_lag5h")
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dqyng"]
|
||||
radius = 0.5600586
|
||||
height = 1.2539063
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xum02"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
|
|
@ -1877,6 +1881,13 @@ interaction = ExtResource("12_viwxf")
|
|||
[node name="MindBoardInteractable" parent="logic" instance=ExtResource("22_ks23q")]
|
||||
transform = Transform3D(-4.371126e-08, 0, -0.9999984, 0, 1, 0, 0.9999984, 0, -4.371126e-08, -0.907206, 1.17661, 1.74337)
|
||||
interaction = ExtResource("4_gyjxx")
|
||||
billboard = false
|
||||
|
||||
[node name="Frame" parent="logic/MindBoardInteractable" index="0"]
|
||||
transform = Transform3D(0.99999994, 0, 3.5527137e-15, 0, 1, 0, -3.5527137e-15, 0, 0.99999994, -0.08004689, -0.023632765, 0)
|
||||
|
||||
[node name="View" parent="logic/MindBoardInteractable" index="1"]
|
||||
transform = Transform3D(-0.9999999, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -0.9999999, -0.08611119, 0.040526867, -0.06492537)
|
||||
|
||||
[node name="CeilingInteractable" parent="logic" instance=ExtResource("22_ks23q")]
|
||||
transform = Transform3D(0.78626597, 0, 0.6178859, 0, 1, 0, -0.6178859, 0, 0.78626597, -0.13478619, 2.0720484, -0.42032808)
|
||||
|
|
@ -1900,7 +1911,18 @@ transform = Transform3D(1, 0, 2.9802322e-08, 0, 1, 0, -2.9802322e-08, 0, 1, -0.0
|
|||
transform = Transform3D(0.99999976, 0, 0, 0, 1, 0, 0, 0, 0.99999976, 0.10009599, -0.040801764, -0.19775379)
|
||||
|
||||
[node name="DoorInteractable" parent="logic" instance=ExtResource("22_ks23q")]
|
||||
transform = Transform3D(-0.9999984, 0, 8.7422585e-08, 0, 1, 0, -8.7422585e-08, 0, -0.9999984, 0.067167796, 1.3931, -0.954428)
|
||||
transform = Transform3D(-0.9999984, 0, 8.7422585e-08, 0, 1, 0, -8.7422585e-08, 0, -0.9999984, 0.42437345, 0.9173807, -0.95442796)
|
||||
billboard = false
|
||||
|
||||
[node name="View" parent="logic/DoorInteractable" index="1"]
|
||||
transform = Transform3D(-0.99999964, 0, -8.7422755e-08, 0, 1, 0, 8.7422755e-08, 0, -0.99999964, 0.30241805, 0.49012983, -5.9604645e-08)
|
||||
|
||||
[node name="Area3D" parent="logic/DoorInteractable" index="2"]
|
||||
transform = Transform3D(0.9999998, 0, 2.1316282e-14, 0, 1, 0, -2.1316282e-14, 0, 0.9999998, 0.5580833, 0.16355383, 0)
|
||||
|
||||
[node name="CollisionShape3D" parent="logic/DoorInteractable/Area3D" index="0"]
|
||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -0.2322388, 0, 0)
|
||||
shape = SubResource("CapsuleShape3D_dqyng")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
|
|
@ -2162,5 +2184,7 @@ data = ExtResource("40_ea6x8")
|
|||
[connection signal="pressed" from="logic/UI/ending_button" to="logic/UI/ending_button" method="hide"]
|
||||
[connection signal="pressed" from="logic/UI/ending_button" to="logic/UI/ending" method="show"]
|
||||
|
||||
[editable path="logic/MindBoardInteractable"]
|
||||
[editable path="logic/ComicInteractable"]
|
||||
[editable path="logic/ClothesInteractable"]
|
||||
[editable path="logic/DoorInteractable"]
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ var mementos_collected: int = 0:
|
|||
4:
|
||||
instructions.text = "Combine cards to order your thoughts."
|
||||
|
||||
@onready var currently_active_node: Area2D = null:
|
||||
@onready var currently_active_node: Draggable = null:
|
||||
set(new_node):
|
||||
# this makes sure no accidental context switches can happen while a card is being dragged.
|
||||
if not (current_context == DRAG):
|
||||
|
|
|
|||
|
|
@ -45,16 +45,17 @@ var transfor_arr: Array[Transform2D] = [
|
|||
@export_range(1, 2) var scale_bump: float = 1.05
|
||||
@export_range(1.0, 10.0) var bounce_speed: float = 5
|
||||
@export_range(1.0, 2.0) var highlight_brightness: float = 1.4
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
|
||||
## Override set_highlight to add visual feedback for cards
|
||||
func set_highlight(value: bool) -> void:
|
||||
if value != _highlighted:
|
||||
_highlighted = value
|
||||
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if scale_tween: scale_tween.kill()
|
||||
if wiggle_tween: wiggle_tween.kill()
|
||||
if brightness_tween: brightness_tween.kill()
|
||||
if highlighted:
|
||||
if _highlighted:
|
||||
scale_tween = get_tree().create_tween()
|
||||
scale_tween.tween_property(self, "scale", Vector2(scale_bump, scale_bump), 0.1)
|
||||
wiggle_tween = get_tree().create_tween()
|
||||
|
|
@ -73,7 +74,7 @@ var transfor_arr: Array[Transform2D] = [
|
|||
brightness_tween.tween_property(background_sprite, "modulate", Color.WHITE, 0.2)
|
||||
brightness_tween.tween_property(label, "modulate", Color.WHITE, 0.2)
|
||||
else:
|
||||
if highlighted:
|
||||
if _highlighted:
|
||||
scale = Vector2(scale_bump, scale_bump)
|
||||
wiggle_intensity = 1
|
||||
if background_sprite:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,19 @@ var is_dragged: bool = false:
|
|||
is_dragged = dragged
|
||||
z_index = int(dragged)
|
||||
|
||||
## Internal highlighted state - do not set directly, use set_highlight()
|
||||
var _highlighted: bool = false
|
||||
|
||||
## Public highlighted property - use for reading state
|
||||
var highlighted: bool:
|
||||
get: return _highlighted
|
||||
set(value): set_highlight(value)
|
||||
|
||||
## Sets the highlight state - override in subclasses for visual feedback
|
||||
## Base implementation just updates the internal state
|
||||
func set_highlight(value: bool) -> void:
|
||||
_highlighted = value
|
||||
|
||||
## Margin from screen edges when confining to screen bounds
|
||||
@export var screen_margin: float = 50.0
|
||||
|
||||
|
|
|
|||
|
|
@ -31,15 +31,16 @@ var label: Label
|
|||
|
||||
@export var shift_by: Vector2 = Vector2(-32, 0)
|
||||
@export_color_no_alpha var highlight_color: Color = Color(1.5, 1.5, 1.5)
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
|
||||
## Override set_highlight to add visual feedback for sticky notes
|
||||
func set_highlight(value: bool) -> void:
|
||||
if value != _highlighted:
|
||||
_highlighted = value
|
||||
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if modulate_tween: modulate_tween.kill()
|
||||
if shift_tween: shift_tween.kill()
|
||||
if highlighted:
|
||||
if _highlighted:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
|
||||
shift_tween = get_tree().create_tween()
|
||||
|
|
@ -50,7 +51,7 @@ var label: Label
|
|||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property(content, "position", Vector2.ZERO, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
if _highlighted:
|
||||
modulate = Color(1, 1, 1)
|
||||
else:
|
||||
modulate = Color(1, 1, 1)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ signal cards_picked(cardnames: Array[String])
|
|||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
if current_scene_id != Scenes.id.NONE:
|
||||
pick_cards(current_scene_id, false)
|
||||
pick_cards(current_scene_id)
|
||||
|
||||
|
||||
func reset():
|
||||
|
|
@ -176,7 +176,6 @@ func pick(id: int) -> void:
|
|||
print_debug("Randomly selected card %s" % HardCards.get_obscure_name(options[1].name))
|
||||
if not (current_scene_id == Scenes.id.YOUTH_JUI_JUTSU and selection_state == CARDS_SELECTED):
|
||||
randomize()
|
||||
# investigate if this fixes error on line 197
|
||||
winning_id = randi() % options.size() - ( 1 if selection_state == POSTS_SELECTED else 0)
|
||||
else:
|
||||
winning_id = 1 if id == 0 else 0
|
||||
|
|
@ -237,17 +236,16 @@ func handle_mouse_button(button_event: InputEventMouseButton, new_selection: Nod
|
|||
pick(options.find(new_selection))
|
||||
|
||||
|
||||
func pick_cards(id: Scenes.id, repeat: bool):
|
||||
func pick_cards(id: Scenes.id):
|
||||
current_scene_id = id
|
||||
print_debug("Reached actor %s in sequence %s. Is%s repeating." % [name, Scenes.id.keys()[id], " not" if repeat else ""])
|
||||
if not repeat:
|
||||
hide()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
fill_card_slots(id)
|
||||
reset()
|
||||
show()
|
||||
selection_state = CARDS
|
||||
if id == Scenes.id.YOUTH_DRAVEN and not repeat:
|
||||
|
||||
if id == Scenes.id.YOUTH_DRAVEN:
|
||||
$Meaning.play()
|
||||
State.room.scene_player.play("intro")
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ func collect_memento() -> void:
|
|||
if interaction_ui is StoryPlayable:
|
||||
# Pick the cards
|
||||
var picker := State.room.get_node("%Picker") as CardPicker
|
||||
await picker.pick_cards(interaction_ui.scene_id, false)
|
||||
await picker.pick_cards(interaction_ui.scene_id)
|
||||
|
||||
# Hide the CanvasLayer when done
|
||||
canvas_layer.hide()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func _process_hover() -> void:
|
|||
func _input(event: InputEvent) -> void:
|
||||
if not active or not hover or not shown: return
|
||||
|
||||
var clicked : bool = (event.is_action_pressed("ui_accept")) or (event is InputEventMouseButton and event.pressed)
|
||||
var clicked : bool = (event.is_action_pressed("ui_accept")) or (event is InputEventMouseButton and event.is_pressed())
|
||||
if hover and shown and clicked:
|
||||
collect_memento()
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ func play_story() -> void:
|
|||
# Pick the cards if not already picked
|
||||
if not repeat:
|
||||
var picker := State.room.get_node("%Picker") as CardPicker
|
||||
await picker.pick_cards(interaction_ui.scene_id, false)
|
||||
await picker.pick_cards(interaction_ui.scene_id)
|
||||
|
||||
|
||||
# Hide the CanvasLayer when done
|
||||
|
|
|
|||
Loading…
Reference in New Issue