Skip to content

Commit

Permalink
Add async load
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Jan 11, 2024
1 parent 6f7d0f7 commit a4ffa6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dmsrc/iconforge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@
/// Returns "OK" if successful, otherwise, returns a string containing the error.
#define rustg_iconforge_gags(config_path, colors, output_dmi_path) RUSTG_CALL(RUST_G, "iconforge_gags")("[config_path]", colors, output_dmi_path)
/// Returns a job_id for use with rustg_iconforge_check()
#define rustg_iconforge_gags_async(config_path, colors, output_dmi_path) RUSTG_CALL(RUST_G, "iconforge_gags")("[config_path]", colors, output_dmi_path)

#define rustg_iconforge_load_gags_config_async(config_path, config_json, config_icon_path) RUSTG_CALL(RUST_G, "iconforge_load_gags_config_async")("[config_path]", config_json, config_icon_path)
/// Returns a job_id for use with rustg_iconforge_check()
#define rustg_iconforge_gags_async(config_path, colors, output_dmi_path) RUSTG_CALL(RUST_G, "iconforge_gags_async")("[config_path]", colors, output_dmi_path)

#define RUSTG_ICONFORGE_BLEND_COLOR "BlendColor"
#define RUSTG_ICONFORGE_BLEND_ICON "BlendIcon"
Expand Down
16 changes: 15 additions & 1 deletion src/iconforge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DMI spritesheet generator
// Multi-threaded DMI spritesheet generator and GAGS re-implementation
// Developed by itsmeow
use crate::{
byond::catch_panic,
Expand Down Expand Up @@ -118,6 +118,20 @@ byond_fn!(fn iconforge_load_gags_config(config_path, config_json, config_icon_pa
result
});

byond_fn!(fn iconforge_load_gags_config_async(config_path, config_json, config_icon_path) {
let config_path = config_path.to_owned();
let config_json = config_json.to_owned();
let config_icon_path = config_icon_path.to_owned();
Some(jobs::start(move || {
let result = match catch_panic(|| load_gags_config(&config_path, &config_json, &config_icon_path)) {
Ok(o) => o.to_string(),
Err(e) => e.to_string()
};
frame!();
result
}))
});

byond_fn!(fn iconforge_gags(config_path, colors, output_dmi_path) {
let config_path = config_path.to_owned();
let colors = colors.to_owned();
Expand Down

0 comments on commit a4ffa6a

Please sign in to comment.