Skip to content

Commit

Permalink
v2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 authored Dec 16, 2018
1 parent fdd60bd commit d4e6ad1
Show file tree
Hide file tree
Showing 31 changed files with 546 additions and 395 deletions.
3 changes: 1 addition & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@
position: absolute;
opacity: 0.4;
cursor: inherit;
pointer-events: none;
}
#uv_dialog_toolbar {
clear: both;
Expand Down Expand Up @@ -1561,7 +1562,6 @@
width: 100%;
min-height: 34px;
padding-left: 6px;
border-bottom: 2px solid var(--color-border);
}
#settings h3 > i {
margin-top: 5px;
Expand Down Expand Up @@ -1618,7 +1618,6 @@
}
#settingslist > li {
padding-left: 6px;
border-bottom: 2px solid var(--color-border);
}
#settingslist li li {
padding-top: 7px;
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2 class="dialog_handle tl">dialog.toolbar_edit.title</h2>
<li v-for="item in currentBar" v-bind:title="item.name" :key="item.id||item">
<div v-if="typeof item === 'string'" class="toolbar_separator"></div>
<div v-else class="tool">
<span class="icon_wrapper" v-bind:style="{opacity: BARS.condition(item.condition) ? 1 : 0.4}" v-html="Blockbench.getIconNode(item.icon).outerHTML"></span>
<span class="icon_wrapper" v-bind:style="{opacity: BARS.condition(item.condition) ? 1 : 0.4}" v-html="Blockbench.getIconNode(item.icon, item.color).outerHTML"></span>
<div class="tooltip">{{item.name + (BARS.condition(item.condition) ? '' : ' (' + tl('dialog.toolbar_edit.hidden') + ')' )}}</div>
</div>
</li>
Expand All @@ -159,7 +159,7 @@ <h2 class="dialog_handle tl">dialog.toolbar_edit.title</h2>

<ul class="list" id="bar_item_list">
<li v-for="item in searchedBarItems" v-on:click="addItem(item)">
<div class="icon_wrapper normal" v-html="Blockbench.getIconNode(item.icon).outerHTML"></div>
<div class="icon_wrapper normal" v-html="Blockbench.getIconNode(item.icon, item.color).outerHTML"></div>
<div class="icon_wrapper add"><i class="material-icons">add</i></div>
{{ item.name }}
</li>
Expand Down Expand Up @@ -452,13 +452,13 @@ <h3 v-on:click="toggleCategory(category)">
<div class="setting_element" v-html="Blockbench.getIconNode(setting.icon).outerHTML"></div>
</template>
<template v-else-if="!setting.type"><!--TOGGLE-->
<div class="setting_element"><input type="checkbox" v-model="setting.value" v-on:click="saveSettings()"></div>
<div class="setting_element"><input type="checkbox" v-model="setting.value" v-bind:id="'setting_'+key" v-on:click="saveSettings()"></div>
</template>

<div class="setting_label">
<label class="setting_label" v-bind:for="'setting_'+key">
<div class="setting_name">{{ tl('settings.'+key) }}</div>
<div class="setting_description">{{ tl('settings.'+key+'.desc') }}</div>
</div>
</label>

