Skip to content

Commit 41ef3bf

Browse files
committed
implement dynamic slot progress loading and click handlers
Refactor quadrant progress data to wod_information.lua Add slot click handlers with border toggle functionality Implement dynamic image updates based on progress frames Load vocation-specific progress data with fallback to defaults Fix slot widget hierarchy and event handling
1 parent c156a9d commit 41ef3bf

File tree

4 files changed

+258
-114
lines changed

4 files changed

+258
-114
lines changed

modules/game_wheel/game_wheel.lua

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -164,57 +164,56 @@ function SelectWindow(type, isBackButtonPress)
164164
end
165165
end
166166

167-
-- Funções para cada tab (agora carregam os módulos específicos)
168-
function showWheelOfDestiny(container)
169-
if WheelOfDestiny and WheelOfDestiny.show then
170-
WheelOfDestiny.show(container)
171-
end
172167

173-
WheelOfDestiny.updateSlicesProgress("TopLeft", {
174-
[1] = { value = 40, total = 50 },
175-
[2] = { value = 0, total = 75 },
176-
[3] = { value = 75, total = 75 },
177-
[4] = { value = 80, total = 100 },
178-
[5] = { value = 100, total = 100 },
179-
[6] = { value = 0, total = 100 },
180-
[7] = { value = 80, total = 150 },
181-
[8] = { value = 0, total = 150 },
182-
[9] = { value = 200, total = 200 },
183-
})
184-
WheelOfDestiny.updateSlicesProgress("BottomLeft", {
185-
[1] = { value = 40, total = 50 },
186-
[2] = { value = 0, total = 75 },
187-
[3] = { value = 75, total = 75 },
188-
[4] = { value = 80, total = 100 },
189-
[5] = { value = 100, total = 100 },
190-
[6] = { value = 0, total = 100 },
191-
[7] = { value = 80, total = 150 },
192-
[8] = { value = 0, total = 150 },
193-
[9] = { value = 200, total = 200 },
194-
})
195-
WheelOfDestiny.updateSlicesProgress("BottomRight", {
196-
[1] = { value = 40, total = 50 },
197-
[2] = { value = 0, total = 75 },
198-
[3] = { value = 75, total = 75 },
199-
[4] = { value = 80, total = 100 },
200-
[5] = { value = 100, total = 100 },
201-
[6] = { value = 0, total = 100 },
202-
[7] = { value = 80, total = 150 },
203-
[8] = { value = 0, total = 150 },
204-
[9] = { value = 200, total = 200 },
205-
})
206-
WheelOfDestiny.updateSlicesProgress("TopRight", {
207-
[1] = { value = 40, total = 50 },
208-
[2] = { value = 25, total = 75 },
209-
[3] = { value = 75, total = 75 },
210-
[4] = { value = 80, total = 100 },
211-
[5] = { value = 100, total = 100 },
212-
[6] = { value = 15, total = 100 },
213-
[7] = { value = 80, total = 150 },
214-
[8] = { value = 120, total = 150 },
215-
[9] = { value = 200, total = 200 },
216-
})
217-
end
168+
function showWheelOfDestiny(container)
169+
if not WheelOfDestiny or not WheelOfDestiny.show then
170+
return
171+
end
172+
173+
WheelOfDestiny.show(container)
174+
175+
-- Obter vocação do jogador
176+
local player = g_game.getLocalPlayer()
177+
if not player then
178+
return
179+
end
180+
181+
-- Obter vocação básica
182+
local basicVocation = WheelOfDestiny.getPlayerBasicVocation()
183+
if not basicVocation then
184+
return
185+
end
186+
187+
-- Carregar módulo de informações
188+
local VocationInfo = dofile('wod/wod_information.lua')
189+
if not VocationInfo or not VocationInfo.quadrantProgress then
190+
return
191+
end
192+
193+
-- Usar dados específicos da vocação ou fallback para default
194+
local progressData = VocationInfo.quadrantProgress[basicVocation] or
195+
VocationInfo.quadrantProgress.default
196+
197+
if not progressData then
198+
return
199+
end
200+
201+
if progressData.TopLeft then
202+
WheelOfDestiny.updateSlicesProgress("TopLeft", progressData.TopLeft)
203+
end
204+
205+
if progressData.BottomLeft then
206+
WheelOfDestiny.updateSlicesProgress("BottomLeft", progressData.BottomLeft)
207+
end
208+
209+
if progressData.BottomRight then
210+
WheelOfDestiny.updateSlicesProgress("BottomRight", progressData.BottomRight)
211+
end
212+
213+
if progressData.TopRight then
214+
WheelOfDestiny.updateSlicesProgress("TopRight", progressData.TopRight)
215+
end
216+
end
218217

