2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-04-04 16:49:54 +00:00
|
|
|
import QtQuick
|
2024-01-24 19:23:29 +00:00
|
|
|
import Fk
|
2023-05-19 02:08:36 +00:00
|
|
|
import Fk.Pages
|
2023-04-04 16:49:54 +00:00
|
|
|
|
|
|
|
MetroButton {
|
|
|
|
id: root
|
|
|
|
property string skill
|
|
|
|
property var choices: []
|
2023-07-16 07:29:20 +00:00
|
|
|
property var all_choices: []
|
2023-04-04 16:49:54 +00:00
|
|
|
property string default_choice
|
|
|
|
property string answer: default_choice
|
2023-06-15 13:19:57 +00:00
|
|
|
property bool detailed: false
|
2023-05-20 08:00:03 +00:00
|
|
|
|
2024-01-24 19:23:29 +00:00
|
|
|
text: Util.processPrompt(answer)
|
2023-04-04 16:49:54 +00:00
|
|
|
|
|
|
|
onAnswerChanged: {
|
|
|
|
if (!answer) return;
|
2024-01-24 19:23:29 +00:00
|
|
|
lcall("SetInteractionDataOfSkill", skill, JSON.stringify(answer));
|
2023-04-04 16:49:54 +00:00
|
|
|
roomScene.dashboard.startPending(skill);
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
2023-06-15 13:19:57 +00:00
|
|
|
if (detailed) {
|
2024-01-24 19:23:29 +00:00
|
|
|
roomScene.popupBox.sourceComponent =
|
|
|
|
Qt.createComponent("../RoomElement/DetailedChoiceBox.qml");
|
2023-06-15 13:19:57 +00:00
|
|
|
} else {
|
2024-01-24 19:23:29 +00:00
|
|
|
roomScene.popupBox.sourceComponent =
|
|
|
|
Qt.createComponent("../RoomElement/ChoiceBox.qml");
|
2023-06-15 13:19:57 +00:00
|
|
|
}
|
2023-06-09 09:23:02 +00:00
|
|
|
const box = roomScene.popupBox.item;
|
2023-04-04 16:49:54 +00:00
|
|
|
box.options = choices;
|
2023-07-16 07:29:20 +00:00
|
|
|
box.all_options = all_choices;
|
2023-04-04 16:49:54 +00:00
|
|
|
box.accepted.connect(() => {
|
2023-08-01 18:19:51 +00:00
|
|
|
answer = all_choices[box.result];
|
2023-04-04 16:49:54 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|