Skip to content

Commit

Permalink
fix: Selection Window will now properly turn cards face-up
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Mar 22, 2022
1 parent f8e457c commit bcc82e6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/core/CardTemplate.gd
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,14 @@ func set_is_faceup(
# We need this check, as this node might not be ready
# Yet when a viewport focus dupe is instancing
buttons.set_button_visible("View", false)
card_back.stop_card_back_animation()
if is_instance_valid(card_back):
card_back.stop_card_back_animation()
else:
_flip_card(_card_front_container, _card_back_container,instant)
buttons.set_button_visible("View", true)
# if get_parent() == cfc.NMAP.board:
card_back.start_card_back_animation()
if is_instance_valid(card_back):
card_back.start_card_back_animation()
# When we flip, we also want to adjust the dupe card
# in the focus viewport
if state != CardState.VIEWED_IN_PILE\
Expand Down Expand Up @@ -1377,6 +1379,10 @@ func move_to(targetHost: Node,
_placement_slot.occupying_card = null
_placement_slot = null
raise()
elif parentHost == targetHost and index != get_my_card_index():
parentHost.move_child(self,
parentHost.translate_card_index_to_node_index(index))
print_debug(get_my_card_index())
elif "CardPopUpSlot" in parentHost.name:
set_state(CardState.IN_POPUP)
common_post_move_scripts(targetHost.name, parentHost.name, tags)
Expand Down
2 changes: 1 addition & 1 deletion src/core/OverridableUtils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func select_card(
# This way we can override the card select scene with a custom one
var selection = card_select_scene.instance()
parent_node.add_child(selection)
selection.initiate_selection(card_list,selection_count,selection_type,selection_optional)
selection.call_deferred("initiate_selection", card_list,selection_count,selection_type,selection_optional)
# We have to wait until the player has finished selecting their cards
yield(selection,"confirmed")
if selection.is_cancelled:
Expand Down
3 changes: 3 additions & 0 deletions src/core/ScriptingEngine.gd
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ func spawn_card_to_container(script: ScriptTask) -> void:
if filtered_cards.size() < selection_amount:
selection_amount == filtered_cards.size()
CFUtils.shuffle_array(filtered_cards)
if filtered_cards.size() == 0:
printerr("WARN: Cannot find any cards to spawn with the selected filter for script:\n" + str(script.script_definition))
return
if selection_amount < 0:
return
if selection_amount == 1:
Expand Down
15 changes: 13 additions & 2 deletions src/core/SelectionWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func initiate_selection(
_selection_count := 0,
_selection_type := 'min',
_selection_optional := false) -> void:
if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'):
print("DEBUG INFO:SelectionWindow: Initiated Selection")
# We don't allow the player to close the popup with the close button
# as that will not send the mandatory signal to unpause the game
get_close_button().visible = false
Expand Down Expand Up @@ -85,7 +87,11 @@ func initiate_selection(
selected_cards = card_array
emit_signal("confirmed")
return
# We change the window title to be descriptive
# When we have 0 cards to select from, we consider the selection cancelled
elif card_array.size() == 0:
is_cancelled = true
emit_signal("confirmed")
return
match selection_type:
"min":
window_title = "Select at least " + str(selection_count) + " cards."
Expand Down Expand Up @@ -113,7 +119,6 @@ func initiate_selection(
dupe_selection.remove_from_group("cards")
dupe_selection.canonical_name = card.canonical_name
dupe_selection.properties = card.properties.duplicate()
dupe_selection.is_faceup = true
card_sample = dupe_selection
var card_grid_obj = grid_card_object_scene.instance()
_card_grid.add_child(card_grid_obj)
Expand All @@ -123,6 +128,10 @@ func initiate_selection(
card_grid_obj.setup(dupe_selection)
_extra_dupe_ready(dupe_selection, card)
_card_dupe_map[card] = dupe_selection
# yield(dupe_selection, "ready")
# yield(get_tree().create_timer(0.3), "timeout")
dupe_selection.set_is_faceup(card.is_faceup,true)
dupe_selection.set_is_faceup(true,true)
# We connect each card grid's gui input into a call which will handle
# The selections
card_grid_obj.connect("gui_input", self, "on_selection_gui_input", [dupe_selection, card])
Expand All @@ -148,6 +157,8 @@ func initiate_selection(
0, 1, 0.5,
Tween.TRANS_SINE, Tween.EASE_IN)
_tween.start()
if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'):
print("DEBUG INFO:SelectionWindow: Started Card Display with a %s card selection" % [_card_grid.get_child_count()])


# Overridable function for games to extend processing of dupe card
Expand Down
2 changes: 1 addition & 1 deletion src/core/SelectionWindow.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource path="res://src/core/SelectionWindow.gd" type="Script" id=1]

[node name="SelectionWindow" type="AcceptDialog"]
[node name="SelectionWindow" type="AcceptDialog" groups=["selection_windows"]]
modulate = Color( 1, 1, 1, 0 )
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down

0 comments on commit bcc82e6

Please sign in to comment.