Skip to content

Commit e964373

Browse files
committed
Progress on scopes
1 parent 6cd5b8f commit e964373

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ const config = {
8181
minify,
8282
outfile: './dist/bundle.js',
8383
mainFields: ['module', 'main'],
84+
logLevel: 'info',
8485
logOverride: {
8586
'commonjs-variable-in-esm': 'silent'
8687
},
8788
external: [
8889
'electron',
8990
],
9091
loader: {
91-
'.bbtheme': 'text'
92+
'.bbtheme': 'text',
93+
'.png': 'dataurl'
9294
},
9395
plugins: [
9496
conditionalImportPlugin(2, {

js/animations/animation.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ export class Animation extends AnimationItem {
275275
}
276276
}
277277
createUniqueName(arr) {
278-
var scope = this;
279278
var others = Animator.animations.slice();
280279
if (arr && arr.length) {
281280
arr.forEach(g => {
@@ -284,9 +283,9 @@ export class Animation extends AnimationItem {
284283
}
285284
others = others.filter(a => a.path == this.path);
286285
var name = this.name.replace(/\d+$/, '');
287-
function check(n) {
286+
const check = (n) => {
288287
for (var i = 0; i < others.length; i++) {
289-
if (others[i] !== scope && others[i].name == n) return false;
288+
if (others[i] !== this && others[i].name == n) return false;
290289
}
291290
return true;
292291
}
@@ -295,19 +294,18 @@ export class Animation extends AnimationItem {
295294
}
296295
for (var num = 2; num < 8e2; num++) {
297296
if (check(name+num)) {
298-
scope.name = name+num;
299-
return scope.name;
297+
this.name = name+num;
298+
return this.name;
300299
}
301300
}
302301
return false;
303302
}
304303
rename() {
305-
var scope = this;
306-
Blockbench.textPrompt('generic.rename', this.name, function(name) {
307-
if (name && name !== scope.name) {
308-
Undo.initEdit({animations: [scope]});
309-
scope.name = name;
310-
scope.createUniqueName();
304+
Blockbench.textPrompt('generic.rename', this.name, (name) => {
305+
if (name && name !== this.name) {
306+
Undo.initEdit({animations: [this]});
307+
this.name = name;
308+
this.createUniqueName();
311309
Undo.finishEdit('Rename animation');
312310
}
313311
})

js/formats/bbmodel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ var codec = new Codec('project', {
680680
new TextureGroup(tex_group, tex_group.uuid).add(false);
681681
})
682682
}
683-
if (model.textures && (!Format.single_texture || Texture.all.length == 0)) {
683+
if (model.textures) {
684684
new_textures.replace(model.textures.map(loadTexture))
685685
}
686686

js/formats/bedrock/bedrock.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ModelLoader } from "./../../io/model_loader";
66
import {animation_codec} from "./bedrock_animation"
77
import "./animation_controller_codec"
88
import { loadBedrockCollisionFromJSON } from "./bedrock_voxel_shape";
9+
import PlayerTexture from './../../../assets/player_skin.png'
910

1011
if (isApp) {
1112
window.BedrockEntityManager = class BedrockEntityManager {
@@ -1792,25 +1793,47 @@ BARS.defineActions(function() {
17921793
show_on_start_screen: false,
17931794
icon: 'icon-player',
17941795
target: 'Minecraft: Bedrock Edition',
1795-
onStart(import_as_attachable) {
1796-
let import_bbmodel = import_as_attachable ? Codecs.project.compile() : null;
1796+
onStart: async function() {
1797+
1798+
let form_config = await new Promise((resolve, reject) => {
1799+
new Dialog({
1800+
title: 'Bedrock Player Model',
1801+
form: {
1802+
import_as_attachable: {label: 'Import current model as attachable', value: true, type: 'checkbox'},
1803+
},
1804+
onConfirm(result) {
1805+
resolve(result)
1806+
},
1807+
onCancel() {
1808+
reject();
1809+
}
1810+
}).show();
1811+
});
1812+
1813+
let import_bbmodel = form_config.import_as_attachable ? Codecs.project.compile() : null;
17971814

17981815
setupProject(entity_format);
17991816
parseGeometry({object: player_geo}, {});
18001817

1818+
1819+
1820+
new Texture({name: 'player.png'}).fromDataURL(PlayerTexture).add(true, true);
1821+
18011822
let elements_before = Outliner.elements.slice();
18021823
let groups_before = Group.all.slice();
1824+
let textures_before = Texture.all.slice();
1825+
let animations_before = Animation.all.slice();
18031826
Outliner.nodes.forEach(node => {
18041827
node.scope = 1;
18051828
})
18061829

1807-
if (import_as_attachable) {
1830+
if (form_config.import_as_attachable) {
18081831
Codecs.project.merge(JSON.parse(import_bbmodel));
18091832
Outliner.nodes.forEach(node => {
18101833
if (!elements_before.includes(node) && !groups_before.includes(node)) {
18111834
node.scope = 2;
18121835
}
1813-
})
1836+
});
18141837
}
18151838
}
18161839
})

js/scopes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ScopeRuleset {
2+
3+
4+
static rulesets: Record<string, ScopeRuleset> = {};
5+
}
6+
7+

0 commit comments

Comments
 (0)