219218
function showGemAtelier(container)
220219
if GemAtelier and GemAtelier.show then

modules/game_wheel/wod/wod.lua

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,26 +489,34 @@ end
489489
function WheelOfDestiny.setupSlotClickHandlers(ui)
490490
print("Setting up slot click handlers...")
491491

492-
local slot = ui:recursiveGetChildById('colorBottomLeft1')
493-
if not slot then
494-
print("ERROR: Slot colorBottomLeft1 not found")
495-
return
496-
end
497-
498-
print("Slot colorBottomLeft1 found, connecting event...")
492+
local quadrants = {
493+
{key = 'BottomLeft', count = 9},
494+
-- Adicionar outros quadrantes depois
495+
}
499496

500-
connect(slot, {
501-
onMousePress = function(widget, mousePos, mouseButton)
502-
print("Mouse pressed on colorBottomLeft1! Button: " .. tostring(mouseButton))
503-
if mouseButton == MouseLeftButton then
504-
toggleSlotBorder(widget, 'BottomLeft', 1)
505-
return true
497+
for _, quadrant in ipairs(quadrants) do
498+
for i = 1, quadrant.count do
499+
local slotId = string.format('color%s%d', quadrant.key, i)
500+
local slot = ui:recursiveGetChildById(slotId)
501+
502+
if slot then
503+
print(string.format("Connecting %s...", slotId))
504+
connect(slot, {
505+
onMousePress = function(widget, mousePos, mouseButton)
506+
if mouseButton == MouseLeftButton then
507+
toggleSlotBorder(widget, quadrant.key, i)
508+
return true
509+
end
510+
return false
511+
end
512+
})
513+
else
514+
print(string.format("ERROR: Slot %s not found", slotId))
506515
end
507-
return false
508516
end
509-
})
517+
end
510518

511-
print("Event connected successfully")
519+
print("All slot click handlers connected")
512520
end
513521

514522
-- Function to check if can access the wheel

modules/game_wheel/wod/wod.otui

Lines changed: 134 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,18 @@ UIWidget
481481
margin-left: 157
482482
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_2.png
483483
image-clip: 157 261 67 73
484-
phantom: true
484+
phantom: false
485+
focusable: false
486+
image-draw-order: 0
487+
488+
UIWidget
489+
id: borderBottomLeft2
490+
anchors.fill: parent
491+
image-source: /images/game/wheel/wheel-border/bottom_left/2.png
492+
image-clip: 157 261 67 73
493+
visible: false
494+
phantom: true
495+
image-draw-order: 1
485496

486497
UIWidget
487498
id: colorBottomLeft3
@@ -492,7 +503,18 @@ UIWidget
492503
margin-left: 188
493504
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_3.png
494505
image-clip: 188 298 73 67
495-
phantom: true
506+
phantom: false
507+
focusable: false
508+
image-draw-order: 0
509+
510+
UIWidget
511+
id: borderBottomLeft3
512+
anchors.fill: parent
513+
image-source: /images/game/wheel/wheel-border/bottom_left/3.png
514+
image-clip: 188 298 73 67
515+
visible: false
516+
phantom: true
517+
image-draw-order: 1
496518

497519
UIWidget
498520
id: colorBottomLeft4
@@ -503,7 +525,18 @@ UIWidget
503525
margin-left: 105
504526
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_4.png
505527
image-clip: 105 261 65 77
506-
phantom: true
528+
phantom: false
529+
focusable: false
530+
image-draw-order: 0
531+
532+
UIWidget
533+
id: borderBottomLeft4
534+
anchors.fill: parent
535+
image-source: /images/game/wheel/wheel-border/bottom_left/4.png
536+
image-clip: 105 261 65 77
537+
visible: false
538+
phantom: true
539+
image-draw-order: 1
507540

