SmartTableLayoutStore.h

Where a rearranged header is kept between sessions, and how it comes back.

Source/SmartTables/Public/SmartTableLayoutStore.h

The one line way in: layouts in the config file, keyed by table id.

Config and not a save game. A column width is a setting and not progress: it carries into a new game, and it never grows a save file.

GGameUserSettingsIni is the file UGameUserSettings writes resolution and quality into, so a packaged build reads and writes it wherever the game runs.

Class
USmartTableConfigLayoutStore
Extends
USmartTableLayoutStore
Members
13
Panel fields
2

Public functions 1

BeginDestroyoverride
virtual void BeginDestroy() override

Protected functions 2

LoadLayout_Implementationoverride
virtual bool LoadLayout_Implementation( FName TableId, FSmartTableLayout & OutLayout ) const override
SaveLayout_Implementationoverride
virtual void SaveLayout_Implementation( FName TableId, const FSmartTableLayout & Layout ) override

Private functions 3

ResolvedConfigFile
const FString & ResolvedConfigFile() const

Worked out on every call and never stored. With ConfigFileName empty, the answer follows GGameUserSettingsIni wherever the engine moves it.

ScheduleFlush
void ScheduleFlush()

Puts the disk write a short while after the last change, and drops any write already waiting.

A sort click, a hide, a menu move and every FRAME of a resize drag each count as a save. Writing the ini on each of those is a file write on the game thread in the middle of the drag.

The value is in GConfig the moment SaveLayout runs, so a load in the same session reads back what was just written whether the file has been touched yet or not.

FlushNow
void FlushNow()

Writes the ini and forgets the waiting write. Called by the timer and by BeginDestroy.

Public variables 2

Config SectionConfigSectionpanel
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Smart Tables" ) FString ConfigSection = TEXT( "SmartTables.Layouts" )

The heading in the ini file that stored layouts sit under. One line per table id, and two stores pointed at two headings keep two sets of layouts apart.

Config File NameConfigFileNamepanel
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Smart Tables", meta = ( ToolTip = "Which ini file the layout is written to. Empty means the game settings ini." ) ) FString ConfigFileName

Which ini file. Empty means the game settings ini, and that is right for nearly every table.

A game that files its settings somewhere of its own names that file here.

Private variables 2

FlushHandle
FTSTicker::FDelegateHandle FlushHandle

Valid exactly while a write is waiting. ScheduleFlush replaces the timer behind it and never adds a second one.

PendingFlushFiles
TSet< FString > PendingFlushFiles

The files already written to and not yet flushed. ConfigFileName is editable in the panel and can be set from a graph, so reading it again at flush time can name a file nothing ever went to. A set, since the name can move between two saves and both files are then owed a flush.

USmartTableLayoutStore class

Where the column layout of a table goes between sessions.

Nothing is set by default, and nothing is written anywhere. With a store set and a TableId on the table, a layout is read back as the table is built and written again on every change the table did itself.

A save game needs none of this. GetLayout and ApplyLayout give over an FSmartTableLayout whose every member is SaveGame, so it drops into a save file as one field.

EditInlineNew is what puts a store in the Details panel. LayoutStore is Instanced, and the panel builds one in place from the classes carrying that flag.

Public functions 2

Load LayoutLoadLayoutoverride
UFUNCTION( BlueprintNativeEvent, Category = "Smart Tables|Layout" ) bool LoadLayout( FName TableId, FSmartTableLayout & OutLayout ) const

False means nothing is on file for this id. A first run is the usual reason, and not a failure.

Save LayoutSaveLayoutoverride
UFUNCTION( BlueprintNativeEvent, Category = "Smart Tables|Layout" ) void SaveLayout( FName TableId, const FSmartTableLayout & Layout )

Called on every layout change the table did itself, and never on ApplyLayout.

SmartTable namespace

Public functions 1

MigrateStoredLayout
SMARTTABLES_API bool MigrateStoredLayout( FSmartTableLayout & Layout )

Brings a layout just read from a store up to FSmartTableLayout::CurrentVersion. True when it arrived below that, which a caller can say once instead of on every load.

A version 0 file carries a width for every column, with nothing marking which of those a drag chose. Those widths go, and hiding, order and sort come through.

A version 1 file holds the drawn order inside Columns. Order is left empty here, since a store knows nothing about the table it loads for, and USmartTable::LoadStoredLayout fills it in.

Next: SmartTableSortKey.h