Implement short-lived stellar event handling and optimize batch processing; add tests for new functionality
This commit is contained in:
+21
-2
@@ -312,6 +312,7 @@ func _page_action_pressed(page_id: int, action_amount: float) -> void:
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
get_tree().auto_accept_quit = false
|
||||
var inited_result = init_enitities()
|
||||
locked_items = inited_result.locked_items
|
||||
load_data()
|
||||
@@ -420,15 +421,33 @@ func save_data() -> void:
|
||||
var page: int = pending_page
|
||||
if page < 0:
|
||||
page = clampi(roundi(float(stage_page_scroller.scroll_horizontal) / PAGE_WIDTH), 0, PAGE_COUNT - 1)
|
||||
SaveManager.save_data("owniverse", "qwerty", {
|
||||
SaveManager.request_save("owniverse", "qwerty", {
|
||||
"state": owniverse.state,
|
||||
"ui": {"current_page": page},
|
||||
})
|
||||
|
||||
|
||||
var closing: bool = false
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if is_node_ready() and (what == NOTIFICATION_WM_CLOSE_REQUEST or what == NOTIFICATION_APPLICATION_PAUSED):
|
||||
if not is_node_ready() or closing:
|
||||
return
|
||||
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||
_close_after_save()
|
||||
elif what == NOTIFICATION_APPLICATION_PAUSED:
|
||||
save_data()
|
||||
# The OS may suspend frames immediately; finish the queued write now.
|
||||
SaveManager.flush_saves()
|
||||
|
||||
|
||||
func _close_after_save() -> void:
|
||||
closing = true
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
save_data()
|
||||
if SaveManager.is_saving():
|
||||
await SaveManager.saves_drained
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func init_enitities() -> Dictionary:
|
||||
|
||||
Reference in New Issue
Block a user