Skip to content

Commit

Permalink
v2.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Mar 11, 2019
1 parent 6ffc628 commit 123d46a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 60 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script>
if (typeof module === 'object') {window.module = module; module = undefined;}//jQuery Fix
const isApp = typeof require !== 'undefined';
const appVersion = '2.5.0';
const appVersion = '2.5.1';
</script>
<script src="lib/vue.min.js"></script>
<script src="lib/vue_sortable.js"></script>
Expand Down Expand Up @@ -242,7 +242,7 @@ <h2 class="dialog_handle tl" id="te_title">dialog.texture.title</h2>
<div class="tool link_only" onclick="textures.selected.reopen()"><div class="tooltip tl">menu.texture.change</div><i class="material-icons">file_upload</i></div>
<div class="tool link_only" onclick="textures.selected.refresh(true)"><div class="tooltip tl">menu.texture.refresh</div><i class="material-icons">refresh</i></div>
<div class="tool link_only" onclick="textures.selected.openFolder()"><div class="tooltip tl">menu.texture.folder</div><i class="material-icons">folder</i></div>
<div class="tool" onclick="textures.selected.remove()"><div class="tooltip tl">menu.texture.delete</div><i class="material-icons">delete</i></div>
<div class="tool" onclick="textures.selected.remove()"><div class="tooltip tl">generic.delete</div><i class="material-icons">delete</i></div>
</div>

<p class="multiline_text" id="te_path">path</p>
Expand Down Expand Up @@ -867,11 +867,11 @@ <h2 class="dialog_handle tl">dialog.input.title</h2>
<i class="material-icons texture_error" title="Image Error" v-if="texture.error">error_outline</i>
<i class="texture_movie fa fa_big fa-film" title="Animated Texture" v-if="texture.frameCount > 1"></i>
</div>
<i class="material-icons texture_particle_icon" v-if="texture.particle">bubble_chart</i>
<i class="material-icons texture_save_icon" v-bind:class="{clickable: !texture.saved}" v-on:click="texture.save()">
<template v-if="texture.saved">check_circle</template>
<template v-else>save</template>
</i>
<i class="material-icons texture_particle_icon" v-if="texture.particle">bubble_chart</i>
<div class="texture_name">{{ texture.name }}</div>
<div class="texture_res">{{!Blockbench.entity_mode ? (texture.ratio == 1 ? texture.res + 'px' : (texture.res + 'px, ' + texture.frameCount+'f')) : (texture.res + ' x ' + texture.res*texture.ratio + 'px')}}</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
<div class="tool link_only" onclick="textures.selected.reopen()"><div class="tooltip tl">menu.texture.change</div><i class="material-icons">file_upload</i></div>
<div class="tool link_only" onclick="textures.selected.refresh(true)"><div class="tooltip tl">menu.texture.refresh</div><i class="material-icons">refresh</i></div>
<div class="tool link_only" onclick="textures.selected.openFolder()"><div class="tooltip tl">menu.texture.folder</div><i class="material-icons">folder</i></div>
<div class="tool" onclick="textures.selected.remove()"><div class="tooltip tl">menu.texture.delete</div><i class="material-icons">delete</i></div>
<div class="tool" onclick="textures.selected.remove()"><div class="tooltip tl">generic.delete</div><i class="material-icons">delete</i></div>
</div>

<p class="multiline_text" id="te_path">path</p>
Expand Down
2 changes: 1 addition & 1 deletion js/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
93 changes: 46 additions & 47 deletions js/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -268,7 +312,7 @@ function loadBlockModel(model, filepath, add) {
}
}
if (import_group) {
import_group.addTo()
import_group.addTo().select()
}
if (
!model.elements &&
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 4 additions & 7 deletions js/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Texture {
this.name = ''
this.folder = '';
this.namespace = '';
this.id = '';
this.source = ''
this.particle = false
this.selected = false
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Blockbench",
"description": "Minecraft Block Model Editor",
"version": "2.5.0",
"version": "2.5.1",
"license": "MIT",
"author": {
"name": "JannisX11",
Expand Down

0 comments on commit 123d46a

Please sign in to comment.