显示选择项提供启用条件
This commit is contained in:
parent
da3546c840
commit
a216caf004
@ -2428,20 +2428,21 @@ return code;
|
|||||||
*/;
|
*/;
|
||||||
|
|
||||||
choicesContext
|
choicesContext
|
||||||
: '子选项' EvalString '图标' IdString? '颜色' ColorString? Colour '出现条件' EvalString? BGNL? Newline action+
|
: '子选项' EvalString '图标' IdString? '颜色' ColorString? Colour '启用条件' EvalString? '出现条件' EvalString? BGNL? Newline action+
|
||||||
|
|
||||||
|
|
||||||
/* choicesContext
|
/* choicesContext
|
||||||
tooltip : 选项的选择
|
tooltip : 选项的选择
|
||||||
helpUrl : /_docs/#/instruction
|
helpUrl : /_docs/#/instruction
|
||||||
default : ["提示文字:红钥匙","","",""]
|
default : ["提示文字:红钥匙","","","",""]
|
||||||
allIds : ['IdString_0']
|
allIds : ['IdString_0']
|
||||||
colour : this.subColor
|
colour : this.subColor
|
||||||
ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : '';
|
ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : '';
|
||||||
EvalString_1 = EvalString_1 && (', "condition": "'+EvalString_1+'"')
|
EvalString_1 = EvalString_1 && (', "need": "'+EvalString_1+'"');
|
||||||
|
EvalString_2 = EvalString_2 && (', "condition": "'+EvalString_2+'"');
|
||||||
IdString_0 = IdString_0?(', "icon": "'+IdString_0+'"'):'';
|
IdString_0 = IdString_0?(', "icon": "'+IdString_0+'"'):'';
|
||||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||||
var code = '{"text": "'+EvalString_0+'"'+IdString_0+ColorString_0+EvalString_1+collapsed+', "action": [\n'+action_0+']},\n';
|
var code = '{"text": "'+EvalString_0+'"'+IdString_0+ColorString_0+EvalString_1+EvalString_2+collapsed+', "action": [\n'+action_0+']},\n';
|
||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
|||||||
@ -689,7 +689,7 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) {
|
for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) {
|
||||||
choice.color = this.Colour(choice.color);
|
choice.color = this.Colour(choice.color);
|
||||||
text_choices=MotaActionFunctions.xmlText('choicesContext', [
|
text_choices=MotaActionFunctions.xmlText('choicesContext', [
|
||||||
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices],
|
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.need||'',choice.condition||'',this.insertActionList(choice.action),text_choices],
|
||||||
/* isShadow */false, /*comment*/ null, /*collapsed*/ choice._collapsed);
|
/* isShadow */false, /*comment*/ null, /*collapsed*/ choice._collapsed);
|
||||||
}
|
}
|
||||||
if (!this.isset(data.text)) data.text = '';
|
if (!this.isset(data.text)) data.text = '';
|
||||||
|
|||||||
@ -108,7 +108,7 @@ editor_blocklyconfig=(function(){
|
|||||||
MotaActionBlocks['confirm_s'].xmlText(),
|
MotaActionBlocks['confirm_s'].xmlText(),
|
||||||
MotaActionBlocks['choices_s'].xmlText([
|
MotaActionBlocks['choices_s'].xmlText([
|
||||||
'选择剑或者盾','流浪者','man',0,MotaActionBlocks['choicesContext'].xmlText([
|
'选择剑或者盾','流浪者','man',0,MotaActionBlocks['choicesContext'].xmlText([
|
||||||
'剑','','',null,'',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
|
'剑','','',null,'','',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -974,10 +974,15 @@ actions.prototype._clickAction = function (x, y) {
|
|||||||
if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) {
|
if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) {
|
||||||
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
|
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
|
||||||
if (y >= topIndex && y < topIndex + choices.length) {
|
if (y >= topIndex && y < topIndex + choices.length) {
|
||||||
|
var choice = choices[y - topIndex];
|
||||||
|
if (choice.need != null && choice.need != '' && !core.calValue(choice.need)) {
|
||||||
|
core.drawTip("无法选择此项");
|
||||||
|
return;
|
||||||
|
}
|
||||||
clearTimeout(core.status.event.interval);
|
clearTimeout(core.status.event.interval);
|
||||||
// 选择
|
// 选择
|
||||||
core.status.route.push("choices:" + (y - topIndex));
|
core.status.route.push("choices:" + (y - topIndex));
|
||||||
core.insertAction(choices[y - topIndex].action);
|
core.insertAction(choice.action);
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1866,7 +1866,13 @@ events.prototype._action_choices = function (data, x, y, prefix) {
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
core.status.route.push("choices:"+index);
|
core.status.route.push("choices:"+index);
|
||||||
if (index != 'none') {
|
if (index != 'none') {
|
||||||
core.insertAction(data.choices[index].action);
|
// 检查
|
||||||
|
var choice = data.choices[index];
|
||||||
|
if (choice.need != null && choice.need != '' && !core.calValue(choice.need)) {
|
||||||
|
// 无法选择此项:直接忽略
|
||||||
|
} else {
|
||||||
|
core.insertAction(choice.action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
|
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
|
||||||
|
|||||||
@ -1659,6 +1659,7 @@ ui.prototype._drawChoices_drawChoices = function (choices, isWindowSkin, hPos, v
|
|||||||
core.setFont('ui', this._buildFont(17, true));
|
core.setFont('ui', this._buildFont(17, true));
|
||||||
for (var i = 0; i < choices.length; i++) {
|
for (var i = 0; i < choices.length; i++) {
|
||||||
var color = core.arrayToRGBA(choices[i].color || core.status.textAttribute.text);
|
var color = core.arrayToRGBA(choices[i].color || core.status.textAttribute.text);
|
||||||
|
if (choices[i].need != null && choices[i].need != '' && !core.calValue(choices[i].need)) color = '#999999';
|
||||||
core.setFillStyle('ui', color);
|
core.setFillStyle('ui', color);
|
||||||
var offset = this.HPIXEL;
|
var offset = this.HPIXEL;
|
||||||
if (choices[i].icon) {
|
if (choices[i].icon) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user