508541
UIWidget
509542
id: colorBottomLeft5
@@ -514,51 +547,106 @@ UIWidget
514547
margin-left: 127
515548
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_5.png
516549
image-clip: 127 314 81 81
517-
phantom: true
518-
519-
UIWidget
520-
id: colorBottomLeft6
521-
anchors.bottom: parent.bottom
522-
anchors.left: parent.left
523-
size: 77 65
524-
margin-bottom: 105
525-
margin-left: 184
526-
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_6.png
527-
image-clip: 184 352 77 65
528-
phantom: true
529-
530-
UIWidget
531-
id: colorBottomLeft7
532-
anchors.bottom: parent.bottom
533-
anchors.left: parent.left
534-
size: 90 107
535-
margin-bottom: 115
536-
margin-left: 60
537-
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_7.png
538-
image-clip: 60 300 90 107
539-
phantom: true
550+
phantom: false
551+
focusable: false
552+
image-draw-order: 0
540553

541-
UIWidget
542-
id: colorBottomLeft8
543-
anchors.bottom: parent.bottom
544-
anchors.left: parent.left
545-
size: 107 90
546-
margin-bottom: 60
547-
margin-left: 115
548-
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_8.png
549-
image-clip: 115 372 107 90
550-
phantom: true
554+
UIWidget
555+
id: borderBottomLeft5
556+
anchors.fill: parent
557+
image-source: /images/game/wheel/wheel-border/bottom_left/5.png
558+
image-clip: 127 314 81 81
559+
visible: false
560+
phantom: true
561+
image-draw-order: 1
551562

552-
UIWidget
553-
id: colorBottomLeft9
554-
anchors.bottom: parent.bottom
555-
anchors.left: parent.left
556-
size: 196 196
557-
margin-bottom: 12
558-
margin-left: 12
559-
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_9.png
560-
image-clip: 12 314 196 196
561-
phantom: true
563+
UIWidget
564+
id: colorBottomLeft6
565+
anchors.bottom: parent.bottom
566+
anchors.left: parent.left
567+
size: 77 65
568+
margin-bottom: 105
569+
margin-left: 184
570+
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_6.png
571+
image-clip: 184 352 77 65
572+
phantom: false
573+
focusable: false
574+
image-draw-order: 0
575+
576+
UIWidget
577+
id: borderBottomLeft6
578+
anchors.fill: parent
579+
image-source: /images/game/wheel/wheel-border/bottom_left/6.png
580+
image-clip: 184 352 77 65
581+
visible: false
582+
phantom: true
583+
image-draw-order: 1
584+
585+
UIWidget
586+
id: colorBottomLeft7
587+
anchors.bottom: parent.bottom
588+
anchors.left: parent.left
589+
size: 90 107
590+
margin-bottom: 115
591+
margin-left: 60
592+
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_7.png
593+
image-clip: 60 300 90 107
594+
phantom: false
595+
focusable: false
596+
image-draw-order: 0
597+
598+
UIWidget
599+
id: borderBottomLeft7
600+
anchors.fill: parent
601+
image-source: /images/game/wheel/wheel-border/bottom_left/7.png
602+
image-clip: 60 300 90 107
603+
visible: false
604+
phantom: true
605+
image-draw-order: 1
606+
607+
UIWidget
608+
id: colorBottomLeft8
609+
anchors.bottom: parent.bottom
610+
anchors.left: parent.left
611+
size: 107 90
612+
margin-bottom: 60
613+
margin-left: 115
614+
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_8.png
615+
image-clip: 115 372 107 90
616+
phantom: false
617+
focusable: false
618+
image-draw-order: 0
619+
620+
UIWidget
621+
id: borderBottomLeft8
622+
anchors.fill: parent
623+
image-source: /images/game/wheel/wheel-border/bottom_left/8.png
624+
image-clip: 115 372 107 90
625+
visible: false
626+
phantom: true
627+
image-draw-order: 1
628+
629+
UIWidget
630+
id: colorBottomLeft9
631+
anchors.bottom: parent.bottom
632+
anchors.left: parent.left
633+
size: 196 196
634+
margin-bottom: 12
635+
margin-left: 12
636+
image-source: /images/game/wheel/wheel-colors/bottom_left/BottonLeft_9.png
637+
image-clip: 12 314 196 196
638+
phantom: false
639+
focusable: false
640+
image-draw-order: 0
641+
642+
UIWidget
643+
id: borderBottomLeft9
644+
anchors.fill: parent
645+
image-source: /images/game/wheel/wheel-border/bottom_left/9.png
646+
image-clip: 12 314 196 196
647+
visible: false
648+
phantom: true
649+
image-draw-order: 1
562650

563651
UIWidget
564652
id: colorQuadrantBottomRight

0 commit comments

Comments
 (0)