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
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
contentWidth: panel.width
|
|
|
|
contentHeight: panel.height
|
2023-02-27 02:23:48 +00:00
|
|
|
contentX: contentWidth - width
|
|
|
|
width: Math.min(150, panel.width)
|
2022-09-14 05:01:10 +00:00
|
|
|
height: Math.min(180, panel.height)
|
|
|
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: active_skills
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: not_active_skills
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: panel
|
|
|
|
width: Math.max(grid1.width, grid2.width)
|
|
|
|
height: grid1.height + grid2.height
|
|
|
|
Grid {
|
|
|
|
id: grid1
|
|
|
|
columns: 2
|
|
|
|
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
|
|
|
|
columns: 3
|
|
|
|
columnSpacing: 2
|
|
|
|
rowSpacing: 2
|
|
|
|
Repeater {
|
|
|
|
model: not_active_skills
|
|
|
|
onItemAdded: parent.forceLayout()
|
|
|
|
SkillButton {
|
|
|
|
skill: model.skill
|
|
|
|
orig: model.orig_skill
|
|
|
|
type: "notactive"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addSkill(skill_name) {
|
|
|
|
let data = JSON.parse(Backend.callLuaFunction(
|
|
|
|
"GetSkillData",
|
|
|
|
[skill_name]
|
|
|
|
));
|
2023-01-04 06:21:29 +00:00
|
|
|
if (data.freq === "active") {
|
2022-09-14 05:01:10 +00:00
|
|
|
active_skills.append(data);
|
|
|
|
} else {
|
|
|
|
not_active_skills.append(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loseSkill(skill_name) {
|
|
|
|
for (let i = 0; i < active_skills.count; i++) {
|
2023-02-21 05:44:24 +00:00
|
|
|
let item = active_skills.get(i);
|
|
|
|
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-03-18 15:37:21 +00:00
|
|
|
let 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
}
|