improved state handling in card picker, implemented animation skipping
This commit is contained in:
parent
2cddc8284c
commit
8e81af33ee
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4caa24820005c1f0e793f4e836707769360b6037e70b57ca7ad33fcd7626c628
|
||||
size 201070796
|
||||
oid sha256:85f04c4e7beb1a1d308b404154546019012df712c6c7da2e85746b03aa03fc3f
|
||||
size 201065016
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ albedo_texture = ExtResource("1_xsr58")
|
|||
normal_enabled = true
|
||||
normal_texture = ExtResource("1_p3lcj")
|
||||
|
||||
[sub_resource type="ImmediateMesh" id="ImmediateMesh_u31or"]
|
||||
[sub_resource type="ImmediateMesh" id="ImmediateMesh_x1eeu"]
|
||||
|
||||
[sub_resource type="MultiMesh" id="MultiMesh_ic3h7"]
|
||||
transform_format = 1
|
||||
|
|
@ -70,7 +70,7 @@ light_array = Array[Vector3]([Vector3(0, 0, 0), Vector3(0, 1, 0)])
|
|||
|
||||
[node name="wires" type="MeshInstance3D" parent="."]
|
||||
material_override = SubResource("StandardMaterial3D_5ca5e")
|
||||
mesh = SubResource("ImmediateMesh_u31or")
|
||||
mesh = SubResource("ImmediateMesh_x1eeu")
|
||||
script = ExtResource("2_javfj")
|
||||
points = Array[Vector3]([Vector3(0, 0, 0), Vector3(0, 1, 0)])
|
||||
start_thickness = 0.01
|
||||
|
|
|
|||
|
|
@ -1570,8 +1570,7 @@ func start_soundtrack():
|
|||
|
||||
func play_scene(id: int, repeat = false):
|
||||
get_tree().call_group(\"interactables\", \"collapse\")
|
||||
State.pass_stage_to(self)
|
||||
State.lock_focus = true
|
||||
State.pass_stage_to(self, false, true)
|
||||
is_repeating = repeat
|
||||
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
|
||||
match id:
|
||||
|
|
@ -1590,22 +1589,18 @@ func _on_ini_room():
|
|||
func on_childhood_done():
|
||||
get_tree().call_group(\"animation_player\", \"scene_finished\", Scenes.id.YOUTH_CHILDHOOD, is_repeating)
|
||||
$childhood.hide()
|
||||
State.lock_focus = is_repeating
|
||||
|
||||
func on_voice_training_done():
|
||||
get_tree().call_group(\"animation_player\", \"scene_finished\", Scenes.id.YOUTH_VOICE_TRAINING, is_repeating)
|
||||
$\"Voice Training\".hide()
|
||||
State.lock_focus = is_repeating
|
||||
|
||||
func on_jui_jutsu_done():
|
||||
get_tree().call_group(\"animation_player\", \"scene_finished\", Scenes.id.YOUTH_JUI_JUTSU, is_repeating)
|
||||
$jui_jutsu.hide()
|
||||
State.lock_focus = is_repeating
|
||||
|
||||
func on_draeven_done():
|
||||
get_tree().call_group(\"animation_player\", \"scene_finished\", Scenes.id.YOUTH_DRAEVEN, is_repeating)
|
||||
$draeven.hide()
|
||||
State.lock_focus = is_repeating
|
||||
queue(\"intro\")
|
||||
|
||||
func scene_finished(_id):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ var selection_state = INI:
|
|||
elif state == DONE:
|
||||
reset()
|
||||
|
||||
var anim_players:Array = []
|
||||
var anim_players:Array[AnimationPlayer] = []
|
||||
var curr_selection_id: int = -1:
|
||||
set(new_id):
|
||||
if selection_state == CARDS or selection_state == POSTS:
|
||||
|
|
@ -107,13 +107,23 @@ func _input(event):
|
|||
fill_card_slots(3)
|
||||
selection_state = CARDS
|
||||
|
||||
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"):
|
||||
curr_selection_id -= 1
|
||||
elif event.is_action_pressed("ui_down") or event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_prev"):
|
||||
curr_selection_id += 1
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
pick(curr_selection_id)
|
||||
if has_stage:
|
||||
if !_input_locked:
|
||||
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
|
||||
elif event.is_action_pressed("ui_down") or event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_prev"):
|
||||
curr_selection_id += 1
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
pick(curr_selection_id)
|
||||
elif event.is_action_pressed("skip"):
|
||||
if selection_state == CARDS_SELECTED:
|
||||
transition()
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
transition()
|
||||
elif selection_state == TRANSITION:
|
||||
show_posts()
|
||||
|
||||
|
||||
func pick(id: int):
|
||||
print("PICK")
|
||||
|
|
@ -161,7 +171,9 @@ func pick(id: int):
|
|||
anim.play("unshuffle")
|
||||
|
||||
await yield_to
|
||||
transition()
|
||||
|
||||
func transition():
|
||||
if selection_state == CARDS_SELECTED:
|
||||
selection_state = TRANSITION
|
||||
options = []
|
||||
|
|
@ -175,7 +187,7 @@ func pick(id: int):
|
|||
fill_post_slots()
|
||||
|
||||
await anim_players[0].animation_finished
|
||||
selection_state = POSTS
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
var out_str:Array[String] = []
|
||||
for card in output:
|
||||
|
|
@ -185,6 +197,12 @@ func pick(id: int):
|
|||
selection_state = DONE
|
||||
State.leave_stage(self)
|
||||
|
||||
func show_posts():
|
||||
selection_state = POSTS
|
||||
for player:AnimationPlayer in anim_players:
|
||||
player.play("reset")
|
||||
|
||||
|
||||
func handle_hover(new_highlight):
|
||||
if not _input_locked:
|
||||
curr_selection_id = options.find(new_highlight)
|
||||
|
|
@ -199,7 +217,7 @@ func scene_finished(id: int, repeat):
|
|||
if not repeat:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
fill_card_slots(id)
|
||||
State.transition_stage_to(self)
|
||||
State.transition_stage_to(self, true)
|
||||
selection_state = CARDS
|
||||
|
||||
func play_scene(_id, _repeat):
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ ui_accept={
|
|||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
ui_cancel={
|
||||
"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":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
player_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,"echo":false,"script":null)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var provide_summaries: bool = false # ContentNotes/.../Checkbox2
|
|||
var allow_skipping: bool = false
|
||||
|
||||
var stage_list:Array = []
|
||||
var lock_focus: bool = false
|
||||
var focus_locked: bool = false
|
||||
|
||||
signal theme_changed
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ func _ready():
|
|||
|
||||
# Intented for use when an actor wants focus for itself, can reclaim focus, thus dropping the stack that focused.
|
||||
func take_stage(actor: Object, reclaim: bool = false) -> bool:
|
||||
if lock_focus: return false
|
||||
if focus_locked: return false
|
||||
if reclaim:
|
||||
stage_list.front().has_stage = false
|
||||
if stage_list.has(actor):
|
||||
|
|
@ -48,7 +48,7 @@ func leave_stage(actor:Object, dropObject: bool = false) -> bool:
|
|||
push_error(actor, " wanted to drop focus while tree is paused.")
|
||||
|
||||
if not dropObject: actor.has_stage = false
|
||||
lock_focus = false
|
||||
focus_locked = false
|
||||
stage_list.erase(actor)
|
||||
|
||||
if stage_list != []:
|
||||
|
|
@ -61,10 +61,10 @@ func leave_stage(actor:Object, dropObject: bool = false) -> bool:
|
|||
func get_current_actor(): return stage_list.front()
|
||||
|
||||
# Used to put a new target on top of the Focus Stack.
|
||||
func pass_stage_to(target:Object, force = false) -> bool:
|
||||
func pass_stage_to(target:Object, force = false, lock_focus = true) -> bool:
|
||||
if "pass_to_actor" in target:
|
||||
pass_stage_to(target.pass_to_actor)
|
||||
if (lock_focus or get_tree().paused) and not force:
|
||||
if (focus_locked or get_tree().paused) and not force:
|
||||
push_error(target, " requested focus while it was locked or tree is paused.")
|
||||
elif !is_instance_valid(target):
|
||||
push_error("Focus instance not valid")
|
||||
|
|
@ -85,10 +85,11 @@ func pass_stage_to(target:Object, force = false) -> bool:
|
|||
|
||||
# Currently focused element loses focus, but remains in stack.
|
||||
func free_focus():
|
||||
if lock_focus: return false
|
||||
if focus_locked: return false
|
||||
if stage_list.size() > 0: stage_list.front().has_stage = false
|
||||
|
||||
func transition_stage_to(thief: Object):
|
||||
func transition_stage_to(thief: Object, lock_focus = false):
|
||||
focus_locked = lock_focus
|
||||
if stage_list.size() > 0:
|
||||
if stage_list.front().has_stage:
|
||||
stage_list.pop_front().has_stage = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue