Exemple #1
0
 private void ChangeViewMode()
 {
     gridNPC.Clear();
     updateNeeded        = true;
     InfoCombat.isUpdate = true;
     if (ViewMode == ViewMode.SpawnNPC)
     {
         panelMain.Append(btnSpawnNPCFilter);
     }
     else
     {
         panelMain.RemoveChild(btnSpawnNPCFilter);
     }
 }
        public override void OnInitialize()
        {
            Elements.Clear();
            grid.Clear();

            grid.Left.Set(-220, 0.5f);
            grid.Top.Set(-220, 0.5f);
            grid.Width.Set(440, 0);
            grid.Height.Set(440, 0);
            grid.ListPadding = 4;
            grid.MaxWidth.Set(440, 0);
            grid.MaxHeight.Set(440, 0);

            Append(grid);

            if (openBag is null)
            {
                return;
            }

            for (int k = 0; k < openBag.items.Count; k++)
            {
                grid.Add(new IngredientStorageSlot(openBag.items[k], k));
            }
        }
Exemple #3
0
        private void OpenItem(ModularItem item)
        {
            selectedItem = item;

            gridModules.Clear();

            foreach (int type in ModuleLoader.validModulesForItem[item.Type])
            {
                BaseModule module = ModuleLoader.GetModule(type);

                UIModule uiModule = new UIModule(module)
                {
                    Color  = item.IsInstalled(module.Type) ? Color.LimeGreen : Color.Red,
                    Width  = { Percent = 100 },
                    Height = { Pixels = 64 }
                };
                uiModule.OnClick += args =>
                {
                    args.Handled = true;

                    OpenModule(module);
                };
                gridModules.Add(uiModule);
            }
        }
Exemple #4
0
        public void Open()
        {
            selectedItem   = null;
            selectedModule = null;

            gridItems.Clear();

            foreach (Item item in InventoryUtility.InvArmorEquips(Main.LocalPlayer))
            {
                if (item.IsAir)
                {
                    continue;
                }

                if (item.ModItem is ModularItem modularItem)
                {
                    UIModularItem uiModularItem = new UIModularItem(modularItem)
                    {
                        Width  = { Pixels = 48 },
                        Height = { Pixels = 48 }
                    };
                    uiModularItem.OnClick += args =>
                    {
                        args.Handled = true;

                        OpenItem(modularItem);
                    };

                    gridItems.Add(uiModularItem);
                }
            }
        }
Exemple #5
0
        public void PopulateGrid()
        {
            gridLocations.Clear();

            foreach (EntryPoint entryPoint in TerraFirma.Instance.TubeNetworkLayer[Container.Position].Network.GetEntryPoints())
            {
                if (entryPoint == Container)
                {
                    continue;
                }

                UIEntryPointItem entryPointItem = new UIEntryPointItem(entryPoint)
                {
                    Width  = (0, 1),
                    Height = (60, 0)
                };
                entryPointItem.OnClick += (evt, element) =>
                {
                    TubularNetwork  network = TerraFirma.Instance.TubeNetworkLayer[Container.Position].Network;
                    Stack <Point16> path    = Pathfinding.FindPath(network.Tiles, Container.Position, entryPoint.Position);

                    TransportingPlayer transfer = new TransportingPlayer(Main.LocalPlayer, path);

                    network.TransportingPlayers.Add(transfer);

                    BaseLibrary.BaseLibrary.PanelGUI.UI.CloseUI(Container);
                };
                gridLocations.Add(entryPointItem);
            }
        }
Exemple #6
0
        internal void UpdateNPCGrid()
        {
            if (!updateNeededNPC)
            {
                return;
            }
            updateNeededNPC = false;

            npcGrid.Clear();
            for (int i = 0; i < Main.npcTexture.Length; i++)             // TODO, right?
            {
                //if (Main.projName[i].ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    NPC npc = new NPC();
                    npc.SetDefaults(i);

                    var box = new UINPCSlot(npc);
                    box.OnClick += Box_OnClick;
                    npcGrid._items.Add(box);
                    npcGrid._innerList.Append(box);
                }
            }

            npcGrid.UpdateOrder();
            npcGrid._innerList.Recalculate();
        }
