DayZ 1.24
Loading...
Searching...
No Matches
CreditsMenu.c
Go to the documentation of this file.
1class CreditsMenu extends UIScriptedMenu
2{
3 protected static float MENU_FADEIN_TIME = 2.0; //fade starts as soon as menu opens
4 protected static float LOGO_FADEIN_TIME = 1.0; //fade starts halfway through menu fade in
5 protected static float CREDIT_SCROLL_SPEED = 200.0; //pixels per second (relative to 1080p res)
6
7 protected float m_MenuFadeInIncrement;
8 protected float m_MenuFadeInLevel;
9 protected float m_MenuFadeInLevel2 = 1;
10 protected float m_LogoFadeInIncrement;
11 protected float m_LogoFadeInLevel;
12 protected float m_ScrollIncrement;
13 protected float m_ScrollLevel;
14 protected float m_ScrollMax;
15 protected float m_ScrollSize;
16
18
19 protected float m_CurrentTime = 0.0;
21
27
28 override Widget Init()
29 {
30 float x_f;
31 int x, y;
32
33 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/credits/credits_menu.layout", null);
34 m_Logo = ImageWidget.Cast(layoutRoot.FindAnyWidget("Logo"));
35 m_Scroller = ScrollWidget.Cast(layoutRoot.FindAnyWidget("CreditsPanel"));
36 m_Content = WrapSpacerWidget.Cast(layoutRoot.FindAnyWidget("CreditsContent"));
37 m_InfoPanelText = RichTextWidget.Cast(layoutRoot.FindAnyWidget("InfoPanelText"));
38 m_InfoPanel = layoutRoot.FindAnyWidget("InfoPanel");
39
41
42 m_MenuFadeInIncrement = 1 / MENU_FADEIN_TIME;
43 m_LogoFadeInIncrement = 1 / LOGO_FADEIN_TIME;
44 m_ScrollIncrement = CREDIT_SCROLL_SPEED * (y / 1080);
45
46 m_Scroller.VScrollToPos01(0);
47 m_Scroller.GetScreenSize(x_f, m_ScrollSize);
48
49 GetGame().GameScript.Call(this, "LoadDataAsync", null);
50
51 UpdateInfoPanelText(GetGame().GetInput().GetCurrentInputDevice());
52
53 return layoutRoot;
54 }
55
57 {
58 m_CreditsData = CreditsLoader.GetData();
59 for (int i = 1; i <= m_CreditsData.Departments.Count(); i++)
60 {
61 ref CreditsDepartmentElement e = new CreditsDepartmentElement(i, m_Content, m_CreditsData.Departments.Get(i - 1));
62 m_CreditsEntries.Insert(e);
63 }
64 m_Content.Update();
65 }
66
67 override void Update(float timeslice)
68 {
69 float new_menu_val;
70 if (m_LogoFadeInLevel != 1)
71 {
72 new_menu_val = m_MenuFadeInLevel + m_MenuFadeInIncrement * timeslice;
73 if (new_menu_val < 1)
74 m_MenuFadeInLevel = new_menu_val;
75 else
76 m_MenuFadeInLevel = 1;
77
78 if (m_MenuFadeInLevel > 0.5)
79 {
80 float new_logo_val = m_LogoFadeInLevel + m_LogoFadeInIncrement * timeslice;
81 if (new_menu_val < 1)
82 m_LogoFadeInLevel = new_logo_val;
83 else
84 m_LogoFadeInLevel = 1;
85 }
86
87 layoutRoot.SetAlpha(m_MenuFadeInLevel);
88 m_Logo.SetAlpha(m_LogoFadeInLevel);
89 m_InfoPanelText.SetAlpha(m_MenuFadeInLevel);
90 }
91 else if (m_ScrollLevel + m_ScrollSize <= m_Scroller.GetContentHeight())
92 {
93 float new_scroll_val = m_ScrollLevel + m_ScrollIncrement * timeslice;
94 m_ScrollLevel = new_scroll_val;
95 m_Scroller.VScrollToPos(m_ScrollLevel);
96 }
97 else
98 {
99 new_menu_val = m_MenuFadeInLevel2 - m_MenuFadeInIncrement * timeslice;
100 if (new_menu_val > 0)
101 m_MenuFadeInLevel2 = new_menu_val;
102 else
103 Close();
104
105 layoutRoot.SetAlpha(m_MenuFadeInLevel2);
106 m_InfoPanelText.SetAlpha(m_MenuFadeInLevel2);
107 }
108
109 m_CurrentTime += timeslice;
110
111 if (GetGame().GetInput().LocalRelease("UAUIBack"))
112 Close();
113 }
114
116 {
117 if (GetGame().GetInput().IsEnabledMouseAndKeyboard() && input_device_type == EInputDeviceType.MOUSE_AND_KEYBOARD)
118 m_InfoPanelText.SetText("ESC " + "#menu_back");
119 else
121 }
122}
ActionInput GetInput()
Definition ActionBase.c:989
Icon x
Icon y
void Close()
static JsonDataCredits GetData()
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition InputUtils.c:151
static const float ICON_SCALE_TOOLBAR
Definition InputUtils.c:15
float m_MenuFadeInLevel
Definition CreditsMenu.c:8
override void Update(float timeslice)
Definition CreditsMenu.c:67
float m_ScrollIncrement
Definition CreditsMenu.c:12
ImageWidget m_Logo
Definition CreditsMenu.c:22
float m_LogoFadeInLevel
Definition CreditsMenu.c:11
RichTextWidget m_InfoPanelText
Definition CreditsMenu.c:25
float m_LogoFadeInIncrement
Definition CreditsMenu.c:10
ref JsonDataCredits m_CreditsData
Definition CreditsMenu.c:17
ScrollWidget m_Scroller
Definition CreditsMenu.c:23
Widget m_InfoPanel
Definition CreditsMenu.c:26
float m_ScrollLevel
Definition CreditsMenu.c:13
void LoadDataAsync()
Definition CreditsMenu.c:56
void UpdateInfoPanelText(int input_device_type)
float m_MenuFadeInIncrement
Definition CreditsMenu.c:7
override Widget Init()
Definition CreditsMenu.c:28
WrapSpacerWidget m_Content
Definition CreditsMenu.c:24
proto native CGame GetGame()
proto void GetScreenSize(out int x, out int y)
EInputDeviceType
Definition input.c:3