Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_ContentBrowser_GalleryDialog.c
Go to the documentation of this file.
1
/*
2
Dialog which shows big image gallery over whole screen.
3
*/
4
5
class
SCR_ContentBrowser_GalleryDialog
:
ChimeraMenuBase
6
{
7
protected
ref
SCR_ContentBrowser_GalleryDialogWidgets
m_Widgets
=
new
SCR_ContentBrowser_GalleryDialogWidgets
;
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);
17
SCR_ContentBrowser_GalleryDialog
galleryDialog =
SCR_ContentBrowser_GalleryDialog
.Cast(menuBase);
18
galleryDialog.
SetImages
(images, selectedImageIndex);
19
return
galleryDialog;
20
}
21
22
//----------------------------------------------------------------------------------
23
override
void
OnMenuOpen
()
24
{
25
m_Widgets
.Init(
GetRootWidget
());
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
39
if
(!
SCR_Global
.
IsEditMode
())
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
{
52
if
(!
SCR_Global
.
IsEditMode
())
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
93
UpdateButtons
();
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
{
107
m_iSelectedItem
=
m_iSelectedItem
+ offset;
108
m_iSelectedItem
=
Math
.ClampInt(
m_iSelectedItem
, 0,
m_aImages
.Count() - 1);
109
ShowImage
(
m_iSelectedItem
);
110
}
111
112
//----------------------------------------------------------------------------------
113
protected
void
OnBackButton
()
114
{
115
Close
();
116
}
117
118
//------------------------------------------------------------------------------------------
119
protected
void
OnNextButton
()
120
{
121
OffsetCurrentItem
(1);
122
}
123
124
//------------------------------------------------------------------------------------------
125
protected
void
OnPrevButton
()
126
{
127
OffsetCurrentItem
(-1);
128
}
129
}
id
AddonBuildInfoTool id
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition
ChimeraMenuBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetRootWidget
Widget GetRootWidget()
Definition
SCR_ModularButtonComponent.c:189
Close
proto native void Close()
Definition
SCR_WorkshopDialogs.c:77
BackendImage
Definition
BackendImage.c:13
ChimeraMenuBase
Constant variables used in various menus.
Definition
ChimeraMenuBase.c:72
Math
Definition
Math.c:13
MenuBase
Definition
MenuBase.c:32
SCR_ContentBrowser_GalleryDialog
Definition
SCR_ContentBrowser_GalleryDialog.c:6
SCR_ContentBrowser_GalleryDialog::m_iSelectedItem
int m_iSelectedItem
Definition
SCR_ContentBrowser_GalleryDialog.c:11
SCR_ContentBrowser_GalleryDialog::OnMenuClose
override void OnMenuClose()
Definition
SCR_ContentBrowser_GalleryDialog.c:50
SCR_ContentBrowser_GalleryDialog::m_aImages
ref array< BackendImage > m_aImages
Definition
SCR_ContentBrowser_GalleryDialog.c:9
SCR_ContentBrowser_GalleryDialog::CreateForImages
static SCR_ContentBrowser_GalleryDialog CreateForImages(array< BackendImage > images, int selectedImageIndex)
Definition
SCR_ContentBrowser_GalleryDialog.c:14
SCR_ContentBrowser_GalleryDialog::OnMenuOpen
override void OnMenuOpen()
Definition
SCR_ContentBrowser_GalleryDialog.c:23
SCR_ContentBrowser_GalleryDialog::UpdateButtons
void UpdateButtons()
Definition
SCR_ContentBrowser_GalleryDialog.c:97
SCR_ContentBrowser_GalleryDialog::OnPrevButton
void OnPrevButton()
Definition
SCR_ContentBrowser_GalleryDialog.c:125
SCR_ContentBrowser_GalleryDialog::OnBackButton
void OnBackButton()
Definition
SCR_ContentBrowser_GalleryDialog.c:113
SCR_ContentBrowser_GalleryDialog::SetImages
void SetImages(array< BackendImage > images, int selectedImageIndex)
Definition
SCR_ContentBrowser_GalleryDialog.c:60
SCR_ContentBrowser_GalleryDialog::ShowImage
void ShowImage(int id)
Definition
SCR_ContentBrowser_GalleryDialog.c:80
SCR_ContentBrowser_GalleryDialog::OffsetCurrentItem
void OffsetCurrentItem(int offset)
Offset - how much to move current item ID right/left.
Definition
SCR_ContentBrowser_GalleryDialog.c:105
SCR_ContentBrowser_GalleryDialog::m_Widgets
ref SCR_ContentBrowser_GalleryDialogWidgets m_Widgets
Definition
SCR_ContentBrowser_GalleryDialog.c:7
SCR_ContentBrowser_GalleryDialog::OnNextButton
void OnNextButton()
Definition
SCR_ContentBrowser_GalleryDialog.c:119
SCR_ContentBrowser_GalleryDialogWidgets
Definition
SCR_ContentBrowser_GalleryDialogWidgets.c:4
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
UIConstants
Definition
Constants.c:151
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
scripts
Game
UI
Menu
ContentBrowser
DetailsMenu
SCR_ContentBrowser_GalleryDialog.c
Generated by
1.17.0