FreeKill/Fk/RoomElement/ChoiceBox.qml
Nyutanislavsky adafcfbae1
Bugfix (#224)
1. 为选项框增加all_choices,可以看到无法选择的选项
2. 体力上限减到0以下不会再死两次
3. 预判超量回复
4. 可以在摸牌前事件打断摸牌
5. 修复卡牌可以使用判断
6. 添加移动场上牌的返回值(卡牌和玩家id)
7. 修复谋徐盛的属性伤害
8. 修改选择多张牌的翻译
9. 修复变更武将的hp设置

---------

Signed-off-by: Mechanel <nyutanislavsky@qq.com>
2023-07-16 15:29:20 +08:00

54 lines
1.4 KiB
QML

// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Layouts
import Fk.Pages
GraphicsBox {
property var options: []
property var all_options: []
property string skill_name: ""
property int result
id: root
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
width: Math.max(140, body.width + 20)
height: body.height + title.height + 20
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
GridLayout {
id: body
x: 10
y: title.height + 5
flow: GridLayout.TopToBottom
rows: 8
columnSpacing: 10
Repeater {
model: all_options
MetroButton {
Layout.fillWidth: true
text: processPrompt(modelData)
enabled: options.indexOf(modelData) !== -1
onClicked: {
result = index;
root.close();
}
}
}
}
}