Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
creditsmenu.c
Go to the documentation of this file.
1 class 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 
17  protected ref JsonDataCredits m_CreditsData;
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;
25  protected RichTextWidget m_InfoPanelText;
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  void LoadDataAsync()
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  {
113  Close();
114  }
115  }
116 
117  void UpdateInfoPanelText(int input_device_type)
118  {
119  if (GetGame().GetInput().IsEnabledMouseAndKeyboard() && input_device_type == EInputDeviceType.MOUSE_AND_KEYBOARD)
120  {
121  m_InfoPanelText.SetText("ESC " + "#menu_back");
122  }
123  else
124  {
125  m_InfoPanelText.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#menu_back", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
126  }
127  }
128 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
InputUtils
Definition: inpututils.c:1
GetScreenSize
proto void GetScreenSize(out int x, out int y)
Close
void Close()
y
Icon y
EInputDeviceType
EInputDeviceType
Definition: input.c:2
RichTextWidget
Definition: gameplay.c:315
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
JsonDataCredits
Definition: jsondatacredits.c:1
LoadDataAsync
void LoadDataAsync(array< string > section_data)
Definition: creditsdepartmentelement.c:65
array< ref CreditsElement >
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
x
Icon x
Widget
Definition: enwidgets.c:189
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
CreditsLoader
Definition: creditsloader.c:1