2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2022-03-30 14:14:40 +08:00
|
|
|
import "../skin-bank.js" as SkinBank
|
|
|
|
|
|
|
|
/* Layout of general card:
|
|
|
|
* +--------+
|
|
|
|
*kindom|wu 9999| <- hp
|
|
|
|
*name -|s |
|
|
|
|
* |q img |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* +--------+
|
|
|
|
* Inherit from CardItem to use common signal
|
|
|
|
*/
|
|
|
|
|
|
|
|
CardItem {
|
2022-05-01 18:37:13 +08:00
|
|
|
property string kingdom
|
|
|
|
property int hp
|
2023-03-18 23:37:21 +08:00
|
|
|
property int maxHp
|
2023-03-19 02:21:45 +08:00
|
|
|
property string pkgName: ""
|
2022-05-01 18:37:13 +08:00
|
|
|
name: ""
|
2022-04-30 15:27:56 +08:00
|
|
|
// description: Sanguosha.getGeneralDescription(name)
|
|
|
|
suit: ""
|
|
|
|
number: 0
|
|
|
|
footnote: ""
|
2023-02-15 19:54:35 +08:00
|
|
|
card.source: SkinBank.getGeneralPicture(name)
|
2022-04-30 15:27:56 +08:00
|
|
|
glow.color: "white" //Engine.kingdomColor[kingdom]
|
2022-05-01 18:37:13 +08:00
|
|
|
|
|
|
|
Image {
|
|
|
|
source: SkinBank.GENERALCARD_DIR + "border"
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
2023-04-05 02:21:59 +08:00
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 4
|
|
|
|
spacing: 1
|
|
|
|
Repeater {
|
2023-03-18 23:37:21 +08:00
|
|
|
model: (hp > 5 || hp !== maxHp) ? 1 : hp
|
2022-05-01 18:37:13 +08:00
|
|
|
Image {
|
2023-04-05 02:21:59 +08:00
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-magatama"
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
2023-03-18 23:37:21 +08:00
|
|
|
visible: hp > 5 || hp !== maxHp
|
|
|
|
text: hp === maxHp ? ("x" + hp) : (" " + hp + "/" + maxHp)
|
2022-05-01 18:37:13 +08:00
|
|
|
color: "white"
|
|
|
|
font.pixelSize: 14
|
|
|
|
style: Text.Outline
|
|
|
|
y: -6
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
width: 20
|
|
|
|
height: 80
|
|
|
|
x: 2
|
|
|
|
y: lineCount > 6 ? 30 : 34
|
|
|
|
text: Backend.translate(name)
|
2023-02-27 10:23:48 +08:00
|
|
|
visible: Backend.translate(name).length <= 6
|
2022-05-01 18:37:13 +08:00
|
|
|
color: "white"
|
2023-01-29 18:11:41 +08:00
|
|
|
font.family: fontLibian.name
|
2022-05-01 18:37:13 +08:00
|
|
|
font.pixelSize: 18
|
|
|
|
lineHeight: Math.max(1.4 - lineCount / 10, 0.6)
|
|
|
|
style: Text.Outline
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
}
|
|
|
|
|
2023-02-27 10:23:48 +08: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-19 02:21:45 +08: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 18:37:13 +08:00
|
|
|
onNameChanged: {
|
|
|
|
let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
|
|
|
|
kingdom = data.kingdom;
|
|
|
|
hp = data.hp;
|
2023-03-18 23:37:21 +08:00
|
|
|
maxHp = data.maxHp;
|
2023-03-19 02:21:45 +08:00
|
|
|
|
|
|
|
let splited = name.split("__");
|
|
|
|
if (splited.length > 1) {
|
|
|
|
pkgName = splited[0];
|
|
|
|
} else {
|
|
|
|
pkgName = "";
|
|
|
|
}
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
2022-03-30 14:14:40 +08:00
|
|
|
}
|