FreeKill/Fk/SkillInteraction/SkillCombo.qml
YoumuKon 7fd39264ee
bugfix (#229)
- 为需要无视描述的请求添加-tmp标签(……)
- 修改铁索相关描述
- 修复了可以通过取消目标以跳过exclusive_targets的bug
- 修复了观星只控顶时还有底部标签的bug
- 修复了没有correct_func时的报错
- 修复了一个人且未分胜负时无限循环的bug
- 将AOE的函数调到了Util内方便其他DIY快速调用
- 将AskForAddTarget转正
- 主动技添加modTargetFilter,负责重新定义目标(借刀摆烂了)
- 游戏模式添加countInFunc(room),负责检测本局游戏是否可以纳入胜率统计(默认true)

---------

Co-authored-by: Nyutanislavsky <nyutanislavsky@qq.com>
2023-08-02 02:19:51 +08:00

53 lines
1.5 KiB
QML

// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import Fk.Pages
MetroButton {
id: root
property string skill
property var choices: []
property var all_choices: []
property string default_choice
property string answer: default_choice
property bool detailed: false
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;
}
text: processPrompt(answer)
onAnswerChanged: {
if (!answer) return;
Backend.callLuaFunction(
"SetInteractionDataOfSkill",
[skill, JSON.stringify(answer)]
);
roomScene.dashboard.startPending(skill);
}
onClicked: {
if (detailed) {
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/DetailedChoiceBox.qml");
} else {
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/ChoiceBox.qml");
}
const box = roomScene.popupBox.item;
box.options = choices;
box.all_options = all_choices;
box.accepted.connect(() => {
answer = all_choices[box.result];
});
}
}