FreeKill/Fk/RoomElement/ChoiceBox.qml

52 lines
1.3 KiB
QML
Raw Normal View History

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