2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2023-04-30 18:55:59 +08:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2023-05-19 10:08:36 +08:00
|
|
|
import Fk
|
|
|
|
import Fk.PhotoElement
|
2022-03-30 14:14:40 +08:00
|
|
|
|
|
|
|
/* 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
|
2023-04-30 18:55:59 +08:00
|
|
|
property string subkingdom: "wei"
|
2022-05-01 18:37:13 +08:00
|
|
|
property int hp
|
2023-03-18 23:37:21 +08:00
|
|
|
property int maxHp
|
2023-04-13 20:17:39 +08:00
|
|
|
property int shieldNum
|
2023-03-19 02:21:45 +08:00
|
|
|
property string pkgName: ""
|
2023-08-27 19:48:15 +08:00
|
|
|
property bool detailed: true
|
2024-04-07 00:45:55 +08:00
|
|
|
property alias hasCompanions: companions.visible
|
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: ""
|
2024-01-25 03:23:29 +08:00
|
|
|
card.source: known ? SkinBank.getGeneralPicture(name)
|
|
|
|
: (SkinBank.GENERALCARD_DIR + 'card-back')
|
2022-04-30 15:27:56 +08:00
|
|
|
glow.color: "white" //Engine.kingdomColor[kingdom]
|
2022-05-01 18:37:13 +08:00
|
|
|
|
2023-09-06 22:16:09 +08:00
|
|
|
// FIXME: 藕!!
|
2024-01-25 03:23:29 +08:00
|
|
|
property bool heg: name.startsWith('hs__') || name.startsWith('ld__') ||
|
|
|
|
name.includes('heg__')
|
2023-09-06 22:16:09 +08:00
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
Image {
|
2023-12-28 12:11:24 +08:00
|
|
|
source: known ? (SkinBank.GENERALCARD_DIR + "border") : ""
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
2023-04-30 18:55:59 +08:00
|
|
|
scale: subkingdom ? 0.6 : 1
|
2023-09-06 22:16:09 +08:00
|
|
|
width: 34; fillMode: Image.PreserveAspectFit
|
2023-04-30 18:55:59 +08:00
|
|
|
transformOrigin: Item.TopLeft
|
2023-04-05 02:21:59 +08:00
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: detailed && known
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
|
|
|
|
2023-04-30 18:55:59 +08:00
|
|
|
Image {
|
|
|
|
scale: 0.6; x: 9; y: 12
|
|
|
|
transformOrigin: Item.TopLeft
|
2023-09-06 22:16:09 +08:00
|
|
|
width: 34; fillMode: Image.PreserveAspectFit
|
2024-01-25 03:23:29 +08:00
|
|
|
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom
|
|
|
|
: ""
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: detailed && known
|
2023-04-30 18:55:59 +08:00
|
|
|
}
|
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 4
|
|
|
|
spacing: 1
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: detailed && known && !heg
|
2022-05-01 18:37:13 +08:00
|
|
|
Repeater {
|
2023-04-13 20:17:39 +08:00
|
|
|
id: hpRepeater
|
2023-09-06 22:16:09 +08:00
|
|
|
model: (!heg) ? ((hp > 5 || hp !== maxHp) ? 1 : hp) : 0
|
2023-04-30 18:55:59 +08:00
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: childrenRect.height
|
|
|
|
Image {
|
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-magatama"
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: subkingdomMagatama
|
|
|
|
visible: false
|
2024-01-25 03:23:29 +08:00
|
|
|
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) +
|
|
|
|
subkingdom + "-magatama" : ""
|
2023-04-30 18:55:59 +08:00
|
|
|
}
|
|
|
|
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 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 22:16:09 +08:00
|
|
|
Row {
|
|
|
|
x: 34
|
|
|
|
y: 3
|
|
|
|
spacing: 0
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: detailed && known && heg
|
2023-09-06 22:16:09 +08:00
|
|
|
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 20:17:39 +08:00
|
|
|
Shield {
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: shieldNum > 0 && detailed && known
|
2023-04-13 20:17:39 +08:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: hpRepeater.model > 4 ? 16 : 0
|
|
|
|
scale: 0.8
|
|
|
|
value: shieldNum
|
|
|
|
}
|
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
Text {
|
|
|
|
width: 20
|
|
|
|
height: 80
|
|
|
|
x: 2
|
|
|
|
y: lineCount > 6 ? 30 : 34
|
2024-04-07 00:45:55 +08:00
|
|
|
z: 999
|
2024-01-25 03:23:29 +08:00
|
|
|
text: name !== "" ? luatr(name) : "nil"
|
|
|
|
visible: luatr(name).length <= 6 && detailed && known
|
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
|
2023-05-19 07:45:21 +08:00
|
|
|
lineHeight: Math.max(1.4 - lineCount / 8, 0.6)
|
2022-05-01 18:37:13 +08:00
|
|
|
style: Text.Outline
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
}
|
|
|
|
|
2023-02-27 10:23:48 +08:00
|
|
|
Text {
|
|
|
|
x: 0
|
|
|
|
y: 12
|
2024-04-07 00:45:55 +08:00
|
|
|
z: 999
|
2023-02-27 10:23:48 +08:00
|
|
|
rotation: 90
|
|
|
|
transformOrigin: Item.BottomLeft
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr(name)
|
|
|
|
visible: luatr(name).length > 6 && detailed && known
|
2023-02-27 10:23:48 +08:00
|
|
|
color: "white"
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 18
|
|
|
|
style: Text.Outline
|
|
|
|
}
|
|
|
|
|
2023-03-19 02:21:45 +08:00
|
|
|
Rectangle {
|
2023-12-28 12:11:24 +08:00
|
|
|
visible: pkgName !== "" && detailed && known
|
2023-03-19 02:21:45 +08:00
|
|
|
height: 16
|
|
|
|
width: childrenRect.width + 4
|
2024-04-07 00:45:55 +08:00
|
|
|
z: 100
|
2023-03-19 02:21:45 +08:00
|
|
|
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 {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr(pkgName)
|
2023-03-19 02:21:45 +08:00
|
|
|
x: 2; y: 1
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 14
|
|
|
|
color: "white"
|
|
|
|
style: Text.Outline
|
|
|
|
textFormat: Text.RichText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-07 00:45:55 +08:00
|
|
|
Image {
|
|
|
|
id: companions
|
|
|
|
width: parent.width
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
visible: false
|
|
|
|
source: SkinBank.getGeneralCardDir(kingdom) + kingdom + "-companions"
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
y: 80
|
|
|
|
z: 1
|
|
|
|
}
|
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
onNameChanged: {
|
2024-01-25 03:23:29 +08:00
|
|
|
const data = lcall("GetGeneralData", name);
|
2022-05-01 18:37:13 +08:00
|
|
|
kingdom = data.kingdom;
|
2023-04-30 18:55:59 +08:00
|
|
|
subkingdom = (data.subkingdom !== kingdom && data.subkingdom) || "";
|
2022-05-01 18:37:13 +08:00
|
|
|
hp = data.hp;
|
2023-03-18 23:37:21 +08:00
|
|
|
maxHp = data.maxHp;
|
2023-04-13 20:17:39 +08:00
|
|
|
shieldNum = data.shield;
|
2023-03-19 02:21:45 +08:00
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
const splited = name.split("__");
|
2023-03-19 02:21:45 +08:00
|
|
|
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
|
|
|
}
|