private void buttonClick(object sender, EventArgs e, bool left) { UIImage uIImage = (UIImage)sender; int num = (int)uIImage.Tag; if (num == (int)NPCBrowserCategories.ModNPCs) { var mods = ModToNPCs.Keys.ToList(); mods.Sort(); if (mods.Count == 0) { Main.NewText("No NPC have been added by mods."); } else { if (uIImage.ForegroundColor == buttonSelectedColor) { lastModNameNumber = left ? (lastModNameNumber + 1) % mods.Count : (mods.Count + lastModNameNumber - 1) % mods.Count; } string currentMod = mods[lastModNameNumber]; npcView.selectedCategory = categories[0].Where(x => npcView.allNPCSlot[x].npcType >= NPCID.Count && NPCLoader.GetNPC(npcView.allNPCSlot[x].npcType).Mod.Name == currentMod).ToArray(); npcView.activeSlots = npcView.selectedCategory; npcView.ReorderSlots(); bCategories[num].Tooltip = categNames[num] + ": " + currentMod; } } else if (num == (int)NPCBrowserCategories.FilteredNPCs) { swapFilter = !swapFilter; if (swapFilter) { npcView.selectedCategory = categories[0].Where(x => npcView.allNPCSlot[x].isFiltered).ToArray(); } else { npcView.selectedCategory = categories[0].Where(x => !npcView.allNPCSlot[x].isFiltered).ToArray(); } npcView.activeSlots = npcView.selectedCategory; npcView.ReorderSlots(); bCategories[num].Tooltip = categNames[num] + " [" + (swapFilter ? "DISABLED" : "ENABLED") + " NPCs]"; } else { npcView.selectedCategory = categories[num].ToArray(); npcView.activeSlots = npcView.selectedCategory; npcView.ReorderSlots(); } textbox.Text = ""; UIImage[] array = bCategories; for (int j = 0; j < array.Length; j++) { UIImage uIImage2 = array[j]; uIImage2.ForegroundColor = buttonColor; } uIImage.ForegroundColor = buttonSelectedColor; }
// 270 : 16 40 ?? 16 public NPCBrowser(CheatSheet mod) { categories.Clear(); this.npcView = new NPCView(); this.mod = mod; this.CanMove = true; base.Width = this.npcView.Width + this.spacing * 2f; base.Height = 300f; // 272f this.npcView.Position = new Vector2(this.spacing, base.Height - this.npcView.Height - this.spacing * 3f); this.AddChild(this.npcView); this.ParseList2(); Texture2D texture = mod.GetTexture("UI/closeButton"); UIImage uIImage = new UIImage(texture); uIImage.Anchor = AnchorPosition.TopRight; uIImage.Position = new Vector2(base.Width - this.spacing, this.spacing); uIImage.onLeftClick += new EventHandler(this.bClose_onLeftClick); this.AddChild(uIImage); this.textbox = new UITextbox(); this.textbox.Anchor = AnchorPosition.BottomLeft; //this.textbox.Position = new Vector2(base.Width - this.spacing * 2f + uIImage.Width * numWidth * 2, this.spacing /** 2f + uIImage.Height*/); this.textbox.Position = new Vector2(this.spacing, base.Height - this.spacing); this.textbox.KeyPressed += new UITextbox.KeyPressedHandler(this.textbox_KeyPressed); this.AddChild(this.textbox); bCategories = new UIImage[categoryIcons.Length]; for (int j = 0; j < NPCBrowser.categoryIcons.Length; j++) { UIImage uIImage2 = new UIImage(NPCBrowser.categoryIcons[j]); Vector2 position = new Vector2(this.spacing, this.spacing); uIImage2.Scale = 32f / Math.Max(categoryIcons[j].Width, categoryIcons[j].Height); position.X += (float)(j % 6 * 40); position.Y += (float)(j / 6 * 40); if (categoryIcons[j].Height > categoryIcons[j].Width) { position.X += (32 - categoryIcons[j].Width) / 2; } else if (categoryIcons[j].Height < categoryIcons[j].Width) { position.Y += (32 - categoryIcons[j].Height) / 2; } uIImage2.Position = position; uIImage2.Tag = j; uIImage2.onLeftClick += new EventHandler(this.button_onLeftClick); uIImage2.ForegroundColor = NPCBrowser.buttonColor; if (j == 0) { uIImage2.ForegroundColor = NPCBrowser.buttonSelectedColor; } uIImage2.Tooltip = NPCBrowser.categNames[j]; NPCBrowser.bCategories[j] = uIImage2; this.AddChild(uIImage2); } npcView.selectedCategory = NPCBrowser.categories[0].ToArray(); npcView.activeSlots = npcView.selectedCategory; npcView.ReorderSlots(); textures = new Texture2D[] { mod.GetTexture("UI/NPCLifeIcon"), mod.GetTexture("UI/NPCDamageIcon"), mod.GetTexture("UI/NPCDefenseIcon"), mod.GetTexture("UI/NPCKnockbackIcon"), }; }
// 270 : 16 40 ?? 16 public NPCBrowser(CheatSheet mod) { categories.Clear(); ModToNPCs.Clear(); npcView = new NPCView(); this.mod = mod; CanMove = true; Width = npcView.Width + spacing * 2f; Height = 300f; // 272f npcView.Position = new Vector2(spacing, Height - npcView.Height - spacing * 3f); AddChild(npcView); ParseList2(); Texture2D texture = mod.GetTexture("UI/closeButton").Value; UIImage uIImage = new UIImage(texture); uIImage.Anchor = AnchorPosition.TopRight; uIImage.Position = new Vector2(Width - spacing, spacing); uIImage.onLeftClick += bClose_onLeftClick; AddChild(uIImage); textbox = new UITextbox(); textbox.Anchor = AnchorPosition.BottomLeft; //this.textbox.Position = new Vector2(base.Width - this.spacing * 2f + uIImage.Width * numWidth * 2, this.spacing /** 2f + uIImage.Height*/); textbox.Position = new Vector2(spacing, Height - spacing); textbox.KeyPressed += textbox_KeyPressed; AddChild(textbox); Main.instance.LoadItem(ItemID.AlphabetStatueA); Main.instance.LoadItem(ItemID.AlphabetStatueB); Main.instance.LoadItem(ItemID.AlphabetStatueT); Main.instance.LoadItem(ItemID.AlphabetStatueN); Main.instance.LoadItem(ItemID.AlphabetStatueF); Main.instance.LoadItem(ItemID.AlphabetStatueM); Texture2D[] categoryIcons = { TextureAssets.Item[ItemID.AlphabetStatueA].Value, TextureAssets.Item[ItemID.AlphabetStatueB].Value, TextureAssets.Item[ItemID.AlphabetStatueT].Value, TextureAssets.Item[ItemID.AlphabetStatueN].Value, TextureAssets.Item[ItemID.AlphabetStatueF].Value, TextureAssets.Item[ItemID.AlphabetStatueM].Value, }; bCategories = new UIImage[categoryIcons.Length]; for (int j = 0; j < categoryIcons.Length; j++) { UIImage uIImage2 = new UIImage(categoryIcons[j]); Vector2 position = new Vector2(spacing, spacing); uIImage2.Scale = 32f / Math.Max(categoryIcons[j].Width, categoryIcons[j].Height); position.X += j % 6 * 40; position.Y += j / 6 * 40; if (categoryIcons[j].Height > categoryIcons[j].Width) { position.X += (32 - categoryIcons[j].Width) / 2; } else if (categoryIcons[j].Height < categoryIcons[j].Width) { position.Y += (32 - categoryIcons[j].Height) / 2; } uIImage2.Position = position; uIImage2.Tag = j; uIImage2.onLeftClick += (s, e) => buttonClick(s, e, true); uIImage2.onRightClick += (s, e) => buttonClick(s, e, false); uIImage2.ForegroundColor = buttonColor; if (j == 0) { uIImage2.ForegroundColor = buttonSelectedColor; } uIImage2.Tooltip = categNames[j]; bCategories[j] = uIImage2; AddChild(uIImage2); } npcView.selectedCategory = categories[0].ToArray(); npcView.activeSlots = npcView.selectedCategory; npcView.ReorderSlots(); textures = new Texture2D[] { mod.GetTexture("UI/NPCLifeIcon").Value, mod.GetTexture("UI/NPCDamageIcon").Value, mod.GetTexture("UI/NPCDefenseIcon").Value, mod.GetTexture("UI/NPCKnockbackIcon").Value, }; }