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