Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
inventorymenu.c
Go to the documentation of this file.
2 {
6 }
7 
8 class InventoryMenu extends UIScriptedMenu
9 {
11  private ref ContextMenu m_context_menu;
12  protected bool m_IsOpened;
13  protected bool m_OnlyFirstTime;
14  protected int m_LastDisplayLanguage;
15 
16  protected static ScreenWidthType m_WidthType;
17  protected static int m_Width;
18  protected static int m_Height;
19 
21  {
22  CheckWidth();
23  m_Inventory = new Inventory(null);
24  m_Inventory.Reset();
25  m_Inventory.UpdateInterval();
26  m_context_menu = new ContextMenu();
27  m_LastDisplayLanguage = g_Game.GetCurrentDisplayLanguageIdx();
28  }
29 
30  override Widget Init()
31  {
32  m_Inventory.Init();
33  m_context_menu.Init(layoutRoot);
34  layoutRoot = m_Inventory.GetMainWidget();
35  return layoutRoot;
36  }
37 
38  void CheckWidth()
39  {
40  GetScreenSize( m_Width, m_Height );
41 
42  if( m_Height > 0 )
43  {
44  float ratio = m_Width / m_Height;
45  if( ratio > 1.75 )
46  m_WidthType = ScreenWidthType.WIDE;
47  else if( ratio > 1.5 )
48  m_WidthType = ScreenWidthType.MEDIUM;
49  else
50  m_WidthType = ScreenWidthType.NARROW;
51  }
52  }
53 
54  static ScreenWidthType GetWidthType()
55  {
56  return m_WidthType;
57  }
58 
59  static int GetWidth()
60  {
61  return m_Width;
62  }
63 
64  static int GetHeight()
65  {
66  return m_Height;
67  }
68 
69  static float GetHeightMultiplied( float value )
70  {
71  float height = m_Height;
72  return height / 1080 * value;
73  }
74 
76  {
77  m_Inventory.RefreshQuickbar();
78  }
79 
80  override ContextMenu GetContextMenu()
81  {
82  return m_context_menu;
83  }
84 
85  void InitContainers(EntityAI target)
86  {
87 
88  }
89 
90  override void Update( float timeslice )
91  {
92  if( m_Inventory )
93  {
94  m_Inventory.Update(timeslice);
95  }
96  }
97 
98  override void Refresh()
99  {
100  super.Refresh();
101 
102  m_Inventory.UpdateConsoleToolbar();
103  }
104 
105  override void OnShow()
106  {
107  super.OnShow();
108  m_IsOpened = true;
109  PPERequesterBank.GetRequester(PPERequesterBank.REQ_INVENTORYBLUR).Start();
110  VicinityItemManager.GetInstance().RefreshVicinityItems();
111 
112  if(m_Inventory)
113  m_Inventory.OnShow();
114 
115  SetFocus( layoutRoot );
116 
117  MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
118  if( mission )
119  {
120  mission.MoveHudForInventory( true );
121  }
122 
123  ItemManager.GetInstance().SetItemMicromanagmentMode( false );
124  ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
125 
126  m_Inventory.Refresh();
127  }
128 
129  override bool OnController( Widget w, int control, int value )
130  {
131  if( m_IsOpened )
132  return m_Inventory.Controller( w, control, value );
133  return false;
134  }
135 
136  bool IsOpened()
137  {
138  return m_IsOpened;
139  }
140 
141  override void OnHide()
142  {
143  super.OnHide();
144  m_context_menu.Hide();
145  m_IsOpened = false;
146  PPERequesterBank.GetRequester(PPERequesterBank.REQ_INVENTORYBLUR).Stop();
147  if(m_Inventory)
148  m_Inventory.OnHide();
149  MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
150  if( mission )
151  {
152  mission.MoveHudForInventory( false );
153  }
154 
155  ItemManager.GetInstance().SetItemMicromanagmentMode( false );
156  ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
157  ItemManager.GetInstance().HideTooltip();
158  }
159 
161  {
162  return m_LastDisplayLanguage;
163  }
164 
166  {
167  return g_Game.GetCurrentDisplayLanguageIdx() != m_LastDisplayLanguage;
168  }
169 }
m_LastDisplayLanguage
protected int m_LastDisplayLanguage
Definition: inventorymenu.c:14
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
RefreshQuickbar
void RefreshQuickbar()
Definition: inventorymenu.c:75
mission
Mission mission
Definition: displaystatus.c:28
OnController
override bool OnController(Widget w, int control, int value)
Definition: inventorymenu.c:129
CheckWidth
void CheckWidth()
Definition: inventorymenu.c:38
OnShow
override void OnShow()
Definition: inventorymenu.c:105
WIDE
@ WIDE
Definition: inventorymenu.c:5
GetScreenSize
proto void GetScreenSize(out int x, out int y)
OnHide
override void OnHide()
Definition: inventorymenu.c:141
Update
override void Update(float timeslice)
Definition: inventorymenu.c:90
Init
override Widget Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: inventorymenu.c:30
GetContextMenu
override ContextMenu GetContextMenu()
Definition: inventorymenu.c:80
GetHeight
float GetHeight()
Definition: dayzplayerimplementfalldamage.c:83
m_OnlyFirstTime
protected bool m_OnlyFirstTime
Definition: inventorymenu.c:13
MEDIUM
@ MEDIUM
Definition: inventorymenu.c:4
VicinityItemManager
Definition: vicinityitemmanager.c:1
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
m_IsOpened
protected bool m_IsOpened
Definition: inventorymenu.c:12
GetLastDisplayLanguage
int GetLastDisplayLanguage()
Definition: inventorymenu.c:160
NARROW
@ NARROW
Definition: inventorymenu.c:3
ItemManager
Definition: itemmanager.c:1
ScreenWidthType
ScreenWidthType
Definition: inventorymenu.c:1
InitContainers
void InitContainers(EntityAI target)
Definition: inventorymenu.c:85
SetFocus
proto native void SetFocus(Widget w)
InventoryMenu
void InventoryMenu()
Definition: inventorymenu.c:20
m_context_menu
private ref ContextMenu m_context_menu
Definition: inventorymenu.c:11
Refresh
override void Refresh()
Definition: inventorymenu.c:98
Inventory
void Inventory(LayoutHolder parent)
Definition: inventory.c:76
Widget
Definition: enwidgets.c:189
EntityAI
Definition: building.c:5
IsOpened
bool IsOpened()
Definition: inventorymenu.c:136
LanguageChanged
bool LanguageChanged()
Definition: inventorymenu.c:165
m_Inventory
enum ScreenWidthType m_Inventory