Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ContentBrowser_GalleryDialog.c
Go to the documentation of this file.
1/*
2Dialog which shows big image gallery over whole screen.
3*/
4
6{
8
9 protected ref array<BackendImage> m_aImages = {};
10
11 protected int m_iSelectedItem;
12
13 //----------------------------------------------------------------------------------
14 static SCR_ContentBrowser_GalleryDialog CreateForImages(array<BackendImage> images, int selectedImageIndex)
15 {
16 MenuBase menuBase = GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.GalleryDialog);
18 galleryDialog.SetImages(images, selectedImageIndex);
19 return galleryDialog;
20 }
21
22 //----------------------------------------------------------------------------------
23 override void OnMenuOpen()
24 {
26
27 m_Widgets.m_BackButtonComponent.m_OnActivated.Insert(OnBackButton);
28 m_Widgets.m_NextButtonComponent.m_OnClicked.Insert(OnNextButton);
29 m_Widgets.m_PrevButtonComponent.m_OnClicked.Insert(OnPrevButton);
30
31 // Close this dialog when user clicks outside
32 SCR_ModularButtonComponent backgroundButtonComponent = SCR_ModularButtonComponent.FindComponent(GetRootWidget());
33 backgroundButtonComponent.m_OnClicked.Insert(OnBackButton);
34
35 // Also close this when user clicks on cross at top-right
36 m_Widgets.m_CloseButtonComponent.m_OnClicked.Insert(OnBackButton);
37
38 // Listen to inputs
40 {
41 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_RIGHT, EActionTrigger.DOWN, OnNextButton);
42 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_LEFT, EActionTrigger.DOWN, OnPrevButton);
43 }
44
45 GetGame().GetWorkspace().SetFocusedWidget(GetRootWidget());
46 }
47
48
49 //----------------------------------------------------------------------------------
50 override void OnMenuClose()
51 {
53 {
54 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_RIGHT, EActionTrigger.DOWN, OnNextButton);
55 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_LEFT, EActionTrigger.DOWN, OnPrevButton);
56 }
57 }
58
59 //----------------------------------------------------------------------------------
60 void SetImages(array<BackendImage> images, int selectedImageIndex)
61 {
62 m_Widgets.m_SpinBoxComponent0.ClearAll();
63 m_aImages.Clear();
64
65 if (images.IsEmpty())
66 return;
67
68 m_aImages = images;
69 int total = m_aImages.Count();
70 foreach (int i, BackendImage img : m_aImages)
71 {
72 m_Widgets.m_SpinBoxComponent0.AddItem(string.Empty, i == total - 1);
73 }
74
75 m_iSelectedItem = selectedImageIndex;
76 ShowImage(selectedImageIndex);
77 }
78
79 //----------------------------------------------------------------------------------
80 protected void ShowImage(int id)
81 {
82 if (m_aImages.IsEmpty())
83 return;
84
85 if (id < 0 || id >= m_aImages.Count())
86 id = m_aImages.Count() - 1;
87
88 BackendImage backendImage = m_aImages[id];
89
90 m_Widgets.m_BackendImageComponent.SetImage(backendImage);
91 m_Widgets.m_SpinBoxComponent0.SetCurrentItem(id);
92
94 }
95
96 //----------------------------------------------------------------------------------
97 protected void UpdateButtons()
98 {
99 m_Widgets.m_NextButtonComponent.SetEnabled(m_iSelectedItem < (m_aImages.Count() - 1));
100 m_Widgets.m_PrevButtonComponent.SetEnabled(m_iSelectedItem > 0);
101 }
102
103 //------------------------------------------------------------------------------------------
105 protected void OffsetCurrentItem(int offset)
106 {
108 m_iSelectedItem = Math.ClampInt(m_iSelectedItem, 0, m_aImages.Count() - 1);
110 }
111
112 //----------------------------------------------------------------------------------
113 protected void OnBackButton()
114 {
115 Close();
116 }
117
118 //------------------------------------------------------------------------------------------
119 protected void OnNextButton()
120 {
122 }
123
124 //------------------------------------------------------------------------------------------
125 protected void OnPrevButton()
126 {
128 }
129}
AddonBuildInfoTool id
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget GetRootWidget()
proto native void Close()
Constant variables used in various menus.
Definition Math.c:13
static bool IsEditMode()
Definition Functions.c:1566
EActionTrigger