-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExaltationResultDialog.qml
More file actions
473 lines (402 loc) · 17.9 KB
/
Copy pathExaltationResultDialog.qml
File metadata and controls
473 lines (402 loc) · 17.9 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import qmlcomponents
TibiaDialog {
id: root
caption: {
// fusion result caption
if (root.isFusion) {
return root.isConvergence ? qsTrId("exaltation_result_convergence_fusion_caption") : qsTrId("exaltation_result_fusion_caption")
}
// transfer result caption
return root.isConvergence ? qsTrId("exaltation_result_convergence_transfer_caption") : qsTrId("exaltation_result_transfer_caption")
}
width: 400
headerDelegate: DialogHeaderDragon {}
property var controller: null
property bool smoothTextureFiltering: controller != null && controller.smoothTextureFiltering
property bool isFusion: controller != null && controller.isFusion
property bool isConvergence: controller != null && controller.isConvergence
property bool wasSuccessful: controller != null && controller.wasSuccessful
property int resultObjectUpgradeTier: controller != null ? controller.resultObjectUpgradeTier : 0
property int fusionBonus: controller != null && controller.fusionBonus
property bool bonusStage: false
readonly property bool softwareRenderBackup: GlobalConstants.isSoftwareRenderer
readonly property int coverBonusMargin: 10
readonly property int blinkNormalMs: 200
readonly property int blinkFastDivisor: 2
readonly property int arrowFactor: 1
readonly property int blinkFastMs: blinkNormalMs / blinkFastDivisor
readonly property int arrowTimeMs: blinkNormalMs * arrowFactor * 2
onVisibleChanged: resetPropertiesAndStartAnimation()
onIsFusionChanged: resetPropertiesAndStartAnimation()
onWasSuccessfulChanged: resetPropertiesAndStartAnimation()
initialFocusItem: root
KeyNavigation.tab: root
KeyNavigation.backtab: root
onReturnPressedFunction: function() {
}
onCancelPressedFunction: function() {
}
function onButtonClicked() {
if (controller != null && dialogButton.enabled) {
if ( root.bonusStage
|| !root.isFusion
|| root.fusionBonus == TibiaEnums.FusionBonusEffectNone) {
controller.requestClose();
} else {
showBonusStage();
}
}
} //function onButtonClicked
function showBonusStage() {
bonusStage = true;
dialogButton.text = qsTrId("close")
} // function showBonusStage()
property bool showLeftAtTheEnd: false
property bool showRightAtTheEnd: false
property color rightCoverColor: TibiaStyle.black2
property color rightFadeColor: TibiaStyle.white4
property int startTargetUpgradeTier: resultObjectUpgradeTier
property string buttonTextAtTheEnd: qsTrId("close")
function resetPropertiesAndStartAnimation() {
animation.stop()
leftObject.visible = true;
rightObject.visible = true;
leftObject.opacity = 1.0;
rightObject.opacity = 1.0;
leftObjectColorOverlay.opacity = 1.0;
rightObjectColorOverlay.opacity = 1.0;
resultText.opacity = 0.0;
arrow1.source = "/images/icon-arrow-rightlarge.png"
arrow2.source = "/images/icon-arrow-rightlarge.png"
arrow3.source = "/images/icon-arrow-rightlarge.png"
root.bonusStage = false;
dialogButton.text = "";
if (root.visible) {
if (root.isFusion && root.wasSuccessful) {
showLeftAtTheEnd = false;
showRightAtTheEnd = true;
rightCoverColor = TibiaStyle.black2;
rightFadeColor = TibiaStyle.white4;
startTargetUpgradeTier = resultObjectUpgradeTier;
} else if (root.isFusion && !root.wasSuccessful) {
showLeftAtTheEnd = true;
showRightAtTheEnd = false;
rightCoverColor = TibiaStyle.black2;
rightFadeColor = TibiaStyle.red3;
startTargetUpgradeTier = resultObjectUpgradeTier;
} else if (!root.isFusion) {
showLeftAtTheEnd = false;
showRightAtTheEnd = true;
rightCoverColor = TibiaStyle.transparent;
rightFadeColor = TibiaStyle.white4;
startTargetUpgradeTier = 0;
}
if (root.fusionBonus == TibiaEnums.FusionBonusEffectNone) {
buttonTextAtTheEnd = qsTrId("close");
} else {
buttonTextAtTheEnd = qsTrId("next");
}
animation.restart();
}
} //function resetPropertiesAndStartAnimation
SequentialAnimation {
id: animation
running: false
loops: 1
alwaysRunToEnd: false
//1000 Item left normal; right black
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.transparent }
PropertyAction { target: rightObjectColorOverlay; property: "color"; value: root.rightCoverColor }
PropertyAction { target: rightObject; property: "upgradeTier"; value: root.startTargetUpgradeTier }
PauseAnimation { duration: 1000 }
//200 Item left white
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.white4 }
ParallelAnimation {
SequentialAnimation {
//200|200 blinking left item
SequentialAnimation {
loops: (4*root.arrowTimeMs) / (2*root.blinkNormalMs)
PauseAnimation { duration: root.blinkNormalMs }
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.transparent }
PauseAnimation { duration: root.blinkNormalMs }
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.white4 }
} //SequentialAnimation
//100|100 blinkinf left item
SequentialAnimation {
loops: (2*root.arrowTimeMs) / (2*root.blinkFastMs)
PauseAnimation { duration: root.blinkFastMs }
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.transparent }
PauseAnimation { duration: root.blinkFastMs }
PropertyAction { target: leftObjectColorOverlay; property: "color"; value: TibiaStyle.white4 }
} //SequentialAnimation
}//SequentialAnimation
//400 fill and empty arrows
SequentialAnimation {
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow1; property: "source"; value: "/images/icon-arrow-rightlarge-filled.png" }
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow2; property: "source"; value: "/images/icon-arrow-rightlarge-filled.png" }
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow3; property: "source"; value: "/images/icon-arrow-rightlarge-filled.png" }
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow1; property: "source"; value: "/images/icon-arrow-rightlarge.png" }
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow2; property: "source"; value: "/images/icon-arrow-rightlarge.png" }
PauseAnimation { duration: root.arrowTimeMs }
PropertyAction { target: arrow3; property: "source"; value: "/images/icon-arrow-rightlarge.png" }
} //SequentialAnimation
} //ParallelAnimation
//100 both white
PropertyAction { target: rightObjectColorOverlay; property: "color"; value: root.rightFadeColor }
PropertyAction { target: rightObject; property: "upgradeTier"; value: root.resultObjectUpgradeTier }
PropertyAction { target: leftObject; property: "visible"; value: root.showLeftAtTheEnd || root.softwareRenderBackup }
PropertyAction { target: rightObject; property: "visible"; value: root.showRightAtTheEnd || root.softwareRenderBackup }
PauseAnimation { duration: 100 }
//1000 left white to nothing; right white to item
ParallelAnimation {
PropertyAnimation { target: leftObjectColorOverlay; property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.InQuad; duration: 1000 }
PropertyAnimation { target: rightObjectColorOverlay; property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.InQuad; duration: 1000 }
PropertyAnimation { target: leftObject; property: "opacity";
from: !root.softwareRenderBackup ? 1.0 : (root.showLeftAtTheEnd ? 0.0 : 1.0);
to: !root.softwareRenderBackup ? 1.0 : (root.showLeftAtTheEnd ? 1.0 : 0.0);
easing.type: Easing.Linear; duration: 1000 }
PropertyAnimation { target: rightObject; property: "opacity";
from: !root.softwareRenderBackup ? 1.0 : (root.showRightAtTheEnd ? 0.0 : 1.0);
to: !root.softwareRenderBackup ? 1.0 : (root.showRightAtTheEnd ? 1.0 : 0.0);
easing.type: Easing.Linear; duration: 1000 }
} //ParallelAnimation
PropertyAction { target: leftObject; property: "visible"; value: root.showLeftAtTheEnd }
PropertyAction { target: rightObject; property: "visible"; value: root.showRightAtTheEnd }
//50 show result text
PropertyAnimation { target: resultText; property: "opacity"; to: 1.0; duration: 50 }
PropertyAction { target: dialogButton; property: "text"; value: root.buttonTextAtTheEnd }
} //SequentialAnimation
ColumnLayout {
anchors { left: parent.left; right: parent.right }
spacing: TibiaStyle.marginUnrelated
RowLayout {
visible: !root.bonusStage
spacing: 0
Layout.topMargin: root.softwareRenderBackup ? root.coverBonusMargin : 0
Layout.leftMargin: Layout.topMargin
Layout.rightMargin: Layout.topMargin
Item {
Layout.preferredWidth: leftObject.width
Layout.preferredHeight: leftObject.height
ScalableObjectDisplay {
id: leftObject
showBackground: false
scaleFactor: TibiaStyle.exaltationForgeItemScaleFactor
animated: true
smoothTextureFiltering: root.smoothTextureFiltering
typeid: controller != null ? controller.inputObjectTypeId : 0
upgradeTier: controller != null ? controller.inputObjectUpgradeTier : 0
} //ScalableObjectDisplay
ColorOverlay {
id: leftObjectColorOverlay
width: leftObject.width
height: leftObject.height
anchors.centerIn: leftObject
visible: !root.softwareRenderBackup
source: leftObject
color: TibiaStyle.transparent
} //ColorOverlay
Rectangle {
id: leftCover
anchors.centerIn: leftObject
width: leftObject.width + 2 * root.coverBonusMargin
height: width
radius: 3 * root.coverBonusMargin
visible: root.softwareRenderBackup
color: leftObjectColorOverlay.color
opacity: leftObjectColorOverlay.opacity
} //Rectangle
} //Item
Item {
Layout.fillWidth: true
} //Item
RowLayout {
spacing: TibiaStyle.marginRelated
Layout.alignment: Qt.AlignVCenter
Image {
id: arrow1
source: "/images/icon-arrow-rightlarge.png"
} //Image
Image {
id: arrow2
source: "/images/icon-arrow-rightlarge.png"
} //Image
Image {
id: arrow3
source: "/images/icon-arrow-rightlarge.png"
} //Image
} //RowLayout
Item {
Layout.fillWidth: true
} //Item
Item {
Layout.preferredWidth: rightObject.width
Layout.preferredHeight: rightObject.height
ScalableObjectDisplay {
id: rightObject
showBackground: false
scaleFactor: TibiaStyle.exaltationForgeItemScaleFactor
animated: true
smoothTextureFiltering: root.smoothTextureFiltering
typeid: controller != null ? controller.resultObjectTypeId : 0
upgradeTier: root.resultObjectUpgradeTier
} //ScalableObjectDisplay
ColorOverlay {
id: rightObjectColorOverlay
width: rightObject.width
height: rightObject.height
anchors.centerIn: rightObject
visible: !root.softwareRenderBackup
source: rightObject
color: TibiaStyle.transparent
} //ColorOverlay
Rectangle {
id: rightCover
anchors.centerIn: rightObject
width: rightObject.width + 2 * root.coverBonusMargin
height: width
radius: 3 * root.coverBonusMargin
visible: root.softwareRenderBackup
color: rightObjectColorOverlay.color
opacity: rightObjectColorOverlay.opacity
} //Rectangle
} //Item
} //RowLayout
TibiaText {
id: resultText
Layout.fillWidth: true
Layout.preferredHeight: 40
horizontalAlignment: Text.AlignHCenter
textFormat: Text.RichText
wrapMode: Text.Wrap
visible: !root.bonusStage
text: {
var resultText = "";
if (root.isFusion) {
if (root.wasSuccessful) {
resultText = qsTrId("exaltation_result_fusion_result_success").arg(TibiaStyle.green1);
} else {
resultText = qsTrId("exaltation_result_fusion_result_fail").arg(TibiaStyle.red2);
}
} else {
resultText = qsTrId("exaltation_result_transfer_result").arg(TibiaStyle.green1);
}
return resultText;
}
opacity: 0
} //TibiaText
ScalableObjectDisplay {
id: bonusObject
Layout.alignment: Qt.AlignHCenter
showBackground: false
scaleFactor: TibiaStyle.exaltationForgeItemScaleFactor
animated: true
smoothTextureFiltering: root.smoothTextureFiltering
cumulativeCount: 100
visible: root.bonusStage
typeid: {
var typeId = 0;
if ( root.fusionBonus == TibiaEnums.FusionBonusEffectNoDustCost
|| root.fusionBonus == TibiaEnums.FusionBonusEffectBackfillDust) {
typeId = TibiaStyle.exaltedDustId;
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectNoCoreCost) {
typeId = TibiaStyle.exaltedCoreId;
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectNoGoldCost) {
typeId = TibiaStyle.goldCoinId;
} else if ( root.fusionBonus == TibiaEnums.FusionBonusEffectDowngradeResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectKeepResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectUpgradeResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectDoubleUpgrade
|| root.fusionBonus == TibiaEnums.FusionBonusEffectTierLossPreventionTriggered) {
typeId = controller != null ? controller.bonusObjectTypeId : 0;
}
return typeId;
}
upgradeTier: {
var tier = 0;
if ( root.fusionBonus == TibiaEnums.FusionBonusEffectDowngradeResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectKeepResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectUpgradeResourceObject
|| root.fusionBonus == TibiaEnums.FusionBonusEffectDoubleUpgrade
|| root.fusionBonus == TibiaEnums.FusionBonusEffectTierLossPreventionTriggered) {
tier = controller != null ? controller.bonusObjectUpgradeTier : 0;
}
return tier;
}
} //ScalableObjectDisplay
TibiaText {
id: bonusText
Layout.fillWidth: true
Layout.preferredHeight: resultText.Layout.preferredHeight
horizontalAlignment: Text.AlignHCenter
textFormat: Text.RichText
wrapMode: Text.Wrap
visible: root.bonusStage
text: {
var resultText = "";
if (controller != null) {
if (root.fusionBonus == TibiaEnums.FusionBonusEffectNoDustCost) {
resultText = qsTrId("exaltation_result_bonus_no_dust_cost").arg(controller.dustCost);
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectNoCoreCost) {
if (controller.coreCount == 1) {
resultText = qsTrId("exaltation_result_bonus_no_core_cost_singular")
} else {
resultText = qsTrId("exaltation_result_bonus_no_core_cost_plural").arg(controller.coreCount)
}
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectNoGoldCost) {
resultText = qsTrId("exaltation_result_bonus_no_gold_cost").arg(TextHelper.formatNumberWithThousandSeparators(controller.goldCost));
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectDowngradeResourceObject) {
resultText = qsTrId("exaltation_result_bonus_downgrade_resource_object");
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectKeepResourceObject) {
resultText = qsTrId("exaltation_result_bonus_keep_resource_object");
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectUpgradeResourceObject) {
resultText = qsTrId("exaltation_result_bonus_upgrade_resource_object");
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectDoubleUpgrade) {
resultText = qsTrId("exaltation_result_bonus_upgrade_double_upgrade");
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectTierLossPreventionTriggered) {
if (controller.bonusObjectUpgradeTier == 0) {
resultText = qsTrId("exaltation_result_bonus_tier_loss_prevention_triggered_tier0");
} else {
resultText = qsTrId("exaltation_result_bonus_tier_loss_prevention_triggered");
}
} else if (root.fusionBonus == TibiaEnums.FusionBonusEffectBackfillDust) {
resultText = qsTrId("exaltation_result_bonus_backfill_dust");
}
}
return resultText;
}
} //TibiaText
TibiaHorizontalSeparator {
Layout.fillWidth: true
} // TibiaHorizontalSeparator
RowLayout {
id: buttonBar
Layout.fillWidth: true
spacing: TibiaStyle.marginRelated
Item {
// Padding
Layout.fillWidth: true
height: 1
} //Item
TibiaButton {
id: dialogButton
enabled: text.length != 0
text: ""
onClicked: onButtonClicked()
TibiaDisabledOverlay {
anchors.fill: parent
anchors.margins: 1
visible: !parent.enabled
} //TibiaDisabledOverlay
} //TibiaButton
} // RowLayout
} // ColumnLayout
} // TibiaDialog