editor.used_flags

This commit is contained in:
oc 2019-06-29 22:58:06 +08:00
parent 90fc42fc31
commit b138d0a157
3 changed files with 16 additions and 3 deletions

View File

@ -98,6 +98,12 @@ editor.prototype.init = function (callback) {
editor_multi = editor_multi(); editor_multi = editor_multi();
editor_blockly = editor_blockly(); editor_blockly = editor_blockly();
// --- 所有用到的flags
editor.used_flags = {};
for (var floorId in editor.main.floors) {
editor.addUsedFlags(JSON.stringify(editor.main.floors[floorId]));
}
if (editor.useCompress == null) editor.useCompress = useCompress; if (editor.useCompress == null) editor.useCompress = useCompress;
if (Boolean(callback)) callback(); if (Boolean(callback)) callback();
@ -574,5 +580,10 @@ editor.prototype.clearPos = function (clearPos, pos, callback) {
}); });
} }
editor.prototype.addUsedFlags = function (s) {
s.replace(/flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, function (s0, s1) {
editor.used_flags[s1] = true; return s0;
});
}
editor = new editor(); editor = new editor();

View File

@ -814,12 +814,13 @@ function omitedcheckUpdateFunction(event) {
} }
else if (before.endsWith("item")) { else if (before.endsWith("item")) {
return Object.keys(core.material.items).filter(function (one) { return Object.keys(core.material.items).filter(function (one) {
return one.startsWith(token); return one != token && one.startsWith(token);
}).sort(); }).sort();
} }
else if (before.endsWith("flag")) { else if (before.endsWith("flag")) {
// TODO提供 flag:xxx 的补全 return Object.keys(editor.used_flags || {}).filter(function (one) {
return []; return one != token && one.startsWith(token);
}).sort();
} }
} }
} }

View File

@ -41,6 +41,7 @@ editor_file = function (editor, callback) {
datastr = datastr.join(''); datastr = datastr.join('');
alertWhenCompress(); alertWhenCompress();
fs.writeFile(filename, encode(datastr), 'base64', function (err, data) { fs.writeFile(filename, encode(datastr), 'base64', function (err, data) {
editor.addUsedFlags(datastr);
callback(err); callback(err);
}); });
} }