This UI shows when there is only one element in the Pages array, if theres more the UI with specific index will still be hidden even tho it’s visibility is set to Visible, can someone help with that?
RunPages(Agent : agent): void =
for (Index := 0..Pages.Length - 1):
if (Element := Pages[Index]):
Element.AssignShopUI(Agent)
RunPages2(Agent : agent): void =
for (Index := 0..Pages.Length - 1):
if (Element := Pages[Index]):
Element.ShowHUD(Agent)
@editable Pages: []shop_pages = array{}
shop_pages := class<concrete>():
var MainDevice : game_manager = game_manager{}
InitPages(PageDevice : game_manager): void =
set MainDevice = PageDevice
ShowPage.TriggeredEvent.Subscribe(ShowHUDWith)
@editable PageName : string = "Placeholder"
@editable ShowPage : trigger_device = trigger_device{}
@editable PageIndex : int = -1
@editable Button1Value : int = 0
@editable Button2Value : int = 0
@editable Button3Value : int = 0
var MaybeMyUIPerPlayer : [player]?canvas = map{}
var Players : []player = array{}
AssignShopUI(Agent : agent) : void =
if:
Player := player[Agent]
PlayerUI := GetPlayerUI[Player]
then:
if(MyUI := MaybeMyUIPerPlayer[Player]?):
#Do nothing
else:
var MyCanvas : canvas = MakeCanvas()
PlayerUI.AddWidget(MyCanvas,player_ui_slot{InputMode:=ui_input_mode.All})
if(set MaybeMyUIPerPlayer[Player] = option{MyCanvas}){}
Print("Shop UI with Index {PageIndex} added (start)")
spawn:
RemoveHUDStart(Agent)
RemoveShopUI(Wdata : widget_message) : void =
if:
Agent := agent[Wdata.Player]
CurrentPage := MainDevice.AgentsCurrentPageIndexMap[Agent]?
CurrentPage <> PageIndex
then:
if(Player := Wdata.Player, PlayerUI := GetPlayerUI[Player]):
if(MyUI := MaybeMyUIPerPlayer[Player]?):
PlayerUI.RemoveWidget(MyUI)
if(set MaybeMyUIPerPlayer[Player] = false){}
Print("Shop UI with Index {PageIndex} remove")
RemoveHUDStart(Agent : agent)<suspends>: void =
Sleep(2.0)
Print("hide triggered")
if:
Player := player[Agent]
CurrentPage := MainDevice.AgentsCurrentPageIndexMap[Agent]?
CurrentPage <> PageIndex
then:
if(MyUI := MaybeMyUIPerPlayer[Player]?):
MyUI.SetVisibility(InVisibility := widget_visibility.Hidden)
Print("Shop UI with Index {PageIndex} collapsed (start)")
RemoveHUD(Wdata : widget_message) : void =
if:
Agent := agent[Wdata.Player]
Player := player[Agent]
then:
if(MyUI := MaybeMyUIPerPlayer[Player]?):
MyUI.SetVisibility(InVisibility := widget_visibility.Hidden)
Print("Shop UI with Index {PageIndex} collapsed")
ShowHUD(Agent : agent): void =
Print("triggered without trigger")
if:
Player := player[Agent]
CurrentPage := MainDevice.AgentsCurrentPageIndexMap[Agent]?
CurrentPage = PageIndex
then:
Print("triggered without trigger")
if(MyUI := MaybeMyUIPerPlayer[Player]?):
MyUI.SetVisibility(InVisibility := widget_visibility.Visible)
Print("Shop UI with Index {PageIndex} shown")