Exemple #7
0
            internal void RefreshGrid()
            {
                Point currSelection = grid.SelectionIndex;

                GetSortedGridElements(refreshGrid_scratch);

                for (int i = 0; i < grid.ActualDimensions.Y; ++i)
                {
                    UIGridShareHubElement elem = grid.Get(0, i) as UIGridShareHubElement;

                    elem.Selected = false;

                    if (!refreshGrid_scratch.Contains(elem))
                    {
                        BokuGame.Unload(elem);
                    }
                }

                grid.Clear();

                for (int i = 0; i < refreshGrid_scratch.Count; ++i)
                {
                    grid.Add(refreshGrid_scratch[i], 0, grid.ActualDimensions.Y);
                    BokuGame.Load(refreshGrid_scratch[i]);
                }

                grid.Dirty = true;

                // Try to preserve selection index.
                // We might want to try to relocate the selected element if it moved instead.
                if (grid.ActualDimensions.Y > currSelection.Y)
                {
                    grid.SelectionIndex = new Point(0, currSelection.Y);
                }
                else if (grid.ActualDimensions.Y > 0)
                {
                    grid.SelectionIndex = new Point(0, grid.ActualDimensions.Y - 1);
                }

                Matrix parentMatrix = Matrix.Identity;

                grid.Update(ref parentMatrix);
            }
        public void UpdateGrid()
        {
            gridLocations.Clear();

            foreach (TileEntities.Teleporter teleporter in Container.GetConnections())
            {
                UITeleporterItem teleporterItem = new UITeleporterItem(teleporter, this)
                {
                    Width  = { Percent = 100 },
                    Height = { Pixels = 60 }
                };
                gridLocations.Add(teleporterItem);
            }
        }
Exemple #9
0
        internal void UpdateHuntList()
        {
            if (!needUpdate)
            {
                return;
            }
            needUpdate = false;
            huntGrid.Clear();

            foreach (HuntInfo hunt in JoostMod.instance.hunts)
            {
                if (hunt.showQuest())
                {
                    HuntUIButton bill = new HuntUIButton(hunt);
                    huntGrid.Add(bill);
                }
            }
        }
Exemple #10
0
        public void PopulateGrid()
        {
            gridItems.Clear();

            foreach (Item item in Network.Items)
            {
                if (item.maxStack > 1 && gridItems.items.Any(gridSlot => gridSlot.Item.type == item.type))
                {
                    continue;
                }

                UIGridSlot slot = new UIGridSlot(Network, item);
                gridItems.Add(slot);
            }

            while (gridItems.Count < 54 || gridItems.Count % 9 != 0)
            {
                gridItems.Add(new UIGridSlot(Network, new Item()));
            }
        }
Exemple #11
0
        public void PopulateCategories()
        {
            UIGrid gridCategories = (UIGrid)typeof(UIElement).GetFieldValue <List <UIElement> >("Elements", sidePanels["Categories"]).First(x => x is UIGrid);

            gridCategories.Clear();
            foreach (KeyValuePair <string, Func <NPC, bool> > categoryName in categories)
            {
                UICategoryItem category = new UICategoryItem(categoryName.Key);
                category.Width.Precent = 1;
                category.Height.Pixels = 40;
                category.OnClick      += (e, element) =>
                {
                    if (currentCategories.Contains(category.category))
                    {
                        category.SetInactive();
                        currentCategories.Remove(category.category);

                        UpdateItems();

                        if (currentCategories.Count == 0)
                        {
                            gridCategories.items.ForEach(x => ((UICategoryItem)x).SetActive());
                        }
                    }
                    else
                    {
                        if (currentCategories.Count == 0)
                        {
                            currentCategories.Clear();
                            gridCategories.items.ForEach(x => ((UICategoryItem)x).SetInactive());
                        }

                        category.SetActive();
                        currentCategories.Add(category.category);
                        UpdateItems();
                    }
                };

                gridCategories.Add(category);
            }
        }
