Differential D7231 Diff 18803 src/activities/penalty/0002-Changes-Removed-dependency-on-mouse-buttons.patch
Changeset View
Changeset View
Standalone View
Standalone View
src/activities/penalty/0002-Changes-Removed-dependency-on-mouse-buttons.patch
- This file was added.
1 | From 9063674ff7186ea03c15fd64789590d8a717e168 Mon Sep 17 00:00:00 2001 | ||||
---|---|---|---|---|---|
2 | From: Rohit Das <rohit.das950@gmail.com> | ||||
3 | Date: Thu, 10 Aug 2017 21:02:28 +0530 | ||||
4 | Subject: [PATCH 2/3] Changes: Removed dependency on mouse buttons | ||||
5 | | ||||
6 | Mouse buttons won't be present in tabs. So instead | ||||
7 | tapping on the corresponding side of the goals will | ||||
8 | do, irrespective of the button clicked. Put three | ||||
9 | MouseArea elements on the left, right and top of the | ||||
10 | goal. | ||||
11 | | ||||
12 | Signed-off-by: Rohit Das <rohit.das950@gmail.com> | ||||
13 | --- | ||||
14 | src/activities/penalty/Penalty.qml | 217 ++++++++++++++++++++++++++++--------- | ||||
15 | 1 file changed, 168 insertions(+), 49 deletions(-) | ||||
16 | | ||||
17 | diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml | ||||
18 | index b9ab4de..55c12d2 100644 | ||||
19 | --- a/src/activities/penalty/Penalty.qml | ||||
20 | +++ b/src/activities/penalty/Penalty.qml | ||||
21 | @@ -45,6 +45,167 @@ ActivityBase { | ||||
22 | activity.stop.connect(stop) | ||||
23 | } | ||||
24 | | ||||
25 | + //To enable tapping/clicking on left side of goal | ||||
26 | + Rectangle{ | ||||
27 | + id: maleft | ||||
28 | + anchors.fill: parent.left | ||||
29 | + width: 475 | ||||
30 | + height: 300 | ||||
31 | + x: 100 | ||||
32 | + y: 50 | ||||
33 | + color: "transparent" | ||||
34 | + | ||||
35 | + MouseArea { | ||||
36 | + anchors.fill: parent | ||||
37 | + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | ||||
38 | + onClicked: { | ||||
39 | + instruction.text = "" | ||||
40 | + | ||||
41 | + if(ball.state === "FAIL") { | ||||
42 | + Activity.resetLevel() | ||||
43 | + return | ||||
44 | + } | ||||
45 | + | ||||
46 | + /* This is a shoot */ | ||||
47 | + var progress = progressTop | ||||
48 | + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { | ||||
49 | + progress = progressLeft | ||||
50 | + } | ||||
51 | + | ||||
52 | + if(progress.ratio > 0) { | ||||
53 | + /* Second click, stop animation */ | ||||
54 | + progress.anim.running = false; | ||||
55 | + | ||||
56 | + /* Play sound */ | ||||
57 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") | ||||
58 | + | ||||
59 | + /* Success or not */ | ||||
60 | + if(progress.ratio < 100) { | ||||
61 | + /* Success */ | ||||
62 | + ball.state = "LEFT" | ||||
63 | + } else { | ||||
64 | + /* failure */ | ||||
65 | + ball.state = "FAIL" | ||||
66 | + } | ||||
67 | + timerBonus.start() | ||||
68 | + } else { | ||||
69 | + /* First click, start animation*/ | ||||
70 | + progress.anim.running = true; | ||||
71 | + | ||||
72 | + /* Play sound */ | ||||
73 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") | ||||
74 | + } | ||||
75 | + } | ||||
76 | + } | ||||
77 | + } | ||||
78 | + | ||||
79 | + //To enable tapping/clicking on top of goal | ||||
80 | + Rectangle{ | ||||
81 | + id: matop | ||||
82 | + width: 600 | ||||
83 | + height: 175 | ||||
84 | + x: 575 | ||||
85 | + y: 50 | ||||
86 | + color: "transparent" | ||||
87 | + | ||||
88 | + MouseArea { | ||||
89 | + anchors.fill: parent | ||||
90 | + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | ||||
91 | + onClicked: { | ||||
92 | + instruction.text = "" | ||||
93 | + | ||||
94 | + if(ball.state === "FAIL") { | ||||
95 | + Activity.resetLevel() | ||||
96 | + return | ||||
97 | + } | ||||
98 | + | ||||
99 | + /* This is a shoot */ | ||||
100 | + var progress = progressTop | ||||
101 | + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { | ||||
102 | + | ||||
103 | + } | ||||
104 | + | ||||
105 | + if(progress.ratio > 0) { | ||||
106 | + /* Second click, stop animation */ | ||||
107 | + progress.anim.running = false; | ||||
108 | + | ||||
109 | + /* Play sound */ | ||||
110 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") | ||||
111 | + | ||||
112 | + /* Success or not */ | ||||
113 | + if(progress.ratio < 100) { | ||||
114 | + /* Success */ | ||||
115 | + ball.state = "CENTER" | ||||
116 | + } else { | ||||
117 | + /* failure */ | ||||
118 | + ball.state = "FAIL" | ||||
119 | + } | ||||
120 | + timerBonus.start() | ||||
121 | + } else { | ||||
122 | + /* First click, start animation*/ | ||||
123 | + progress.anim.running = true; | ||||
124 | + | ||||
125 | + /* Play sound */ | ||||
126 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") | ||||
127 | + } | ||||
128 | + } | ||||
129 | + } | ||||
130 | + } | ||||
131 | + | ||||
132 | + //To enable tapping/clicking on right side of goal | ||||
133 | + Rectangle{ | ||||
134 | + id: maright | ||||
135 | + anchors.fill: parent.right | ||||
136 | + width: 475 | ||||
137 | + height: 300 | ||||
138 | + x: 800 | ||||
139 | + y: 50 | ||||
140 | + color: "transparent" | ||||
141 | + | ||||
142 | + MouseArea { | ||||
143 | + anchors.fill: parent | ||||
144 | + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | ||||
145 | + onClicked: { | ||||
146 | + instruction.text = "" | ||||
147 | + | ||||
148 | + if(ball.state === "FAIL") { | ||||
149 | + Activity.resetLevel() | ||||
150 | + return | ||||
151 | + } | ||||
152 | + | ||||
153 | + /* This is a shoot */ | ||||
154 | + var progress = progressTop | ||||
155 | + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { | ||||
156 | + progress = progressRight | ||||
157 | + } | ||||
158 | + | ||||
159 | + if(progress.ratio > 0) { | ||||
160 | + /* Second click, stop animation */ | ||||
161 | + progress.anim.running = false; | ||||
162 | + | ||||
163 | + /* Play sound */ | ||||
164 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") | ||||
165 | + | ||||
166 | + /* Success or not */ | ||||
167 | + if(progress.ratio < 100) { | ||||
168 | + /* Success */ | ||||
169 | + ball.state = "RIGHT" | ||||
170 | + } else { | ||||
171 | + /* failure */ | ||||
172 | + ball.state = "FAIL" | ||||
173 | + } | ||||
174 | + timerBonus.start() | ||||
175 | + } else { | ||||
176 | + /* First click, start animation*/ | ||||
177 | + progress.anim.running = true; | ||||
178 | + | ||||
179 | + /* Play sound */ | ||||
180 | + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") | ||||
181 | + } | ||||
182 | + } | ||||
183 | + } | ||||
184 | + } | ||||
185 | + | ||||
186 | // Add here the QML items you need to access in javascript | ||||
187 | QtObject { | ||||
188 | id: items | ||||
189 | @@ -275,7 +436,7 @@ ActivityBase { | ||||
190 | } | ||||
191 | PropertyChanges { | ||||
192 | target: instruction | ||||
193 | - text: qsTr("Double click or double tap on the ball to kick it.") | ||||
194 | + text: qsTr("Double click or double tap on the side of the goal you want to put the ball in.") | ||||
195 | } | ||||
196 | }, | ||||
197 | State { | ||||
198 | @@ -320,56 +481,14 @@ ActivityBase { | ||||
199 | } | ||||
200 | ] | ||||
201 | | ||||
202 | - MouseArea { | ||||
203 | + MouseArea{ | ||||
204 | anchors.fill: parent | ||||
205 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | ||||
206 | - onClicked: { | ||||
207 | - instruction.text = "" | ||||
208 | - | ||||
209 | - if(ball.state === "FAIL") { | ||||
210 | - Activity.resetLevel() | ||||
211 | - return | ||||
212 | - } | ||||
213 | - | ||||
214 | - /* This is a shoot */ | ||||
215 | - var progress = progressTop | ||||
216 | - if (mouse.button == Qt.LeftButton) { | ||||
217 | - progress = progressLeft | ||||
218 | - } else if (mouse.button == Qt.RightButton) { | ||||
219 | - progress = progressRight | ||||
220 | - } else if (mouse.button == Qt.MidButton) { | ||||
221 | - progress = progressTop | ||||
222 | - } | ||||
223 | - | ||||
224 | - if(progress.ratio > 0) { | ||||
225 | - /* Second click, stop animation */ | ||||
226 | - progress.anim.running = false; | ||||
227 | - | ||||
228 | - /* Play sound */ | ||||
229 | - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") | ||||
230 | - | ||||
231 | - /* Success or not */ | ||||
232 | - if(progress.ratio < 100) { | ||||
233 | - /* Success */ | ||||
234 | - if(progress === progressLeft) { | ||||
235 | - ball.state = "LEFT" | ||||
236 | - } else if(progress === progressRight) { | ||||
237 | - ball.state = "RIGHT" | ||||
238 | - } else { | ||||
239 | - ball.state = "CENTER" | ||||
240 | - } | ||||
241 | - } else { | ||||
242 | - /* failure */ | ||||
243 | - ball.state = "FAIL" | ||||
244 | - } | ||||
245 | - timerBonus.start() | ||||
246 | - } else { | ||||
247 | - /* First click, start animation*/ | ||||
248 | - progress.anim.running = true; | ||||
249 | - | ||||
250 | - /* Play sound */ | ||||
251 | - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") | ||||
252 | - } | ||||
253 | + onClicked:{ | ||||
254 | + ball.state = "INITIAL" | ||||
255 | + progressRight.ratio = 0 | ||||
256 | + progressLeft.ratio = 0 | ||||
257 | + progressTop.ratio = 0 | ||||
258 | } | ||||
259 | } | ||||
260 | } | ||||
261 | -- | ||||
262 | 2.7.4 | ||||
263 | |