making sure card picker can be reset
This commit is contained in:
parent
b063842695
commit
3423505322
|
|
@ -7,6 +7,7 @@ enum {
|
||||||
CARDS_SELECTED,
|
CARDS_SELECTED,
|
||||||
TRANSITION,
|
TRANSITION,
|
||||||
POSTS,
|
POSTS,
|
||||||
|
POSTS_SELECTED,
|
||||||
DONE
|
DONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,8 +31,11 @@ var selection_state = INI:
|
||||||
set(state):
|
set(state):
|
||||||
selection_state = state
|
selection_state = state
|
||||||
_input_locked = !(state == CARDS or state == POSTS)
|
_input_locked = !(state == CARDS or state == POSTS)
|
||||||
|
|
||||||
|
if state == DONE:
|
||||||
|
reset()
|
||||||
|
|
||||||
var anim_players:Array
|
var anim_players:Array = []
|
||||||
var curr_selection_id: int = -1:
|
var curr_selection_id: int = -1:
|
||||||
set(new_id):
|
set(new_id):
|
||||||
if selection_state == CARDS or selection_state == POSTS:
|
if selection_state == CARDS or selection_state == POSTS:
|
||||||
|
|
@ -47,8 +51,8 @@ var curr_selection_id: int = -1:
|
||||||
|
|
||||||
print(curr_selection_id)
|
print(curr_selection_id)
|
||||||
|
|
||||||
var output:Array
|
var output:Array = []
|
||||||
var options:Array
|
var options:Array = []
|
||||||
|
|
||||||
signal cards_picked(Array)
|
signal cards_picked(Array)
|
||||||
|
|
||||||
|
|
@ -56,12 +60,17 @@ signal cards_picked(Array)
|
||||||
func _ready():
|
func _ready():
|
||||||
if get_parent() == get_tree().root: selection_state = CARDS
|
if get_parent() == get_tree().root: selection_state = CARDS
|
||||||
|
|
||||||
|
reset()
|
||||||
|
|
||||||
|
func reset():
|
||||||
|
output = []
|
||||||
|
options = []
|
||||||
|
anim_players = []
|
||||||
|
curr_selection_id = -1
|
||||||
var card_controls = $cards.get_children()
|
var card_controls = $cards.get_children()
|
||||||
for control in card_controls:
|
for control in card_controls:
|
||||||
options.append(control.get_child(1))
|
options.append(control.get_child(1))
|
||||||
anim_players.append(control.get_child(0))
|
anim_players.append(control.get_child(0))
|
||||||
|
|
||||||
fill_card_slots(0)
|
|
||||||
|
|
||||||
func fill_card_slots(id: int):
|
func fill_card_slots(id: int):
|
||||||
for i in range($cards.get_child_count()):
|
for i in range($cards.get_child_count()):
|
||||||
|
|
@ -80,7 +89,10 @@ func fill_post_slots():
|
||||||
options[i].replace_with(post_its[i])
|
options[i].replace_with(post_its[i])
|
||||||
options[i].owner = self
|
options[i].owner = self
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _input(event):
|
||||||
|
if event.is_action_pressed("ui_end"):
|
||||||
|
scene_finished(1, false)
|
||||||
|
|
||||||
if has_stage and not _input_locked:
|
if has_stage and not _input_locked:
|
||||||
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_next"):
|
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_next"):
|
||||||
curr_selection_id -= 1
|
curr_selection_id -= 1
|
||||||
|
|
@ -88,8 +100,6 @@ func _unhandled_input(event):
|
||||||
curr_selection_id += 1
|
curr_selection_id += 1
|
||||||
if event.is_action_pressed("ui_accept"):
|
if event.is_action_pressed("ui_accept"):
|
||||||
pick(curr_selection_id)
|
pick(curr_selection_id)
|
||||||
if event.is_action_pressed("ui_end"):
|
|
||||||
scene_finished(1)
|
|
||||||
|
|
||||||
func pick(id: int):
|
func pick(id: int):
|
||||||
if id == -1:
|
if id == -1:
|
||||||
|
|
@ -99,7 +109,7 @@ func pick(id: int):
|
||||||
if selection_state == CARDS:
|
if selection_state == CARDS:
|
||||||
selection_state = CARDS_SELECTED
|
selection_state = CARDS_SELECTED
|
||||||
elif selection_state == POSTS:
|
elif selection_state == POSTS:
|
||||||
selection_state = DONE
|
selection_state = POSTS_SELECTED
|
||||||
|
|
||||||
anim_players[id].play("pick")
|
anim_players[id].play("pick")
|
||||||
var yield_to = anim_players[id].animation_finished
|
var yield_to = anim_players[id].animation_finished
|
||||||
|
|
@ -145,11 +155,13 @@ func pick(id: int):
|
||||||
|
|
||||||
await anim_players[0].animation_finished
|
await anim_players[0].animation_finished
|
||||||
selection_state = POSTS
|
selection_state = POSTS
|
||||||
elif selection_state == DONE:
|
elif selection_state == POSTS_SELECTED:
|
||||||
var out_str:Array[String] = []
|
var out_str:Array[String] = []
|
||||||
for card in output:
|
for card in output:
|
||||||
out_str.append(card.name)
|
out_str.append(card.name)
|
||||||
emit_signal("cards_picked", out_str)
|
emit_signal("cards_picked", out_str)
|
||||||
|
print(out_str)
|
||||||
|
selection_state = DONE
|
||||||
State.leave_stage(self)
|
State.leave_stage(self)
|
||||||
|
|
||||||
func handle_hover(new_highlight):
|
func handle_hover(new_highlight):
|
||||||
|
|
@ -161,10 +173,12 @@ func handle_mouse_button(new_selection: Node, button_event: InputEventMouseButto
|
||||||
if button_event.button_index == MOUSE_BUTTON_LEFT and button_event.pressed:
|
if button_event.button_index == MOUSE_BUTTON_LEFT and button_event.pressed:
|
||||||
pick(options.find(new_selection))
|
pick(options.find(new_selection))
|
||||||
|
|
||||||
func scene_finished(id: int):
|
func scene_finished(id: int, repeat):
|
||||||
fill_card_slots(id)
|
print(name, id, repeat)
|
||||||
State.transition_stage_to(self)
|
if not repeat:
|
||||||
selection_state = CARDS
|
fill_card_slots(id)
|
||||||
|
State.transition_stage_to(self)
|
||||||
|
selection_state = CARDS
|
||||||
|
|
||||||
func play_scene(_id):
|
func play_scene(_id, _repeat):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,18 @@ tracks/1/keys = {
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [0.174533, -0.109599]
|
"values": [0.174533, -0.109599]
|
||||||
}
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath(".:scale")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0.5),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ldr2c"]
|
[sub_resource type="Animation" id="Animation_ldr2c"]
|
||||||
resource_name = "select"
|
resource_name = "select"
|
||||||
|
|
@ -369,6 +381,18 @@ tracks/1/keys = {
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [0.349066, 0.0]
|
"values": [0.349066, 0.0]
|
||||||
}
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath(".:scale")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0.5),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_2c94q"]
|
[sub_resource type="Animation" id="Animation_2c94q"]
|
||||||
resource_name = "select"
|
resource_name = "select"
|
||||||
|
|
@ -599,6 +623,18 @@ tracks/1/keys = {
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [0.349066, 0.10472]
|
"values": [0.349066, 0.10472]
|
||||||
}
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath(".:scale")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0.5),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_pcu23"]
|
[sub_resource type="Animation" id="Animation_pcu23"]
|
||||||
resource_name = "select"
|
resource_name = "select"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue