Skip to content

SaveState

Brandon Blanker Lim-it edited this page Dec 23, 2021 · 2 revisions
Table of Contents

Overview

The save state feature allows Slab to serialize the current state of windows and other controls to disk such as position and size. The next time Slab is run, this state is read from disk and applied to all valid windows. This allows user to customize the positions and size of windows they are engaging without needing to reposition and resizing everytime Slab is launched.

The file the state is saved to is 'Slab.ini' located at Love's save directory. This is enabled by default. The user is able to disable saving the state to disk by setting this path to nil. Below are examples of how this can be achieved.

function love.load(args)
        --no saving
	Slab.SetINIStatePath(nil)

        --save to base directory
        Slab.SetINIStatePath("./Slab.ini")

        --save to parent directory
        Slab.SetINIStatePath("../Slab.ini")

        --save to child directory
        Slab.SetINIStatePath("./MyData/Slab.ini")

        --Important to be last called
	Slab.Initialize(args)
end

Certain controls can pass in the 'NoSavedSettings' boolean option to ignore saving their state to disk. Below are the current list of controls that currently support this option:

API

Below is a list of functions associated with the save state API.

SetINIStatePath

Sets the INI path to save the UI state. If nil, Slab will not save the state to disk.

GetINIStatePath

Gets the INI path to save the UI state. This value can be nil.

Return Description
String The path on disk the UI state will be saved to.
Clone this wiki locally