Exemple #12
0
        public void PopulateMods()
        {
            UIGrid gridMods = (UIGrid)typeof(UIElement).GetFieldValue <List <UIElement> >("Elements", sidePanels["Mods"]).First(x => x is UIGrid);

            gridMods.Clear();
            foreach (Mod mod in ModLoader.GetLoadedMods().Select(ModLoader.GetMod).Where(x => !x.Name.StartsWith("ModLoader") && typeof(Mod).GetFieldValue <Dictionary <string, ModNPC> >("npcs", x).Count > 0))
            {
                UIModItem modItem = new UIModItem(mod);
                modItem.Width.Precent = 1;
                modItem.Height.Pixels = 40;
                modItem.OnClick      += (e, element) =>
                {
                    if (currentMods.Contains(modItem.mod.Name))
                    {
                        modItem.SetInactive();
                        currentMods.Remove(modItem.mod.Name);

                        UpdateItems();

                        if (!currentMods.Any())
                        {
                            gridMods.items.ForEach(x => ((UIModItem)x).SetActive());
                        }
                    }
                    else
                    {
                        if (!currentMods.Any())
                        {
                            currentMods.Clear();
                            gridMods.items.ForEach(x => ((UIModItem)x).SetInactive());
                        }

                        modItem.SetActive();
                        currentMods.Add(modItem.mod.Name);

                        UpdateItems();
                    }
                };
                gridMods.Add(modItem);
            }
        }
Exemple #13
0
        internal void UpdateGrid()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;

            projectileGrid.Clear();
            for (int i = 1; i < Main.projectileTexture.Length; i++)
            {
                if (Lang.GetProjectileName(i).Value.ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    var box = new ProjectileSlot(i);
                    projectileGrid._items.Add(box);
                    projectileGrid._innerList.Append(box);
                }
            }

            projectileGrid.UpdateOrder();
            projectileGrid._innerList.Recalculate();
        }
Exemple #14
0
        internal void UpdateGrid()
        {
            if (!updateneeded)
            {
                return;
            }
            updateneeded = false;

            dustGrid.Clear();
            for (int i = 0; i < DustTool.dustCount; i++)
            {
                //if (Main.projName[i].ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    var box = new DustSlot(i);
                    dustGrid._items.Add(box);
                    dustGrid._innerList.Append(box);
                }
            }

            dustGrid.UpdateOrder();
            dustGrid._innerList.Recalculate();
        }
            }   // end of Shared c'tor

            #endregion

            #region Internal

            /// <summary>
            /// Set up the Examples grid based on the ActorHelp for the current actor.
            /// </summary>
            public void SetUpGrid()
            {
                examplesGrid.Clear();

                // We set this here instead of the c'tor since the renderObj doesn't exist at that point...
                examplesBlob.Font = UI2D.Shared.GetGameFont20;

                if (actorHelp != null && actorHelp.programs != null)
                {
                    for (int i = 0; i < actorHelp.programs.Count; i++)
                    {
                        UIGrid2DProgrammedBotElement e = new UIGrid2DProgrammedBotElement(examplesBlob, actorHelp, i);
                        examplesGrid.Add(e, 0, i);
                    }

                    // Start with the top one in focus.
                    examplesGrid.SelectionIndex = new Point(0, 0);

                    // Allow the geometry for the examples to load.
                    examplesGrid.LoadContent(true);
                }
            }   // end of SetUpGrid()
Exemple #16
0
        public override void Update(GameTime gameTime)
        {
            if (hasChanges || selected != parent.selectedRecipe || selected == null || !selected.Equals(parent.selectedRecipe))
            {
                selected = parent.selectedRecipe;

                internalGrid.Left.Set(0, 0);
                internalGrid.Top.Set(0, 0);
                internalGrid.Width.Set(this.Width.Pixels - 4, 0);
                internalGrid.Height.Set(this.Height.Pixels - 4, 0);
                internalGrid.Clear();

                float startX = 0;
                float startY = 0;
                if (selected != null)
                {
                    PartsPlayer prt = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();
                    foreach (Item part in selected.parts)
                    {
                        PartItemSlot pt = new PartItemSlot(ARareItemSwapJPANs.ItemToTag(part), part.stack);
                        //pt.Left.Set(startX, 0);
                        // pt.Top.Set(startY, 0);

                        /*startX += pt.Width.Pixels + 2;
                         * if (startX + pt.Width.Pixels + 2 > this.Height.Pixels - 4)
                         * {
                         *  startX = 0;
                         *  startY += pt.Height.Pixels + 2;
                         * }*/
                        internalGrid.Add(pt);
                    }
                }
                //  internalGrid.Height.Set(Math.Max(this.Height.Pixels, startY + parent.destroySlot.Height.Pixels + 2), 0);
                internalGrid.Recalculate();
                Recalculate();
                hasChanges = false;
            }
            base.Update(gameTime);
        }
Exemple #17
0
 private void LoadImage()
 {
     if (File.Exists(imageFilePath))
     {
         grid.Clear();
         foreach (var path in File.ReadAllLines(imageFilePath, Encoding.UTF8))
         {
             try
             {
                 using (var fs = new FileStream(path, FileMode.Open))
                 {
                     var fileInfo = new FileInfo(fs.Name);
                     var slot     = new UISlotImage(Texture2D.FromStream(Main.graphics.GraphicsDevice, fs), grid.Count, fileInfo.Name.Replace(fileInfo.Extension, ""));
                     grid._items.Add(slot);
                     grid._innerList.Append(slot);
                 }
             }
             catch { }
         }
         grid.UpdateOrder();
         grid._innerList.Recalculate();
     }
 }
Exemple #18
0
        public void PopulateRecipe()
        {
            gridIngredients.Clear();
            gridResults.Clear();

            ItemRecipe currentRecipe = allRecipes.Any() ? allRecipes.Where(x => x.requiredTiles.IsEqual(tiles[currentTileIndex])).ToList()[currentRecipeIndex] : null;

            if (currentRecipe != null)
            {
                textRecipe.SetText($"{currentRecipeIndex + 1}/{allRecipes.Count(x => x.requiredTiles.IsEqual(tiles[currentTileIndex]))}");

                for (int i = 0; i < currentRecipe.requiredItem.Count; i++)
                {
                    UIIngredient ing = new UIIngredient(i, currentRecipe.requiredItem[i]);
                    gridIngredients.Add(ing);
                }

                for (int i = 0; i < currentRecipe.createItems.Count; i++)
                {
                    UIIngredient ing = new UIIngredient(i, currentRecipe.createItems[i]);
                    gridResults.Add(ing);
                }
            }
        }
