Update client screens and deck editor
This commit is contained in:
@@ -29,7 +29,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
# Add popup to the viewport root so it overlays above the VBoxContainer.
|
# Add popup to the viewport root so it overlays above the VBoxContainer.
|
||||||
_card_popup = CARD_DETAIL_POPUP.instantiate()
|
_card_popup = CARD_DETAIL_POPUP.instantiate()
|
||||||
get_tree().get_root().add_child(_card_popup)
|
get_tree().get_root().call_deferred("add_child", _card_popup)
|
||||||
cards_view.card_selected.connect(_on_card_selected)
|
cards_view.card_selected.connect(_on_card_selected)
|
||||||
|
|
||||||
_show_tab(0)
|
_show_tab(0)
|
||||||
|
|||||||
@@ -130,10 +130,36 @@ size_flags_horizontal = 3
|
|||||||
theme_override_font_sizes/font_size = 13
|
theme_override_font_sizes/font_size = 13
|
||||||
placeholder_text = "Search…"
|
placeholder_text = "Search…"
|
||||||
|
|
||||||
[node name="TypeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/SearchBar"]
|
[node name="FilterBar" type="HBoxContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 4
|
||||||
|
|
||||||
|
[node name="TypeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(110, 30)
|
custom_minimum_size = Vector2(110, 30)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
|
||||||
|
[node name="AffinityMenuBtn" type="MenuButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(118, 30)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "Affinities"
|
||||||
|
|
||||||
|
[node name="AffinityModeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(72, 30)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
|
||||||
|
[node name="SortOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(104, 30)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
theme_override_font_sizes/font_size = 12
|
theme_override_font_sizes/font_size = 12
|
||||||
|
|
||||||
[node name="CollLoadingLabel" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
[node name="CollLoadingLabel" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ signal back_pressed()
|
|||||||
@onready var _deck_card_list : VBoxContainer = %DeckCardList
|
@onready var _deck_card_list : VBoxContainer = %DeckCardList
|
||||||
@onready var _search_input : LineEdit = %SearchInput
|
@onready var _search_input : LineEdit = %SearchInput
|
||||||
@onready var _type_option : OptionButton = %TypeOption
|
@onready var _type_option : OptionButton = %TypeOption
|
||||||
|
@onready var _affinity_menu_btn : MenuButton = %AffinityMenuBtn
|
||||||
|
@onready var _affinity_mode_option : OptionButton = %AffinityModeOption
|
||||||
|
@onready var _sort_option : OptionButton = %SortOption
|
||||||
@onready var _coll_loading_lbl : Label = %CollLoadingLabel
|
@onready var _coll_loading_lbl : Label = %CollLoadingLabel
|
||||||
@onready var _coll_list : VBoxContainer = %CollList
|
@onready var _coll_list : VBoxContainer = %CollList
|
||||||
|
|
||||||
@@ -28,6 +31,7 @@ var _deck_id : String = ""
|
|||||||
var _deck_name : String = ""
|
var _deck_name : String = ""
|
||||||
## { cardDefinitionId(String): quantity(int) } — kept in sync after mutations
|
## { cardDefinitionId(String): quantity(int) } — kept in sync after mutations
|
||||||
var _deck_qty : Dictionary = {}
|
var _deck_qty : Dictionary = {}
|
||||||
|
var _deck_cards : Array = []
|
||||||
var _arch_spirit_id : String = ""
|
var _arch_spirit_id : String = ""
|
||||||
var _arch_spirit_row : Control = null
|
var _arch_spirit_row : Control = null
|
||||||
var _arch_picker_panel : Control = null
|
var _arch_picker_panel : Control = null
|
||||||
@@ -36,6 +40,28 @@ var _arch_picker_panel : Control = null
|
|||||||
var _owned : Dictionary = {}
|
var _owned : Dictionary = {}
|
||||||
var _search_timer : float = 0.0
|
var _search_timer : float = 0.0
|
||||||
const _DEBOUNCE := 0.15
|
const _DEBOUNCE := 0.15
|
||||||
|
const _AFFINITIES := [
|
||||||
|
"Void", "Aether", "Lake", "Hill", "Forest", "Field",
|
||||||
|
"Ocean", "Island", "Marsh", "Swamp",
|
||||||
|
"Mountain", "Steppe", "Fort",
|
||||||
|
"Plains", "Grove", "Jungle",
|
||||||
|
"PerfectAether", "PureVoid",
|
||||||
|
]
|
||||||
|
const _AFFINITY_PARTS := {
|
||||||
|
"Ocean": ["Lake"],
|
||||||
|
"Island": ["Lake", "Hill"],
|
||||||
|
"Marsh": ["Lake", "Forest"],
|
||||||
|
"Swamp": ["Lake", "Field"],
|
||||||
|
"Mountain": ["Hill"],
|
||||||
|
"Steppe": ["Hill", "Forest"],
|
||||||
|
"Fort": ["Hill", "Field"],
|
||||||
|
"Plains": ["Forest"],
|
||||||
|
"Grove": ["Forest", "Field"],
|
||||||
|
"Jungle": ["Field"],
|
||||||
|
"PerfectAether": ["Aether", "Lake", "Hill", "Forest", "Field"],
|
||||||
|
"PureVoid": ["Void"],
|
||||||
|
}
|
||||||
|
var _selected_affinities : Array = []
|
||||||
|
|
||||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -43,8 +69,16 @@ func _ready() -> void:
|
|||||||
%BackBtn.pressed.connect(func(): back_pressed.emit())
|
%BackBtn.pressed.connect(func(): back_pressed.emit())
|
||||||
_search_input.text_changed.connect(_on_search_changed)
|
_search_input.text_changed.connect(_on_search_changed)
|
||||||
_type_option.item_selected.connect(func(_i): _rebuild_coll_list())
|
_type_option.item_selected.connect(func(_i): _rebuild_coll_list())
|
||||||
|
_affinity_mode_option.item_selected.connect(func(_i): _rebuild_coll_list())
|
||||||
|
_sort_option.item_selected.connect(func(_i):
|
||||||
|
_rebuild_coll_list()
|
||||||
|
_render_deck_cards()
|
||||||
|
)
|
||||||
|
_affinity_menu_btn.get_popup().id_pressed.connect(_on_affinity_filter_pressed)
|
||||||
%LoadMoreBtn.hide()
|
%LoadMoreBtn.hide()
|
||||||
_populate_type_options()
|
_populate_type_options()
|
||||||
|
_populate_affinity_options()
|
||||||
|
_populate_sort_options()
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
@@ -61,6 +95,29 @@ func _populate_type_options() -> void:
|
|||||||
for t in ["ArchSpirit", "Spirit", "Ruin", "Terramorpha", "Repentance", "Instinct"]:
|
for t in ["ArchSpirit", "Spirit", "Ruin", "Terramorpha", "Repentance", "Instinct"]:
|
||||||
_type_option.add_item(t)
|
_type_option.add_item(t)
|
||||||
|
|
||||||
|
|
||||||
|
func _populate_affinity_options() -> void:
|
||||||
|
_selected_affinities.clear()
|
||||||
|
var popup := _affinity_menu_btn.get_popup()
|
||||||
|
popup.clear()
|
||||||
|
popup.add_check_item("Void", 0)
|
||||||
|
for i in range(1, _AFFINITIES.size()):
|
||||||
|
popup.add_check_item(str(_AFFINITIES[i]), i)
|
||||||
|
_update_affinity_button_text()
|
||||||
|
|
||||||
|
_affinity_mode_option.clear()
|
||||||
|
_affinity_mode_option.add_item("Any")
|
||||||
|
_affinity_mode_option.add_item("All")
|
||||||
|
_affinity_mode_option.selected = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _populate_sort_options() -> void:
|
||||||
|
_sort_option.clear()
|
||||||
|
_sort_option.add_item("Name")
|
||||||
|
_sort_option.add_item("Type")
|
||||||
|
_sort_option.add_item("Affinity")
|
||||||
|
_sort_option.selected = 0
|
||||||
|
|
||||||
# ── Public ────────────────────────────────────────────────────────────────────
|
# ── Public ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func open_deck(deck_id: String, deck_name: String) -> void:
|
func open_deck(deck_id: String, deck_name: String) -> void:
|
||||||
@@ -69,7 +126,11 @@ func open_deck(deck_id: String, deck_name: String) -> void:
|
|||||||
_title_lbl.text = "Editing: %s" % deck_name
|
_title_lbl.text = "Editing: %s" % deck_name
|
||||||
_search_input.text = ""
|
_search_input.text = ""
|
||||||
_type_option.selected = 0
|
_type_option.selected = 0
|
||||||
|
_affinity_mode_option.selected = 0
|
||||||
|
_sort_option.selected = 0
|
||||||
|
_clear_affinity_filters()
|
||||||
_deck_qty.clear()
|
_deck_qty.clear()
|
||||||
|
_deck_cards.clear()
|
||||||
_load_deck_contents()
|
_load_deck_contents()
|
||||||
_fetch_owned()
|
_fetch_owned()
|
||||||
|
|
||||||
@@ -78,6 +139,7 @@ func open_deck(deck_id: String, deck_name: String) -> void:
|
|||||||
func _load_deck_contents() -> void:
|
func _load_deck_contents() -> void:
|
||||||
for child in _deck_card_list.get_children():
|
for child in _deck_card_list.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
_deck_cards.clear()
|
||||||
_deck_loading_lbl.visible = true
|
_deck_loading_lbl.visible = true
|
||||||
var cached := CollectionCache.get_deck_response(_deck_id)
|
var cached := CollectionCache.get_deck_response(_deck_id)
|
||||||
if not cached.is_empty():
|
if not cached.is_empty():
|
||||||
@@ -192,6 +254,7 @@ func _rebuild_coll_list() -> void:
|
|||||||
var search := _search_input.text.strip_edges().to_lower()
|
var search := _search_input.text.strip_edges().to_lower()
|
||||||
var type_idx := _type_option.selected
|
var type_idx := _type_option.selected
|
||||||
var type_filter := _type_option.get_item_text(type_idx) if type_idx > 0 else ""
|
var type_filter := _type_option.get_item_text(type_idx) if type_idx > 0 else ""
|
||||||
|
var sort_key := _sort_option.get_item_text(_sort_option.selected).to_lower()
|
||||||
|
|
||||||
var rows : Array = []
|
var rows : Array = []
|
||||||
for def_id_var in _owned:
|
for def_id_var in _owned:
|
||||||
@@ -201,21 +264,24 @@ func _rebuild_coll_list() -> void:
|
|||||||
continue
|
continue
|
||||||
var card_name := str(def.get("name", ""))
|
var card_name := str(def.get("name", ""))
|
||||||
var card_type := str(def.get("cardType", ""))
|
var card_type := str(def.get("cardType", ""))
|
||||||
|
var affinity := str(def.get("affinity", ""))
|
||||||
if not search.is_empty() and not card_name.to_lower().contains(search):
|
if not search.is_empty() and not card_name.to_lower().contains(search):
|
||||||
continue
|
continue
|
||||||
if not type_filter.is_empty() and card_type != type_filter:
|
if not type_filter.is_empty() and card_type != type_filter:
|
||||||
continue
|
continue
|
||||||
|
if not _passes_affinity_filter(affinity):
|
||||||
|
continue
|
||||||
rows.append({
|
rows.append({
|
||||||
"cardDefinitionId": def_id,
|
"cardDefinitionId": def_id,
|
||||||
"name": card_name,
|
"name": card_name,
|
||||||
"cardType": card_type,
|
"cardType": card_type,
|
||||||
"affinity": str(def.get("affinity", "")),
|
"affinity": affinity,
|
||||||
"rarity": str(def.get("rarity", "")),
|
"rarity": str(def.get("rarity", "")),
|
||||||
"tier": def.get("tier"),
|
"tier": def.get("tier"),
|
||||||
"ownedCount": int(_owned[def_id_var]),
|
"ownedCount": int(_owned[def_id_var]),
|
||||||
})
|
})
|
||||||
|
|
||||||
rows.sort_custom(func(a, b): return str(a["name"]) < str(b["name"]))
|
rows.sort_custom(func(a, b): return _sort_collection_rows(a, b, sort_key))
|
||||||
for dto in rows:
|
for dto in rows:
|
||||||
_coll_list.add_child(_make_coll_row(dto))
|
_coll_list.add_child(_make_coll_row(dto))
|
||||||
|
|
||||||
@@ -282,6 +348,83 @@ func _refresh_coll_in_deck_labels() -> void:
|
|||||||
func _on_search_changed(_t: String) -> void:
|
func _on_search_changed(_t: String) -> void:
|
||||||
_search_timer = _DEBOUNCE
|
_search_timer = _DEBOUNCE
|
||||||
|
|
||||||
|
|
||||||
|
func _on_affinity_filter_pressed(id: int) -> void:
|
||||||
|
if id < 0 or id >= _AFFINITIES.size():
|
||||||
|
return
|
||||||
|
var affinity := str(_AFFINITIES[id])
|
||||||
|
var popup := _affinity_menu_btn.get_popup()
|
||||||
|
var idx := popup.get_item_index(id)
|
||||||
|
var checked := not popup.is_item_checked(idx)
|
||||||
|
popup.set_item_checked(idx, checked)
|
||||||
|
if checked and affinity not in _selected_affinities:
|
||||||
|
_selected_affinities.append(affinity)
|
||||||
|
elif not checked:
|
||||||
|
_selected_affinities.erase(affinity)
|
||||||
|
_update_affinity_button_text()
|
||||||
|
_rebuild_coll_list()
|
||||||
|
|
||||||
|
|
||||||
|
func _clear_affinity_filters() -> void:
|
||||||
|
_selected_affinities.clear()
|
||||||
|
if not is_inside_tree():
|
||||||
|
return
|
||||||
|
var popup := _affinity_menu_btn.get_popup()
|
||||||
|
for i in range(popup.item_count):
|
||||||
|
popup.set_item_checked(i, false)
|
||||||
|
_update_affinity_button_text()
|
||||||
|
|
||||||
|
|
||||||
|
func _update_affinity_button_text() -> void:
|
||||||
|
if _selected_affinities.is_empty():
|
||||||
|
_affinity_menu_btn.text = "Affinities"
|
||||||
|
elif _selected_affinities.size() == 1:
|
||||||
|
_affinity_menu_btn.text = str(_selected_affinities[0])
|
||||||
|
else:
|
||||||
|
_affinity_menu_btn.text = "%d Affinities" % _selected_affinities.size()
|
||||||
|
|
||||||
|
|
||||||
|
func _passes_affinity_filter(card_affinity: String) -> bool:
|
||||||
|
if _selected_affinities.is_empty():
|
||||||
|
return true
|
||||||
|
var terms : Array = _affinity_terms(card_affinity)
|
||||||
|
var require_all : bool = _affinity_mode_option.selected == 1
|
||||||
|
for selected in _selected_affinities:
|
||||||
|
var has_term : bool = selected in terms
|
||||||
|
if require_all and not has_term:
|
||||||
|
return false
|
||||||
|
if not require_all and has_term:
|
||||||
|
return true
|
||||||
|
return require_all
|
||||||
|
|
||||||
|
|
||||||
|
func _affinity_terms(card_affinity: String) -> Array:
|
||||||
|
var terms : Array = []
|
||||||
|
if not card_affinity.is_empty():
|
||||||
|
terms.append(card_affinity)
|
||||||
|
var parts : Variant = _AFFINITY_PARTS.get(card_affinity, [])
|
||||||
|
if typeof(parts) == TYPE_ARRAY:
|
||||||
|
for part in parts as Array:
|
||||||
|
if str(part) not in terms:
|
||||||
|
terms.append(str(part))
|
||||||
|
return terms
|
||||||
|
|
||||||
|
|
||||||
|
func _sort_collection_rows(a: Dictionary, b: Dictionary, sort_key: String) -> bool:
|
||||||
|
match sort_key:
|
||||||
|
"type":
|
||||||
|
var type_cmp := str(a["cardType"]).naturalnocasecmp_to(str(b["cardType"]))
|
||||||
|
if type_cmp != 0:
|
||||||
|
return type_cmp < 0
|
||||||
|
"affinity":
|
||||||
|
var aff_cmp := str(a["affinity"]).naturalnocasecmp_to(str(b["affinity"]))
|
||||||
|
if aff_cmp != 0:
|
||||||
|
return aff_cmp < 0
|
||||||
|
var name_cmp := str(a["name"]).naturalnocasecmp_to(str(b["name"]))
|
||||||
|
if name_cmp != 0:
|
||||||
|
return name_cmp < 0
|
||||||
|
return str(a["cardDefinitionId"]) < str(b["cardDefinitionId"])
|
||||||
|
|
||||||
# ── Mutate: add / remove ──────────────────────────────────────────────────────
|
# ── Mutate: add / remove ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _add_card(def_id: String) -> void:
|
func _add_card(def_id: String) -> void:
|
||||||
@@ -318,10 +461,9 @@ func _render_deck_response(payload: Dictionary) -> void:
|
|||||||
|
|
||||||
# ── Commander (Tier-1 ArchSpirit) ───────────────────────────────────────
|
# ── Commander (Tier-1 ArchSpirit) ───────────────────────────────────────
|
||||||
_arch_spirit_id = str(deck.get("archSpiritCardDefinitionId", ""))
|
_arch_spirit_id = str(deck.get("archSpiritCardDefinitionId", ""))
|
||||||
_update_arch_spirit_row()
|
|
||||||
|
|
||||||
var cards : Array = deck.get("cards", [])
|
var cards : Array = deck.get("cards", [])
|
||||||
_deck_qty.clear()
|
_deck_qty.clear()
|
||||||
|
_deck_cards.clear()
|
||||||
var non_as_total := 0
|
var non_as_total := 0
|
||||||
for raw_card in cards:
|
for raw_card in cards:
|
||||||
var card := raw_card as Dictionary
|
var card := raw_card as Dictionary
|
||||||
@@ -332,14 +474,11 @@ func _render_deck_response(payload: Dictionary) -> void:
|
|||||||
var def := ContentCache.get_definition(def_id)
|
var def := ContentCache.get_definition(def_id)
|
||||||
if str(def.get("cardType", "")) != "ArchSpirit":
|
if str(def.get("cardType", "")) != "ArchSpirit":
|
||||||
non_as_total += qty
|
non_as_total += qty
|
||||||
|
_deck_cards.append(_hydrate_card_dto(card, def))
|
||||||
|
|
||||||
_count_lbl.text = "%d / 40" % non_as_total
|
_count_lbl.text = "%d / 40" % non_as_total
|
||||||
|
|
||||||
for raw_card in cards:
|
_render_deck_cards()
|
||||||
var card := raw_card as Dictionary
|
|
||||||
var def := ContentCache.get_definition(str(card.get("cardDefinitionId", "")))
|
|
||||||
_deck_card_list.add_child(_make_deck_row(_hydrate_card_dto(card, def)))
|
|
||||||
|
|
||||||
_refresh_coll_in_deck_labels()
|
_refresh_coll_in_deck_labels()
|
||||||
|
|
||||||
|
|
||||||
@@ -357,6 +496,19 @@ func _hydrate_card_dto(dto: Dictionary, def: Dictionary) -> Dictionary:
|
|||||||
|
|
||||||
# ── Commander / ArchSpirit swap ───────────────────────────────────────────────
|
# ── Commander / ArchSpirit swap ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
func _render_deck_cards() -> void:
|
||||||
|
if not is_instance_valid(_deck_card_list):
|
||||||
|
return
|
||||||
|
for child in _deck_card_list.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
_update_arch_spirit_row()
|
||||||
|
var cards := _deck_cards.duplicate(true)
|
||||||
|
var sort_key := _sort_option.get_item_text(_sort_option.selected).to_lower() if _sort_option.item_count > 0 else "name"
|
||||||
|
cards.sort_custom(func(a, b): return _sort_collection_rows(a, b, sort_key))
|
||||||
|
for card in cards:
|
||||||
|
_deck_card_list.add_child(_make_deck_row(card as Dictionary))
|
||||||
|
|
||||||
|
|
||||||
func _update_arch_spirit_row() -> void:
|
func _update_arch_spirit_row() -> void:
|
||||||
if is_instance_valid(_arch_spirit_row):
|
if is_instance_valid(_arch_spirit_row):
|
||||||
_arch_spirit_row.queue_free()
|
_arch_spirit_row.queue_free()
|
||||||
|
|||||||
@@ -152,8 +152,11 @@ func handle_board_click(mouse_pos: Vector2, coord: Vector2i, unit_id: String) ->
|
|||||||
_handle_unit_selected_click(coord, resolved_unit_id)
|
_handle_unit_selected_click(coord, resolved_unit_id)
|
||||||
Mode.PLACEMENT:
|
Mode.PLACEMENT:
|
||||||
if coord.x >= 0:
|
if coord.x >= 0:
|
||||||
Game.send_place_arch_spirit(coord.x, coord.y)
|
var valid_tiles: Array = tile_target_resolver.valid_placement_tiles() \
|
||||||
set_mode(Mode.NONE)
|
if tile_target_resolver != null else []
|
||||||
|
if valid_tiles.has(coord):
|
||||||
|
Game.send_place_arch_spirit(coord.x, coord.y)
|
||||||
|
set_mode(Mode.NONE)
|
||||||
Mode.SACRIFICE_SELECT:
|
Mode.SACRIFICE_SELECT:
|
||||||
_handle_sacrifice_click(coord, resolved_unit_id)
|
_handle_sacrifice_click(coord, resolved_unit_id)
|
||||||
Mode.ABILITY_TARGET:
|
Mode.ABILITY_TARGET:
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ var _expected_total : int = 1
|
|||||||
var _pulse_tween : Tween = null
|
var _pulse_tween : Tween = null
|
||||||
## SceneTree timer that fires if the sync hangs with no progress.
|
## SceneTree timer that fires if the sync hangs with no progress.
|
||||||
var _sync_timeout : SceneTreeTimer = null
|
var _sync_timeout : SceneTreeTimer = null
|
||||||
|
## True only while we are actively waiting for sync signals from ContentCache.
|
||||||
|
## Cleared by _on_sync_failed so that a late sync_complete/sync_progress from a
|
||||||
|
## timed-out run cannot navigate the player or restart the watchdog.
|
||||||
|
var _sync_accepting : bool = false
|
||||||
|
|
||||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -138,6 +142,7 @@ func _on_version_error(code: String) -> void:
|
|||||||
|
|
||||||
func _do_sync() -> void:
|
func _do_sync() -> void:
|
||||||
_stop_pulse()
|
_stop_pulse()
|
||||||
|
_sync_accepting = true
|
||||||
_expected_total = max(ContentCache.definition_count(), 1)
|
_expected_total = max(ContentCache.definition_count(), 1)
|
||||||
var cached := ContentCache.definition_count()
|
var cached := ContentCache.definition_count()
|
||||||
if cached > 0:
|
if cached > 0:
|
||||||
@@ -152,6 +157,8 @@ func _do_sync() -> void:
|
|||||||
# ── ContentCache signal handlers ──────────────────────────────────────────────
|
# ── ContentCache signal handlers ──────────────────────────────────────────────
|
||||||
|
|
||||||
func _on_sync_progress(fetched_total: int) -> void:
|
func _on_sync_progress(fetched_total: int) -> void:
|
||||||
|
if not _sync_accepting:
|
||||||
|
return
|
||||||
_expected_total = max(_expected_total, fetched_total)
|
_expected_total = max(_expected_total, fetched_total)
|
||||||
var pct := 5.0 + 80.0 * float(fetched_total) / float(_expected_total)
|
var pct := 5.0 + 80.0 * float(fetched_total) / float(_expected_total)
|
||||||
progress_bar.value = clampf(pct, 5.0, 85.0)
|
progress_bar.value = clampf(pct, 5.0, 85.0)
|
||||||
@@ -159,6 +166,9 @@ func _on_sync_progress(fetched_total: int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_sync_complete(_total: int) -> void:
|
func _on_sync_complete(_total: int) -> void:
|
||||||
|
if not _sync_accepting:
|
||||||
|
return
|
||||||
|
_sync_accepting = false
|
||||||
_sync_timeout = null
|
_sync_timeout = null
|
||||||
progress_bar.value = 90.0
|
progress_bar.value = 90.0
|
||||||
_check_active_session()
|
_check_active_session()
|
||||||
@@ -224,6 +234,7 @@ func _go_to_main() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_sync_failed(error: String) -> void:
|
func _on_sync_failed(error: String) -> void:
|
||||||
|
_sync_accepting = false
|
||||||
_sync_timeout = null
|
_sync_timeout = null
|
||||||
_stop_pulse()
|
_stop_pulse()
|
||||||
_set_status("Sync failed: %s" % error)
|
_set_status("Sync failed: %s" % error)
|
||||||
|
|||||||
Reference in New Issue
Block a user