Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
mainmenupromo.c
Go to the documentation of this file.
1 class 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_LIVONIA_EMERALD_GREEN);
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  #else
176  m_GamepadStoreImage = m_Root.FindAnyWidget("image_button_xbox");
177  desc.SetText("#dlc_open_store");
178  #endif
179  }
180 
181  //updates on language change etc.
182  protected void UpdateAllPromotionInfo()
183  {
184  UpdateDlcData();
185  UpdateOwnedStatus();
186  UpdateIconVisibility();
187  }
188 
189  protected void UpdateDlcData()
190  {
191  m_TitleTextDlc.SetText(m_DlcInfo.HeaderText);
192  m_DescriptionTextDlc.SetText(m_DlcInfo.DescriptionText);
193  }
194 
195  protected void UpdateIconVisibility()
196  {
197  #ifdef PLATFORM_CONSOLE
198  m_GamepadStoreImage.Show(!GetGame().GetInput().IsEnabledMouseAndKeyboard() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER);
199  #endif
200  }
201 
202  protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
203  {
204  UpdateIconVisibility();
205  }
206 
207  ModInfo GetModInfo()
208  {
209  return m_ThisModInfo;
210  }
211 }
GetGame
proto native CGame GetGame()
ModInfo
Definition: modinfo.c:1
y
Icon y
JsonDataDLCInfo
Definition: jsondatadlcinfo.c:6
OnInputDeviceChanged
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition: inventory.c:167
Colors
Definition: colors.c:3
EInputDeviceType
EInputDeviceType
Definition: input.c:2
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
TextWidget
Definition: enwidgets.c:219
OnDLCChange
void OnDLCChange(EDLCId dlcId)
Definition: serverbrowsertab.c:113
x
Icon x
VideoState
VideoState
Definition: enwidgets.c:516
Widget
Definition: enwidgets.c:189
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
path
string path
Definition: optionselectormultistate.c:135