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
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Controls
|
2023-05-19 02:08:36 +00:00
|
|
|
import Fk.RoomElement
|
2023-08-25 13:08:03 +00:00
|
|
|
import "RoomLogic.js" as RoomLogic
|
2022-04-15 10:37:20 +00:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: root
|
2022-04-15 10:37:20 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
property bool loaded: false
|
2022-04-15 10:37:20 +00:00
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: listView
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
radius: 6
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
ListView {
|
2023-04-21 09:49:30 +00:00
|
|
|
id: listView
|
2023-06-16 15:53:44 +00:00
|
|
|
clip: true
|
2023-04-21 09:49:30 +00:00
|
|
|
width: 130
|
|
|
|
height: parent.height - 20
|
|
|
|
y: 10
|
2022-04-30 07:27:56 +00:00
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
model: ListModel {
|
|
|
|
id: packages
|
|
|
|
}
|
2022-04-15 10:37:20 +00:00
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
highlight: Rectangle { color: "#E91E63"; radius: 5 }
|
|
|
|
highlightMoveDuration: 500
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
width: listView.width
|
|
|
|
height: 40
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate(name)
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onTapped: {
|
|
|
|
listView.currentIndex = index;
|
2022-04-15 10:37:20 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-15 10:37:20 +00:00
|
|
|
}
|
2023-04-21 09:49:30 +00:00
|
|
|
|
|
|
|
onCurrentIndexChanged: { vanishAnim.start(); }
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-15 10:37:20 +00:00
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
GridView {
|
|
|
|
id: gridView
|
2023-06-16 15:53:44 +00:00
|
|
|
clip: true
|
2023-04-21 09:49:30 +00:00
|
|
|
width: root.width - listView.width - generalDetail.width - 16
|
|
|
|
height: parent.height - 20
|
|
|
|
y: 10
|
|
|
|
anchors.left: listView.right
|
|
|
|
anchors.leftMargin: 8 + (width % 100) / 2
|
|
|
|
cellHeight: 140
|
|
|
|
cellWidth: 100
|
|
|
|
|
|
|
|
delegate: GeneralCardItem {
|
|
|
|
autoBack: false
|
|
|
|
name: modelData
|
|
|
|
onClicked: {
|
|
|
|
generalText.clear();
|
|
|
|
generalDetail.general = modelData;
|
|
|
|
generalDetail.updateGeneral();
|
2023-05-13 06:20:48 +00:00
|
|
|
// generalDetail.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "black"
|
|
|
|
opacity: config.disabledGenerals.includes(modelData) ? 0.7 : 0
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GlowText {
|
|
|
|
visible: config.disabledGenerals.includes(modelData)
|
|
|
|
text: '禁'
|
|
|
|
anchors.centerIn: parent
|
|
|
|
font.family: fontLi2.name
|
|
|
|
color: "#E4D5A0"
|
|
|
|
font.pixelSize: 36
|
|
|
|
font.weight: Font.Medium
|
|
|
|
glow.color: "black"
|
|
|
|
glow.spread: 0.3
|
|
|
|
glow.radius: 5
|
2023-04-21 09:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: vanishAnim
|
|
|
|
PropertyAnimation {
|
|
|
|
target: gridView
|
|
|
|
property: "opacity"
|
|
|
|
to: 0
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
PropertyAnimation {
|
|
|
|
target: gridView
|
|
|
|
property: "y"
|
|
|
|
to: 30
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
onFinished: {
|
2023-06-16 15:53:44 +00:00
|
|
|
if (word.text !== "") {
|
|
|
|
gridView.model = JSON.parse(Backend.callLuaFunction("SearchAllGenerals",
|
|
|
|
[word.text]));
|
|
|
|
} else {
|
|
|
|
gridView.model = JSON.parse(Backend.callLuaFunction("SearchGenerals",
|
|
|
|
[listView.model.get(listView.currentIndex).name, word.text]));
|
|
|
|
}
|
|
|
|
word.text = "";
|
2023-04-21 09:49:30 +00:00
|
|
|
appearAnim.start();
|
2022-04-15 10:37:20 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-15 10:37:20 +00:00
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
SequentialAnimation {
|
|
|
|
id: appearAnim
|
|
|
|
PauseAnimation { duration: 200 }
|
|
|
|
ParallelAnimation {
|
|
|
|
PropertyAnimation {
|
|
|
|
target: gridView
|
|
|
|
property: "opacity"
|
|
|
|
to: 1
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
PropertyAnimation {
|
|
|
|
target: gridView
|
|
|
|
property: "y"
|
|
|
|
from: 20
|
|
|
|
to: 10
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2023-02-15 11:54:35 +00:00
|
|
|
id: generalDetail
|
2023-04-21 09:49:30 +00:00
|
|
|
width: 310
|
2023-06-16 15:53:44 +00:00
|
|
|
height: parent.height - searcher.height - 20
|
2023-04-21 09:49:30 +00:00
|
|
|
y: 10
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
radius: 8
|
|
|
|
|
|
|
|
property string general: "caocao"
|
2023-06-09 18:18:51 +00:00
|
|
|
|
2023-08-25 13:08:03 +00:00
|
|
|
function addSpecialSkillAudio(skill) {
|
|
|
|
const gdata = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general]));
|
|
|
|
const extension = gdata.extension;
|
|
|
|
let ret = false;
|
|
|
|
for (let i = 0; i < 999; i++) {
|
|
|
|
const fname = AppPath + "/packages/" + extension + "/audio/skill/" +
|
|
|
|
skill + "_" + general + (i !== 0 ? i.toString() : "") + ".mp3";
|
|
|
|
|
|
|
|
if (Backend.exists(fname)) {
|
|
|
|
ret = true;
|
|
|
|
audioModel.append({ name: skill, idx: i });
|
|
|
|
} else {
|
|
|
|
if (i > 0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-06-09 18:18:51 +00:00
|
|
|
function addSkillAudio(skill) {
|
2023-08-25 13:08:03 +00:00
|
|
|
if (addSpecialSkillAudio(skill)) return;
|
2023-06-09 18:18:51 +00:00
|
|
|
const skilldata = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
|
|
|
|
if (!skilldata) return;
|
|
|
|
const extension = skilldata.extension;
|
|
|
|
for (let i = 0; i < 999; i++) {
|
2023-06-11 08:22:11 +00:00
|
|
|
const fname = AppPath + "/packages/" + extension + "/audio/skill/" +
|
2023-06-09 18:18:51 +00:00
|
|
|
skill + (i !== 0 ? i.toString() : "") + ".mp3";
|
|
|
|
|
|
|
|
if (Backend.exists(fname)) {
|
|
|
|
audioModel.append({ name: skill, idx: i });
|
|
|
|
} else {
|
|
|
|
if (i > 0) break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-14 05:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function findDeathAudio(general) {
|
|
|
|
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])).extension;
|
2023-06-11 08:22:11 +00:00
|
|
|
const fname = AppPath + "/packages/" + extension + "/audio/death/" + general + ".mp3";
|
|
|
|
if (Backend.exists(fname)) {
|
|
|
|
audioDeath.visible = true;
|
|
|
|
} else {
|
|
|
|
audioDeath.visible = false;
|
|
|
|
}
|
2023-06-09 18:18:51 +00:00
|
|
|
}
|
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
function updateGeneral() {
|
|
|
|
detailGeneralCard.name = general;
|
2023-06-09 09:23:02 +00:00
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
|
2023-04-21 09:49:30 +00:00
|
|
|
generalText.clear();
|
2023-06-09 18:18:51 +00:00
|
|
|
audioModel.clear();
|
2023-08-24 13:37:06 +00:00
|
|
|
|
|
|
|
if (data.companions.length > 0){
|
|
|
|
let ret = '';
|
|
|
|
ret += "<font color=\"slategrey\"><b>" + Backend.translate("Companions") + "</b>: ";
|
|
|
|
data.companions.forEach(t => {
|
|
|
|
ret += Backend.translate(t) + ' '
|
|
|
|
});
|
|
|
|
generalText.append(ret)
|
|
|
|
}
|
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
data.skill.forEach(t => {
|
2023-06-09 18:18:51 +00:00
|
|
|
generalText.append("<b>" + Backend.translate(t.name) +
|
|
|
|
"</b>: " + t.description);
|
|
|
|
|
|
|
|
addSkillAudio(t.name);
|
2023-04-21 09:49:30 +00:00
|
|
|
});
|
|
|
|
data.related_skill.forEach(t => {
|
2023-06-09 18:18:51 +00:00
|
|
|
generalText.append("<font color=\"purple\"><b>" + Backend.translate(t.name) +
|
|
|
|
"</b>: " + t.description + "</font>");
|
|
|
|
|
|
|
|
addSkillAudio(t.name);
|
2023-04-21 09:49:30 +00:00
|
|
|
});
|
2023-06-14 05:40:50 +00:00
|
|
|
findDeathAudio(general);
|
2023-06-09 18:18:51 +00:00
|
|
|
|
|
|
|
addSkillAudio(general + "_win_audio");
|
2023-04-21 09:49:30 +00:00
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
|
|
|
|
Flickable {
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
2023-04-21 09:49:30 +00:00
|
|
|
contentHeight: detailLayout.height
|
|
|
|
width: parent.width - 40
|
|
|
|
height: parent.height - 40
|
2023-02-15 11:54:35 +00:00
|
|
|
clip: true
|
|
|
|
anchors.centerIn: parent
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
|
2023-04-21 09:49:30 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: detailLayout
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
GeneralCardItem {
|
|
|
|
id: detailGeneralCard
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
name: "caocao"
|
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: generalText
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
readOnly: true
|
|
|
|
selectByKeyboard: true
|
|
|
|
selectByMouse: false
|
|
|
|
wrapMode: TextEdit.WordWrap
|
|
|
|
textFormat: TextEdit.RichText
|
|
|
|
font.pixelSize: 16
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
2023-06-09 18:18:51 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: ListModel {
|
|
|
|
id: audioModel
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
2023-08-27 13:22:03 +00:00
|
|
|
text: {
|
|
|
|
if (name.endsWith("_win_audio")) {
|
|
|
|
return "胜利语音";
|
|
|
|
}
|
|
|
|
return Backend.translate(name) + (idx ? " (" + idx.toString() + ")" : "");
|
|
|
|
}
|
2023-06-09 18:18:51 +00:00
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
2023-08-25 13:08:03 +00:00
|
|
|
text: {
|
|
|
|
const orig = '$' + name + (idx ? idx.toString() : "");
|
|
|
|
const orig_trans = Backend.translate(orig);
|
|
|
|
|
|
|
|
// try general specific
|
|
|
|
const orig_g = '$' + name + '_' + detailGeneralCard.name + (idx ? idx.toString() : "");
|
|
|
|
const orig_g_trans = Backend.translate(orig_g);
|
|
|
|
|
|
|
|
if (orig_g_trans !== orig_g) {
|
|
|
|
return orig_g_trans;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orig_trans !== orig) {
|
|
|
|
return orig_trans;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
2023-06-09 18:18:51 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
2023-08-25 13:08:03 +00:00
|
|
|
callbacks["LogEvent"](JSON.stringify({
|
|
|
|
type: "PlaySkillSound",
|
|
|
|
name: name,
|
|
|
|
general: detailGeneralCard.name,
|
|
|
|
i: idx,
|
|
|
|
}));
|
2023-06-09 18:18:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2023-06-11 08:22:11 +00:00
|
|
|
id: audioDeath
|
2023-06-09 18:18:51 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: Backend.translate("Death audio")
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
2023-06-15 13:19:57 +00:00
|
|
|
text: Backend.translate("~" + generalDetail.general) == "~" + generalDetail.general ? "" : Backend.translate("~" + generalDetail.general)
|
2023-06-09 18:18:51 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
const general = generalDetail.general
|
|
|
|
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])).extension;
|
|
|
|
Backend.playSound("./packages/" + extension + "/audio/death/" + general);
|
|
|
|
}
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-16 15:53:44 +00:00
|
|
|
Rectangle {
|
|
|
|
id: searcher
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
|
|
|
color: "snow"
|
|
|
|
opacity: 0.75
|
|
|
|
anchors.top: parent.bottom
|
|
|
|
radius: 8
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
TextField {
|
|
|
|
id: word
|
|
|
|
Layout.fillWidth: true
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: qsTr("Search")
|
|
|
|
enabled: word.text !== ""
|
|
|
|
onClicked: {
|
|
|
|
listView.currentIndex = 0;
|
|
|
|
vanishAnim.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
|
2023-05-13 06:20:48 +00:00
|
|
|
ColumnLayout {
|
2023-04-21 09:49:30 +00:00
|
|
|
anchors.right: parent.right
|
2023-05-13 06:20:48 +00:00
|
|
|
Button {
|
|
|
|
text: Backend.translate("Quit")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.pop();
|
|
|
|
config.saveConf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: banButton
|
|
|
|
text: Backend.translate(config.disabledGenerals.includes(detailGeneralCard.name) ? 'ResumeGeneral' : 'BanGeneral')
|
|
|
|
visible: detailGeneralCard.name
|
|
|
|
onClicked: {
|
|
|
|
const { disabledGenerals } = config;
|
|
|
|
const { name } = detailGeneralCard;
|
|
|
|
|
|
|
|
if (banButton.text === Backend.translate('ResumeGeneral')) {
|
|
|
|
const deleteIndex = disabledGenerals.findIndex((general) => general === name);
|
|
|
|
if (deleteIndex === -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
disabledGenerals.splice(deleteIndex, 1);
|
|
|
|
} else {
|
|
|
|
if (disabledGenerals.includes(name)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
disabledGenerals.push(name);
|
|
|
|
}
|
|
|
|
config.disabledGeneralsChanged();
|
|
|
|
}
|
2023-04-21 09:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
function loadPackages() {
|
|
|
|
if (loaded) return;
|
2023-06-09 09:23:02 +00:00
|
|
|
const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
|
2023-08-03 07:24:17 +00:00
|
|
|
packs.forEach(name => {
|
|
|
|
if (!config.serverHiddenPacks.includes(name)) {
|
|
|
|
packages.append({ name: name });
|
|
|
|
}
|
|
|
|
});
|
2023-04-21 09:49:30 +00:00
|
|
|
generalDetail.updateGeneral();
|
2022-04-30 07:27:56 +00:00
|
|
|
loaded = true;
|
|
|
|
}
|
2022-04-15 10:37:20 +00:00
|
|
|
}
|