diff --git a/RecipeBrowserPlayer.cs b/RecipeBrowserPlayer.cs index 630868a..c934785 100644 --- a/RecipeBrowserPlayer.cs +++ b/RecipeBrowserPlayer.cs @@ -13,6 +13,7 @@ public override void ProcessTriggers(TriggersSet triggersSet) if (RecipeBrowser.instance.ToggleRecipeBrowserHotKey.JustPressed) { RecipeBrowser.instance.recipeBrowserTool.visible = !RecipeBrowser.instance.recipeBrowserTool.visible; + // Debug assistance, allows for reinitializing RecipeBrowserUI //if (!RecipeBrowser.instance.recipeBrowserTool.visible) //{ // RecipeBrowserUI.instance.RemoveAllChildren(); diff --git a/RecipeBrowserUI.cs b/RecipeBrowserUI.cs index 6180cdd..e4816e7 100644 --- a/RecipeBrowserUI.cs +++ b/RecipeBrowserUI.cs @@ -51,7 +51,7 @@ public RecipeBrowserUI(UserInterface ui) : base(ui) public override void OnInitialize() { - mainPanel = new UIDragablePanel(); + mainPanel = new UIDragablePanel(true); mainPanel.SetPadding(6); mainPanel.Left.Set(400f, 0f); mainPanel.Top.Set(400f, 0f); @@ -143,7 +143,9 @@ public override void OnInitialize() inlaidPanel.Top.Pixels = 60; //inlaidPanel.Width.Set(-25f, 1f); inlaidPanel.Width.Set(0, 1f); - inlaidPanel.Height.Set(155, 0f); + //inlaidPanel.Height.Set(155, 0f); + // Use to be 155, now is 100% minus top minus what is below. + inlaidPanel.Height.Set(-60 - 121, 1f); inlaidPanel.BackgroundColor = Color.DarkBlue; mainPanel.Append(inlaidPanel); @@ -165,7 +167,7 @@ public override void OnInitialize() recipeGrid.SetScrollbar(lootItemsScrollbar); recipeInfo = new UIRecipeInfo(); - recipeInfo.Top.Pixels = 217; + recipeInfo.Top.Set(-118, 1f); recipeInfo.Width.Set(0, 1f); recipeInfo.Height.Set(120, 0f); mainPanel.Append(recipeInfo); diff --git a/UIElements/UIDragablePanel.cs b/UIElements/UIDragablePanel.cs index 4df4668..51d69c8 100644 --- a/UIElements/UIDragablePanel.cs +++ b/UIElements/UIDragablePanel.cs @@ -2,19 +2,28 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.UI.Elements; +using Terraria.Graphics; using Terraria.UI; namespace RecipeBrowser { class UIDragablePanel : UIPanel { - Vector2 offset; - bool dragging = false; + private static Texture2D dragTexture; + private Vector2 offset; + private bool dragging; + private bool resizeing; + private bool resizeable; - public UIDragablePanel() + public UIDragablePanel(bool resizeable = false) { OnMouseDown += DragStart; OnMouseUp += DragEnd; + this.resizeable = resizeable; + if (dragTexture == null) + { + dragTexture = TextureManager.Load("Images/UI/PanelBorder"); + } } //public override void MouseDown(UIMouseEvent evt) @@ -36,10 +45,19 @@ public UIDragablePanel() private void DragStart(UIMouseEvent evt, UIElement listeningElement) { + CalculatedStyle innerDimensions = GetInnerDimensions(); if (evt.Target == this || evt.Target == RecipeBrowserUI.instance.recipeInfo || evt.Target == RecipeBrowserUI.instance.RadioButtonGroup) { - offset = new Vector2(evt.MousePosition.X - Left.Pixels, evt.MousePosition.Y - Top.Pixels); - dragging = true; + if (new Rectangle((int)(innerDimensions.X + innerDimensions.Width - 12), (int)(innerDimensions.Y + innerDimensions.Height - 12), 12 + 6, 12 + 6).Contains(evt.MousePosition.ToPoint())) + { + offset = new Vector2(evt.MousePosition.X - innerDimensions.X - innerDimensions.Width - 6, evt.MousePosition.Y - innerDimensions.Y - innerDimensions.Height - 6); + resizeing = true; + } + else + { + offset = new Vector2(evt.MousePosition.X - Left.Pixels, evt.MousePosition.Y - Top.Pixels); + dragging = true; + } } } @@ -47,18 +65,19 @@ private void DragEnd(UIMouseEvent evt, UIElement listeningElement) { if (evt.Target == this || evt.Target == RecipeBrowserUI.instance.recipeInfo || evt.Target == RecipeBrowserUI.instance.RadioButtonGroup) { - Vector2 end = evt.MousePosition; + //Vector2 end = evt.MousePosition; dragging = false; + resizeing = false; - Left.Set(end.X - offset.X, 0f); - Top.Set(end.Y - offset.Y, 0f); - - Recalculate(); + //Left.Set(end.X - offset.X, 0f); + //Top.Set(end.Y - offset.Y, 0f); + //Recalculate(); } } protected override void DrawSelf(SpriteBatch spriteBatch) { + CalculatedStyle dimensions = base.GetOuterDimensions(); if (ContainsPoint(Main.MouseScreen)) { Main.LocalPlayer.mouseInterface = true; @@ -70,7 +89,35 @@ protected override void DrawSelf(SpriteBatch spriteBatch) Top.Set(Main.MouseScreen.Y - offset.Y, 0f); Recalculate(); } + if (resizeing) + { + Height.Pixels = Utils.Clamp(Main.MouseScreen.Y - dimensions.Y - offset.Y, 243, 1000); + //Width.Pixels = Utils.Clamp(Main.MouseScreen.X - dimensions.X - offset.X, 415, 1000); + Recalculate(); + } base.DrawSelf(spriteBatch); + if (resizeable) + { + DrawDragAnchor(spriteBatch, dragTexture, this.BorderColor); + } + } + + private void DrawDragAnchor(SpriteBatch spriteBatch, Texture2D texture, Color color) + { + CalculatedStyle dimensions = GetDimensions(); + //CalculatedStyle innerDimensions = GetInnerDimensions(); + + //Rectangle hitbox = new Rectangle((int)(innerDimensions.X + innerDimensions.Width - 12), (int)(innerDimensions.Y + innerDimensions.Height - 12), 12 + 6, 12 + 6); + //Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.LightBlue * 0.6f); + + Point point = new Point((int)dimensions.X, (int)dimensions.Y); + Point point2 = new Point(point.X + (int)dimensions.Width - 12, point.Y + (int)dimensions.Height - 12); + int width = point2.X - point.X - 12; + int height = point2.Y - point.Y - 12; + //spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, 12, 12), new Rectangle?(new Rectangle(12 + 4, 12 + 4, 12, 12)), color); + spriteBatch.Draw(texture, new Rectangle(point2.X - 2, point2.Y - 2, 12 - 2, 12 - 2), new Rectangle?(new Rectangle(12 + 4, 12 + 4, 12, 12)), color); + spriteBatch.Draw(texture, new Rectangle(point2.X - 4, point2.Y - 4, 12 - 4, 12 - 4), new Rectangle?(new Rectangle(12 + 4, 12 + 4, 12, 12)), color); + spriteBatch.Draw(texture, new Rectangle(point2.X - 6, point2.Y - 6, 12 - 6, 12 - 6), new Rectangle?(new Rectangle(12 + 4, 12 + 4, 12, 12)), color); } } } diff --git a/build.txt b/build.txt index b3fc631..8cd08ce 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly -version = 0.2.0.1 +version = 0.2.0.2 displayName = Recipe Browser homepage = http://forums.terraria.org/index.php?threads/cheat-sheet.41407/ buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, unused\*