Files
armorpaint/base/assets/plugins/autosave.js
T

25 lines
461 B
JavaScript
Raw Normal View History

2023-02-08 14:51:54 +01:00
2024-04-02 15:45:49 +02:00
let plugin = plugin_create();
2023-02-08 14:51:54 +01:00
2024-09-03 15:52:05 +02:00
let h1 = ui_handle_create();
let h2 = ui_handle_create();
ui_handle_set_value(h2, 5.0);
2023-02-08 14:51:54 +01:00
let timer = 0.0;
2024-08-24 11:17:02 +02:00
plugin_notify_on_ui(plugin, function() {
2024-09-03 15:52:05 +02:00
if (ui_panel(h1, "Auto Save")) {
ui_slider(h2, "min", 1, 15, false, 1);
2023-02-08 14:51:54 +01:00
}
2024-08-24 11:17:02 +02:00
});
2023-02-08 14:51:54 +01:00
2024-08-24 11:17:02 +02:00
plugin_notify_on_update(plugin, function() {
if (project_filepath_get() == "") {
2024-04-02 15:45:49 +02:00
return;
}
2023-02-08 14:51:54 +01:00
timer += 1 / 60;
2024-09-03 15:52:05 +02:00
if (timer >= ui_handle_get_value(h2) * 60) {
2023-02-08 14:51:54 +01:00
timer = 0.0;
2024-04-02 15:45:49 +02:00
project_save();
2023-02-08 14:51:54 +01:00
}
2024-08-24 11:17:02 +02:00
});