Skip to content

Commit

Permalink
v0.10.0 pt.4
Browse files Browse the repository at this point in the history
- ScopeGuard is back in action
- fixed pollution of proposal scope
- improved loot_table auto-completions
- tweaks to the settings window
- added new setting "auto fill inputs"
  • Loading branch information
solvedDev committed Mar 12, 2019
1 parent 32cd761 commit b082cfc
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 32 deletions.
16 changes: 7 additions & 9 deletions src/renderer/components/editor_shell/JsonEditor/JsonInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:auto-select-first="true"
:menu-props="{ maxHeight: 130, top: false }"
:hide-no-data="true"
no-data-text="No suggestions available..."
dense
class="json-input-menu"
></v-combobox>
Expand Down Expand Up @@ -137,7 +138,6 @@
} else if(this.file_navigation != "global") {
current.data += this.value + "";
current.type = typeof this.value;
this.updateAutoCompletions();
this.navigationBack();
//PLUGIN HOOK
Expand All @@ -151,6 +151,7 @@
this.$nextTick(() => {
this.value = "";
});
},
updateAutoCompletions() {
Expand Down Expand Up @@ -182,16 +183,13 @@
return this.items = [];
this.items = propose.filter(e => !context.includes(e));
// CURRENTLY MAKES IT IMPOSSIBLE TO SELECT A NODE WHICH IS CONSIDERED "FILLED"
// if(this.items.length == 0) {
// this.navigationBack();
// }
this.$nextTick(() => {
if(this.items && this.items.length > 0 && this.$refs.input)
this.$refs.input.focus();
if(this.items && this.items.length > 0 && this.$refs.input) {
if(this.$store.state.Settings.auto_fill_inputs) this.value = this.items[0];
this.$refs.input.focus();
}
});
},
expandPath(path) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/windowFactory/WindowContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
:items="content.options"
@change="action.default"
:color="content.color"
background-color="rgba(0, 0, 0, 0)"
:value="content.input"
solo
/>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/scripts/EventBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class EventBus {
else {
for(let i = 0; i < events[event].length; i++) {
if(events[event][i] === cb) {
console.log(events[event].splice(i, 1));
events[event].splice(i, 1);
return;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/scripts/detachObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const ARRAY_MERGE = (target, source) => {
let tmp = [];
source.forEach(e => {
if(typeof e != "object") tmp.push(e);
else tmp.push(DETACH({}, e));
else tmp.push(detachObj({}, e));
})
return tmp;
};

const DETACH = (...objs) => {
const detachObj = (...objs) => {
if(objs.length == 1) return deepmerge({}, objs[0], { arrayMerge: ARRAY_MERGE });
if(objs.length == 2) return deepmerge.all([{}, ...objs], { arrayMerge: ARRAY_MERGE });
if(objs.length == 2) return deepmerge(objs[0], objs[1], { arrayMerge: ARRAY_MERGE });
return deepmerge.all(objs, { arrayMerge: ARRAY_MERGE });
}

export default DETACH;
export default detachObj;
25 changes: 21 additions & 4 deletions src/renderer/scripts/editor/autoCompletions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import deepmerge from "deepmerge";
import VersionMap from "./VersionMap";
import Store from "../../store/index";
import detachObj from "../detachObj";
import ScopeGuard from "./ScopeGuard";

let FILE_DEFS = [];
let PARENT_CONTEXT = {};
Expand Down Expand Up @@ -132,7 +133,10 @@ class Provider {
}
if(propose.$dynamic_template !== undefined) {
let t = this.compileTemplate(propose.$dynamic_template);
if(t !== undefined) propose = detachObj(propose, t);
if(t !== undefined) {
propose = Object.assign(propose, t);
this.installScopeGuard(propose, t);
}
}

return {
Expand All @@ -155,7 +159,6 @@ class Provider {
walk(path_arr, current=LIB) {
if(path_arr === undefined || path_arr.length === 0 || current === undefined) return current;
let key = path_arr.shift();
let key_backup = key;

if(typeof current[key] === "string") {
current[key] = this.omegaExpression(current[key], null, null, false);
Expand All @@ -168,13 +171,17 @@ class Provider {
} else if(current[key] === undefined) {
if(current["$dynamic_template"] !== undefined) {
for(let i = 0; i < path_arr.length + 1; i++) this.contextUp();

let t = this.compileTemplate(current["$dynamic_template"]);
if(t !== undefined) current = detachObj(current, t);
if(t !== undefined) {
current = Object.assign(current, t);
this.installScopeGuard(current, t);
}
}

if(current[key] === undefined && current["$placeholder"] === undefined && current !== LIB) {
for(let k of Object.keys(current)) {
if(k[0] == "$") {
if(k.startsWith("$dynamic.")) {
key = k;
break;
}
Expand Down Expand Up @@ -224,6 +231,16 @@ class Provider {
if(PARENT_CONTEXT !== undefined) PARENT_CONTEXT = PARENT_CONTEXT.parent;
}

installScopeGuard(propose, new_propose) {
ScopeGuard.onScopeChange(() => {
// console.log(JSON.stringify(propose));
Object.keys(new_propose).forEach(key => {
delete propose[key];
});
// console.log(JSON.stringify(propose));
});
}

compileTemplate(template) {
// console.log(template["$key"], this.dynamic(template["$key"]), template[this.dynamic(template["$key"])]);
return template[this.dynamic(template["$key"])];
Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function setup() {
use_tabs: true,
line_wraps: false,
auto_completions: true,
auto_fill_inputs: false,
open_all_nodes: false,
default_project: "",
target_version: ""
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/store/data/settings
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"is_dev_mode":false,"is_dark_mode":false,"inversed_arrows":false,"use_tabs":true,"line_wraps":false,"auto_completions":true,"open_all_nodes":false,"default_project":"MysticBP","target_version":"v1.11"}
{"is_dev_mode":false,"is_dark_mode":false,"inversed_arrows":false,"use_tabs":true,"line_wraps":false,"auto_completions":true,"open_all_nodes":false,"default_project":"MysticBP","target_version":"v1.11","auto_fill_inputs":true}
67 changes: 58 additions & 9 deletions src/renderer/windows/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,45 @@ export default class SettingsWindow extends TabWindow {
color: "grey",
text: "\nTarget Minecraft Version"
},
new ReactiveDropdown(this, "target_version", MINECRAFT_VERSIONS ,{ text: "Choose a version...", key: `settings.editor.tab.target_version.${Math.random()}` }, () => EventBus.trigger("updateAutoCompletions")),
new ReactiveSwitch(this, "use_tabs", { color: "light-green", text: "Use Tabs", key: `settings.editor.tab.tabs.${Math.random()}` }),
new ReactiveSwitch(this, "line_wraps", { color: "light-green", text: "Word Wrap", key: `settings.editor.tab.tabs.${Math.random()}` }),
new ReactiveSwitch(this, "open_all_nodes", { color: "light-green", text: "Open All Nodes", key: `settings.editor.tab.open_all_nodes.${Math.random()}` }),
new ReactiveSwitch(this, "auto_completions", { color: "light-green", text: "Provide Auto-Completions", key: `settings.editor.tab.auto_completions.${Math.random()}` })
new ReactiveDropdown(this, "target_version", MINECRAFT_VERSIONS, {
text: "Choose a version...",
key: `settings.editor.tab.target_version.${Math.random()}`
}, () => EventBus.trigger("updateAutoCompletions")),

{
color: "grey",
text: "\nGeneral"
},
new ReactiveSwitch(this, "use_tabs", {
color: "light-green",
text: "Use Tabs",
key: `settings.editor.tab.tabs.${Math.random()}`
}),
new ReactiveSwitch(this, "line_wraps", {
color: "light-green",
text: "Word Wrap",
key: `settings.editor.tab.line_wraps.${Math.random()}`
}),
new ReactiveSwitch(this, "open_all_nodes", {
color: "light-green",
text: "Open All Nodes",
key: `settings.editor.tab.open_all_nodes.${Math.random()}`
}),

{
color: "grey",
text: "\nAuto-Completions"
},
new ReactiveSwitch(this, "auto_completions", {
color: "light-green",
text: "Provide Auto-Completions",
key: `settings.editor.tab.auto_completions.${Math.random()}`
}),
new ReactiveSwitch(this, "auto_fill_inputs", {
color: "light-green",
text: "Auto Fill Inputs",
key: `settings.editor.tab.auto_fill_inputs.${Math.random()}`
})
]
});
this.addTab({
Expand All @@ -82,7 +116,10 @@ export default class SettingsWindow extends TabWindow {
title: "Explorer"
},
content: [
new ReactiveInput(this, "default_project", { text: "Default Project", key: `settings.editor.tab.default_project.${Math.random()}` })
new ReactiveInput(this, "default_project", {
text: "Default Project",
key: `settings.editor.tab.default_project.${Math.random()}`
})
]
});
this.addTab({
Expand All @@ -91,8 +128,16 @@ export default class SettingsWindow extends TabWindow {
title: "Appearance"
},
content: [
new ReactiveSwitch(this, "is_dark_mode", { color: "light-green", text: "Dark Mode", key: `settings.appearance.tab.${Math.random()}` }),
new ReactiveSwitch(this, "inversed_arrows", { color: "light-green", text: "Inverse Arrows", key: `settings.editor.tab.arrows.${Math.random()}` })
new ReactiveSwitch(this, "is_dark_mode", {
color: "light-green",
text: "Dark Mode",
key: `settings.appearance.tab.${Math.random()}`
}),
new ReactiveSwitch(this, "inversed_arrows", {
color: "light-green",
text: "Inverse Arrows",
key: `settings.editor.tab.arrows.${Math.random()}`
})
]
});
this.addTab({
Expand All @@ -101,7 +146,11 @@ export default class SettingsWindow extends TabWindow {
title: "Developer Mode"
},
content: [
new ReactiveSwitch(this, "is_dev_mode", { color: "error", text: "Asserts", key: `settings.dev.tab.${Math.random()}` })
new ReactiveSwitch(this, "is_dev_mode", {
color: "error",
text: "Asserts",
key: `settings.dev.tab.${Math.random()}`
})
]
});

Expand Down
17 changes: 13 additions & 4 deletions static/auto_completions/loot_table/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
"entries": {
"$dynamic.list.next_index": {
"type": [ "item", "loot_table" ],
"name": "$general.item_identifier and $dynamic.loot_table_files",
"weight": "$general.number",
"functions": "$loot_table.functions",
"pools": "$loot_table.main.pools"
"$dynamic_template": {
"$key": "$dynamic.children.type",

"item": {
"name": "$general.item_identifier",
"weight": "$general.number",
"functions": "$loot_table.functions",
"pools": "$loot_table.main.pools"
},
"loot_table": {
"name": "$dynamic.loot_table_files"
}
}
}
}
}
Expand Down

0 comments on commit b082cfc

Please sign in to comment.