From eb09fcb4a5580c7898986d8457a96c29dbe09fa8 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Mon, 27 Mar 2023 22:54:07 +0200 Subject: [PATCH] Integrate export codec selector into closing save flow Fix issue with uninstalling plugins Add preview.texture_frame variable Fix textures getting stuck in non-existant frame after removing animation frames --- js/animations/animation.js | 8 ++++++++ js/io/project.js | 6 +++++- js/plugin_loader.js | 4 +--- js/texturing/textures.js | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/js/animations/animation.js b/js/animations/animation.js index 5cd3e39a..51486af3 100644 --- a/js/animations/animation.js +++ b/js/animations/animation.js @@ -1197,6 +1197,14 @@ const Animator = { let texture = Texture.all[tex_index % Texture.all.length]; if (texture) texture.select(); } + if (Interface.Panels.variable_placeholders.inside_vue.text.match(/^\s*preview\.texture_frame\s*=/mi)) { + let frame = Animator.MolangParser.variableHandler('preview.texture_frame'); + + Texture.all.forEach(tex => { + tex.currentFrame = (frame % tex.frameCount) || 0; + }) + TextureAnimator.update(Texture.all.filter(tex => tex.frameCount > 1)); + } if (Project) Project.model_3d.scale.set(1, 1, 1); if (Interface.Panels.variable_placeholders.inside_vue.text.match(/^\s*preview\.scale\s*=/mi)) { let scale = Animator.MolangParser.variableHandler('preview.scale'); diff --git a/js/io/project.js b/js/io/project.js index ee168206..631dbfee 100644 --- a/js/io/project.js +++ b/js/io/project.js @@ -342,7 +342,11 @@ class ModelProject { noLink: true }) if (answer === 0) { - BarItems.save_project.trigger(); + if (Project.save_path || Project.export_path) { + BarItems.save_project.trigger(); + } else { + await BarItems.export_over.click(); + } return Project.saved; } return answer !== 2; diff --git a/js/plugin_loader.js b/js/plugin_loader.js index 8407864c..4c48d33b 100644 --- a/js/plugin_loader.js +++ b/js/plugin_loader.js @@ -31,7 +31,7 @@ const Plugins = { } } StateMemory.init('installed_plugins', 'array') -Plugins.installed = StateMemory.installed_plugins.filter(p => typeof p == 'object'); +Plugins.installed = StateMemory.installed_plugins = StateMemory.installed_plugins.filter(p => p && typeof p == 'object'); class Plugin { constructor(id, data) { @@ -436,8 +436,6 @@ async function loadInstalledPlugins() { } const install_promises = []; - Plugins.installed.replace(Plugins.installed.filter(p => p !== null)) - if (Plugins.json instanceof Object && navigator.onLine) { //From Store for (var id in Plugins.json) { diff --git a/js/texturing/textures.js b/js/texturing/textures.js index 3a41dd36..0259b076 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -192,6 +192,7 @@ class Texture { let dimensions_changed = scope.width !== img.naturalWidth || scope.height !== img.naturalHeight; scope.width = img.naturalWidth; scope.height = img.naturalHeight; + scope.currentFrame = Math.min(scope.currentFrame, (scope.frameCount||1)-1) if (scope.isDefault) { console.log('Successfully loaded '+scope.name+' from default pack')