Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
8
9 protected Widget m_Root;
14 protected ImageWidget m_DlcPromotionImage;
16 protected MultilineTextWidget m_DescriptionTextDlc;
17 protected VideoWidget m_VideoWidget;
18 protected ref ModInfo m_ThisModInfo;
20
22
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 g_Game.GetContentDLCService().m_OnChange.Insert(OnDLCChange);
33 if (g_Game.GetMission())
34 {
35 g_Game.GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
36 }
37 #endif
38 }
39
41 {
42 #ifdef PLATFORM_CONSOLE
43 if (g_Game.GetContentDLCService())
44 g_Game.GetContentDLCService().m_OnChange.Remove(OnDLCChange);
45 #endif
46 }
47
48 void Init()
49 {
51 m_StoreButton = m_Root.FindAnyWidget("dlc_openStore");
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
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);
63
65 //StartVideo();
66 }
67
69 {
70 m_Root = g_Game.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);
77 }
78
80 {
81 return m_Root.IsVisible();
82 }
83
85 {
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
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
116 {
117 if (LoadVideoFile())
118 m_VideoWidget.Play();
119 }
120
122 {
123 m_VideoWidget.Stop();
124 }
125
127 {
128 m_VideoWidget.Pause();
129 }
130
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 {
145 }
146
147 protected void UpdateOwnedStatus()
148 {
149 if (m_ThisModInfo)
150 {
151 if (m_ThisModInfo.GetIsOwned())
152 {
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 {
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.
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(!g_Game.GetInput().IsEnabledMouseAndKeyboard() || g_Game.GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER);
204 #endif
205 }
206
207 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
208 {
210 }
211
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}
Definition colors.c:4
const int COLOR_DAYZ_RED
Definition colors.c:51
const int COLOR_FROSTLINE_MOUNTAIN_BLUE
Definition colors.c:65
map: item x vector(index, width, height)
Definition enwidgets.c:657
void MainMenuDlcHandlerBase(ModInfo info, Widget parent, JsonDataDLCInfo DlcInfo)
MultilineTextWidget m_DescriptionTextDlc
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
ref BannerHandlerBase m_BannerHandler
bool LoadVideoFile()
returns 'true' when video is loaded
ref JsonDataDLCInfo m_DlcInfo
void ColorFocussed(Widget w, int x, int y)
void CreateRootWidget(Widget parent)
void ShowInfoPanel(bool show)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
void BannerHandlerBase(Widget parent)
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnClick(Widget w, int x, int y, int button)
void ColorUnfocussed(Widget w, Widget enterW, int x, int y)
DayZGame g_Game
Definition dayzgame.c:3942
VideoState
Definition enwidgets.c:517
Icon x
Icon y
EInputDeviceType
Definition input.c:3
int ARGB(int a, int r, int g, int b)
Definition proto.c:322