diff --git a/ItemChecklist.cs b/ItemChecklist.cs index 97a1875..4367156 100644 --- a/ItemChecklist.cs +++ b/ItemChecklist.cs @@ -1,5 +1,4 @@ -using System; -using Terraria; +using Terraria; using Terraria.ModLoader; using System.Collections.Generic; using Terraria.UI; @@ -14,7 +13,6 @@ namespace ItemChecklist static internal ItemChecklist instance; internal static ModHotKey ToggleChecklistHotKey; internal static UserInterface ItemChecklistInterface; - //internal bool UIInitialized; internal ItemChecklistUI ItemChecklistUI; public ItemChecklist() @@ -29,27 +27,8 @@ namespace ItemChecklist { instance = this; ToggleChecklistHotKey = RegisterHotKey("Toggle Item Checklist", "I"); - //UIInitialized = false; - //if (!Main.dedServ) - //{ - // ItemChecklistUI = new ItemChecklistUI(); - // ItemChecklistUI.Activate(); - // ItemChecklistInterface = new UserInterface(); - // ItemChecklistInterface.SetState(ItemChecklistUI); - //} } - //public override void PostSetupContent() - //{ - // if (!Main.dedServ) - // { - // ItemChecklistUI = new ItemChecklistUI(); - // ItemChecklistUI.Activate(); - // ItemChecklistInterface = new UserInterface(); - // ItemChecklistInterface.SetState(ItemChecklistUI); - // } - //} - public override void AddRecipes() { if (!Main.dedServ) @@ -65,14 +44,6 @@ namespace ItemChecklist int lastSeenScreenHeight; public override void ModifyInterfaceLayers(List layers) { - //if (!UIInitialized) - //{ - // ItemChecklistUI = new ItemChecklistUI(); - // ItemChecklistUI.Activate(); - // ItemChecklistInterface = new UserInterface(); - // ItemChecklistInterface.SetState(ItemChecklistUI); - //} - int MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text")); if (MouseTextIndex != -1) { diff --git a/ItemChecklistGlobalItem.cs b/ItemChecklistGlobalItem.cs index 83cf349..13e2bdb 100644 --- a/ItemChecklistGlobalItem.cs +++ b/ItemChecklistGlobalItem.cs @@ -1,9 +1,6 @@ using ItemChecklist.UI; -using System.Linq; using Terraria; -using Terraria.GameInput; using Terraria.ModLoader; -using Terraria.ModLoader.IO; namespace ItemChecklist { @@ -33,7 +30,6 @@ namespace ItemChecklist itemChecklistPlayer.foundItems.Add(newItem); itemChecklistPlayer.totalItemsFound++; itemChecklistPlayer.foundItem[item.type] = true; - //ItemChecklist.instance.ItemChecklistUI.UpdateCheckboxes(); ItemChecklist.instance.ItemChecklistUI.UpdateNeeded(); if (ItemChecklistUI.announce) { diff --git a/ItemChecklistUI.cs b/ItemChecklistUI.cs index c85a598..33f7c92 100644 --- a/ItemChecklistUI.cs +++ b/ItemChecklistUI.cs @@ -1,15 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; using Terraria.GameContent.UI.Elements; using Terraria.UI; -using System; -using System.Collections.Generic; using Terraria.ID; -using Terraria.ModLoader.UI; -using System.Reflection; -using Terraria.Graphics; namespace ItemChecklist.UI { @@ -18,9 +12,7 @@ namespace ItemChecklist.UI public UIHoverImageButton toggleButton; public UIToggleHoverImageButton muteButton; public UIPanel checklistPanel; - //public UIList checklistList; public UIGrid checklistList; - // private FieldInfo uilistinnerlist; float spacing = 8f; public static bool visible = false; @@ -34,7 +26,6 @@ namespace ItemChecklist.UI { // Is initialize called? (Yes it is called on reload) I want to reset nicely with new character or new loaded mods: visible = false; - // uilistinnerlist = typeof(UIList).GetField("_innerList", BindingFlags.Instance | BindingFlags.NonPublic); announce = true; checklistPanel = new UIPanel(); @@ -48,8 +39,6 @@ namespace ItemChecklist.UI toggleButton = new UIHoverImageButton(Main.itemTexture[ItemID.Book], "Toggle Found"); toggleButton.OnClick += ToggleButtonClicked; - //toggleButton.Left.Pixels = spacing; - //toggleButton.Top.Pixels = spacing; checklistPanel.Append(toggleButton); muteButton = new UIToggleHoverImageButton(Main.itemTexture[ItemID.Megaphone], ItemChecklist.instance.GetTexture("closeButton"), "Toggle Messages", announce); @@ -84,8 +73,6 @@ namespace ItemChecklist.UI itemSlots[i] = new ItemSlot(i); } updateneeded = true; - // TODO, game window resize issue --> UserInterface.ActiveInstance.Recalculate(); on resize? new hook? - // TODO, Scrollbar can't click } private void ToggleButtonClicked(UIMouseEvent evt, UIElement listeningElement) @@ -114,13 +101,10 @@ namespace ItemChecklist.UI if (!updateneeded) { return; } updateneeded = false; checklistList.Clear(); - // var uilistinner = (UIElement)uilistinnerlist.GetValue(checklistList); var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer(ItemChecklist.instance); - //var itemChecklistPlayer = ItemChecklistPlayer.localInstance; UIElement element = new UIElement(); - int count = 0; for (int i = 0; i < itemChecklistPlayer.findableItems.Length; i++) { if (itemChecklistPlayer.findableItems[i]) @@ -128,32 +112,15 @@ namespace ItemChecklist.UI if (showCompleted || !itemChecklistPlayer.foundItem[i]) { - //ItemSlot box = new ItemSlot(i); ItemSlot box = itemSlots[i]; - //keyImage.Left.Set(xOffset, 1f); - //element.Append(keyImage); - //count++; - //if(count == 4) - //{ - // count = 0; - // element = new UIElement(); - //} - //UIHoverImageButton box = new UIHoverImageButton(Main.itemTexture[i], Main.itemName[i]); - - //UICheckbox box = new UICheckbox(i, Main.itemName[i], 1f, false); - //box.Selected = itemChecklistPlayer.foundItem[i]; - //checklistList.Add(box); n squared - checklistList._items.Add(box); checklistList._innerList.Append(box); - // uilistinner.Append(box); } } } checklistList.UpdateOrder(); checklistList._innerList.Recalculate(); - // uilistinner.Recalculate(); } protected override void DrawSelf(SpriteBatch spriteBatch) @@ -168,71 +135,8 @@ namespace ItemChecklist.UI } } - //public class FixedUIScrollbar : UIElement public class FixedUIScrollbar : UIScrollbar { - //private float _viewPosition; - //private float _viewSize = 1f; - //private float _maxViewSize = 20f; - //private bool _isDragging; - //private bool _isHoveringOverHandle; - //private float _dragYOffset; - //private Texture2D _texture; - //private Texture2D _innerTexture; - - //public float ViewPosition - //{ - // get - // { - // return this._viewPosition; - // } - // set - // { - // this._viewPosition = MathHelper.Clamp(value, 0f, this._maxViewSize - this._viewSize); - // } - //} - - //public FixedUIScrollbar() - //{ - // this.Width.Set(20f, 0f); - // this.MaxWidth.Set(20f, 0f); - // this._texture = TextureManager.Load("Images/UI/Scrollbar"); - // this._innerTexture = TextureManager.Load("Images/UI/ScrollbarInner"); - // this.PaddingTop = 5f; - // this.PaddingBottom = 5f; - //} - - //public void SetView(float viewSize, float maxViewSize) - //{ - // viewSize = MathHelper.Clamp(viewSize, 0f, maxViewSize); - // this._viewPosition = MathHelper.Clamp(this._viewPosition, 0f, maxViewSize - viewSize); - // this._viewSize = viewSize; - // this._maxViewSize = maxViewSize; - //} - - //public float GetValue() - //{ - // return this._viewPosition; - //} - - //private Rectangle GetHandleRectangle() - //{ - // CalculatedStyle innerDimensions = base.GetInnerDimensions(); - // if (this._maxViewSize == 0f && this._viewSize == 0f) - // { - // this._viewSize = 1f; - // this._maxViewSize = 1f; - // } - // return new Rectangle((int)innerDimensions.X, (int)(innerDimensions.Y + innerDimensions.Height * (this._viewPosition / this._maxViewSize)) - 3, 20, (int)(innerDimensions.Height * (this._viewSize / this._maxViewSize)) + 7); - //} - - //private void DrawBar(SpriteBatch spriteBatch, Texture2D texture, Rectangle dimensions, Color color) - //{ - // spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y - 6, dimensions.Width, 6), new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), color); - // spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y, dimensions.Width, dimensions.Height), new Rectangle?(new Rectangle(0, 9, texture.Width, 2)), color); - // spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y + dimensions.Height, dimensions.Width, 6), new Rectangle?(new Rectangle(0, texture.Height - 6, texture.Width, 6)), color); - //} - protected override void DrawSelf(SpriteBatch spriteBatch) { UserInterface temp = UserInterface.ActiveInstance; @@ -248,27 +152,5 @@ namespace ItemChecklist.UI base.MouseDown(evt); UserInterface.ActiveInstance = temp; } - - //public override void MouseUp(UIMouseEvent evt) - //{ - // base.MouseUp(evt); - // this._isDragging = false; - //} } - - //public class BossInfo - //{ - // internal Func available; - // internal Func downed; - // internal string name; - // internal float progression; - - // public BossInfo(string name, float progression, Func available, Func downed) - // { - // this.name = name; - // this.progression = progression; - // this.available = available; - // this.downed = downed; - // } - //} } diff --git a/ItemSlot.cs b/ItemSlot.cs index 97c714e..388ccdf 100644 --- a/ItemSlot.cs +++ b/ItemSlot.cs @@ -87,27 +87,6 @@ namespace ItemChecklist { ItemChecklistUI.hoverText = item.name + (item.modItem != null ? " [" + item.modItem.mod.Name + "]" : ""); } - //if (IsMouseHovering) - //{ - // string hoverText = item.name + " " + item.type; - // float x = Main.fontMouseText.MeasureString(hoverText).X; - // Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f, 0f); - // if (vector.Y > (float)(Main.screenHeight - 30)) - // { - // vector.Y = (float)(Main.screenHeight - 30); - // } - // if (vector.X > (float)(Parent.GetDimensions().Width + Parent.GetDimensions().X - x - 16)) - // { - // vector.X = (float)(Parent.GetDimensions().Width + Parent.GetDimensions().X - x - 16); - // } - // Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, hoverText, vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f); - //} } - - //public override void MouseOver(UIMouseEvent evt) - //{ - // base.MouseOver(evt); - // Main.PlaySound(12, -1, -1, 1, 1f, 0f); - //} } } diff --git a/UIHoverImageButton.cs b/UIHoverImageButton.cs index c7ba16c..a35c2c1 100644 --- a/UIHoverImageButton.cs +++ b/UIHoverImageButton.cs @@ -1,12 +1,5 @@ using ItemChecklist.UI; -using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria; using Terraria.GameContent.UI.Elements; namespace ItemChecklist @@ -26,17 +19,6 @@ namespace ItemChecklist if (IsMouseHovering) { ItemChecklistUI.hoverText = hoverText; - //float x = Main.fontMouseText.MeasureString(hoverText).X; - //Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f, 0f); - //if (vector.Y > (float)(Main.screenHeight - 30)) - //{ - // vector.Y = (float)(Main.screenHeight - 30); - //} - //if (vector.X > (float)(Parent.GetDimensions().Width + Parent.GetDimensions().X - x - 16)) - //{ - // vector.X = (float)(Parent.GetDimensions().Width + Parent.GetDimensions().X - x - 16); - //} - //Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, hoverText, vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f); } } } diff --git a/UIToggleHoverImageButton.cs b/UIToggleHoverImageButton.cs index 9353bf9..9d2529f 100644 --- a/UIToggleHoverImageButton.cs +++ b/UIToggleHoverImageButton.cs @@ -1,17 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria.UI; using ItemChecklist.UI; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria; -using Terraria.GameContent.UI.Elements; namespace Terraria.GameContent.UI.Elements {