Cleanup
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
|
||||
function export_gpl(path, name, swatches) {
|
||||
let o: string = "";
|
||||
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");
|
||||
});
|
||||
@@ -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");
|
||||
});
|
||||
Reference in New Issue
Block a user