Dayz Explorer 1.28.160049
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;
20 protected ref array<ref CreditsElement> m_CreditsEntries = new array<ref CreditsElement>;
21
22 protected ImageWidget m_Logo;
23 protected ScrollWidget m_Scroller;
24 protected WrapSpacerWidget m_Content;
26 protected Widget m_InfoPanel;
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
40 GetScreenSize( x, y );
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
56 override void OnShow()
57 {
58 super.OnShow();
59
60 MissionMainMenu mainMenu = MissionMainMenu.Cast(g_Game.GetMission());
61
63 playbackData.m_Category = EDynamicMusicPlayerCategory.CREDITS;
64 playbackData.m_Forced = true;
65 playbackData.m_FadeOut = true;
66 mainMenu.GetDynamicMusicPlayer().SetCategory(playbackData);
67 }
68
69 override void OnHide()
70 {
71 super.OnHide();
72
73 MissionMainMenu mainMenu = MissionMainMenu.Cast(g_Game.GetMission());
74
76 playbackData.m_Category = EDynamicMusicPlayerCategory.MENU;
77 playbackData.m_Forced = true;
78 playbackData.m_FadeOut = true;
79 mainMenu.GetDynamicMusicPlayer().SetCategory(playbackData);
80 }
81
83 {
84 m_CreditsData = CreditsLoader.GetData();
85 for(int i = 1; i <= m_CreditsData.Departments.Count(); ++i)
86 {
87 CreditsDepartmentElement e = new CreditsDepartmentElement( i, m_Content, m_CreditsData.Departments.Get( i - 1 ) );
88 m_CreditsEntries.Insert(e);
89 }
90
91 m_Content.Update();
92 }
93
94 override void Update( float timeslice )
95 {
96 float new_menu_val;
97 if( m_LogoFadeInLevel != 1 )
98 {
99 new_menu_val = m_MenuFadeInLevel + m_MenuFadeInIncrement * timeslice;
100 if( new_menu_val < 1 )
101 m_MenuFadeInLevel = new_menu_val;
102 else
103 m_MenuFadeInLevel = 1;
104
105 if( m_MenuFadeInLevel > 0.5 )
106 {
107 float new_logo_val = m_LogoFadeInLevel + m_LogoFadeInIncrement * timeslice;
108 if( new_menu_val < 1 )
109 m_LogoFadeInLevel = new_logo_val;
110 else
111 m_LogoFadeInLevel = 1;
112 }
113
114 layoutRoot.SetAlpha( m_MenuFadeInLevel );
115 m_Logo.SetAlpha( m_LogoFadeInLevel );
116 m_InfoPanelText.SetAlpha( m_MenuFadeInLevel );
117 }
118 else if( m_ScrollLevel + m_ScrollSize <= m_Scroller.GetContentHeight() )
119 {
120 float new_scroll_val = m_ScrollLevel + m_ScrollIncrement * timeslice;
121 m_ScrollLevel = new_scroll_val;
122 m_Scroller.VScrollToPos( m_ScrollLevel );
123 }
124 else
125 {
126 new_menu_val = m_MenuFadeInLevel2 - m_MenuFadeInIncrement * timeslice;
127 if( new_menu_val > 0 )
128 m_MenuFadeInLevel2 = new_menu_val;
129 else
130 Close();
131
132 layoutRoot.SetAlpha( m_MenuFadeInLevel2 );
133 m_InfoPanelText.SetAlpha( m_MenuFadeInLevel2 );
134 }
135
136 m_CurrentTime += timeslice;
137
138 if( GetGame().GetInput().LocalRelease("UAUIBack") )
139 {
140 Close();
141 }
142 }
143
144 void UpdateInfoPanelText(int input_device_type)
145 {
146 if (GetGame().GetInput().IsEnabledMouseAndKeyboard() && input_device_type == EInputDeviceType.MOUSE_AND_KEYBOARD)
147 {
148 m_InfoPanelText.SetText("ESC " + "#menu_back");
149 }
150 else
151 {
152 m_InfoPanelText.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#menu_back", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
153 }
154 }
155}
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:167
static const float ICON_SCALE_TOOLBAR
Definition inpututils.c:15
override void OnShow()
Definition creditsmenu.c:56
float m_MenuFadeInLevel
Definition creditsmenu.c:8
override void Update(float timeslice)
Definition creditsmenu.c:94
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
static float LOGO_FADEIN_TIME
Definition creditsmenu.c:4
ref JsonDataCredits m_CreditsData
Definition creditsmenu.c:17
override void OnHide()
Definition creditsmenu.c:69
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:82
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
static float MENU_FADEIN_TIME
Definition creditsmenu.c:3
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3868
proto native CGame GetGame()
proto void GetScreenSize(out int x, out int y)
Icon x
Icon y
EInputDeviceType
Definition input.c:3
void Close()