<template v-if="setting.type === 'text'">
<input type="text" class="dark_bordered" style="width: 96%" v-model="setting.value" v-on:input="saveSettings()">
Expand Down
224 changes: 113 additions & 111 deletions index.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,14 @@ class BarSelect extends Widget {
})
}
change(event) {
this.set( $(event.target).find('option:selected').attr('id') )
this.set( $(event.target).find('option:selected').prop('id') )
if (this.onChange) {
this.onChange(this, event)
}
}
set(id) {
this.value = id
$(this.nodes).find('option#'+id).attr('selected', true).siblings().attr('selected', false)
$(this.nodes).find('option#'+id).prop('selected', true).siblings().prop('selected', false)
}
get() {
return this.value
Expand Down
38 changes: 26 additions & 12 deletions js/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,12 @@ class Keyframe {
}
}
get(axis) {
let num = parseFloat(this[axis])
if (isNaN(num)) {
return this[axis]
if (!this[axis]) {
return 0;
} else if (!isNaN(this[axis])) {
return parseFloat(this[axis])
} else {
return num
return this[axis]
}
}
calc(axis) {
Expand All @@ -423,6 +424,9 @@ class Keyframe {
}
}
getArray() {
if (this.channel === 'scale') {
return this.get('x')
}
var arr = [
this.get('x'),
this.get('y'),
Expand Down Expand Up @@ -636,7 +640,7 @@ function selectAllKeyframes() {
updateKeyframeSelection()
}
function removeSelectedKeyframes() {
Undo.initEdit({keyframes: Timeline.selected})
Undo.initEdit({keyframes: Timeline.selected, keep_saved: true})
var i = Timeline.keyframes.length;
while (i > 0) {
i--;
Expand All @@ -645,6 +649,7 @@ function removeSelectedKeyframes() {
kf.remove()
}
}
updateKeyframeSelection()
Undo.finishEdit('remove keyframes')
}

Expand Down Expand Up @@ -689,6 +694,10 @@ const Animator = {
if (Animator.selected) {
Animator.selected.select()
}
if (isApp && !Prop.animation_path && !Animator.animations.length && Prop.file_path) {
//Load
findBedrockAnimation()
}
},
leave: function (argument) {
Timeline.pause()
Expand Down Expand Up @@ -745,6 +754,9 @@ const Animator = {
}
}
}
if (isApp && file.path) {
Prop.animation_path = file.path
}
}
},
buildFile: function(options) {
Expand Down Expand Up @@ -866,7 +878,7 @@ const Timeline = {
}
})
$('.keyframe_input').click(e => {
Undo.initEdit({keyframes: Timeline.selected})
Undo.initEdit({keyframes: Timeline.selected, keep_saved: true})
}).focusout(e => {
Undo.finishEdit('edit keyframe')
})
Expand All @@ -878,7 +890,7 @@ const Timeline = {
axis: 'x',
distance: 10,
start: function(event, ui) {
Undo.initEdit({keyframes: Timeline.keyframes})
Undo.initEdit({keyframes: Timeline.keyframes, keep_saved: true})
var id = $(ui.helper).attr('id')
var i = 0;
while (i < Timeline.vue._data.keyframes.length) {
Expand Down Expand Up @@ -1020,7 +1032,7 @@ const Timeline = {
Blockbench.showQuickMessage('message.no_bone_selected')
return
}
Undo.initEdit({keyframes: bone.keyframes})
Undo.initEdit({keyframes: bone.keyframes, keep_saved: true})
var kf = bone.addKeyframe(false, Timeline.second, channel?channel:'rotation')
kf.select()
Undo.finishEdit('add_keyframe')
Expand All @@ -1041,7 +1053,7 @@ const Timeline = {
}
var bone = Animator.selected.getBoneAnimator()
if (bone) {
Undo.initEdit({keyframes: bone.keyframes})
Undo.initEdit({keyframes: bone.keyframes, keep_saved: true})
var kf = bone.addKeyframe(false, Math.round(time*30)/30, row === 2 ? 'scale' : (row === 1 ? 'position' : 'rotation'))
kf.select().callMarker()
Vue.nextTick(Timeline.update)
Expand Down Expand Up @@ -1096,8 +1108,10 @@ BARS.defineActions(function() {
condition: () => Animator.open,
click: function () {
var content = autoStringify(Animator.buildFile())
var path = Prop.file_path
if (isApp) {
var path = Prop.animation_path

if (isApp && !path) {
path = Prop.file_path
var exp = new RegExp(osfs.replace('\\', '\\\\')+'models'+osfs.replace('\\', '\\\\'))
var m_index = path.search(exp)
if (m_index > 3) {
Expand Down Expand Up @@ -1160,7 +1174,7 @@ BARS.defineActions(function() {
Animator.preview()
},
onBefore: function() {
Undo.initEdit({keyframes: Timeline.selected})
Undo.initEdit({keyframes: Timeline.selected, keep_saved: true})
},
onAfter: function() {
Undo.finishEdit('edit keyframe')
Expand Down
150 changes: 79 additions & 71 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ class API {
icon = icon()
}
if (icon === undefined) {
//Missing
jq = $('<i class="material-icons icon">help_outline</i>')
} else if (icon instanceof HTMLElement) {
//Node
jq = $(icon)
} else if (icon.substr(0, 2) === 'fa') {
//Font Awesome
jq = $('<i class="icon fa fa_big ' + icon + '"></i>')
} else if (icon.substr(0, 5) === 'icon-') {
//Icomoon
jq = $('<i class="' + icon + '"></i>')
} else if (icon.substr(0, 14) === 'data:image/png') {
//Data URL
jq = $('<img class="icon" src="'+icon+'">')
} else {
//Material Icon
jq = $('<i class="material-icons icon">' + icon + '</i>')
}
if (color) {
Expand Down Expand Up @@ -228,77 +234,7 @@ class API {
defaultPath: options.startpath
},
function (fileNames) {
if (fileNames == undefined) return;

var results = [];
var result_count = 0;
var i = 0;
var errant;
while (i < fileNames.length) {
(function() {
var this_i = i;
var file = fileNames[i]

if (options.readtype === 'image') {
//
var extension = pathToExtension(file)
if (extension === 'tga') {
var targa_loader = new Targa()
targa_loader.open(file, () => {

results[this_i] = {
name: pathToName(file, true),
path: file,
content: targa_loader.getDataURL()
}

result_count++;
if (result_count === fileNames.length) {
cb(results)
}
})

} else {
results[this_i] = {
name: pathToName(file, true),
path: file
}
result_count++;
if (result_count === fileNames.length) {
cb(results)
}
}
} else /*text*/ {
fs.readFile(file, 'utf-8', function (err, data) {
if (err) {
console.log(err)
if (!errant && options.errorbox !== false) {
Blockbench.showMessageBox({
translateKey: 'file_not_found',
icon: 'error_outline'
})
}
errant = true
return;
}
if (data.charCodeAt(0) === 0xFEFF) {
data = data.substr(1)
}
results[this_i] = {
name: pathToName(file, true),
path: file,
content: data
}
result_count++;
if (result_count === fileNames.length) {
cb(results)
}
})
}
})()
i++;
}

Blockbench.read(fileNames, options, cb)
})
} else {
$('<input '+
Expand Down Expand Up @@ -350,6 +286,78 @@ class API {
}).click()
}
}
read(paths, options, cb) {
if (!isApp || paths == undefined) return false;

var results = [];
var result_count = 0;
var i = 0;
var errant;
while (i < paths.length) {
(function() {
var this_i = i;
var file = paths[i]

if (options.readtype === 'image') {
//
var extension = pathToExtension(file)
if (extension === 'tga') {
var targa_loader = new Targa()
targa_loader.open(file, () => {

results[this_i] = {
name: pathToName(file, true),
path: file,
content: targa_loader.getDataURL()
}

result_count++;
if (result_count === paths.length) {
cb(results)
}
})

} else {
results[this_i] = {
name: pathToName(file, true),
path: file
}
result_count++;
if (result_count === paths.length) {
cb(results)
}
}
} else /*text*/ {
fs.readFile(file, 'utf-8', function (err, data) {
if (err) {
console.log(err)
if (!errant && options.errorbox !== false) {
Blockbench.showMessageBox({
translateKey: 'file_not_found',
icon: 'error_outline'
})
}
errant = true
return;
}
if (data.charCodeAt(0) === 0xFEFF) {
data = data.substr(1)
}
results[this_i] = {
name: pathToName(file, true),
path: file,
content: data
}
result_count++;
if (result_count === paths.length) {
cb(results)
}
})
}
})()
i++;
}
}
export(options, cb) {
if (!options) return;
/*
Expand Down
12 changes: 12 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ function findEntityTexture(mob, return_path) {
}
}
}
function findBedrockAnimation() {

var animation_path = Prop.file_path.split(osfs)
var index = animation_path.lastIndexOf('models')
animation_path.splice(index)
animation_path = [...animation_path, 'animations', pathToName(Prop.file_path)+'.json'].join(osfs)
if (fs.existsSync(animation_path)) {
Blockbench.read([animation_path], {}, (files) => {
Animator.loadFile(files[0])
})
}
}
//Writers
function saveFile(props) {
if (Prop.file_path) {
Expand Down
Loading

0 comments on commit d4e6ad1

Please sign in to comment.