-
Notifications
You must be signed in to change notification settings - Fork 6
/
plugin.js
70 lines (57 loc) · 1.48 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var compileCallback = (e) => {
e.model.bone_option = boneOptions;
e.model.variant = variantBones;
};
var parseCallback = (e) => {
Object.assign(boneOptions, e.model.bone_option);
Object.assign(variantBones, e.model.variant);
for (const key in variantBones) {
if (variantBones.hasOwnProperty(key)) {
selectVariant.addOption(key, variantBones[key].name);
}
}
};
(function() {
let button = $(`<div><button onclick="displayErrorList()" style="width: 100%">Error</button></div>`)
let modeSelectCallback = (e)=> {
if(e.mode.id == 'edit')
$('#left_bar').append(button)
else
button.detach();
}
Plugin.register('meg', {
title: 'ModelEngine',
author: 'Pande, Ticxo',
icon: 'icon',
description: 'A ModelEngine addon for Blockbench',
version: '0.1.0',
variant: 'both',
onload() {
// Events
Blockbench.on('select_mode', modeSelectCallback);
Codecs.project.on('compile', compileCallback);
Codecs.project.on('parse', parseCallback);
// Menus
generateBoneAction();
generateErrorAction();
generateVariantActions();
if(Mode.selected.id == 'edit')
$('#left_bar').append(button);
Blockbench.showToastNotification({
text: 'Model Engine Plugin is loaded!',
color: 'Azure',
expire: 2000
});
},
onunload() {
this.onuninstall()
},
onuninstall() {
button.detach();
Codecs.project.events.compile.remove(compileCallback);
errorListAction.delete();
boneOptionAction.delete();
selectVariant.delete();
}
})
})();