Refactor save management; update validation logic in save_manager.gd and enhance action handling in actions.gd for improved data integrity and user experience
This commit is contained in:
+11
-2
@@ -5,6 +5,7 @@ const OWNIVERSE_ITEM = preload("uid://d3xjfxwe3w16v")
|
||||
const SPEED_TEXTURE_NAME_TEMPLATE = "res://ui/topmenu/time&speed/time%s.png"
|
||||
|
||||
const PAGE_COUNT = 5
|
||||
const RESOURCE_PAGE = 1
|
||||
const PAGE_WIDTH = 1080
|
||||
const DRAG_TOLERANCE = 360
|
||||
const SWIPE_DURATION: float = 0.4
|
||||
@@ -256,7 +257,12 @@ func _set_active_page_actions() -> void:
|
||||
#var amount = owniverse.get_available_to_produce(entity)
|
||||
var amount = owniverse.calculate_max_producible(entity)
|
||||
#print(item_id, " : ", amount)
|
||||
page_actions[pa].set_actions(item_id, amount)
|
||||
if item_id == "SMBH":
|
||||
var preview: Callable = func(requested: float) -> float:
|
||||
return owniverse.calculate_max_producible(entity, requested)
|
||||
page_actions[pa].set_actions(item_id, amount, preview)
|
||||
else:
|
||||
page_actions[pa].set_actions(item_id, amount)
|
||||
|
||||
|
||||
func _page_action_pressed(page_id: int, action_amount: float) -> void:
|
||||
@@ -329,7 +335,7 @@ func _change_speed(delta: int) -> void:
|
||||
g_time_plus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % str(speed + 1))
|
||||
|
||||
|
||||
func _on_topmenu_button_pressed(ButtonName) -> void:
|
||||
func _on_topmenu_button_pressed(_ButtonName) -> void:
|
||||
print("Debug → ")
|
||||
#, owniverse.state)
|
||||
for id in owniverse.state.batches:
|
||||
@@ -359,6 +365,9 @@ func _on_unlock_and_save_timeout() -> void:
|
||||
func load_data() -> bool:
|
||||
var game_data: Dictionary = SaveManager.load_data("owniverse", "qwerty")
|
||||
if game_data.is_empty():
|
||||
if SaveManager.last_error == "":
|
||||
pending_page = RESOURCE_PAGE
|
||||
_restore_page.call_deferred()
|
||||
return false
|
||||
var restored: Dictionary = game_data.state
|
||||
# Current definitions are initialized first; reject incompatible saves before publishing.
|
||||
|
||||
Reference in New Issue
Block a user