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: ""
|
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
|
|
|
|
|
|
|
Image {
|
|
|
|
source: SkinBank.GENERALCARD_DIR + "border"
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
2023-04-30 10:55:59 +00:00
|
|
|
scale: subkingdom ? 0.6 : 1
|
|
|
|
transformOrigin: Item.TopLeft
|
2023-04-04 18:21:59 +00:00
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom
|
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
|
|
|
|
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom : ""
|
|
|
|
}
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 4
|
|
|
|
spacing: 1
|
|
|
|
Repeater {
|
2023-04-13 12:17:39 +00:00
|
|
|
id: hpRepeater
|
2023-03-18 15:37:21 +00:00
|
|
|
model: (hp > 5 || hp !== maxHp) ? 1 : hp
|
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-04-13 12:17:39 +00:00
|
|
|
Shield {
|
|
|
|
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
|
|
|
|
text: Backend.translate(name)
|
2023-02-27 02:23:48 +00:00
|
|
|
visible: Backend.translate(name).length <= 6
|
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)
|
|
|
|
visible: Backend.translate(name).length > 6
|
|
|
|
color: "white"
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 18
|
|
|
|
style: Text.Outline
|
|
|
|
}
|
|
|
|
|
2023-03-18 18:21:45 +00:00
|
|
|
Rectangle {
|
|
|
|
visible: pkgName !== ""
|
|
|
|
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: {
|
|
|
|
let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
|
|
|
|
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
|
|
|
|
|
|
|
let splited = name.split("__");
|
|
|
|
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
|
|
|
}
|