Skip to content

Commit 787dffe

Browse files
authored
IconForge: DMI Generation, Code Reorganization, Improved Caching, Cleaner I/O (#213)
1 parent 8cb606e commit 787dffe

File tree

10 files changed

+2206
-1763
lines changed

10 files changed

+2206
-1763
lines changed

dmsrc/iconforge.dm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
/// Generates a spritesheet at: [file_path][spritesheet_name]_[size_id].png
1+
/// Generates a spritesheet at: [file_path][spritesheet_name]_[size_id].[png or dmi]
22
/// The resulting spritesheet arranges icons in a random order, with the position being denoted in the "sprites" return value.
33
/// All icons have the same y coordinate, and their x coordinate is equal to `icon_width * position`.
44
///
55
/// hash_icons is a boolean (0 or 1), and determines if the generator will spend time creating hashes for the output field dmi_hashes.
6-
/// These hashes can be heplful for 'smart' caching (see rustg_iconforge_cache_valid), but require extra computation.
6+
/// These hashes can be helpful for 'smart' caching (see rustg_iconforge_cache_valid), but require extra computation.
7+
///
8+
/// generate_dmi is a boolean (0 or 1), and determines if the generator will save the sheet as a DMI or stripped PNG file.
9+
/// DMI files can be used to replace bulk Insert() operations, PNGs are more useful for asset transport or UIs. DMI generation is slower due to more metadata.
10+
/// flatten is a boolean (0 or 1), and determines if the DMI output will be flattened to a single frame/dir if unscoped (null/0 dir or frame values).
11+
/// PNGs are always flattened, regardless of argument.
712
///
813
/// Spritesheet will contain all sprites listed within "sprites".
914
/// "sprites" format:
@@ -32,9 +37,9 @@
3237
/// "error" = "[A string, empty if there were no errors.]"
3338
/// )
3439
/// In the case of an unrecoverable panic from within Rust, this function ONLY returns a string containing the error.
35-
#define rustg_iconforge_generate(file_path, spritesheet_name, sprites, hash_icons) RUSTG_CALL(RUST_G, "iconforge_generate")(file_path, spritesheet_name, sprites, "[hash_icons]")
40+
#define rustg_iconforge_generate(file_path, spritesheet_name, sprites, hash_icons, generate_dmi, flatten) RUSTG_CALL(RUST_G, "iconforge_generate")(file_path, spritesheet_name, sprites, "[hash_icons]", "[generate_dmi]", "[flatten]")
3641
/// Returns a job_id for use with rustg_iconforge_check()
37-
#define rustg_iconforge_generate_async(file_path, spritesheet_name, sprites, hash_icons) RUSTG_CALL(RUST_G, "iconforge_generate_async")(file_path, spritesheet_name, sprites, "[hash_icons]")
42+
#define rustg_iconforge_generate_async(file_path, spritesheet_name, sprites, hash_icons, generate_dmi, flatten) RUSTG_CALL(RUST_G, "iconforge_generate_async")(file_path, spritesheet_name, sprites, "[hash_icons]", "[generate_dmi]", "[flatten]")
3843
/// Returns the status of an async job_id, or its result if it is completed. See RUSTG_JOB DEFINEs.
3944
#define rustg_iconforge_check(job_id) RUSTG_CALL(RUST_G, "iconforge_check")("[job_id]")
4045
/// Clears all cached DMIs and images, freeing up memory.

0 commit comments

Comments
 (0)