DayZ 1.24
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;
20
21 protected ref BannerHandlerBase m_BannerHandler;
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 GetGame().GetContentDLCService().m_OnChange.Insert(OnDLCChange);
33 if (GetGame().GetMission())
34 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
35#endif
36 }
37
39 {
40#ifdef PLATFORM_CONSOLE
41 if (GetGame().GetContentDLCService())
42 GetGame().GetContentDLCService().m_OnChange.Remove(OnDLCChange);
43#endif
44 }
45
46 void Init()
47 {
48 m_Background = m_Root;
49 m_StoreButton = m_Root.FindAnyWidget("dlc_openStore");
51 m_VideoWidget = VideoWidget.Cast(m_Root.FindAnyWidget("dlc_Video"));
52 m_VideoWidget.Show(false);
53 m_DlcPromotionImage = ImageWidget.Cast(m_Root.FindAnyWidget("dlc_ImageMain"));
54 m_DlcPromotionImage.Show(true);
55 m_BannerFrame = m_Root.FindAnyWidget("dlc_BannerFrame");//dlc_BannerFrame //dlc_BannerFrameVideo
56 m_BannerHandler = new BannerHandlerBase(m_BannerFrame);
57 m_TitleTextDlc = TextWidget.Cast(m_Root.FindAnyWidget("dlc_title"));
58 m_DescriptionTextDlc = MultilineTextWidget.Cast(m_Root.FindAnyWidget("dlc_Description"));
59 m_DescriptionTextDlc.SetLineBreakingOverride(LinebreakOverrideMode.LINEBREAK_WESTERN);
60 m_ColorBackgroundOriginal = m_Background.GetColor();
61
63 //StartVideo();
64 }
65
67 {
68 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/dlc_panels/DLC_Panel.layout", parent);
69 }
70
71 void ShowInfoPanel(bool show)
72 {
73 m_Root.Show(show);
75 }
76
78 {
79 return m_Root.IsVisible();
80 }
81
83 {
85 return;
86
87 /*if (IsInfoPanelVisible())
88 StartVideo();
89 else
90 PauseVideo();*/
91 }
92
93 //works on button only
94 override bool OnClick(Widget w, int x, int y, int button)
95 {
96 m_ThisModInfo.GoToStore();
97 return super.OnClick(w, x, y, button);
98 }
99
102 {
103 if (m_VideoWidget.GetState() != VideoState.NONE)
104 return true;
105
106 string path = "video\\" + m_DlcInfo.VideoFileName;
107 if (m_DlcInfo.VideoFileName != "")
108 return m_VideoWidget.Load(path, true);
109
110 return false;
111 }
112
114 {
115 if (LoadVideoFile())
116 m_VideoWidget.Play();
117 }
118
120 {
121 m_VideoWidget.Stop();
122 }
123
125 {
126 m_VideoWidget.Pause();
127 }
128
130 {
131 m_VideoWidget.Stop();
132 m_VideoWidget.Unload();
133 }
134
135 protected void ColorFocussed(Widget w, int x, int y)
136 {
137 m_Background.SetColor(ARGB(255, 54, 16, 16));
138 }
139
140 protected void ColorUnfocussed(Widget w, Widget enterW, int x, int y)
141 {
142 m_Background.SetColor(m_ColorBackgroundOriginal);
143 }
144
145 protected void UpdateOwnedStatus()
146 {
147 if (m_ThisModInfo)
148 {
149 if (m_ThisModInfo.GetIsOwned())
150 {
151 m_BannerHandler.SetBannerColor(Colors.COLOR_LIVONIA_EMERALD_GREEN);
152 m_BannerHandler.SetBannerText(TEXT_OWNED);
153 }
154 else
155 {
156 m_BannerHandler.SetBannerColor(Colors.COLOR_DAYZ_RED);
157 m_BannerHandler.SetBannerText(TEXT_UNOWNED);
158 }
159 }
160 }
161
162 protected void OnDLCChange()
163 {
165 }
166
167 protected void SetPlatformSpecifics()
168 {
169 TextWidget desc = TextWidget.Cast(m_StoreButton.FindAnyWidget("dlc_openStore_label"));
170#ifdef PLATFORM_PS4
171 m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_ps");
172 desc.SetText("#dlc_open_store_PS");
173#else
174 m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_xbox");
175 desc.SetText("#dlc_open_store");
176#endif
177 }
178
179 //updates on language change etc.
180 protected void UpdateAllPromotionInfo()
181 {
185 }
186
187 protected void UpdateDlcData()
188 {
189 m_TitleTextDlc.SetText(m_DlcInfo.HeaderText);
190 m_DescriptionTextDlc.SetText(m_DlcInfo.DescriptionText);
191 }
192
193 protected void UpdateIconVisibility()
194 {
195#ifdef PLATFORM_CONSOLE
196 m_GamepadStoreImage.Show(!GetGame().GetInput().IsEnabledMouseAndKeyboard() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER);
197#endif
198 }
199
204
206 {
207 return m_ThisModInfo;
208 }
209}
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition Inventory.c:167
ActionInput GetInput()
Definition ActionBase.c:989
Icon x
Icon y
void OnDLCChange(EDLCId dlcId)
Widget m_Root
Definition SizeToChild.c:85
Definition Colors.c:4
const int COLOR_LIVONIA_EMERALD_GREEN
Definition Colors.c:47
const int COLOR_DAYZ_RED
Definition Colors.c:40
map: item x vector(index, width, height)
Definition EnWidgets.c:651
void ShowInfoPanel(bool show)
void MainMenuDlcHandlerBase(ModInfo info, Widget parent, JsonDataDLCInfo DlcInfo)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
void BannerHandlerBase(Widget parent)
bool LoadVideoFile()
returns 'true' when video is loaded
MultilineTextWidget m_DescriptionTextDlc
override bool OnClick(Widget w, int x, int y, int button)
ref BannerHandlerBase m_BannerHandler
void CreateRootWidget(Widget parent)
void ColorFocussed(Widget w, int x, int y)
ref JsonDataDLCInfo m_DlcInfo
void ColorUnfocussed(Widget w, Widget enterW, int x, int y)
proto native CGame GetGame()
VideoState
Definition EnWidgets.c:517
EInputDeviceType
Definition input.c:3
int ARGB(int a, int r, int g, int b)
Definition proto.c:322