Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MainMenuTile_MenuComponent.c
Go to the documentation of this file.
2{
3 [Attribute("")]
4 string m_sTitle;
5
6 [Attribute("")]
7 string m_sDescription;
8
9 [Attribute("")]
10 ResourceName m_sImage;
11
12 [Attribute("-1", UIWidgets.SearchComboBox, enumType: ChimeraMenuPreset)]
14
20
22
23 protected bool m_bFocused;
24 protected bool m_bDisabled;
25
26 protected bool m_bIsTutorialNeeded;
28
29 //------------------------------------------------------------------------------------------------
30 override void HandlerAttached(Widget w)
31 {
32 super.HandlerAttached(w);
33
34 m_wName = TextWidget.Cast(w.FindAnyWidget("Name"));
35 m_wName.SetText(m_sTitle);
36
37 m_wDescription = TextWidget.Cast(w.FindAnyWidget("Description"));
38 m_wDescription.SetVisible(false);
39 m_wDescription.SetText(m_sDescription);
40
41 m_wTextContent = w.FindAnyWidget("TextSizeLayout");
42
43 m_wBackground = ImageWidget.Cast(w.FindAnyWidget("Shading"));
44 m_wBackground.SetVisible(false);
45
46 m_DisabledTileShadow = w.FindAnyWidget("m_DisabledTileShadow");
47 m_DisabledTileShadow.SetVisible(false);
48
50 if (comp)
51 {
52 if (!m_sImage.IsEmpty())
53 comp.SetImage(m_sImage);
54 }
55
57 m_Play.m_OnActivated.Insert(OnPlay);
58 m_Play.SetVisible(m_bFocused, false);
59
60 bool isMouseInteraction = GetGame().GetInputManager().GetLastUsedInputDevice() == EInputDeviceType.MOUSE;
61
62 UpdateButtonInputVisibility(m_Play.GetRootWidget(), !isMouseInteraction);
63
64 GetGame().OnInputDeviceUserChangedInvoker().Insert(OnInputDeviceUserChanged);
65 }
66
67 // React on switching between input methods
68 //------------------------------------------------------------------------------------------------
69 protected void OnInputDeviceUserChanged(EInputDeviceType oldDevice, EInputDeviceType newDevice)
70 {
71 if (m_bDisabled || newDevice == EInputDeviceType.TRACK_IR || newDevice == EInputDeviceType.JOYSTICK)
72 return;
73
74 bool isMouseInteraction = newDevice == EInputDeviceType.MOUSE;
75
76 UpdateButtonInputVisibility(m_Play.GetRootWidget(), !isMouseInteraction);
77 }
78
79 //------------------------------------------------------------------------------------------------
80 protected void UpdateButtonInputVisibility(notnull Widget root, bool visibility)
81 {
82 Widget buttonWidget = root.FindAnyWidget("InputButtonDisplayRoot");
83 if (!buttonWidget)
84 return;
85
86 buttonWidget.SetEnabled(visibility);
87 buttonWidget.SetVisible(visibility);
88 }
89
90 //------------------------------------------------------------------------------------------------
92 {
93 m_bDisabled = true;
94
95 m_DisabledTileShadow.SetVisible(true);
96
97 m_Play.SetEnabled(false);
98 }
99
100 //------------------------------------------------------------------------------------------------
101 override bool OnClick(Widget w, int x, int y, int button)
102 {
103 if (button == MouseState.RIGHT)
104 return true;
105
106 OnPlay();
107
108 return super.OnClick(w, x, y, button);
109 }
110
111 //------------------------------------------------------------------------------------------------
112 override bool OnFocus(Widget w, int x, int y)
113 {
114 if (m_bDisabled)
115 return super.OnFocus(w, x, y);
116
117 m_bFocused = true;
118 float position[4] = {20.0, 0.0, 20.0, 25.0};
119
121 m_wDescription.SetVisible(true);
122 m_wBackground.SetVisible(true);
123
124 m_Play.SetVisible(m_bFocused, false);
125
126 return super.OnFocus(w, x, y);
127 }
128
129 //------------------------------------------------------------------------------------------------
130 override bool OnFocusLost(Widget w, int x, int y)
131 {
132 m_bFocused = false;
133 float position[4] = {20.0, 0.0, 20.0, -70.0};
134
136 m_wDescription.SetVisible(false);
137 m_wBackground.SetVisible(false);
138
139 m_Play.SetVisible(m_bFocused, false);
140
141 return super.OnFocusLost(w, x, y);
142 }
143
144 //------------------------------------------------------------------------------------------------
145 protected void OnPlay()
146 {
147 if (m_bDisabled)
148 return;
149
151 {
152 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_RecentGames");
153
154 if (settings)
155 {
156 int playTutorialShowCount;
157
158 settings.Get("m_iPlayTutorialShowCount", playTutorialShowCount);
159 playTutorialShowCount++;
160
161 settings.Set("m_iPlayTutorialShowCount", playTutorialShowCount);
162 GetGame().UserSettingsChanged();
163 }
164
165 // Tutorial confirmation dialog
166 SCR_ConfigurableDialogUi dialog = SCR_CommonDialogs.CreateTutorialDialog();
167 if (dialog)
168 {
169 dialog.m_OnConfirm.Insert(OnPlayTutorial);
170 dialog.m_OnCancel.Insert(OnPlayMenu);
171
172 return;
173 }
174 }
175
176 OnPlayMenu();
177 }
178
179 //------------------------------------------------------------------------------------------------
180 protected void OnPlayMenu()
181 {
182 GetGame().GetMenuManager().OpenMenu(m_pMenuPreset);
183 }
184
185 //------------------------------------------------------------------------------------------------
186 protected void OnPlayTutorial()
187 {
189 SCR_MenuLoadingComponent.SaveLastMenu(ChimeraMenuPreset.MainMenu);
190 }
191
192 //------------------------------------------------------------------------------------------------
193 void SetTutorial(notnull MissionWorkshopItem tutorialMission)
194 {
195 m_TutorialMission = tutorialMission;
196 m_bIsTutorialNeeded = true;
197 }
198}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector position
static WidgetAnimationPadding Padding(Widget widget, float padding[4], float speed)
static SCR_InputButtonComponent GetInputButtonComponent(string name, notnull Widget parent, bool searchAllChildren=true)
override bool OnClick(Widget w, int x, int y, int button)
void SetTutorial(notnull MissionWorkshopItem tutorialMission)
void OnInputDeviceUserChanged(EInputDeviceType oldDevice, EInputDeviceType newDevice)
override bool OnFocusLost(Widget w, int x, int y)
override bool OnFocus(Widget w, int x, int y)
void UpdateButtonInputVisibility(notnull Widget root, bool visibility)
SCR_FieldOfViewSettings Attribute
MouseState
Definition MouseState.c:13