This commit is contained in:
luboslenco
2025-09-01 21:31:59 +02:00
parent 53ec3068a2
commit 3faf6b3d73
174 changed files with 352 additions and 343 deletions
+24
View File
@@ -0,0 +1,24 @@
let plugin = plugin_create();
let h1 = ui_handle_create();
let h2 = ui_handle_create();
ui_handle_set_value(h2, 5.0);
let timer = 0.0;
plugin_notify_on_ui(plugin, function() {
if (ui_panel(h1, "Auto Save")) {
ui_slider(h2, "min", 1, 15, false, 1);
}
});
plugin_notify_on_update(plugin, function() {
if (project_filepath_get() == "") {
return;
}
timer += 1 / 60;
if (timer >= ui_handle_get_value(h2) * 60) {
timer = 0.0;
project_save();
}
});
+24
View File
@@ -0,0 +1,24 @@
function export_gpl(path, name, swatches) {
let o = "";
o += "GIMP Palette\\n";
o += "Name: " + name + "\\n";
o += "# armorpaint.org\\n";
o += "#\\n";
for (let i = 0; i < swatches.length; ++i) {
let swatch = swatches[i];
let rb = color_get_rb(swatch.base);
let gb = color_get_gb(swatch.base);
let bb = color_get_bb(swatch.base);
o += rb + " " + gb + " " + bb + "\\n";
}
iron_file_save_bytes(path, sys_string_to_buffer(o), o.length);
}
let plugin = plugin_create();
// path_swatch_exporters_set("gpl", export_gpl);
plugin_notify_on_delete(plugin, function() {
// path_swatch_exporters_delete("gpl");
});
+47
View File
@@ -0,0 +1,47 @@
function import_gpl(path, replace_existing) {
let b = data_get_blob(path);
// let swatches: TSwatchColor[] = [];
// let str: string = sys_buffer_to_string(b);
// let lines: string[] = string_split(str, "\\n");
// // GIMP's color palette importer: https://gitlab.gnome.org/GNOME/gimp/-/blob/gimp-2-10/app/core/gimppalette-load.c#L39
// if (!starts_with(lines[0], "GIMP Palette")) {
// console_error(tr("Not a valid GIMP color palette"));
// return;
// }
// let delimiter: string = ~/\s+/ig;
// for (let line of lines) {
// if (starts_with(line, "Name:")) continue;
// else if (starts_with(line, "Columns:")) continue;
// else if (starts_with(line, "#")) continue;
// else {
// let tokens: string[] = string_split(delimiter, line);
// if (tokens.length < 3) continue;
// let swatch: TSwatchColor = makeSwatch(Color.fromBytes(tokens[0], tokens[1], tokens[2]));
// array_push(swatches, swatch);
// }
// }
// if (replaceExisting) {
// raw.swatches = [];
// if (swatches.length == 0) { // No swatches contained
// array_push(raw.swatches, makeSwatch());
// }
// }
// if (swatches.length > 0) {
// for (let s of swatches) {
// array_push(raw.swatches, s);
// }
// }
}
let plugin = plugin_create();
// path_swatch_importers_set("gpl", import_gpl);
plugin_notify_on_delete(plugin, function() {
// path_swatch_importers_delete("gpl");
});
File diff suppressed because one or more lines are too long
+13
View File
@@ -0,0 +1,13 @@
function import_txt(path) {
let b = data_get_blob(path);
let filename = path.split("\\\\").pop().split("/").pop();
ui_box_show_message(filename, buffer_to_string(b));
data_delete_blob(path);
}
let plugin = plugin_create();
path_texture_importers_set("txt", import_txt);
plugin_notify_on_delete(plugin, function() {
path_texture_importers_delete("txt");
});