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
|
2022-03-23 11:40:28 +00:00
|
|
|
|
|
|
|
|
|
Flickable {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
id: root
|
2022-09-14 05:01:10 +00:00
|
|
|
|
property alias skill_buttons: skill_buttons
|
2023-04-23 13:10:07 +00:00
|
|
|
|
property alias prelight_buttons: prelight_buttons
|
2022-09-14 05:01:10 +00:00
|
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
contentWidth: panel.width
|
|
|
|
|
contentHeight: panel.height
|
2023-02-27 02:23:48 +00:00
|
|
|
|
contentX: contentWidth - width
|
2023-04-23 13:10:07 +00:00
|
|
|
|
width: Math.min(180, panel.width)
|
|
|
|
|
height: Math.min(200, panel.height)
|
2022-09-14 05:01:10 +00:00
|
|
|
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
|
ListModel {
|
|
|
|
|
id: prelight_skills
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
ListModel {
|
|
|
|
|
id: active_skills
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: not_active_skills
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: panel
|
2023-04-23 13:10:07 +00:00
|
|
|
|
width: Math.max(grid0.width, grid1.width, grid2.width)
|
|
|
|
|
height: grid0.height + grid1.height + grid2.height
|
|
|
|
|
Grid {
|
|
|
|
|
id: grid0
|
2023-11-07 04:49:31 +00:00
|
|
|
|
// FIXME: 得优化成类似mark区域那种自动化布局才行啊,可惜鸽
|
|
|
|
|
columns: config.language.startsWith('zh') ? 2 : 1
|
2023-04-23 13:10:07 +00:00
|
|
|
|
columnSpacing: 2
|
|
|
|
|
rowSpacing: 2
|
|
|
|
|
Repeater {
|
|
|
|
|
id: prelight_buttons
|
|
|
|
|
model: prelight_skills
|
|
|
|
|
onItemAdded: parent.forceLayout()
|
|
|
|
|
SkillButton {
|
|
|
|
|
skill: model.skill
|
|
|
|
|
type: "prelight"
|
|
|
|
|
enabled: !config.observing
|
|
|
|
|
orig: model.orig_skill
|
|
|
|
|
|
|
|
|
|
onPressedChanged: {
|
|
|
|
|
if (!pressed) return;
|
|
|
|
|
enabled = false;
|
2023-04-27 06:15:08 +00:00
|
|
|
|
ClientInstance.notifyServer("PushRequest", [
|
2023-04-23 13:10:07 +00:00
|
|
|
|
"prelight", orig, (!prelighted).toString()
|
|
|
|
|
].join(","));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
Grid {
|
|
|
|
|
id: grid1
|
2023-04-23 13:10:07 +00:00
|
|
|
|
anchors.top: grid0.bottom
|
2023-11-07 04:49:31 +00:00
|
|
|
|
columns: config.language.startsWith('zh') ? 2 : 1
|
2022-09-14 05:01:10 +00:00
|
|
|
|
columnSpacing: 2
|
|
|
|
|
rowSpacing: 2
|
|
|
|
|
Repeater {
|
|
|
|
|
id: skill_buttons
|
|
|
|
|
model: active_skills
|
|
|
|
|
onItemAdded: parent.forceLayout()
|
|
|
|
|
SkillButton {
|
|
|
|
|
skill: model.skill
|
|
|
|
|
type: "active"
|
|
|
|
|
enabled: false
|
|
|
|
|
orig: model.orig_skill
|
|
|
|
|
|
|
|
|
|
onPressedChanged: {
|
|
|
|
|
if (enabled)
|
|
|
|
|
roomScene.activateSkill(orig, pressed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
|
id: grid2
|
|
|
|
|
anchors.top: grid1.bottom
|
|
|
|
|
anchors.topMargin: 2
|
2023-11-07 04:49:31 +00:00
|
|
|
|
columns: config.language.startsWith('zh') ? 3 : 1
|
2022-09-14 05:01:10 +00:00
|
|
|
|
columnSpacing: 2
|
|
|
|
|
rowSpacing: 2
|
|
|
|
|
Repeater {
|
|
|
|
|
model: not_active_skills
|
|
|
|
|
onItemAdded: parent.forceLayout()
|
|
|
|
|
SkillButton {
|
|
|
|
|
skill: model.skill
|
|
|
|
|
orig: model.orig_skill
|
|
|
|
|
type: "notactive"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
|
function addSkill(skill_name, prelight) {
|
|
|
|
|
const modelContains = (m, e) => {
|
|
|
|
|
for (let i = 0; i < m.count; i++) {
|
|
|
|
|
if (m.get(i).orig_skill === e.orig_skill) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const data = JSON.parse(Backend.callLuaFunction(
|
2022-09-14 05:01:10 +00:00
|
|
|
|
"GetSkillData",
|
|
|
|
|
[skill_name]
|
|
|
|
|
));
|
2023-04-23 13:10:07 +00:00
|
|
|
|
|
|
|
|
|
if (prelight) {
|
|
|
|
|
if (!modelContains(prelight_skills, data))
|
|
|
|
|
prelight_skills.append(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 06:21:29 +00:00
|
|
|
|
if (data.freq === "active") {
|
2023-04-23 13:10:07 +00:00
|
|
|
|
if (!modelContains(active_skills, data)) active_skills.append(data);
|
2022-09-14 05:01:10 +00:00
|
|
|
|
} else {
|
2023-04-23 13:10:07 +00:00
|
|
|
|
if (!modelContains(not_active_skills, data))
|
|
|
|
|
not_active_skills.append(data);
|
2022-09-14 05:01:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
|
function loseSkill(skill_name, prelight) {
|
|
|
|
|
if (prelight) {
|
|
|
|
|
for (let i = 0; i < prelight_skills.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = prelight_skills.get(i);
|
2023-04-23 13:10:07 +00:00
|
|
|
|
if (item.orig_skill == skill_name) {
|
|
|
|
|
prelight_skills.remove(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
for (let i = 0; i < active_skills.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = active_skills.get(i);
|
2023-02-21 05:44:24 +00:00
|
|
|
|
if (item.orig_skill == skill_name) {
|
2022-09-14 05:01:10 +00:00
|
|
|
|
active_skills.remove(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < not_active_skills.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = not_active_skills.get(i);
|
2023-02-21 05:44:24 +00:00
|
|
|
|
if (item.orig_skill == skill_name) {
|
2022-09-14 05:01:10 +00:00
|
|
|
|
not_active_skills.remove(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-27 06:15:08 +00:00
|
|
|
|
|
|
|
|
|
function clearSkills() {
|
|
|
|
|
prelight_skills.clear();
|
|
|
|
|
active_skills.clear();
|
|
|
|
|
not_active_skills.clear();
|
|
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|