← API Reference Struct

asge::game::asset::FrameTable

A named sequence of source rects into a spritesheet — one entry per animation frame, shared by every components::Animation whose m_ClipPath resolves to the same virtual path (see asset::AssetManager::GetFrameTable/ResolveAssets).

#include <FrameTable.hpp>

Load() reads a small TOML meta-file (its own [FrameTable] table, keyed by kTableName) describing a contiguous run of cells on one regular grid (see GridSpec): "x"/"y"/"w"/"h" for the first cell, "columns"/"rows" for the grid size, "first"/"count" for which cells (indexed in "order", either "row" (default) or "column") are frames, and "spacing" for the pixel gap between cells. Every key but x/y/w/h/columns/count is optional, so older files still load; "rows" = 0 means unknown. Load() fails on an unknown "order" or on a clip that runs past the end of a known-size grid. See MakeGridFrames, which does the actual grid math. Not the spritesheet's pixels themselves; the entity's own Sprite::m_VirtualPath still points at the texture this FrameTable's rects are meant to crop m_OriginAsset (also read from the same table, key "m_OriginAsset") is that same texture's virtual path, recorded purely as editor bookkeeping (see the level editor's "Create Clip" modal and its Asset Panel import gate) so a clip's own file can point back at the spritesheet it was sliced from. Load() never rejects a file missing it — defaults to an empty string, same as any other unset field — it's the editor's explicit "Load Asset..." import that treats an empty m_OriginAsset as reason to reject a file as not one of its own clips.

An optional "frame_durations" float array gives each frame its own display time in seconds (m_FrameDurations); see FrameDuration for the fallback.

Static Public Attributes

#static constexpr str::StringView kTableName = "FrameTable"

Public Attributes

#std::vector< math::Rect > m_Frames
#std::vector< float > m_FrameDurations {}
#str::String m_OriginAsset {}

Public Member Functions

#float FrameDuration(std::size_t inIndex, float inFallback) const noexcept

Seconds frame inIndex is shown: its m_FrameDurations entry if present and positive, else inFallback.

Static Public Member Functions

#static Result< FrameTable > Load(filesystem::Path const &inPath)

Parses inPath's [FrameTable] TOML table into m_Frames/m_OriginAsset.

#static BoolResult Save(filesystem::Path const &inPath, GridSpec const &inSpec, str::StringView inOriginAsset, std::vector< float > const &inFrameDurations={}) noexcept

Writes inSpec/inOriginAsset as inPath's [FrameTable] table — the exact schema Load() reads back (see the struct doc comment).

Creates inPath if it doesn't exist; overwrites it (as a fresh file containing just this table) if it does — meant for a file this call is the sole owner of (the level editor's in-editor spritesheet slicer, say), not one with other hand-authored content to preserve.

#static bool IsFrameTable(filesystem::Path const &inPath)

Checks whether inPath is a FrameTable clip — a TOML file with a top-level [FrameTable] table — without building the frame grid.

Parses the real TOML, unlike a substring search.

Returns

false for a missing, malformed, or non-matching file alike.