public static MyGuiScreenInventory OpenInventory(MyGuiScreenInventoryType inventoryScreenType, MyEntity otherSide = null, MySmallShipInteractionActionEnum? action = null) { MyMwcLog.WriteLine("OpenInventory()"); // return harvester when opening inventory, harvester can update inventory, which would not propagete to inventory screen and closing inventory would override those changes var harvester = MySession.PlayerShip.Weapons.GetMountedHarvestingDevice(); if (harvester != null && harvester.CurrentState != MyHarvestingDeviceEnum.InsideShip) harvester.Shot(null); StringBuilder otherSideInventoryName = null; MyInventory otherSideInventory = null; List<MySmallShipBuilderWithName> shipsObjectBuilders = null; bool closeOtherSideInventory = false; m_inventoryScreenType = inventoryScreenType; m_shipsInventoryOwner = MySession.Static; m_player = MySession.Static.Player; m_detectedEntity = otherSide; m_detectedAction = action; shipsObjectBuilders = new List<MySmallShipBuilderWithName>(); shipsObjectBuilders.Add(new MySmallShipBuilderWithName(MySession.PlayerShip.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Player)); switch(m_inventoryScreenType) { case MyGuiScreenInventoryType.GodEditor: LoadGodEditorInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); closeOtherSideInventory = true; break; case MyGuiScreenInventoryType.InGameEditor: LoadIngameEditorInventory(ref otherSideInventory, ref otherSideInventoryName); break; case MyGuiScreenInventoryType.Game: LoadGameInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); break; } var currentShipBuilder = shipsObjectBuilders[0]; shipsObjectBuilders.Sort((x, y) => ((int)x.Builder.ShipType).CompareTo((int)y.Builder.ShipType)); m_curentIndex = shipsObjectBuilders.IndexOf(currentShipBuilder); MyMwcObjectBuilder_Inventory otherSideInventoryBuilder = otherSideInventory != null ? otherSideInventory.GetObjectBuilder(true) : null; if (closeOtherSideInventory) { Debug.Assert(otherSideInventory != null); otherSideInventory.Close(); } m_currentInventoryScreen = new MyGuiScreenInventory(shipsObjectBuilders, m_curentIndex, m_player.Money, m_tradeForMoney, otherSideInventoryBuilder, otherSideInventoryName, m_inventoryScreenType); m_currentInventoryScreen.OnSave += Save; m_currentInventoryScreen.Closed += OnInventoryScreenClosed; MyGuiScreenGamePlay.Static.HideSelectAmmo(); return m_currentInventoryScreen; }
public MyGuiScreenInventory(List<MySmallShipBuilderWithName> smallShipsBuilders, int currentShipBuilderIndex, float money, bool tradeForMoney, MyMwcObjectBuilder_Inventory otherSidesInventoryBuilder, StringBuilder otherSideInventoryName, MyGuiScreenInventoryType inventoryScreenType, bool resetWasAnythingTrasferedAfterComboboxChanged = false) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(1.0f, 1.0f), true, MyGuiManager.GetInventoryScreenBackgroundTexture()) { ScreenTimeout = TimeSpan.MaxValue; m_isInventoryLocked = true; m_resetWasAnythingTrasferedAfterComboboxChanged = resetWasAnythingTrasferedAfterComboboxChanged; m_isTransferingInProgress = false; m_wasAnythingTrasfered = false; m_smallShipsBuilders = smallShipsBuilders; m_smallShipsInventoryItemIDs = new List<MySmallShipInventoryItemIDs>(smallShipsBuilders.Count); m_currentShipBuilderIndex = currentShipBuilderIndex; m_otherSideInventoryBuilder = otherSidesInventoryBuilder; if (m_otherSideInventoryBuilder != null) { m_otherSideInventoryItemIDs = new List<int>(); } m_shipInventoryHideList = new List<int>(); m_otherSideInventoryHideList = new List<int>(); m_tradeForMoney = tradeForMoney; m_inventoryScreenType = inventoryScreenType; m_itemsRepository = new MyInventoryItemsRepository(); m_removedInventoryItemIDs = new List<int>(); LoadInventoryItemsFromObjectBuilders(); if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor) { AddCaption(MyTextsWrapperEnum.ShipCustomizationCaption, new Vector2(0, 0.005f)); } else { AddCaption(MyTextsWrapperEnum.ShipInventoryCaption, new Vector2(0, 0.005f)); } m_enableBackgroundFade = false; m_backgroundFadeColor = Vector4.Zero; OnEnterCallback += OnOkClickDelegate; m_shipTexture = GetShipTexture(); m_shipPanel = new MyGuiControlPanel(this, new Vector2(0.005f, -0.2347f), new Vector2(480 / 1600f, 367 / 1200f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, m_shipTexture, null, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_shipPanel); InitControls(otherSideInventoryName); FillOtherSideInventoryListbox(); FillShipCustomizationListboxes(m_currentShipBuilderIndex); FillShipsCombobox(); SwitchToShip(m_currentShipBuilderIndex); SetMoney(money); if (m_tradeForMoney) { UpdateOtherSideInventoryListboxForTrading(); } MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlOpen); }
public static MyGuiScreenInventory OpenInventory(MyGuiScreenInventoryType inventoryScreenType, MyEntity otherSide = null, MySmallShipInteractionActionEnum?action = null) { MyMwcLog.WriteLine("OpenInventory()"); // return harvester when opening inventory, harvester can update inventory, which would not propagete to inventory screen and closing inventory would override those changes var harvester = MySession.PlayerShip.Weapons.GetMountedHarvestingDevice(); if (harvester != null && harvester.CurrentState != MyHarvestingDeviceEnum.InsideShip) { harvester.Shot(null); } StringBuilder otherSideInventoryName = null; MyInventory otherSideInventory = null; List <MySmallShipBuilderWithName> shipsObjectBuilders = null; bool closeOtherSideInventory = false; m_inventoryScreenType = inventoryScreenType; m_shipsInventoryOwner = MySession.Static; m_player = MySession.Static.Player; m_detectedEntity = otherSide; m_detectedAction = action; shipsObjectBuilders = new List <MySmallShipBuilderWithName>(); shipsObjectBuilders.Add(new MySmallShipBuilderWithName(MySession.PlayerShip.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Player)); switch (m_inventoryScreenType) { case MyGuiScreenInventoryType.GodEditor: LoadGodEditorInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); closeOtherSideInventory = true; break; case MyGuiScreenInventoryType.InGameEditor: LoadIngameEditorInventory(ref otherSideInventory, ref otherSideInventoryName); break; case MyGuiScreenInventoryType.Game: LoadGameInventory(ref otherSideInventory, ref otherSideInventoryName, ref shipsObjectBuilders); break; } var currentShipBuilder = shipsObjectBuilders[0]; shipsObjectBuilders.Sort((x, y) => ((int)x.Builder.ShipType).CompareTo((int)y.Builder.ShipType)); m_curentIndex = shipsObjectBuilders.IndexOf(currentShipBuilder); MyMwcObjectBuilder_Inventory otherSideInventoryBuilder = otherSideInventory != null?otherSideInventory.GetObjectBuilder(true) : null; if (closeOtherSideInventory) { Debug.Assert(otherSideInventory != null); otherSideInventory.Close(); } m_currentInventoryScreen = new MyGuiScreenInventory(shipsObjectBuilders, m_curentIndex, m_player.Money, m_tradeForMoney, otherSideInventoryBuilder, otherSideInventoryName, m_inventoryScreenType); m_currentInventoryScreen.OnSave += Save; m_currentInventoryScreen.Closed += OnInventoryScreenClosed; MyGuiScreenGamePlay.Static.HideSelectAmmo(); return(m_currentInventoryScreen); }
private void OpenInventoryMultiplayer(MyGuiScreenInventoryType inventoryType) { var tradeEntity = MySession.PlayerShip.TradeDetector.GetNearestEntity(); if (tradeEntity == null) { var inventoryScreen = MyGuiScreenInventoryManagerForGame.OpenInventory(inventoryType); MyGuiManager.AddScreen(inventoryScreen); } else { var tradeEntityCriterias = (MySmallShipInteractionActionEnum)MySession.PlayerShip.TradeDetector.GetNearestEntityCriterias(); Debug.Assert(tradeEntity.EntityId != null, "tradeEntity.EntityId != null"); var entityID = tradeEntity.EntityId.Value; MyMultiplayerGameplay.Static.LockReponse = (e, success) => { MyMultiplayerGameplay.Static.LockReponse = null; if (tradeEntity != e) { Debug.Fail("Something went wrong, locked different entity"); MyMultiplayerGameplay.Static.Lock(e, false); return; } if (success) { var inventoryScreen = MyGuiScreenInventoryManagerForGame.OpenInventory(inventoryType, tradeEntity, tradeEntityCriterias); //inventoryScreen.ScreenTimeout = TimeSpan.FromSeconds(25); inventoryScreen.Closed += (s) => MyMultiplayerGameplay.Static.Lock(entityID, false); MyGuiManager.AddScreen(inventoryScreen); } }; MyMultiplayerGameplay.Static.Lock(tradeEntity, true); } }