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
|
2023-04-30 10:55:59 +00:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2023-05-19 02:08:36 +00:00
|
|
|
import Fk
|
|
|
|
import Fk.PhotoElement
|
2022-03-30 06:14:40 +00:00
|
|
|
|
|
|
|
/* Layout of general card:
|
|
|
|
* +--------+
|
|
|
|
*kindom|wu 9999| <- hp
|
|
|
|
*name -|s |
|
|
|
|
* |q img |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* +--------+
|
|
|
|
* Inherit from CardItem to use common signal
|
|
|
|
*/
|
|
|
|
|
|
|
|
CardItem {
|
2022-05-01 10:37:13 +00:00
|
|
|
property string kingdom
|
2023-04-30 10:55:59 +00:00
|
|
|
property string subkingdom: "wei"
|
2022-05-01 10:37:13 +00:00
|
|
|
property int hp
|
2023-03-18 15:37:21 +00:00
|
|
|
property int maxHp
|
2023-04-13 12:17:39 +00:00
|
|
|
property int shieldNum
|
2023-03-18 18:21:45 +00:00
|
|
|
property string pkgName: ""
|
2023-08-27 11:48:15 +00:00
|
|
|
property bool detailed: true
|
2022-05-01 10:37:13 +00:00
|
|
|
name: ""
|
2022-04-30 07:27:56 +00:00
|
|
|
// description: Sanguosha.getGeneralDescription(name)
|
|
|
|
suit: ""
|
|
|
|
number: 0
|
|
|
|
footnote: ""
|
2023-02-15 11:54:35 +00:00
|
|
|
card.source: SkinBank.getGeneralPicture(name)
|
2022-04-30 07:27:56 +00:00
|
|
|
glow.color: "white" //Engine.kingdomColor[kingdom]
|
2022-05-01 10:37:13 +00:00
|
|
|
|
2023-09-06 14:16:09 +00:00
|
|
|
// FIXME: 藕!!
|
|
|
|
property bool heg: name.startsWith('hs__') || name.startsWith('ld__') || name.includes('heg__')
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Image {
|
|
|
|
source: SkinBank.GENERALCARD_DIR + "border"
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
2023-04-30 10:55:59 +00:00
|
|
|
scale: subkingdom ? 0.6 : 1
|
2023-09-06 14:16:09 +00:00
|
|
|
width: 34; fillMode: Image.PreserveAspectFit
|
2023-04-30 10:55:59 +00:00
|
|
|
transformOrigin: Item.TopLeft
|
2023-04-04 18:21:59 +00:00
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom
|
2023-08-27 11:48:15 +00:00
|
|
|
visible: detailed
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
2023-04-30 10:55:59 +00:00
|
|
|
Image {
|
|
|
|
scale: 0.6; x: 9; y: 12
|
|
|
|
transformOrigin: Item.TopLeft
|
2023-09-06 14:16:09 +00:00
|
|
|
width: 34; fillMode: Image.PreserveAspectFit
|
2023-04-30 10:55:59 +00:00
|
|
|
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom : ""
|
2023-08-27 11:48:15 +00:00
|
|
|
visible: detailed
|
2023-04-30 10:55:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 4
|
|
|
|
spacing: 1
|
2023-09-06 14:16:09 +00:00
|
|
|
visible: detailed && !heg
|
2022-05-01 10:37:13 +00:00
|
|
|
Repeater {
|
2023-04-13 12:17:39 +00:00
|
|
|
id: hpRepeater
|
2023-09-06 14:16:09 +00:00
|
|
|
model: (!heg) ? ((hp > 5 || hp !== maxHp) ? 1 : hp) : 0
|
2023-04-30 10:55:59 +00:00
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: childrenRect.height
|
|
|
|
Image {
|
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-magatama"
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: subkingdomMagatama
|
|
|
|
visible: false
|
|
|
|
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom + "-magatama" : ""
|
|
|
|
}
|
|
|
|
LinearGradient {
|
|
|
|
id: subkingdomMask
|
|
|
|
visible: false
|
|
|
|
anchors.fill: subkingdomMagatama
|
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.35; color: "transparent" }
|
|
|
|
GradientStop { position: 0.50; color: "white" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OpacityMask {
|
|
|
|
anchors.fill: subkingdomMagatama
|
|
|
|
source: subkingdomMagatama
|
|
|
|
maskSource: subkingdomMask
|
|
|
|
visible: subkingdom
|
|
|
|
}
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
2023-03-18 15:37:21 +00:00
|
|
|
visible: hp > 5 || hp !== maxHp
|
|
|
|
text: hp === maxHp ? ("x" + hp) : (" " + hp + "/" + maxHp)
|
2022-05-01 10:37:13 +00:00
|
|
|
color: "white"
|
|
|
|
font.pixelSize: 14
|
|
|
|
style: Text.Outline
|
|
|
|
y: -6
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 14:16:09 +00:00
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 3
|
|
|
|
spacing: 0
|
|
|
|
visible: detailed && heg
|
|
|
|
Repeater {
|
|
|
|
id: hegHpRepeater
|
|
|
|
model: heg ? ((hp > 7 || hp !== maxHp) ? 1 : Math.ceil(hp / 2)) : 0
|
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: childrenRect.height
|
|
|
|
Image {
|
|
|
|
height: 12; fillMode: Image.PreserveAspectFit
|
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-magatama-l"
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
x: 4.4
|
|
|
|
opacity: (index + 1) * 2 <= hp ? 1 : 0
|
|
|
|
height: 12; fillMode: Image.PreserveAspectFit
|
|
|
|
source: {
|
|
|
|
const k = subkingdom ? subkingdom : kingdom;
|
|
|
|
SkinBank.getGeneralCardDir(k) + k + "-magatama-r"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
visible: hp > 7 || hp !== maxHp
|
|
|
|
text: hp === maxHp ? ("x" + hp / 2) : (" " + hp / 2 + "/" + maxHp / 2)
|
|
|
|
color: "white"
|
|
|
|
font.pixelSize: 14
|
|
|
|
style: Text.Outline
|
|
|
|
y: -4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-13 12:17:39 +00:00
|
|
|
Shield {
|
2023-08-27 13:22:03 +00:00
|
|
|
visible: shieldNum > 0 && detailed
|
2023-04-13 12:17:39 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: hpRepeater.model > 4 ? 16 : 0
|
|
|
|
scale: 0.8
|
|
|
|
value: shieldNum
|
|
|
|
}
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Text {
|
|
|
|
width: 20
|
|
|
|
height: 80
|
|
|
|
x: 2
|
|
|
|
y: lineCount > 6 ? 30 : 34
|
2023-12-06 13:07:35 +00:00
|
|
|
text: name !== "" ? Backend.translate(name) : "nil"
|
2023-08-27 11:48:15 +00:00
|
|
|
visible: Backend.translate(name).length <= 6 && detailed
|
2022-05-01 10:37:13 +00:00
|
|
|
color: "white"
|
2023-01-29 10:11:41 +00:00
|
|
|
font.family: fontLibian.name
|
2022-05-01 10:37:13 +00:00
|
|
|
font.pixelSize: 18
|
2023-05-18 23:45:21 +00:00
|
|
|
lineHeight: Math.max(1.4 - lineCount / 8, 0.6)
|
2022-05-01 10:37:13 +00:00
|
|
|
style: Text.Outline
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
}
|
|
|
|
|
2023-02-27 02:23:48 +00:00
|
|
|
Text {
|
|
|
|
x: 0
|
|
|
|
y: 12
|
|
|
|
rotation: 90
|
|
|
|
transformOrigin: Item.BottomLeft
|
|
|
|
text: Backend.translate(name)
|
2023-08-27 11:48:15 +00:00
|
|
|
visible: Backend.translate(name).length > 6 && detailed
|
2023-02-27 02:23:48 +00:00
|
|
|
color: "white"
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 18
|
|
|
|
style: Text.Outline
|
|
|
|
}
|
|
|
|
|
2023-03-18 18:21:45 +00:00
|
|
|
Rectangle {
|
2023-08-27 11:48:15 +00:00
|
|
|
visible: pkgName !== "" && detailed
|
2023-03-18 18:21:45 +00:00
|
|
|
height: 16
|
|
|
|
width: childrenRect.width + 4
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 4
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 4
|
|
|
|
|
|
|
|
color: "#3C3229"
|
|
|
|
opacity: 0.8
|
|
|
|
radius: 4
|
|
|
|
border.color: "white"
|
|
|
|
border.width: 1
|
|
|
|
Text {
|
|
|
|
text: Backend.translate(pkgName)
|
|
|
|
x: 2; y: 1
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 14
|
|
|
|
color: "white"
|
|
|
|
style: Text.Outline
|
|
|
|
textFormat: Text.RichText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
onNameChanged: {
|
2023-06-09 09:23:02 +00:00
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
|
2022-05-01 10:37:13 +00:00
|
|
|
kingdom = data.kingdom;
|
2023-04-30 10:55:59 +00:00
|
|
|
subkingdom = (data.subkingdom !== kingdom && data.subkingdom) || "";
|
2022-05-01 10:37:13 +00:00
|
|
|
hp = data.hp;
|
2023-03-18 15:37:21 +00:00
|
|
|
maxHp = data.maxHp;
|
2023-04-13 12:17:39 +00:00
|
|
|
shieldNum = data.shield;
|
2023-03-18 18:21:45 +00:00
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
const splited = name.split("__");
|
2023-03-18 18:21:45 +00:00
|
|
|
if (splited.length > 1) {
|
|
|
|
pkgName = splited[0];
|
|
|
|
} else {
|
|
|
|
pkgName = "";
|
|
|
|
}
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
}
|