I am new to purebasic and finding it quite a bit different to the previous languages I've used (not many by the way, only a novice programmer).
I am writing a program to change the faction that players in my game are representing. Currently, I have a listview gadget that lists the multiplayer character names and a randomize button that randomly picks a faction with which the character has enough rep and applies it to each one. That has been working well.
Now I'm adding the ability to double click on a character name and manually choose the faction to represent. So my process is that once you double click on a character, that listview gadget (0) is hidden and another listview gadget (1), which is over top of the first one, is un-hidden and lists all the factions that the character has enough rep with to choose.
Oh btw, while the first listview is shown, as you click on each character an image gadget displays that character's faction uniform and a text gadget displays the faction name. What should happen, but doesn't, is when you click on the factions in the second listview, the image gadget and text gadget should update as it does with the first listview gadget.
The relevant code that I believe I have issue with is:
Code: Select all
Repeat
myevent = WaitWindowEvent()
Select myevent
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case Button_0
If GetGadgetState(Option_0) = 1
RandomizeAllS(EventType())
Gosub Populate
Else
RandomizeAllM(EventType())
Gosub Populate
EndIf
SetGadgetState(ListView_0,0)
For a = 0 To ArraySize(myListItemsSorted$())
If GetGadgetItemText(ListView_0,(GetGadgetState(ListView_0))) = myListItems$(a)
myItem=a
FactionNames$ = myListName$(myItem)
FactionGroup$ = myListGroup$(myItem)
EndIf
Next
Gosub mySelection
Case Button_1
End
Case ListView_0_Event_Gadget
For a = 0 To ArraySize(myListItemsSorted$())
If GetGadgetItemText(ListView_0,(GetGadgetState(ListView_0))) = myListItems$(a)
myItem=a
FactionNames$ = myListName$(myItem)
FactionGroup$ = myListGroup$(myItem)
EndIf
Next
Gosub mySelection
Case ListView_1_Event_Gadget
Restore FactionData
For factionFinder = 1 To 48
Read.s FactionGroup$
Read.s FactionChest$
Read.s FactionAcron$
Read.s FactionNames$
If FactionNames$ = GetGadgetItemText(ListView_1,(GetGadgetState(ListView_1)))
Break
EndIf
Next
Gosub mySelection
Case Option_0
Gosub OptionChange
Case Option_1
Gosub OptionChange
EndSelect
If EventType() = #PB_EventType_LeftDoubleClick
Gosub SuitSelector
EndIf
EndSelect
Until myevent = #PB_Event_CloseWindowI've manually added listview_1 to the enumeration but it wipes it when run.
Code: Select all
Global Window_0
Global Button_0, Button_1, Text_1, Image_0, Container_0, Option_0, Option_1, Container_1, Text_2, Text_3, ListView_1
Enumeration FormGadget
#ListView_0
EndEnumeration
Enumeration FormFont
#Font_Window_0_0
#Font_Window_0_1
#Font_Window_0_2
#Font_Window_0_3
EndEnumeration
LoadFont(#Font_Window_0_0,"Calibri Light", 12)
LoadFont(#Font_Window_0_1,"Agency FB", 37, #PB_Font_Bold)
LoadFont(#Font_Window_0_2,"Calibri", 12)
LoadFont(#Font_Window_0_3,"Calibri", 16, #PB_Font_Bold | #PB_Font_Italic)
Procedure OpenWindow_0(x = 0, y = 0, width = 700, height = 850)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "Freelancer Body Swap v4.0", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Button_0 = ButtonGadget(#PB_Any, 90, 480, 260, 30, "Randomize All")
SetGadgetFont(Button_0, FontID(#Font_Window_0_0))
Button_1 = ButtonGadget(#PB_Any, 450, 480, 220, 30, "Exit")
SetGadgetFont(Button_1, FontID(#Font_Window_0_0))
Text_1 = TextGadget(#PB_Any, 40, 10, 620, 70, "Freelancer Body Swap", #PB_Text_Center)
SetGadgetFont(Text_1, FontID(#Font_Window_0_1))
ListViewGadget(#ListView_0, 40, 160, 370, 270)
SetGadgetFont(#ListView_0, FontID(#Font_Window_0_2))
Image_0 = ImageGadget(#PB_Any, 510, 160, 150, 270, 0)
Container_0 = ContainerGadget(#PB_Any, 40, 90, 370, 60, #PB_Container_Raised)
Option_0 = OptionGadget(#PB_Any, 10, 10, 220, 20, "Load Single Player Save Games")
Option_1 = OptionGadget(#PB_Any, 10, 30, 220, 20, "Load Multiplayer Characters")
SetGadgetState(Option_1, 1)
CloseGadgetList()
Container_1 = ContainerGadget(#PB_Any, 440, 90, 220, 60, #PB_Container_Raised)
Text_2 = TextGadget(#PB_Any, 0, 0, 220, 60, "", #PB_Text_Center)
SetGadgetFont(Text_2, FontID(#Font_Window_0_3))
CloseGadgetList()
Text_3 = TextGadget(#PB_Any, 40, 440, 370, 30, "Double-Click to Choose Manually", #PB_Text_Center)
ListView_1 = ListViewGadget(#PB_Any, 40, 160, 370, 270)
SetGadgetFont(ListView_1, FontID(#Font_Window_0_2))
EndProcedure
Thank you in advance,
Beamer
Edit: I thought I'd expand slightly on the issue. I've added a debug line into the wait event for listviews 0 and 1, but nothing ever shows for listview 1 even though I can see and select each faction name in that listview.



