Snapshottab
Based on game build 714014 | Last updated: 2026-03-08
Overview
SnapshotTab is a UI widget responsible for rendering a scrollable list of server snapshot entries and handling snapshot restoration workflows. It manages fetching snapshot metadata (including day and season data), displaying them in a list, and presenting a confirmation dialog before truncating snapshots to a selected save point. It integrates with TheNet and TheSim to access networked and persistent storage APIs, and uses ShardSaveGameIndex to resolve session metadata.
Usage example
local SnapshotTab = require "widgets/redux/snapshottab"
local tab = SnapshotTab(function()
print("Snapshot list updated")
end)
tab:SetDataForSlot(1)
-- snapshots are loaded and displayed automatically
Dependencies & tags
Components used: None (this is a standalone UI widget, not an ECS component).
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
save_slot | number | -1 | Slot index of the save game to list snapshots for. |
session_id | string or nil | nil | Session identifier used for snapshot listing. |
online_mode | boolean | nil | Whether the session is in online mode. |
multi_level | boolean | nil | Whether the save uses multi-level world structure. |
use_legacy_session_path | boolean | nil | Whether to use legacy pathing for session data. |
cb | function or nil | nil | Callback invoked after snapshot truncation. |
snapshots | table | {} | List of snapshot entries with metadata (snapshot_id, world_day, world_season, empty). |
slotsnaps | table | {} | Reserved; unused in current implementation. |
snapshot_page | Widget | nil | Parent container widget. |
snapshot_scroll_list | ScrollingGrid | nil | Widget managing scrollable list of snapshot tiles. |
focus_forward | Widget | snapshot_scroll_list | Widget to receive focus when this tab gains focus. |
Main functions
RefreshSnapshots()
- Description: Updates the snapshot list widget (
snapshot_scroll_list) with currentsnapshotsdata. Ensures the list contains exactlyvisible_rowsitems by padding with empty placeholders if needed. - Parameters: None.
- Returns: Nothing.
MakeSnapshotsMenu()
- Description: Constructs the scrollable list UI for snapshots using
TEMPLATES.ScrollingGrid. Defines tile creation (MakeSnapshotTile) and update (UpdateSnapshot) functions, and sets up scrolling behavior. - Parameters: None.
- Returns: Nothing.
OnClickSnapshot(snapshot_num)
- Description: Displays a confirmation dialog to restore a snapshot. On confirmation, calls
TheNet:TruncateSnapshotsorTheNet:TruncateSnapshotsInClusterSlotto truncate the snapshot chain up to the selected snapshot ID, then refreshes the snapshot list and invokes the callback. - Parameters:
snapshot_num(number) — 1-based index intoself.snapshots.
- Returns: Nothing.
- Error states: Returns early if
snapshot_numis out of bounds or the snapshot ID isnilor<= 0.
ListSnapshots()
- Description: Fetches snapshot metadata from storage (
TheNet:ListSnapshotsInClusterSlotorTheNet:ListSnapshots) and populatesself.snapshots. For each snapshot, attempts to read the metadata file (.meta) to extractworld_dayandworld_season; if metadata is unavailable, falls back to reading the world file directly. Removes the first entry (current save) from the list. - Parameters: None.
- Returns: Nothing.
- Error states: Sets
self.snapshotsto{}ifsave_slotorsession_idisnil.
UpdateSaveSlot(save_slot)
- Description: Updates the
save_slotproperty to a new value. Does not reload snapshots. - Parameters:
save_slot(number) — New slot index.
- Returns: Nothing.
SetDataForSlot(save_slot)
- Description: Sets session and save parameters (
save_slot,session_id,online_mode,multi_level,use_legacy_session_path) usingShardSaveGameIndex, then triggersListSnapshots()andRefreshSnapshots(). - Parameters:
save_slot(number) — Slot index to configure for snapshot listing.
- Returns: Nothing.
Events & listeners
- Listens to: None.
- Pushes: None.