From 123d46a37aafdcb39eeb80f2115b7ac7ce542956 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Mon, 11 Mar 2019 19:57:22 +0100 Subject: [PATCH] v2.5.1 --- index.html | 6 ++-- index.php | 2 +- js/element.js | 2 +- js/io.js | 93 +++++++++++++++++++++++++------------------------- js/textures.js | 11 +++--- package.json | 2 +- 6 files changed, 56 insertions(+), 60 deletions(-) diff --git a/index.html b/index.html index df091e91f..6f705665a 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ @@ -242,7 +242,7 @@

dialog.texture.title

-
menu.texture.delete
delete
+
generic.delete
delete

path

@@ -867,11 +867,11 @@

dialog.input.title

error_outline - bubble_chart + bubble_chart
{{ texture.name }}
{{!Blockbench.entity_mode ? (texture.ratio == 1 ? texture.res + 'px' : (texture.res + 'px, ' + texture.frameCount+'f')) : (texture.res + ' x ' + texture.res*texture.ratio + 'px')}}
diff --git a/index.php b/index.php index fc8c93e76..b5964a3db 100644 --- a/index.php +++ b/index.php @@ -257,7 +257,7 @@ -
menu.texture.delete
delete
+
generic.delete
delete

path

diff --git a/js/element.js b/js/element.js index 2c9abaa04..6f6ae9201 100644 --- a/js/element.js +++ b/js/element.js @@ -1161,7 +1161,7 @@ class Group extends OutlinerElement { //Clear Old Group if (selected_group) selected_group.unselect() - if (event.shiftKey === false && event.ctrlKey === false) { + if (event.shiftKey === true || event.ctrlKey === true) { selected.length = 0 } //Select This Group diff --git a/js/io.js b/js/io.js index a3756e330..1d3cba231 100644 --- a/js/io.js +++ b/js/io.js @@ -218,6 +218,44 @@ function loadBlockModel(model, filepath, add) { if (model.display !== undefined) { DisplayMode.loadJSON(model.display) } + var texture_ids = {} + if (model.textures) { + //Create Path Array to fetch textures + var path_arr = filepath.split(osfs) + var index = path_arr.length - path_arr.indexOf('models') + path_arr.splice(-index) + + var texture_arr = model.textures + var paths = {} + + for (var tex in texture_arr) { + if (texture_arr.hasOwnProperty(tex)) { + if (tex != 'particle') { + var t = new Texture({id: tex}).fromJavaLink(texture_arr[tex], path_arr.slice()).add(false) + paths[texture_arr[tex]] = texture_ids[tex] = t + } + } + } + if (texture_arr.particle) { + if (paths[texture_arr.particle]) { + paths[texture_arr.particle].enableParticle() + } else { + var t = new Texture({id: 'particle'}).fromJavaLink(texture_arr[tex], path_arr.slice()).add(false).enableParticle() + texture_ids.particle = t; + } + } + //Get Rid Of ID overlapping + for (var i = previous_texture_length; i < textures.length; i++) { + var t = textures[i] + if (getTexturesById(t.id).length > 1) { + t.id = Prop.added_models + '_' + t.id + } + } + //Select Last Texture + if (textures.length > 0) { + textures[textures.length-1].select(); + } + } var oid = elements.length @@ -233,11 +271,17 @@ function loadBlockModel(model, filepath, add) { base_cube.faces[face].texture = null base_cube.faces[face].uv = [0,0,0,0] } else { + delete base_cube.faces[face].texture; if (typeof obj.faces[face].uv === 'object') { uv_stated = true } if (obj.faces[face].texture === '#missing') { - delete base_cube.faces[face].texture; + + } else if (obj.faces[face].texture) { + var t = texture_ids[obj.faces[face].texture.replace(/^#/, '')] + if (t instanceof Texture) { + base_cube.faces[face].texture = t.uuid; + } } if (obj.faces[face].tintindex !== undefined) { base_cube.faces[face].tint = true; @@ -268,7 +312,7 @@ function loadBlockModel(model, filepath, add) { } } if (import_group) { - import_group.addTo() + import_group.addTo().select() } if ( !model.elements && @@ -301,51 +345,6 @@ function loadBlockModel(model, filepath, add) { message: tl('message.child_model_only.message', [model.parent]) }) } - if (model.textures) { - //Create Path Array to fetch textures - var path_arr = filepath.split(osfs) - var index = path_arr.length - path_arr.indexOf('models') - path_arr.splice(-index) - - var texture_arr = model.textures - var names = {} - - for (var tex in texture_arr) { - if (texture_arr.hasOwnProperty(tex)) { - if (tex != 'particle') { - var t = new Texture({id: tex}).fromJavaLink(texture_arr[tex], path_arr.slice()).add(false) - names[texture_arr[tex]] = t - } - } - } - if (texture_arr === undefined) texture_arr = {} - if (texture_arr.particle) { - if (names[texture_arr.particle]) { - names[texture_arr.particle].enableParticle() - } else { - new Texture({id: 'particle'}).fromJavaLink(texture_arr[tex], path_arr.slice()).add(false).enableParticle() - } - } - //Get Rid Of ID overlapping - for (var i = previous_texture_length; i < textures.length; i++) { - var t = textures[i] - var import_id = t.id; - if (getTexturesById(t.id).length > 1) { - t.id = Prop.added_models + '_' + t.id - } - elements.forEach(function(s, si) { - for (var face in s.faces) { - if (s.faces[face].texture === '#'+import_id) { - s.faces[face].texture = t.uuid - } - } - }) - } - //Select Last Texture - if (textures.length > 0) { - textures[textures.length-1].select(); - } - } //Set Parent if (model.parent !== undefined) { diff --git a/js/textures.js b/js/textures.js index 6fa7708f6..7e6eae60d 100644 --- a/js/textures.js +++ b/js/textures.js @@ -5,6 +5,7 @@ class Texture { this.name = '' this.folder = ''; this.namespace = ''; + this.id = ''; this.source = '' this.particle = false this.selected = false @@ -54,6 +55,7 @@ class Texture { name: this.name, folder: this.folder, namespace: this.namespace, + id: this.id, particle: this.particle, selected: this.selected, mode: this.mode, @@ -72,18 +74,13 @@ class Texture { Merge.string(this, data, 'name') Merge.string(this, data, 'folder') Merge.string(this, data, 'namespace') + Merge.string(this, data, 'id') Merge.boolean(this, data, 'particle') Merge.string(this, data, 'mode') Merge.boolean(this, data, 'saved') if (this.mode === 'bitmap') { Merge.string(this, data, 'source') } - /* - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - this[key] = properties[key] - } - }*/ return this; } //Loading @@ -618,7 +615,7 @@ class Texture { $('#texture_edit input#te_variable').val(scope.id) $('#texture_edit input#te_name').val(scope.name) $('#texture_edit input#te_folder').val(scope.folder) - $('#texture_edit input#te_namespace').val() + $('#texture_edit input#te_namespace').val(scope.namespace) $('#texture_menu_thumbnail').html(scope.img) if (scope.mode === 'link') { diff --git a/package.json b/package.json index 68796b18d..26ce43f28 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Blockbench", "description": "Minecraft Block Model Editor", - "version": "2.5.0", + "version": "2.5.1", "license": "MIT", "author": { "name": "JannisX11",