editor_blockly getAutoCompletions
This commit is contained in:
parent
42d8a4df8f
commit
90fc42fc31
@ -799,6 +799,57 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor_blockly.getAutoCompletions = function (content) {
|
||||||
|
// --- content为当前框中输入内容;将返回一个列表,为后续所有可补全内容
|
||||||
|
|
||||||
|
// 检查 flag:xxx,item:xxx和flag:xxx
|
||||||
|
var index = content.lastIndexOf(":");
|
||||||
|
if (index >= 0) {
|
||||||
|
var before = content.substring(0, index), token = content.substring(index+1);
|
||||||
|
if (/^\w*$/.test(token)) {
|
||||||
|
if (before.endsWith("status")) {
|
||||||
|
return Object.keys(core.status.hero).filter(function (one) {
|
||||||
|
return one != token && one.startsWith(token);
|
||||||
|
}).sort();
|
||||||
|
}
|
||||||
|
else if (before.endsWith("item")) {
|
||||||
|
return Object.keys(core.material.items).filter(function (one) {
|
||||||
|
return one.startsWith(token);
|
||||||
|
}).sort();
|
||||||
|
}
|
||||||
|
else if (before.endsWith("flag")) {
|
||||||
|
// TODO:提供 flag:xxx 的补全
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提供 core.xxx 的补全
|
||||||
|
index = content.lastIndexOf("core.");
|
||||||
|
if (index >= 0) {
|
||||||
|
var s = content.substring(index + 5);
|
||||||
|
if (/^[\w.]*$/.test(s)) {
|
||||||
|
var tokens = s.split(".");
|
||||||
|
var now = core, prefix = tokens[tokens.length - 1];
|
||||||
|
for (var i = 0; i < tokens.length - 1; ++i) {
|
||||||
|
now = now[tokens[i]];
|
||||||
|
if (now == null) break;
|
||||||
|
}
|
||||||
|
if (now != null) {
|
||||||
|
var candidates = [];
|
||||||
|
for (var i in now) {
|
||||||
|
candidates.push(i);
|
||||||
|
}
|
||||||
|
return candidates.filter(function (one) {
|
||||||
|
return one != prefix && one.startsWith(prefix);
|
||||||
|
}).sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return editor_blockly;
|
return editor_blockly;
|
||||||
}
|
}
|
||||||
//editor_blockly=editor_blockly();
|
//editor_blockly=editor_blockly();
|
||||||
@ -885,15 +885,12 @@ ui.prototype.drawTextContent = function (ctx, content, config) {
|
|||||||
config.blocks = [];
|
config.blocks = [];
|
||||||
|
|
||||||
// 创建一个新的临时画布
|
// 创建一个新的临时画布
|
||||||
var tempCtx = core.bigmap.tempCanvas;
|
var tempCtx = core.createCanvas('__temp__', 0, 0, ctx.canvas.width, ctx.canvas.height, -1);
|
||||||
tempCtx.canvas.height = ctx.canvas.height;
|
|
||||||
tempCtx.canvas.width = ctx.canvas.width;
|
|
||||||
var _textBaseLine = tempCtx.textBaseline;
|
|
||||||
tempCtx.textBaseline = 'top';
|
tempCtx.textBaseline = 'top';
|
||||||
tempCtx.font = this._buildFont(config.fontSize, config.bold);
|
tempCtx.font = this._buildFont(config.fontSize, config.bold);
|
||||||
tempCtx.fillStyle = config.color;
|
tempCtx.fillStyle = config.color;
|
||||||
this._drawTextContent_draw(ctx, tempCtx, content, config);
|
this._drawTextContent_draw(ctx, tempCtx, content, config);
|
||||||
tempCtx.textBaseline = _textBaseLine;
|
core.deleteCanvas('__temp__');
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.prototype._uievent_drawTextContent = function (data) {
|
ui.prototype._uievent_drawTextContent = function (data) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user