FreeKill/Fk/RoomElement/ChoiceBox.qml
YoumuKon e9a81cd185
卡牌标记清除后缀+pattern相关fix (#220)
- 修复了翻译只替换一次参数(%src之类的)的bug
- 添加了卡牌专属的清除后缀,现在cheat获得的牌自带信仰之力
- 补齐了neg判定相关的函数
- 添加multiple_targets,标记多目标牌
- 添加复原武将牌的描述
- 房间名带省略号

---------

Co-authored-by: notify <notify-ctrl@qq.com>
2023-07-11 23:16:46 +08:00

52 lines
1.3 KiB
QML

// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Layouts
import Fk.Pages
GraphicsBox {
property var 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("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
return raw;
}
GridLayout {
id: body
x: 10
y: title.height + 5
flow: GridLayout.TopToBottom
rows: 8
columnSpacing: 10
Repeater {
model: options
MetroButton {
Layout.fillWidth: true
text: processPrompt(modelData)
onClicked: {
result = index;
root.close();
}
}
}
}
}