diff --git a/AllItemsMenu.cs b/AllItemsMenu.cs index a19bc3d..e3cd313 100644 --- a/AllItemsMenu.cs +++ b/AllItemsMenu.cs @@ -74,7 +74,7 @@ public void DrawUpdateAll(SpriteBatch spriteBatch) //((CheatSheet)mod).eventManagerHotbar.Draw(spriteBatch); spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); // DrawUpdateExtraAccessories(spriteBatch); } diff --git a/CheatSheet.cs b/CheatSheet.cs index 4dd5dae..accc26b 100644 --- a/CheatSheet.cs +++ b/CheatSheet.cs @@ -386,6 +386,24 @@ public override void HandlePacket(BinaryReader reader, int whoAmI) break; } } + + public static Rectangle GetClippingRectangle(SpriteBatch spriteBatch, Rectangle r) + { + //Vector2 vector = new Vector2(this._innerDimensions.X, this._innerDimensions.Y); + //Vector2 position = new Vector2(this._innerDimensions.Width, this._innerDimensions.Height) + vector; + Vector2 vector = new Vector2(r.X, r.Y); + Vector2 position = new Vector2(r.Width, r.Height) + vector; + vector = Vector2.Transform(vector, Main.UIScaleMatrix); + position = Vector2.Transform(position, Main.UIScaleMatrix); + Rectangle result = new Rectangle((int)vector.X, (int)vector.Y, (int)(position.X - vector.X), (int)(position.Y - vector.Y)); + int width = spriteBatch.GraphicsDevice.Viewport.Width; + int height = spriteBatch.GraphicsDevice.Viewport.Height; + result.X = Utils.Clamp(result.X, 0, width); + result.Y = Utils.Clamp(result.Y, 0, height); + result.Width = Utils.Clamp(result.Width, 0, width - result.X); + result.Height = Utils.Clamp(result.Height, 0, height - result.Y); + return result; + } } public static class CheatSheetInterface diff --git a/Menus/EventManagerHotbar.cs b/Menus/EventManagerHotbar.cs index 76c32e7..85319ca 100644 --- a/Menus/EventManagerHotbar.cs +++ b/Menus/EventManagerHotbar.cs @@ -260,13 +260,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -283,7 +283,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -291,7 +292,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } // base.Draw(spriteBatch); diff --git a/Menus/NPCButchererHotbar.cs b/Menus/NPCButchererHotbar.cs index 925f40f..8bd8516 100644 --- a/Menus/NPCButchererHotbar.cs +++ b/Menus/NPCButchererHotbar.cs @@ -167,13 +167,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -190,7 +190,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -198,7 +199,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } // base.Draw(spriteBatch); diff --git a/Menus/PaintToolsHotbar.cs b/Menus/PaintToolsHotbar.cs index f84029b..493ee8b 100644 --- a/Menus/PaintToolsHotbar.cs +++ b/Menus/PaintToolsHotbar.cs @@ -143,13 +143,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -166,7 +166,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -174,7 +175,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } //Main.LocalPlayer.showItemIcon = false; if (Visible && !base.IsMouseInside() && (StampToolActive || EyeDropperActive)) diff --git a/Menus/QuickClearHotbar.cs b/Menus/QuickClearHotbar.cs index 14ee41d..aac8982 100644 --- a/Menus/QuickClearHotbar.cs +++ b/Menus/QuickClearHotbar.cs @@ -229,13 +229,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -252,7 +252,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -260,7 +261,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } // base.Draw(spriteBatch); diff --git a/Menus/QuickTeleportHotbar.cs b/Menus/QuickTeleportHotbar.cs index 31b54cc..612486e 100644 --- a/Menus/QuickTeleportHotbar.cs +++ b/Menus/QuickTeleportHotbar.cs @@ -295,13 +295,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -318,7 +318,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -326,7 +327,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } // base.Draw(spriteBatch); diff --git a/Menus/SampleHotbar.cs b/Menus/SampleHotbar.cs index 73a65da..b6520bc 100644 --- a/Menus/SampleHotbar.cs +++ b/Menus/SampleHotbar.cs @@ -91,13 +91,13 @@ public override void Draw(SpriteBatch spriteBatch) if (Visible) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); // Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height); //Parent.Position.Y // Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition); // Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height); Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(mod.hotbar.Position.Y - shownPosition)); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -114,7 +114,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; @@ -122,7 +123,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); } // base.Draw(spriteBatch); diff --git a/UI/UIScrollView.cs b/UI/UIScrollView.cs index f27a627..cc864b3 100644 --- a/UI/UIScrollView.cs +++ b/UI/UIScrollView.cs @@ -235,9 +235,9 @@ public override void Draw(SpriteBatch spriteBatch) if (vector.X <= (float)Main.screenWidth && vector.Y <= (float)Main.screenHeight && vector.X + base.Width >= 0f && vector.Y + base.Height >= 0f) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix); Rectangle scissorRectangle = new Rectangle((int)vector.X, (int)vector.Y, (int)base.Width, (int)base.Height); - if (scissorRectangle.X < 0) + /*if (scissorRectangle.X < 0) { scissorRectangle.Width += scissorRectangle.X; scissorRectangle.X = 0; @@ -254,7 +254,8 @@ public override void Draw(SpriteBatch spriteBatch) if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight) { scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y; - } + }*/ + scissorRectangle = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle); Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle; if (this.OverrideDrawAndUpdate) @@ -267,7 +268,7 @@ public override void Draw(SpriteBatch spriteBatch) } spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, Main.UIScaleMatrix); this.scrollBar.Draw(spriteBatch); } } diff --git a/UI/UITextbox.cs b/UI/UITextbox.cs index 610b8f4..efa47e9 100644 --- a/UI/UITextbox.cs +++ b/UI/UITextbox.cs @@ -265,7 +265,7 @@ public override void Draw(SpriteBatch spriteBatch) OnEnterPress?.Invoke(this, new EventArgs()); } spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); Main.instance.DrawWindowsIMEPanel(new Vector2(98f, (float)(Main.screenHeight - 36)), 0f); } @@ -286,10 +286,10 @@ public override void Draw(SpriteBatch spriteBatch) if (pos.X <= Main.screenWidth && pos.Y <= Main.screenHeight && pos.X + Width >= 0 && pos.Y + Height >= 0) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _rasterizerState); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _rasterizerState, null, Main.UIScaleMatrix); Rectangle cutRect = new Rectangle((int)pos.X, (int)pos.Y, (int)Width, (int)Height); - if (cutRect.X < 0) + /*if (cutRect.X < 0) { cutRect.Width += cutRect.X; cutRect.X = 0; @@ -300,8 +300,8 @@ public override void Draw(SpriteBatch spriteBatch) cutRect.Y = 0; } if (cutRect.X + Width > Main.screenWidth) cutRect.Width = Main.screenWidth - cutRect.X; - if (cutRect.Y + Height > Main.screenHeight) cutRect.Height = Main.screenHeight - cutRect.Y; - + if (cutRect.Y + Height > Main.screenHeight) cutRect.Height = Main.screenHeight - cutRect.Y;*/ + cutRect = CheatSheet.GetClippingRectangle(spriteBatch, cutRect); Rectangle currentRect = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = cutRect; @@ -309,7 +309,7 @@ public override void Draw(SpriteBatch spriteBatch) spriteBatch.GraphicsDevice.ScissorRectangle = currentRect; spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, Main.UIScaleMatrix); } } } diff --git a/build.txt b/build.txt index 3b9abc0..9c68c6d 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly, jofairden -version = 0.2.7 +version = 0.2.7.1 displayName = Cheat Sheet homepage = http://forums.terraria.org/index.php?threads/cheat-sheet.41407/ buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*