Beispiel #1
0
        public static bool DrawStorageGUI()
        {
            Player        player        = Main.player[Main.myPlayer];
            StoragePlayer modPlayer     = player.GetModPlayer <StoragePlayer>();
            Point16       storageAccess = modPlayer.ViewingStorage();

            if (!Main.playerInventory || storageAccess.X < 0 || storageAccess.Y < 0)
            {
                return(true);
            }
            ModTile modTile = TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type);

            if (modTile == null || !(modTile is StorageAccess))
            {
                return(true);
            }
            TEStorageHeart heart = ((StorageAccess)modTile).GetHeart(storageAccess.X, storageAccess.Y);

            if (heart == null)
            {
                return(true);
            }
            if (modTile is CraftingAccess)
            {
                CraftingGUI.Draw(heart);
            }
            else
            {
                StorageGUI.Draw(heart);
            }
            return(true);
        }
Beispiel #2
0
        public static void RefreshItems()
        {
            if (StoragePlayer.IsStorageCrafting())
            {
                CraftingGUI.RefreshItems();
                return;
            }
            items.Clear();
            didMatCheck.Clear();
            TEStorageHeart heart = GetHeart();

            if (heart == null)
            {
                return;
            }
            InitLangStuff();
            InitSortButtons();
            InitFilterButtons();
            SortMode   sortMode   = (SortMode)sortButtons.Choice;
            FilterMode filterMode = (FilterMode)filterButtons.Choice;

            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text));
            for (int k = 0; k < items.Count; k++)
            {
                didMatCheck.Add(false);
            }
        }
Beispiel #3
0
        public override void Unload()
        {
            StorageUI  = null;
            CraftingUI = null;

            Instance = null;
        }
Beispiel #4
0
 public override void Unload()
 {
     Instance     = null;
     bluemagicMod = null;
     legendMod    = null;
     StorageGUI.Unload();
     CraftingGUI.Unload();
 }
Beispiel #5
0
 public override void PostUpdateInput()
 {
     if (!Main.instance.IsActive)
     {
         return;
     }
     StorageGUI.Update(null);
     CraftingGUI.Update(null);
 }
Beispiel #6
0
        public override void Load()
        {
            Instance = this;

            if (!Main.dedServ)
            {
                UI = new UserInterface();

                StorageUI  = new StorageGUI();
                CraftingUI = new CraftingGUI();
            }
        }
Beispiel #7
0
        public static void ReceiveCraftRequest(BinaryReader reader, int sender)
        {
            int ent   = reader.ReadInt32();
            int count = reader.ReadInt32();

            if (Main.netMode != 2)
            {
                //Still need to read the data for exceptions to not be thrown
                for (int i = 0; i < count; i++)
                {
                    ItemIO.Receive(reader, true);
                }

                ItemIO.Receive(reader, true);
                return;
            }
            if (!TileEntity.ByID.ContainsKey(ent) || !(TileEntity.ByID[ent] is TEStorageHeart))
            {
                return;
            }
            TEStorageHeart heart      = (TEStorageHeart)TileEntity.ByID[ent];
            List <Item>    toWithdraw = new List <Item>();

            for (int k = 0; k < count; k++)
            {
                toWithdraw.Add(ItemIO.Receive(reader, true));
            }
            Item        result = ItemIO.Receive(reader, true);
            List <Item> items  = CraftingGUI.DoCraft(heart, toWithdraw, result);

            if (items.Count > 0)
            {
                ModPacket packet = MagicStorage.Instance.GetPacket();
                packet.Write((byte)MessageType.CraftResult);
                packet.Write(items.Count);
                foreach (Item item in items)
                {
                    ItemIO.Send(item, packet, true);
                }
                packet.Send(sender);
            }
            SendRefreshNetworkItems(ent);
        }
Beispiel #8
0
        public static void RefreshItems()
        {
            if (StoragePlayer.IsStorageCrafting())
            {
                CraftingGUI.RefreshItems();
                return;
            }
            items.Clear();
            didMatCheck.Clear();
            TEStorageHeart heart = GetHeart();

            if (heart == null)
            {
                return;
            }
            InitLangStuff();
            InitSortButtons();
            InitFilterButtons();
            InitSubFilterButtons();
            SortMode sortMode;

            switch (sortButtons.Choice)
            {
            case 0:
                sortMode = SortMode.Default;
                break;

            case 1:
                sortMode = SortMode.Id;
                break;

            case 2:
                sortMode = SortMode.Name;
                break;

            case 3:
                sortMode = SortMode.Quantity;
                break;

            default:
                sortMode = SortMode.Default;
                break;
            }
            switch (filterButtons.Choice)
            {
            case 0:
                filterMode = FilterMode.All;
                break;

            case 1:
                filterMode = FilterMode.Weapons;
                break;

            case 2:
                filterMode = FilterMode.Tools;
                break;

            case 3:
                filterMode = FilterMode.Equipment;
                break;

            case 4:
                filterMode = FilterMode.Potions;
                break;

            case 5:
                filterMode = FilterMode.Placeables;
                break;

            case 6:
                filterMode = FilterMode.Misc;
                break;

            default:
                filterMode = FilterMode.All;
                break;
            }
            if (filterMode != oldFilterMode)
            {
                UpdateSubFilterButtons();
                oldFilterMode = filterMode;
            }
            SubFilterMode subFilterMode;

            subFilterMode = (SubFilterMode)subFilterButtons.Choice;
            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, subFilterMode, searchBar2.Text, searchBar.Text));
            numItemsShown = items.Count;
            for (int k = 0; k < items.Count; k++)
            {
                didMatCheck.Add(false);
            }
        }
Beispiel #9
0
 public override void PostUpdateInput()
 {
     StorageGUI.Update(null);
     CraftingGUI.Update(null);
 }