File size: 3,288 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 |
enum ScreenWidthType
{
NARROW,
MEDIUM,
WIDE
}
class InventoryMenu extends UIScriptedMenu
{
ref Inventory m_Inventory;
private ref ContextMenu m_context_menu;
protected bool m_IsOpened;
protected bool m_OnlyFirstTime;
protected int m_LastDisplayLanguage;
protected static ScreenWidthType m_WidthType;
protected static int m_Width;
protected static int m_Height;
void InventoryMenu()
{
CheckWidth();
m_Inventory = new Inventory(null);
m_Inventory.Reset();
m_Inventory.UpdateInterval();
m_context_menu = new ContextMenu();
m_LastDisplayLanguage = g_Game.GetCurrentDisplayLanguageIdx();
}
override Widget Init()
{
m_Inventory.Init();
m_context_menu.Init(layoutRoot);
layoutRoot = m_Inventory.GetMainWidget();
return layoutRoot;
}
void CheckWidth()
{
GetScreenSize( m_Width, m_Height );
if( m_Height > 0 )
{
float ratio = m_Width / m_Height;
if( ratio > 1.75 )
m_WidthType = ScreenWidthType.WIDE;
else if( ratio > 1.5 )
m_WidthType = ScreenWidthType.MEDIUM;
else
m_WidthType = ScreenWidthType.NARROW;
}
}
static ScreenWidthType GetWidthType()
{
return m_WidthType;
}
static int GetWidth()
{
return m_Width;
}
static int GetHeight()
{
return m_Height;
}
static float GetHeightMultiplied( float value )
{
float height = m_Height;
return height / 1080 * value;
}
void RefreshQuickbar()
{
m_Inventory.RefreshQuickbar();
}
override ContextMenu GetContextMenu()
{
return m_context_menu;
}
void InitContainers(EntityAI target)
{
}
override void Update( float timeslice )
{
if( m_Inventory )
{
m_Inventory.Update(timeslice);
}
}
override void Refresh()
{
super.Refresh();
m_Inventory.UpdateConsoleToolbar();
}
override void OnShow()
{
super.OnShow();
m_IsOpened = true;
PPERequesterBank.GetRequester(PPERequesterBank.REQ_INVENTORYBLUR).Start();
VicinityItemManager.GetInstance().RefreshVicinityItems();
if(m_Inventory)
m_Inventory.OnShow();
SetFocus( layoutRoot );
MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
if( mission )
{
mission.MoveHudForInventory( true );
}
ItemManager.GetInstance().SetItemMicromanagmentMode( false );
ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
m_Inventory.Refresh();
}
override bool OnController( Widget w, int control, int value )
{
if( m_IsOpened )
return m_Inventory.Controller( w, control, value );
return false;
}
bool IsOpened()
{
return m_IsOpened;
}
override void OnHide()
{
super.OnHide();
m_context_menu.Hide();
m_IsOpened = false;
PPERequesterBank.GetRequester(PPERequesterBank.REQ_INVENTORYBLUR).Stop();
if(m_Inventory)
m_Inventory.OnHide();
MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
if( mission )
{
mission.MoveHudForInventory( false );
}
ItemManager.GetInstance().SetItemMicromanagmentMode( false );
ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
ItemManager.GetInstance().HideTooltip();
}
int GetLastDisplayLanguage()
{
return m_LastDisplayLanguage;
}
bool LanguageChanged()
{
return g_Game.GetCurrentDisplayLanguageIdx() != m_LastDisplayLanguage;
}
}
|