9 protected ref array<ref BackendImage> m_aImages = {};
11 protected int m_iCurrentItem;
18 galleryDialog.Init(images, selectedImageIndex);
24 protected void Init(array<BackendImage> images,
int selectedImageIndex)
29 int total = images.Count();
30 foreach (
int i, BackendImage img : images)
32 m_Widgets.m_SpinBoxComponent.AddItem(
string.Empty, i == total - 1);
33 m_aImages.Insert(img);
36 if (!m_aImages.IsEmpty())
38 m_iCurrentItem = selectedImageIndex;
39 ShowImage(selectedImageIndex);
45 protected void ShowImage(
int id)
47 if (id < 0 || id >= m_aImages.Count())
50 BackendImage backendImage = m_aImages[id];
52 m_Widgets.m_BackendImageComponent.SetImage(backendImage);
54 m_Widgets.m_SpinBoxComponent.SetCurrentItem(
id);
61 protected void UpdateButtons()
63 m_Widgets.m_NextButtonComponent.SetEnabled(m_iCurrentItem < (m_aImages.Count() - 1));
64 m_Widgets.m_PrevButtonComponent.SetEnabled(m_iCurrentItem > 0);
70 protected void OffsetCurrentItem(
int offset)
72 m_iCurrentItem = m_iCurrentItem + offset;
73 m_iCurrentItem = Math.ClampInt(m_iCurrentItem, 0, m_aImages.Count() - 1);
74 ShowImage(m_iCurrentItem);
79 protected void OnBackButton()
85 protected void OnNextButton()
91 protected void OnPrevButton()
93 OffsetCurrentItem(-1);
97 override void OnMenuOpen()
101 m_Widgets.m_BackButtonComponent.m_OnActivated.Insert(OnBackButton);
102 m_Widgets.m_NextButtonComponent.m_OnClicked.Insert(OnNextButton);
103 m_Widgets.m_PrevButtonComponent.m_OnClicked.Insert(OnPrevButton);
106 SCR_ModularButtonComponent backgroundButtonComponent = SCR_ModularButtonComponent.Cast(
GetRootWidget().FindHandler(SCR_ModularButtonComponent));
107 backgroundButtonComponent.m_OnClicked.Insert(OnBackButton);
110 m_Widgets.m_CloseButtonComponent.m_OnClicked.Insert(OnBackButton);
115 GetGame().GetInputManager().AddActionListener(
"MenuRight", EActionTrigger.DOWN, OnNextButton);
116 GetGame().GetInputManager().AddActionListener(
"MenuLeft", EActionTrigger.DOWN, OnPrevButton);
124 override void OnMenuClose()
128 GetGame().GetInputManager().RemoveActionListener(
"MenuRight", EActionTrigger.DOWN, OnNextButton);
129 GetGame().GetInputManager().RemoveActionListener(
"MenuLeft", EActionTrigger.DOWN, OnPrevButton);