class

GSDL::AssetManager

Inherits Reference < Object

Constants

FormatCode = "PACK"

This FormatCode must match the FormatCode in src/packer.cr but we shouldn't include src/packer.cr in GDSL code otherwise it will pack the assets everytime GSDL is required, instead the GSDL consumer should manually pack assets using the provided gsdl-packer tool specified in the README, installed via: crystal lib/game_sdl/install_gsdl_tools.cr

Class methods

asset_path

Returns the base path for loading loose assets.

Source
asset_path=(path : String)

Sets the base path for loading loose assets in debug mode.

Source
close_pack

Closes the opened packfile. Should be called when all assets are loaded in release mode, or on application exit

Source
initialized?

Checks if the AssetManager has been initialized (i.e., packfile loaded).

Source
load_pack(path : String = "")

Loads the assets.pack file and parses its manifest. The packfile is kept open for subsequent asset loading. should only be called in release mode

Source
load_raw_data(path_key : String) : Bytes

Reads raw byte data for a given path_key from the loaded packfile. Returns a Bytes object.

Source
open_io_stream(path_key : String) : SDL3::IOStream

Loads raw data from the asset pack and then creates an SDL3::IOStream from raw byte data. This loads the entire asset into memory before passing it to SDL3. Suitable for smaller to medium-sized assets.

Source
with_io_stream(path_key : String, close_io = false, &)
Source