2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
import QtQuick
|
2023-03-20 12:15:24 +00:00
|
|
|
import QtQuick.Layouts
|
2023-05-19 02:08:36 +00:00
|
|
|
import Fk.Pages
|
2022-04-02 07:11:13 +00:00
|
|
|
|
|
|
|
GraphicsBox {
|
2022-04-30 07:27:56 +00:00
|
|
|
property var options: []
|
2023-07-16 07:29:20 +00:00
|
|
|
property var all_options: []
|
2022-04-30 07:27:56 +00:00
|
|
|
property string skill_name: ""
|
|
|
|
property int result
|
2022-04-02 07:11:13 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
id: root
|
2022-05-01 10:37:13 +00:00
|
|
|
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
|
2022-04-30 07:27:56 +00:00
|
|
|
width: Math.max(140, body.width + 20)
|
|
|
|
height: body.height + title.height + 20
|
2022-04-02 07:11:13 +00:00
|
|
|
|
2023-05-20 08:00:03 +00:00
|
|
|
function processPrompt(prompt) {
|
|
|
|
const data = prompt.split(":");
|
|
|
|
let raw = Backend.translate(data[0]);
|
|
|
|
const src = parseInt(data[1]);
|
|
|
|
const dest = parseInt(data[2]);
|
2023-07-11 15:16:46 +00:00
|
|
|
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]));
|
2023-07-14 14:17:54 +00:00
|
|
|
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
|
2023-05-20 08:00:03 +00:00
|
|
|
return raw;
|
|
|
|
}
|
|
|
|
|
2023-03-20 12:15:24 +00:00
|
|
|
GridLayout {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: body
|
|
|
|
x: 10
|
|
|
|
y: title.height + 5
|
2023-03-20 12:15:24 +00:00
|
|
|
flow: GridLayout.TopToBottom
|
|
|
|
rows: 8
|
|
|
|
columnSpacing: 10
|
2022-04-02 07:11:13 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Repeater {
|
2023-07-16 07:29:20 +00:00
|
|
|
model: all_options
|
2022-04-02 07:11:13 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
MetroButton {
|
2023-03-20 12:15:24 +00:00
|
|
|
Layout.fillWidth: true
|
2023-05-20 08:00:03 +00:00
|
|
|
text: processPrompt(modelData)
|
2023-07-16 07:29:20 +00:00
|
|
|
enabled: options.indexOf(modelData) !== -1
|
2022-04-02 07:11:13 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
onClicked: {
|
|
|
|
result = index;
|
|
|
|
root.close();
|
2022-04-02 07:11:13 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-02 07:11:13 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-02 07:11:13 +00:00
|
|
|
}
|