Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
mainmenupromo.c
Go to the documentation of this file.
1
2class MainMenuDlcHandlerBase extends ScriptedWidgetEventHandler
3{
4 protected const string TEXT_OWNED = "#layout_dlc_owned";
5 protected const string TEXT_UNOWNED = "#layout_dlc_unowned";
6
7 protected int m_ColorBackgroundOriginal;
8
9 protected Widget m_Root;
10 protected Widget m_BannerFrame;
11 protected Widget m_Background;
12 protected Widget m_StoreButton;
13 protected Widget m_GamepadStoreImage;
14 protected ImageWidget m_DlcPromotionImage;
15 protected TextWidget m_TitleTextDlc;
16 protected MultilineTextWidget m_DescriptionTextDlc;
17 protected VideoWidget m_VideoWidget;
18 protected ref ModInfo m_ThisModInfo;
19 protected ref JsonDataDLCInfo m_DlcInfo;
20
21 protected ref BannerHandlerBase m_BannerHandler;
22
23 void MainMenuDlcHandlerBase(ModInfo info, Widget parent, JsonDataDLCInfo DlcInfo)
24 {
25 CreateRootWidget(parent);
26 m_Root.SetHandler(this);
27 m_DlcInfo = DlcInfo;
28 m_ThisModInfo = info;
29 Init();
30
31 #ifdef PLATFORM_CONSOLE
32 GetGame().GetContentDLCService().m_OnChange.Insert(OnDLCChange);
33 if (GetGame().GetMission())
34 {
35 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
36 }
37 #endif
38 }
39
40 void ~MainMenuDlcHandlerBase()
41 {
42 #ifdef PLATFORM_CONSOLE
43 if (GetGame().GetContentDLCService())
44 GetGame().GetContentDLCService().m_OnChange.Remove(OnDLCChange);
45 #endif
46 }
47
48 void Init()
49 {
50 m_Background = m_Root;
51 m_StoreButton = m_Root.FindAnyWidget("dlc_openStore");
52 SetPlatformSpecifics();
53 m_VideoWidget = VideoWidget.Cast(m_Root.FindAnyWidget("dlc_Video"));
54 m_VideoWidget.Show(false);
55 m_DlcPromotionImage = ImageWidget.Cast(m_Root.FindAnyWidget("dlc_ImageMain"));
56 m_DlcPromotionImage.Show(true);
57 m_BannerFrame = m_Root.FindAnyWidget("dlc_BannerFrame");//dlc_BannerFrame //dlc_BannerFrameVideo
58 m_BannerHandler = new BannerHandlerBase(m_BannerFrame);
59 m_TitleTextDlc = TextWidget.Cast(m_Root.FindAnyWidget("dlc_title"));
60 m_DescriptionTextDlc = MultilineTextWidget.Cast(m_Root.FindAnyWidget("dlc_Description"));
61 m_DescriptionTextDlc.SetLineBreakingOverride(LinebreakOverrideMode.LINEBREAK_WESTERN);
62 m_ColorBackgroundOriginal = m_Background.GetColor();
63
64 UpdateAllPromotionInfo();
65 //StartVideo();
66 }
67
68 void CreateRootWidget(Widget parent)
69 {
70 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/dlc_panels/DLC_Panel.layout", parent);
71 }
72
73 void ShowInfoPanel(bool show)
74 {
75 m_Root.Show(show);
76 OnPanelVisibilityChanged();
77 }
78
79 bool IsInfoPanelVisible()
80 {
81 return m_Root.IsVisible();
82 }
83
84 void OnPanelVisibilityChanged()
85 {
86 UpdateAllPromotionInfo();
87 return;
88
89 /*if (IsInfoPanelVisible())
90 StartVideo();
91 else
92 PauseVideo();*/
93 }
94
95 //works on button only
96 override bool OnClick(Widget w, int x, int y, int button)
97 {
98 m_ThisModInfo.GoToStore();
99 return super.OnClick(w,x,y,button);
100 }
101
103 bool LoadVideoFile()
104 {
105 if (m_VideoWidget.GetState() != VideoState.NONE)
106 return true;
107
108 string path = "video\\" + m_DlcInfo.VideoFileName;
109 if (m_DlcInfo.VideoFileName != "")
110 return m_VideoWidget.Load(path, true);
111
112 return false;
113 }
114
115 void StartVideo()
116 {
117 if (LoadVideoFile())
118 m_VideoWidget.Play();
119 }
120
121 void StopVideo()
122 {
123 m_VideoWidget.Stop();
124 }
125
126 void PauseVideo()
127 {
128 m_VideoWidget.Pause();
129 }
130
131 void UnloadVideo()
132 {
133 m_VideoWidget.Stop();
134 m_VideoWidget.Unload();
135 }
136
137 protected void ColorFocussed(Widget w, int x, int y)
138 {
139 m_Background.SetColor(ARGB(255,54,16,16));
140 }
141
142 protected void ColorUnfocussed(Widget w, Widget enterW, int x, int y)
143 {
144 m_Background.SetColor(m_ColorBackgroundOriginal);
145 }
146
147 protected void UpdateOwnedStatus()
148 {
149 if (m_ThisModInfo)
150 {
151 if (m_ThisModInfo.GetIsOwned())
152 {
153 m_BannerHandler.SetBannerColor(Colors.COLOR_FROSTLINE_MOUNTAIN_BLUE);
154 m_BannerHandler.SetBannerText(TEXT_OWNED);
155 }
156 else
157 {
158 m_BannerHandler.SetBannerColor(Colors.COLOR_DAYZ_RED);
159 m_BannerHandler.SetBannerText(TEXT_UNOWNED);
160 }
161 }
162 }
163
164 protected void OnDLCChange()
165 {
166 UpdateOwnedStatus();
167 }
168
169 protected void SetPlatformSpecifics()
170 {
171 TextWidget desc = TextWidget.Cast(m_StoreButton.FindAnyWidget("dlc_openStore_label"));
172 #ifdef PLATFORM_PS4
173 m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_ps");
174 desc.SetText("#dlc_open_store_PS");
175 #endif
176 #ifdef PLATFORM_XBOX
177 m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_xbox");
178 desc.SetText("#dlc_open_store_Xbox");
179 #endif
180 #ifdef PLATFORM_PC
181 m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_xbox");
182 desc.SetText("#dlc_open_store");
183 #endif
184 }
185
186 //updates on language change etc.
187 void UpdateAllPromotionInfo()
188 {
189 UpdateDlcData();
190 UpdateOwnedStatus();
191 UpdateIconVisibility();
192 }
193
194 protected void UpdateDlcData()
195 {
196 m_TitleTextDlc.SetText(m_DlcInfo.HeaderText);
197 m_DescriptionTextDlc.SetText(m_DlcInfo.DescriptionText);
198 }
199
200 protected void UpdateIconVisibility()
201 {
202 #ifdef PLATFORM_CONSOLE
203 m_GamepadStoreImage.Show(!GetGame().GetInput().IsEnabledMouseAndKeyboard() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER);
204 #endif
205 }
206
207 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
208 {
209 UpdateIconVisibility();
210 }
211
212 ModInfo GetModInfo()
213 {
214 return m_ThisModInfo;
215 }
216
217 override bool OnMouseEnter(Widget w, int x, int y)
218 {
219 if (w == m_StoreButton)
220 {
221 m_Root.FindAnyWidget("dlc_openStore_panel").SetColor(ARGB(255, 0, 0, 0));
222 m_Root.FindAnyWidget("dlc_openStore_label").SetColor(ARGB(255, 255, 0, 0));
223 return true;
224 }
225
226 return false;
227 }
228
229 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
230 {
231 if (w == m_StoreButton)
232 {
233 m_Root.FindAnyWidget("dlc_openStore_panel").SetColor(ARGB(140, 0, 0, 0));
234 m_Root.FindAnyWidget("dlc_openStore_label").SetColor(ARGB(255, 255, 255, 255));
235 return true;
236 }
237
238 return false;
239 }
240}
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition inventory.c:175
proto native ContentDLC GetContentDLCService()
Return DLC service (service for entitlement keys for unlock content)
Definition colors.c:4
override Widget Init()
Definition dayzgame.c:127
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition dayzgame.c:151
proto native CGame GetGame()
Icon x
Icon y
EInputDeviceType
Definition input.c:3
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
void OnDLCChange(EDLCId dlcId)
Widget m_Root
Definition sizetochild.c:91