Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LoadoutGallery.c
Go to the documentation of this file.
2
4
5typedef ScriptInvokerBase<OnLoadoutFocusLostDelegate> OnLoadoutFocusLostInvoker;
6
8{
9 [Attribute("{39D815C843414C76}UI/layouts/Menus/DeployMenu/LoadoutButton.layout")]
11 protected ref set<SCR_LoadoutButton> m_aLoadoutButtons = new set<SCR_LoadoutButton>();
12
17 protected bool m_bFocused;
19
20 override void HandlerAttached(Widget w)
21 {
22 super.HandlerAttached(w);
24 }
25
30
31 void SetGalleryFocused(bool focused)
32 {
33 Widget focusedWidget = GetGame().GetWorkspace().GetFocusedWidget();
34 if (m_bFocused && (focusedWidget && focusedWidget.IsInherited(SCR_LoadoutButton)))
35 return;
36
37 m_bFocused = focused;
39 }
40
41 override bool OnFocus(Widget w, int x, int y)
42 {
43 super.OnFocus(w, x, y);
45
46 return false;
47 }
48
49 override bool OnFocusLost(Widget w, int x, int y)
50 {
51 super.OnFocusLost(w, x, y);
52 SetGalleryFocused(false);
53
54 return false;
55 }
56
58 {
59 return m_bFocused;
60 }
61
63 {
64 GetGame().GetInputManager().RemoveActionListener(m_sActionLeft, EActionTrigger.DOWN, OnCustomLeft);
65 GetGame().GetInputManager().RemoveActionListener(m_sActionRight, EActionTrigger.DOWN, OnCustomRight);
66
67 if (!enable)
68 return;
69
70 GetGame().GetInputManager().AddActionListener(m_sActionLeft, EActionTrigger.DOWN, OnCustomLeft);
71 GetGame().GetInputManager().AddActionListener(m_sActionRight, EActionTrigger.DOWN, OnCustomRight);
72 }
73
74 int AddItem(SCR_BasePlayerLoadout loadout, bool enabled = true)
75 {
76 Widget supplies = GetGame().GetWorkspace().FindAnyWidget("w_Supplies");
77 Widget loadoutEntry = GetGame().GetWorkspace().CreateWidgets(m_sLoadoutButton, supplies);
78 SCR_LoadoutButton loadoutBtn = SCR_LoadoutButton.Cast(loadoutEntry.FindHandler(SCR_LoadoutButton));
79 if (loadoutBtn)
80 {
81 loadoutBtn.SetLoadout(loadout);
82 loadoutBtn.SetEnabled(enabled);
83
84 loadoutBtn.m_OnClicked.Insert(OnLoadoutClicked);
85 loadoutBtn.m_OnFocus.Insert(OnLoadoutHovered);
86 loadoutBtn.m_OnMouseEnter.Insert(OnLoadoutHovered);
87 loadoutBtn.m_OnMouseLeave.Insert(OnLoadoutMouseLeave);
88 loadoutBtn.m_OnFocusLost.Insert(OnLoadoutFocusLost);
89
90 m_aLoadoutButtons.Insert(loadoutBtn);
91 }
92
93 int itm = AddItem(loadoutEntry);
94 ShowPagingButtons(); // hack to go around hajkovinas
95
96 return itm;
97 }
98
99 override void ShowPagingButtons(bool animate = true)
100 {
101 bool show = (m_aWidgets.Count() > m_iCountShownItems);
102 if (m_PagingLeft)
103 m_PagingLeft.SetVisible(show, false);
104
105 if (m_PagingRight)
106 m_PagingRight.SetVisible(show, false);
107 }
108
109 protected void OnLoadoutClicked(notnull SCR_LoadoutButton loadoutBtn)
110 {
111 GetOnLoadoutClicked().Invoke(loadoutBtn);
112 }
113
114 protected void OnLoadoutHovered(notnull Widget btn)
115 {
116 SCR_LoadoutButton loadoutBtn = SCR_LoadoutButton.Cast(btn.FindHandler(SCR_LoadoutButton));
117 if (loadoutBtn)
118 GetOnLoadoutHovered().Invoke(loadoutBtn.GetLoadout());
119 }
120
121 protected void OnLoadoutFocusLost(notnull Widget btn)
122 {
123 SCR_LoadoutButton loadoutBtn = SCR_LoadoutButton.Cast(btn.FindHandler(SCR_LoadoutButton));
124 if(!loadoutBtn)
125 return;
126
127 if (loadoutBtn.IsSelected() && m_OnLoadoutFocusLost)
128 GetOnLoadoutFocusLost().Invoke(loadoutBtn.GetLoadout());
129
130 if(m_SelectedButton && !loadoutBtn.IsSelected() && m_OnLoadoutClicked)
132 }
133
134 protected void OnLoadoutMouseLeave(notnull Widget btn)
135 {
137 }
138
140 {
141 return m_wContentRoot;
142 }
143
145 {
146 foreach (SCR_LoadoutButton loadoutBtn : m_aLoadoutButtons)
147 {
148 if(loadoutBtn.GetLoadout() == loadout)
149 {
150 loadoutBtn.SetSelected(true);
151 m_SelectedButton = loadoutBtn;
152 }
153 else
154 {
155 loadoutBtn.SetSelected(false);
156 }
157 }
158 }
159
160 override void ClearAll()
161 {
162 super.ClearAll();
163 m_aLoadoutButtons.Clear();
164 }
165
167 {
169 {
170 if (btn.GetLoadout() == loadout)
171 return btn;
172 }
173
174 return null;
175 }
176
184
192
200};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
SCR_BasePlayerLoadout GetLoadout()
return player loadout
void SetLoadout(SCR_BasePlayerLoadout loadout)
Assign loadout associated with this button.
SCR_FieldOfViewSettings Attribute
EActionTrigger
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134