Skip to content

savegame_react_util

Source: base/tealdef/gui/menu/savegame_react_util.d.tl

Notes

Savegame helpers and recipes of the load, save and new game pages, loaded with ug_require "/gui/menu/savegame_react_util.tl".

SavegameReactUtil

record global base/tealdef/gui/menu/savegame_react_util.d.tl:3

global record SavegameReactUtil

Load: local savegame_react_util = ug_require "/gui/menu/savegame_react_util.tl"

Notes

Savegame helpers and recipes for the main menu and pause menu pages.

Fields

Name Type Description
SavegameCard Recipe<SavegameCardParams> Tile showing a savegame group with its screenshot, save date and info icons, and a load button unless save is set. used 4× in the base game
SavegameFilters Recipe<SavegameFiltersParam> Filter text field and sort mode combo box for savegame lists. used 2× in the base game
SavegameSelectCard Recipe<SavegameCardSelectParams> Detail view of a savegame group on the load page, with the saves of the group, their details, load, share and delete buttons and tabs for gameplay settings and mods. used 1× in the base game
SavegameStorageBar Recipe0 Progress bar showing the used and total savegame storage space in MB. used 2× in the base game
LoadPreview Recipe<LoadPreviewParam> Image of a savegame (from app.getSavegameImage, or the screenshot in the savegame data), or a loading or error image. used 1× in the base game
ScrollableAchievementsList Recipe<ScrollableAchievementsListParams> Scrollable list of all achievements with their unlocked state and progress. used 2× in the base game

Functions

makeModIdList({string}) : {Mod.ModId} base/tealdef/gui/menu/savegame_react_util.d.tl:48

Call as savegame_react_util.makeModIdList

Notes

Converts mod names to mod ids.

Returns {Mod.ModId}: A Mod.ModId per name.

Used in the base game: 4 times in 1 file

base/content/gui/gui/menu/new_game_or_map_settings_page.tl:603

local modIdList = savegame_react_util.makeModIdList(activeModsState:old())

makeModStringList({Mod.ModId}) : {string} base/tealdef/gui/menu/savegame_react_util.d.tl:49

Call as savegame_react_util.makeModStringList

Notes

Converts mod ids to mod names.

Returns {string}: The name of each mod id.

groupSaves(savegames : {SaveGameInfo}, filter : string, prefix : string, sortMode? : SavegameFiltersParam.SortMode, ascending? : boolean, saveTypeFilter? : SaveGameType) : {SaveGroup} base/tealdef/gui/menu/savegame_react_util.d.tl:50

Call as savegame_react_util.groupSaves

Notes

Groups savegames by their group name and sorts the groups.

Parameter Type Description
savegames {SaveGameInfo} Savegames to group, for example from app.findAllSavegames(namespace).
filter string If set, only saves whose name contains this text are included.
prefix string Stored as groupName.prefix of each group; the base game uses "!" for normal and "?" for built-in saves.
sortMode? SavegameFiltersParam.SortMode "Name" sorts by group name, otherwise by the time of the most recent save.
ascending? boolean Order of the sort.
saveTypeFilter? SaveGameType If set, only saves of this type are included.

Returns {SaveGroup}: The groups. Within a group the saves are sorted newest first; mostRecent is the newest manual save, or the newest save if there is no manual one.

Used in the base game: 5 times in 3 files

base/content/gui/gui/menu/load_game_page.tl:34

return savegame_react_util.groupSaves(app.findAllSavegames(saveGameNamespace), filterText, "!", sortMode, ascending)
base/content/gui/gui/menu/save_game_page.tl:163
return savegame_react_util.groupSaves(app.findAllSavegames(savegameNameSpace), filterText, "!", sortMode, ascending, api.type["enum"].SaveGameType.Manual)
base/content/gui/gui/menu/new_game_page.tl:25
local saveGroups = savegame_react_util.groupSaves(app.findAllSavegames(app.SaveGameNamespace.getSavemap()), "", "!", "Date", false)

getSaveGroupAndType(saveName : string) : string, SaveGameType, string, string base/tealdef/gui/menu/savegame_react_util.d.tl:51

Call as savegame_react_util.getSaveGroupAndType

group, type, ingame date, file timestamp

Notes

Parses a savegame name with app.parseSavegameName.

Returns string, SaveGameType, string, string: Group name, save type, in-game date and file timestamp.

Used in the base game: 3 times in 3 files

base/content/gui/gui/menu/progress_page.tl:54

title = savegame_react_util.getSaveGroupAndType(progressDataState:old().saveGameId.saveGameName)
base/content/gui/gui/menu/new_game_page.tl:135
local __, savetype = savegame_react_util.getSaveGroupAndType(group.mostRecent.saveName)
base/content/gui/gui/menu/main_page.tl:411
local continueTitle = continueState:old().lastSaveGameId and savegame_react_util.getSaveGroupAndType(continueState:old().lastSaveGameId.saveGameName) or ""

