Files
armorpaint/paint/assets/plugins/converter.js
T

26 lines
774 B
JavaScript
Raw Normal View History

2019-10-30 21:40:35 +01:00
2024-04-02 15:45:49 +02:00
let plugin = plugin_create();
2024-09-03 15:52:05 +02:00
let h1 = ui_handle_create();
2019-10-30 21:40:35 +01:00
2024-08-09 14:51:14 +02:00
plugin_notify_on_ui(plugin, function() {
2024-09-03 15:52:05 +02:00
if (ui_panel(h1, "Converter")) {
ui_row([1 / 2, 1 / 2]);
if (ui_button(".arm to .json")) {
2024-04-02 15:45:49 +02:00
ui_files_show("arm", false, true, function(path) {
let b = data_get_blob(path);
let parsed = armpack_decode(b);
2024-08-16 11:44:07 +02:00
let out = string_to_buffer(JSON.stringify(parsed, null, " "));
2024-09-03 16:39:16 +02:00
iron_file_save_bytes(path.substr(0, path.length - 3) + "json", out);
2019-11-12 10:50:25 +01:00
});
2019-10-30 21:40:35 +01:00
}
2024-09-03 15:52:05 +02:00
if (ui_button(".json to .arm")) {
2024-04-02 15:45:49 +02:00
ui_files_show("json", false, true, function(path) {
let b = data_get_blob(path);
2024-08-16 11:44:07 +02:00
let parsed = JSON.parse(buffer_to_string(b));
2024-04-02 15:45:49 +02:00
let out = armpack_encode(parsed);
2024-09-03 16:39:16 +02:00
iron_file_save_bytes(path.substr(0, path.length - 4) + "arm", out);
2019-11-12 10:50:25 +01:00
});
2019-10-30 21:40:35 +01:00
}
}
2024-08-09 14:51:14 +02:00
});