-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreatureUnlockProgress.qml
More file actions
105 lines (86 loc) · 3.51 KB
/
CreatureUnlockProgress.qml
File metadata and controls
105 lines (86 loc) · 3.51 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
101
102
103
104
105
import QtQuick
import QtQuick.Layouts
import qmlcomponents
RowLayout {
spacing: 1
implicitHeight: TibiaStyle.progressBarLargeHeight
Layout.preferredHeight: TibiaStyle.progressBarLargeHeight
Layout.fillHeight: false
property int currentKills: 0
property int killsToUnlockDetails1: 1
property int killsToUnlockDetails2: 2
property int killsToFullUnlock: 3
property bool isFullyUnlocked: currentKills >= killsToFullUnlock
property string colorInProgress: "orange"
property string colorFull: "green"
readonly property string barFillSource: isFullyUnlocked
? "/images/progressbar-" + colorFull + "-large.png"
: "/images/progressbar-" + colorInProgress + "-large.png"
function calculateFillPercentage(Maximum, Current)
{
if (!isFullyUnlocked) {
var MaximumValue = Math.max(Maximum, 1.0);
var CurrentValue = Math.min(Math.max(Current, 0.0), MaximumValue);
return CurrentValue / MaximumValue;
} else {
return 1.0;
}
}
TibiaProgressBar {
Layout.fillHeight: true
Layout.fillWidth: true
fillPercentage: calculateFillPercentage(killsToUnlockDetails1, currentKills)
frameSource: "/images/1pixel-down-frame.png"
backgroundSource: "/images/backdrop-dark-grey.png"
fillSource: barFillSource
frameBorder { left: 1; right: 1; top:1; bottom: 1}
fillOffset { left: 1; right: 1; top:1; bottom: 1}
Tooltip {
anchors.fill: parent
text: qsTrId("monsters_unlock_state")
.arg(TextHelper.formatNumberWithThousandSeparators(currentKills))
.arg(TextHelper.formatNumberWithThousandSeparators(killsToUnlockDetails1))
.arg(isFullyUnlocked ? qsTrId("monsters_fully_unlocked") : "")
} // Tooltip
} //TibiaProgressBar
TibiaProgressBar {
Layout.fillHeight: true
Layout.fillWidth: true
fillPercentage: calculateFillPercentage(killsToUnlockDetails2 - killsToUnlockDetails1,
currentKills - killsToUnlockDetails1)
frameSource: "/images/1pixel-down-frame.png"
backgroundSource: "/images/backdrop-dark-grey.png"
fillSource: barFillSource
frameBorder { left: 1; right: 1; top:1; bottom: 1}
fillOffset { left: 1; right: 1; top:1; bottom: 1}
TibiaText {
anchors.centerIn: parent
text: TextHelper.formatNumberWithThousandSeparators(currentKills)
} //TibiaText
Tooltip {
anchors.fill: parent
text: qsTrId("monsters_unlock_state")
.arg(TextHelper.formatNumberWithThousandSeparators(currentKills))
.arg(TextHelper.formatNumberWithThousandSeparators(killsToUnlockDetails2))
.arg(isFullyUnlocked ? qsTrId("monsters_fully_unlocked") : "")
} // Tooltip
} //TibiaProgressBar
TibiaProgressBar {
Layout.fillHeight: true
Layout.fillWidth: true
fillPercentage: calculateFillPercentage(killsToFullUnlock - killsToUnlockDetails2,
currentKills - killsToUnlockDetails2)
frameSource: "/images/1pixel-down-frame.png"
backgroundSource: "/images/backdrop-dark-grey.png"
fillSource: barFillSource
frameBorder { left: 1; right: 1; top:1; bottom: 1}
fillOffset { left: 1; right: 1; top:1; bottom: 1}
Tooltip {
anchors.fill: parent
text: qsTrId("monsters_unlock_state")
.arg(TextHelper.formatNumberWithThousandSeparators(currentKills))
.arg(TextHelper.formatNumberWithThousandSeparators(killsToFullUnlock))
.arg(isFullyUnlocked ? qsTrId("monsters_fully_unlocked") : "")
} // Tooltip
} //TibiaProgressBar
} // RowLayout