checkForError(savegameData : SaveGameData) : {ErrorType}, string base/tealdef/gui/menu/savegame_react_util.d.tl:58

Call as savegame_react_util.checkForError

Notes

Checks whether a savegame can be loaded.

Parameter Type Description
savegameData SaveGameData Savegame data from app.getSavegameInfo.

Returns {ErrorType}, string: The list of errors (empty if none) and a translated error text.

Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/main_page.tl:368

errorTypes, errorMsg = savegame_react_util.checkForError(dataContinueState:old())

getCampaignInfoSorted(campaign : ResName) : CampaignInfo base/tealdef/gui/menu/savegame_react_util.d.tl:86

Call as savegame_react_util.getCampaignInfoSorted

Notes

Collects the missions of a campaign, sorted by order, with their completion-based availability.

Parameter Type Description
campaign ResName Resource name of the campaign.

Returns CampaignInfo: The campaign info, or nil if the campaign is not found.

Used in the base game: 3 times in 2 files

base/content/gui/gui/menu/campaign_page.tl:171

local campaignInfo = savegame_react_util.getCampaignInfoSorted(campaign)
base/content/gui/gui/menu/main_page.tl:434
local campaignInfo = savegame_react_util.getCampaignInfoSorted(continueState:old().recentCampaign.campaign)

SavegameReactUtil.SavegameCardParams

record base/tealdef/gui/menu/savegame_react_util.d.tl:4

record SavegameCardParams

Notes

Parameters of SavegameCard.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:244

