-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacterCombatStatBlock.qml
More file actions
100 lines (84 loc) · 3.29 KB
/
CharacterCombatStatBlock.qml
File metadata and controls
100 lines (84 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import QtQuick
import QtQuick.Layouts
import qmlcomponents
ColumnLayout {
id: statBlock
enum EType {
From,
Against,
For,
Nothing
}
property var statBlockData
property bool alwaysShowSources: false
property int type: CharacterCombatStatBlock.EType.From
property int sourcesMarginLeft: TibiaStyle.marginUnrelated
Layout.fillWidth: true
visible: statBlockData != null && statBlockData.visible
TextMetrics {
id: textMeasurer
font: TibiaStyle.defaultTextFont
renderType: TextEdit.NativeRendering
text: "* 555.55% "
}
RowLayout {
TibiaText {
text: statBlock.statBlockData != null ? statBlock.statBlockData.caption : qsTrId("dummy_unknown")
tooltipText: statBlock.statBlockData != null ? statBlock.statBlockData.tooltip : qsTrId("dummy_unknown")
tooltipMaxWidth: TibiaStyle.tooltipRestrictedWidth
Layout.fillWidth: true
}
TibiaText {
text: statBlock.statBlockData != null ? statBlock.statBlockData.total : qsTrId("dummy_unknown")
tooltipText: statBlock.statBlockData != null ? statBlock.statBlockData.tooltip : qsTrId("dummy_unknown")
tooltipMaxWidth: TibiaStyle.tooltipRestrictedWidth
styleType: statBlock.statBlockData == null || statBlock.statBlockData.styleType === undefined ? "Dialog" : statBlock.statBlockData.styleType
}
Image {
source: statBlock.statBlockData == null || statBlock.statBlockData.iconSource === undefined ? "" : statBlock.statBlockData.iconSource
Tooltip {
anchors.fill: parent
text: statBlock.statBlockData != null ? (statBlock.statBlockData.iconTooltip === undefined || statBlock.statBlockData.iconTooltip == "" ? statBlock.statBlockData.caption : statBlock.statBlockData.iconTooltip) : qsTrId("dummy_unknown")
maxWidth: TibiaStyle.tooltipRestrictedWidth
}
}
} // RowLayout
Repeater {
id: sourceRepeater
model: statBlock.statBlockData != null ? statBlock.statBlockData.sources : []
property string descriptionTextTemplate: switch (statBlock.type) {
case CharacterCombatStatBlock.EType.From: return qsTrId("charinfo_statblock_from")
case CharacterCombatStatBlock.EType.Against: return qsTrId("charinfo_statblock_against")
case CharacterCombatStatBlock.EType.For: return qsTrId("charinfo_statblock_for")
case CharacterCombatStatBlock.EType.Nothing: return "%1"
}
RowLayout {
id: statRow
visible: statBlock.alwaysShowSources || sourceRepeater.count > 1
required property string name
required property string value
required property string tooltip
TibiaText {
text: statRow.value
horizontalAlignment: Text.AlignRight
Layout.leftMargin: statBlock.sourcesMarginLeft
Layout.preferredWidth: textMeasurer.width
Tooltip {
anchors.fill: parent
text: statRow.tooltip
maxWidth: TibiaStyle.tooltipRestrictedWidth
} // Tooltip
}
TibiaText {
text: sourceRepeater.descriptionTextTemplate.arg(statRow.name)
Layout.fillWidth: true
Tooltip {
anchors.fill: parent
text: statRow.tooltip
enabled: text.length > 0
maxWidth: TibiaStyle.tooltipRestrictedWidth
} // Tooltip
} // TibiaText
} // RowLayout
} // Repeater
} // ColumnLayout