Exemple #19
0
        public void recreateList()
        {
            internalGrid.Left.Set(0, 0);
            internalGrid.Top.Set(0, 0);
            internalGrid.Width.Set(this.Width.Pixels - 4, 0);
            internalGrid.Height.Set(this.Height.Pixels - 4, 0);

            ResearchPlayer player    = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
            List <Item>    toDisplay = new List <Item>();

            while (player.waitingForResearchCache())
            {
                Task.Yield();
            }
restart:
            changedToList = false;
            toDisplay.Clear();
            internalGrid.Clear();

            foreach (int type in player.researchedCache)
            {
                Item itm = new Item();
                itm.SetDefaults(type);
                itm.stack = 1;
                if (parent.search.GetText() == null || parent.search.GetText().Trim().Length == 0 || itm.Name.ToLower().Contains(parent.search.GetText().ToLower()) ||
                    (tooltipSearch && condensedTooltip(itm).ToLower().Contains(parent.search.GetText().ToLower())))
                {
                    toDisplay.Add(itm);
                }
                if (changedToList)
                {
                    goto restart;
                }
            }
            toDisplay.Sort(new ItemNameComparer());

            if (selected.Equals(changer.allTree))
            {
                foreach (Item itm in toDisplay)
                {
                    internalGrid.Add(new PurchaseItemSlot(itm));
                    if (changedToList)
                    {
                        goto restart;
                    }
                }
            }
            else
            {
                if (ResearchTable.category.ContainsKey(selected.getFullPath()))
                {
                    // ModLoader.GetMod("ResearchFrom14").Logger.Info("Category " + selected.getFullPath() + " has items:");

                    /* foreach (int cat in ResearchTable.category[selected.getFullPath()])
                     * {
                     *   Item test = new Item();
                     *   test.SetDefaults(cat);
                     *   //   ModLoader.GetMod("ResearchFrom14").Logger.Info("  - " + test.Name + " ( id " + test.type + " = "+cat + ")" );
                     * }*/
                    foreach (Item itm in toDisplay)
                    {
                        if (ResearchTable.category[selected.getFullPath()].Contains(itm.type))
                        {
                            internalGrid.Add(new PurchaseItemSlot(itm));
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
        }
Exemple #20
0
        internal void UpdateDamageLists()
        {
            //ShowFavoritePanel = favoritedRecipes.Count > 0;
            //	teamDPSPanel.RemoveAllChildren();

            //UIText label = new UIText("DPS");
            //label.OnClick += Label_OnClick;
            //teamDPSPanel.Append(label);

            //label.Recalculate();
            var labelDimensions = label.GetInnerDimensions();
            int top             = (int)labelDimensions.Height + 4;

            if (showDPSPanel)
            {
                dpsList.Clear();
                int   width  = 1;
                int   height = 0;
                float max    = 1f;
                int   total  = 0;
                for (int i = 0; i < DPSExtreme.dpss.Length; i++)
                {
                    int playerDPS = DPSExtreme.dpss[i];
                    if (playerDPS > -1)
                    {
                        max    = Math.Max(max, playerDPS);
                        total += playerDPS;
                    }
                }
                for (int i = 0; i < DPSExtreme.dpss.Length; i++)
                {
                    int playerDPS = DPSExtreme.dpss[i];
                    if (playerDPS > -1)
                    {
                        UIPlayerDPS t = new UIPlayerDPS(i, "", "");
                        t.SetDPS(playerDPS, max, total);
                        t.Recalculate();
                        var inner = t.GetInnerDimensions();
                        t.Width.Set(200, 0);
                        height += (int)(inner.Height + dpsList.ListPadding);
                        width   = Math.Max(width, (int)inner.Width);
                        dpsList.Add(t);
                        teamDPSPanel.AddDragTarget(t);
                    }
                }

                dpsList.Recalculate();
                var fff = dpsList.GetTotalHeight();

                width = 200;
                teamDPSPanel.Height.Pixels = top + /*height*/ fff + teamDPSPanel.PaddingBottom + teamDPSPanel.PaddingTop - dpsList.ListPadding;
                teamDPSPanel.Width.Pixels  = width + teamDPSPanel.PaddingLeft + teamDPSPanel.PaddingRight;
                teamDPSPanel.Recalculate();
            }
            else
            {
                bossList.Clear();

                int height = 0;
                int max    = 1;
                int total  = 0;
                for (int i = 0; i < DPSExtreme.bossDamage.Length; i++)
                {
                    int playerBossDamage = DPSExtreme.bossDamage[i];
                    if (playerBossDamage > -1)
                    {
                        max    = Math.Max(max, playerBossDamage);
                        total += playerBossDamage;
                    }
                }
                for (int i = 0; i < DPSExtreme.dpss.Length; i++)
                {
                    int playerBossDamage = DPSExtreme.bossDamage[i];
                    if (playerBossDamage > -1)
                    {
                        UIPlayerDPS t = new UIPlayerDPS(i, "", "");
                        t.SetDPS(playerBossDamage, max, total);
                        t.Recalculate();
                        var inner = t.GetInnerDimensions();
                        t.Width.Set(200, 0);
                        height += (int)(inner.Height + bossList.ListPadding);
                        bossList.Add(t);
                        teamDPSPanel.AddDragTarget(t);
                    }
                }

                if (bossUpdateNeeded)
                {
                    string bossname = "No Boss";
                    if (DPSExtreme.bossIndex > -1)
                    {
                        bossname = Lang.GetNPCNameValue(Main.npc[DPSExtreme.bossIndex].type);
                    }
                    label.SetText("Boss - " + bossname);
                    bossUpdateNeeded = false;
                }

                bossList.Recalculate();
                var fff = bossList.GetTotalHeight();
                teamDPSPanel.Height.Pixels = top + /*height*/ fff + teamDPSPanel.PaddingBottom + teamDPSPanel.PaddingTop - dpsList.ListPadding;
                teamDPSPanel.Width.Pixels  = 200 + teamDPSPanel.PaddingLeft + teamDPSPanel.PaddingRight;
                teamDPSPanel.Recalculate();
            }
        }
        // todo, items on load.
        internal void UpdateCheckboxes()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;
            checklistGrid.Clear();

            if (buttonsHaveDummyTextures)
            {
                Texture2D foundFilterTexture = Utilities.ResizeImage(ItemChecklist.instance.GetTexture("Images/filterFound"), 32, 32);
                Texture2D muteButtonTexture  = Utilities.ResizeImage(Main.itemTexture[ItemID.Megaphone], 32, 32);
                //Texture2D sortButtonTexture = Utilities.ResizeImage(Main.itemTexture[ItemID.ToxicFlask], 32, 32);
                Texture2D modFilterButtonTexture         = Utilities.ResizeImage(ItemChecklist.instance.GetTexture("Images/filterMod"), 32, 32);
                Texture2D collectChestItemsButtonTexture = Utilities.ResizeImage(Main.cursorTextures[8], 32, 32);
                Texture2D showBadgeButtonTexture         = Utilities.ResizeImage(Main.itemTexture[ItemID.Book], 32, 32);         // Main.extraTexture[58]

                foundFilterButton.SetImage(foundFilterTexture);
                muteButton.SetImage(muteButtonTexture);
                modFilterButton.SetImage(modFilterButtonTexture);
                collectChestItemsButton.SetImage(collectChestItemsButtonTexture);
                showBadgeButton.SetImage(showBadgeButtonTexture);

                buttonsHaveDummyTextures = false;
            }

            var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer <ItemChecklistPlayer>(ItemChecklist.instance);
            var temp = new List <UIItemSlot>();

            for (int i = 0; i < itemChecklistPlayer.findableItems.Length; i++)
            {
                if (itemChecklistPlayer.findableItems[i])
                {
                    // filters here
                    if ((showCompleted != 1 && itemChecklistPlayer.foundItem[i]) || (showCompleted != 2 && !itemChecklistPlayer.foundItem[i]))
                    {
                        if (!PassModFilter(itemSlots[i]))
                        {
                            continue;
                        }

                        if (SharedUI.instance.SelectedCategory != null)
                        {
                            if (!SharedUI.instance.SelectedCategory.belongs(itemSlots[i].item) && !SharedUI.instance.SelectedCategory.subCategories.Any(x => x.belongs(itemSlots[i].item)))
                            {
                                continue;
                            }
                        }

                        bool filtered = false;
                        foreach (var filter in SharedUI.instance.availableFilters)
                        {
                            if (filter.button.selected)
                            {
                                if (!filter.belongs(itemSlots[i].item))
                                {
                                    filtered = true;
                                }
                            }
                        }
                        if (filtered)
                        {
                            continue;
                        }

                        if (itemSlots[i].item.Name.IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }

                        if (itemDescriptionFilter.currentString.Length > 0)
                        {
                            if ((itemSlots[i].item.ToolTip != null && GetTooltipsAsString(itemSlots[i].item.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/)
                            {
                            }
                            else
                            {
                                continue;
                            }
                        }

                        UIItemSlot box = itemSlots[i];
                        box.badge = SharedUI.instance.SelectedSort?.badge(box.item) ?? "";
                        temp.Add(box);
                    }
                }
            }
            checklistGrid.AddRange(temp);

            if (lastfoundID > 0)
            {
                checklistGrid.Recalculate();
                if (showCompleted != 1)                 // Don't Goto when unfound is the display mode.
                {
                    checklistGrid.Goto(delegate(UIElement element)
                    {
                        UIItemSlot itemSlot = element as UIItemSlot;
                        return(itemSlot != null && itemSlot.id == lastfoundID);
                    }, true);
                }
                lastfoundID = -1;
            }
        }
Exemple #22
0
        public void recreateList()
        {
            internalGrid.Left.Set(0, 0);
            internalGrid.Top.Set(0, 0);
            internalGrid.Width.Set(this.Width.Pixels - 4, 0);
            internalGrid.Height.Set(this.Height.Pixels - 4, 0);

restart:
            changedToList = false;
            internalGrid.Clear();

            if (parent.destroySlot.item != null && parent.destroySlot.item.type != 0 && !ARareItemSwapJPANs.tokenList.Contains(ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)) && PartRecipes.recipesByResult.ContainsKey(ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)))
            {
                foreach (PartRecipe pr in PartRecipes.recipesByResult[ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)])
                {
                    if (pr.isAvailable())
                    {
                        PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                        if (parent.selectedRecipe == null)
                        {
                            parent.selectedRecipe = pr;
                        }
                        if (pr.Equals(parent.selectedRecipe))
                        {
                            pt.select(true);
                        }
                        internalGrid.Add(pt);
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else if (selected.Equals(changer.availableTree))
            {
                List <PartRecipe> prtList = new List <PartRecipe>();

                prtList.AddRange(PartRecipes.allRecipes);
                prtList.Sort(PartRecipe.orderByResultName);
                for (int i = 0; i < prtList.Count; i++)
                {
                    if (!prtList[i].isAvailable())
                    {
                        prtList.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        if (!Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>().CanCraftRecipe(prtList[i]))
                        {
                            prtList.RemoveAt(i);
                            i--;
                        }
                    }
                    if (changedToList)
                    {
                        goto restart;
                    }
                }

                foreach (PartRecipe pr in prtList)
                {
                    if (search == null || search.Trim().Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                    {
                        PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                        internalGrid.Add(pt);
                    }
                    if (changedToList)
                    {
                        goto restart;
                    }
                }
            }
            else if (selected.Equals(changer.allTree))
            {
                List <PartRecipe> prtList = new List <PartRecipe>();

                prtList.AddRange(PartRecipes.allRecipes);
                prtList.Sort(PartRecipe.orderByResultName);

                foreach (PartRecipe pr in prtList)
                {
                    if (pr.isAvailable())
                    {
                        if (search == null || search.Trim().Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                        {
                            PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                            internalGrid.Add(pt);
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else if (selected.Equals(changer.partsTree))
            {
                PartsPlayer prt = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();
                foreach (string s in ARareItemSwapJPANs.tokenList)
                {
                    if (prt.parts.ContainsKey(s))
                    {
                        Item part = ARareItemSwapJPANs.getItemFromTag(s);
                        if (search == null || search.Trim().Length == 0 || part.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(part).ToLower().Contains(search.ToLower())))
                        {
                            PartItemSlot pt = new PartItemSlot(s, -1);
                            internalGrid.Add(pt);
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else
            {
                if (selected != null && PartRecipes.recipesByCategory.ContainsKey(selected.getFullPath()))
                {
                    List <PartRecipe> prtList = new List <PartRecipe>();
                    prtList.AddRange(PartRecipes.recipesByCategory[selected.getFullPath()]);
                    prtList.Sort(PartRecipe.orderByResultName);
                    foreach (PartRecipe pr in prtList)
                    {
                        if (pr.isAvailable())
                        {
                            if (search == null || search.Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                            {
                                PurchaseItemSlot pt = new PurchaseItemSlot(pr);

                                internalGrid.Add(pt);
                            }
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
        }