savegame_react_util.SavegameCard = react.RegisterRecipe("SavegameCard", function(savegameCardParams : SavegameReactUtil.SavegameCardParams) : TreeNodeId

Fields

Name Type Description
saveGame SaveGroup Savegame group shown by the card; its most recent save is loaded and shown.
saveGameNamespace string Namespace of the savegame (for example app.SaveGameNamespace.getSavemap() for maps).
mapEditor boolean Whether the save is loaded in the map editor (button text "Load Map").
mapNewGame boolean Whether the card starts a new game on a map (button text "Play Map").
builtinSavegame boolean Whether the savegame is built into the game; shows an info icon that it cannot be deleted.
modMap boolean Whether the map comes from a mod; shows an info icon.
deluxeMap boolean Whether to show the animated "Deluxe" badge.
save boolean Whether the card is used on the save page; the card then has no load button.
extraClass string Additional style classes of the card.
calloutContainerRef ReactRefWrapApi0<CalloutApi> Callout container used by the card.
commonParams CommonMenuParams Common parameters of the menu page.

Functions

onClickMain(SaveGameData, SaveGameId) base/tealdef/gui/menu/savegame_react_util.d.tl:12

optional

onClickDetails(SaveGameData, SaveGameId) base/tealdef/gui/menu/savegame_react_util.d.tl:13

optional

onDoubleClickMain(SaveGameData, SaveGameId) base/tealdef/gui/menu/savegame_react_util.d.tl:14

optional

SavegameReactUtil.SavegameFiltersParam

record base/tealdef/gui/menu/savegame_react_util.d.tl:21

record SavegameFiltersParam

Notes

Parameters of SavegameFilters.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:703

savegame_react_util.SavegameFilters = react.RegisterRecipe("SavegameFilters", function(savegameCardParams : SavegameReactUtil.SavegameFiltersParam) : TreeNodeId

Fields

Name Type Description
sortMode SortMode Current sort mode.
filterText string Current filter text.

Functions

setSortMode(mode : SortMode) base/tealdef/gui/menu/savegame_react_util.d.tl:27

Notes

Called when the player chooses another sort mode.

setFilterText(text : string) base/tealdef/gui/menu/savegame_react_util.d.tl:29

Notes

Called while the player types in the filter field.

SavegameReactUtil.SavegameFiltersParam.SortMode

enum base/tealdef/gui/menu/savegame_react_util.d.tl:22

enum SortMode

Notes

Sort order of savegame groups.

Used in the base game: 9 times in 3 files

base/content/gui/gui/menu/load_game_page.tl:33

local fetchSaveGames = function(filterText : string, sortMode : SavegameReactUtil.SavegameFiltersParam.SortMode, ascending : boolean) : {SaveGroup}
base/content/gui/gui/menu/savegame_react_util.tl:121
function savegame_react_util.groupSaves(savegames : {SaveGameInfo}, filter : string, prefix : string, sortMode : SavegameReactUtil.SavegameFiltersParam.SortMode
base/content/gui/gui/menu/save_game_page.tl:162
local fetchSaveGames = function(filterText : string, sortMode : SavegameReactUtil.SavegameFiltersParam.SortMode, ascending : boolean) : {SaveGroup}

Value Description
"Name" Sort by group name.
"Date" Sort by the time of the most recent save.

SavegameReactUtil.SelectedSavegame

record base/tealdef/gui/menu/savegame_react_util.d.tl:32

record SelectedSavegame

Notes

Savegame selected on the load page.

Used in the base game: 7 times in 3 files

base/content/gui/gui/menu/savegame_react_util.tl:880

local savegameNameState : ReactStateT<SavegameReactUtil.SelectedSavegame> = react.useState({
base/content/gui/gui/menu/advanced_settings.tl:14
savegameNameState : ReactStateT<SavegameReactUtil.SelectedSavegame>
base/content/gui/gui/menu/mod_selector_page.tl:39
savegameNameState : ReactStateT<SavegameReactUtil.SelectedSavegame>

Fields

Name Type Description
saveGroup GroupId Group of the selected savegame.
savegameData SaveGameData Data of the selected savegame, possibly with changed mods and settings; nil until loaded.
initialData SaveGameData Data of the savegame as stored, used to detect changed mods and settings.
index integer Index of the selected save within the group's saves.

SavegameReactUtil.SavegameCardSelectParams

record base/tealdef/gui/menu/savegame_react_util.d.tl:39

record SavegameCardSelectParams

Notes

Parameters of SavegameSelectCard.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:848

savegame_react_util.SavegameSelectCard = react.RegisterRecipe("SavegameSelectCard", function(savegameCardParams : SavegameReactUtil.SavegameCardSelectParams) : 

Fields

Name Type Description
selectedSavegame SelectedSavegame Initially selected savegame.
saveNameSpace string Namespace of the savegames.
map boolean Whether the save is loaded in the map editor.
inPauseMenu boolean Whether the card is shown in the pause menu; passed on to the mod selector page.
commonParams CommonMenuParams Common parameters of the menu page.

Functions

onDelete() base/tealdef/gui/menu/savegame_react_util.d.tl:45

Notes

Called when the selected group no longer exists, for example after its last save has been deleted.

SavegameReactUtil.ErrorType

enum base/tealdef/gui/menu/savegame_react_util.d.tl:53

enum ErrorType

Notes

Reason why a savegame cannot be loaded as it is.

Used in the base game: 3 times in 2 files

base/content/gui/gui/menu/savegame_react_util.tl:208

savegame_react_util.checkForError = function(savegameData : SaveGameData) : {SavegameReactUtil.ErrorType}, string
base/content/gui/gui/menu/main_page.tl:365
local errorTypes : {SavegameReactUtil.ErrorType} = {}

Value Description
"ModMissing" Required mods or DLCs are missing.
"CannotLoad" The savegame information could not be read.
"UnsupportedMapDimension" The map size or format is not supported (checked on consoles only).

SavegameReactUtil.LoadPreviewParam

record base/tealdef/gui/menu/savegame_react_util.d.tl:65

record LoadPreviewParam

Notes

Parameters of LoadPreview.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:73

savegame_react_util.LoadPreview = react.RegisterRecipe("LoadPreview", function(param : SavegameReactUtil.LoadPreviewParam) : TreeNodeId

Fields

Name Type Description
saveGameData SaveGameData Savegame data; its screenshot is used if the savegame image cannot be loaded.
saveGameId SaveGameId Id of the savegame whose image is shown.

SavegameReactUtil.ScrollableAchievementsListParams

record base/tealdef/gui/menu/savegame_react_util.d.tl:71

record ScrollableAchievementsListParams

Notes

Parameters of ScrollableAchievementsList.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:1551

savegame_react_util.ScrollableAchievementsList = react.RegisterRecipe("ScrollableAchievementsList", function(params : SavegameReactUtil.ScrollableAchievementsLi

Fields

Name Type Description
enableRightStickNavigation boolean Whether the list scrolls with the IA_SCROLL_UP and IA_SCROLL_DOWN input actions.

SavegameReactUtil.CampaignInfo

record base/tealdef/gui/menu/savegame_react_util.d.tl:76

record CampaignInfo

Notes

Missions of a campaign with their unlocked state, returned by getCampaignInfoSorted.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/savegame_react_util.tl:1724

savegame_react_util.getCampaignInfoSorted = function(campaign : ResName) : SavegameReactUtil.CampaignInfo

Fields

Name Type Description
missionInfo {MissionInfo} Missions of the campaign, sorted by their order.
desc CampaignDesc Campaign description.
highestUnlocked integer Position (in missionInfo) of the last completed mission; 0 if none is completed.

SavegameReactUtil.CampaignInfo.MissionInfo

record base/tealdef/gui/menu/savegame_react_util.d.tl:77

record MissionInfo

Notes

One mission of a campaign.

Fields

Name Type Description
name string Resource name of the mission.
desc MissionDesc Mission description.
enabled boolean Whether the mission can be started. With unlockingProgression, only missions up to one after the last completed one are enabled.