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 Qt5Compat.GraphicalEffects
|
2024-06-10 06:58:48 +00:00
|
|
|
import QtQuick.Controls
|
2022-09-14 05:01:10 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
property alias skill: skill.text
|
|
|
|
property string type: "active"
|
|
|
|
property string orig: ""
|
|
|
|
property bool pressed: false
|
2023-04-23 13:10:07 +00:00
|
|
|
property bool prelighted: false
|
2022-09-14 05:01:10 +00:00
|
|
|
|
|
|
|
onEnabledChanged: {
|
|
|
|
if (!enabled)
|
|
|
|
pressed = false;
|
|
|
|
}
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
width: type !== "notactive" ? Math.max(80, skill.width + 8) : skill.width
|
|
|
|
height: type !== "notactive" ? 36 : 24
|
2022-09-14 05:01:10 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
x: -13 - 120 * 0.166
|
|
|
|
y: -6 - 55 * 0.166
|
|
|
|
scale: 0.66
|
2023-09-19 06:27:54 +00:00
|
|
|
source: {
|
|
|
|
if (type === "notactive") {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
let ret = AppPath + "/image/button/skill/" + type + "/";
|
|
|
|
let suffix = enabled ? (pressed ? "pressed" : "normal") : "disabled";
|
|
|
|
if (enabled && type === "active" && orig.endsWith("&")) {
|
|
|
|
suffix += "-attach";
|
|
|
|
}
|
|
|
|
return ret + suffix;
|
|
|
|
}
|
2022-09-14 05:01:10 +00:00
|
|
|
}
|
|
|
|
|
2023-04-23 13:10:07 +00:00
|
|
|
Image {
|
|
|
|
visible: type === "prelight"
|
|
|
|
source: AppPath + "/image/button/skill/" +
|
|
|
|
(prelighted ? "prelight.png" : "unprelight.png")
|
|
|
|
transformOrigin: Item.TopLeft
|
|
|
|
x: -10
|
|
|
|
scale: 0.7
|
|
|
|
}
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
Text {
|
|
|
|
anchors.centerIn: parent
|
2023-05-20 08:00:03 +00:00
|
|
|
topPadding: 5
|
2022-09-14 05:01:10 +00:00
|
|
|
id: skill
|
|
|
|
font.family: fontLi2.name
|
2023-02-27 02:23:48 +00:00
|
|
|
font.pixelSize: Math.max(26 - text.length, 18)
|
2022-09-14 05:01:10 +00:00
|
|
|
visible: false
|
2023-05-20 08:00:03 +00:00
|
|
|
font.bold: true
|
2022-09-14 05:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Glow {
|
|
|
|
id: glowItem
|
|
|
|
source: skill
|
|
|
|
anchors.fill: skill
|
2023-05-20 08:00:03 +00:00
|
|
|
color: "black"
|
|
|
|
spread: 0.3
|
|
|
|
radius: 5
|
2022-09-14 05:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LinearGradient {
|
|
|
|
anchors.fill: skill
|
|
|
|
source: skill
|
|
|
|
gradient: Gradient {
|
2023-05-20 08:00:03 +00:00
|
|
|
GradientStop {
|
|
|
|
position: 0
|
|
|
|
color: "#FEF7C2"
|
|
|
|
}
|
|
|
|
|
|
|
|
GradientStop {
|
|
|
|
position: 0.5
|
|
|
|
color: "#D2AD4A"
|
|
|
|
}
|
|
|
|
|
|
|
|
GradientStop {
|
|
|
|
position: 1
|
|
|
|
color: "#BE9878"
|
|
|
|
}
|
2022-09-14 05:01:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 07:34:42 +00:00
|
|
|
TapHandler {
|
2024-06-10 06:58:48 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.NoButton
|
|
|
|
onTapped: (p, btn) => {
|
|
|
|
if ((btn === Qt.LeftButton || btn === Qt.NoButton) && root.type !== "notactive" && root.enabled) {
|
|
|
|
parent.pressed = !parent.pressed;
|
|
|
|
} else if (btn === Qt.RightButton) {
|
|
|
|
skillDetail.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: skillDetail
|
|
|
|
x: Math.round((parent.width - width) / 2)
|
|
|
|
y: Math.round((parent.height - height) / 2)
|
|
|
|
property string text: ""
|
|
|
|
width: Math.min(contentWidth, realMainWin.width * 0.4)
|
|
|
|
height: Math.min(contentHeight + 24, realMainWin.height * 0.9)
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
padding: 12
|
|
|
|
background: Rectangle {
|
|
|
|
color: "#EEEEEEEE"
|
|
|
|
radius: 5
|
|
|
|
border.color: "#A6967A"
|
|
|
|
border.width: 1
|
|
|
|
}
|
|
|
|
contentItem: Text {
|
|
|
|
text: "<b>" + luatr(orig) + "</b>: " + luatr(":" + orig)
|
|
|
|
font.pixelSize: 20
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
textFormat: TextEdit.RichText
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onTapped: skillDetail.close();
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 05:01:10 +00:00
|
|
|
}
|
|
|
|
}
|