-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPound.qml
95 lines (91 loc) · 2.74 KB
/
Pound.qml
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
import QtQuick 2.0
Item {
id: poundRoot
property var leftGate
property var rightGate
property bool magic: false
property double baseHeight: 0
property double maxDepth: 0
property double maxHeight: baseHeight + maxDepth
property double maxVolume: width * maxDepth
property double waterVolume: maxVolume //Initial setting only
property double excessVolume: Math.max(0, waterVolume - maxVolume)
property double waterDepth: waterVolume / width
property double waterHeight: baseHeight + waterDepth
onWaterVolumeChanged: {
if (magic) {
waterVolume = maxVolume;
}
}
width: 200
anchors.bottom: parent.bottom
Image {
id: waterTop
source: "watertop.png"
fillMode: Image.TileHorizontally
verticalAlignment: Image.AlignTop
horizontalAlignment: Image.AlignLeft
anchors.top: parent.top
anchors.topMargin: -2 //For wibbly surface
anchors.left: parent.left
anchors.right: parent.right
}
Rectangle {
id: water
color: "#E1000000"
anchors.top: waterTop.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Rectangle {
id: ground
color: "black"
height: 3 * baseHeight
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Image {
id: groundTop
source: "mudtop.png"
fillMode: Image.TileHorizontally
anchors.top: ground.top
anchors.topMargin: -3 //For wibbly surface
anchors.left: parent.left
anchors.right: parent.right
}
Image {
id: poundSideTop
source: "bricktop.png"
fillMode: Image.TileHorizontally
verticalAlignment: Image.AlignTop
horizontalAlignment: Image.AlignLeft
z: -1
anchors.left: parent.left
anchors.right: parent.right
anchors.top: ground.top
anchors.topMargin: -(3 * maxDepth + 10) //Water not right to top
}
Image {
id: poundSide
source: "brick.png"
fillMode: Image.Tile
verticalAlignment: Image.AlignTop
horizontalAlignment: Image.AlignLeft
z: -1
anchors.left: parent.left
anchors.right: parent.right
anchors.top: poundSideTop.bottom
anchors.bottom: parent.bottom
}
Text {
visible: labelsButton.checked
text: Math.abs(waterVolume).toFixed() + "/" + maxVolume.toFixed()
anchors.bottom: poundSideTop.top
anchors.bottomMargin: 14
anchors.horizontalCenter: parent.horizontalCenter
}
height: 3 * waterHeight
property bool isPound: true //This is stupid
}