Skip to content

Commit

Permalink
0.2.7.1 release, fixed uiscaling except paint tools
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Jun 28, 2017
1 parent 4e756ed commit a65add0
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 36 deletions.
2 changes: 1 addition & 1 deletion AllItemsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 18 additions & 0 deletions CheatSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(result.X, 0, width);
result.Y = Utils.Clamp<int>(result.Y, 0, height);
result.Width = Utils.Clamp<int>(result.Width, 0, width - result.X);
result.Height = Utils.Clamp<int>(result.Height, 0, height - result.Y);
return result;
}
}

public static class CheatSheetInterface
Expand Down
9 changes: 5 additions & 4 deletions Menus/EventManagerHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -283,15 +283,16 @@ 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;

base.Draw(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);
Expand Down
9 changes: 5 additions & 4 deletions Menus/NPCButchererHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -190,15 +190,16 @@ 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;

base.Draw(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);
Expand Down
9 changes: 5 additions & 4 deletions Menus/PaintToolsHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -166,15 +166,16 @@ 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;

base.Draw(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))
Expand Down
9 changes: 5 additions & 4 deletions Menus/QuickClearHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -252,15 +252,16 @@ 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;

base.Draw(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);
Expand Down
9 changes: 5 additions & 4 deletions Menus/QuickTeleportHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -318,15 +318,16 @@ 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;

base.Draw(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);
Expand Down
9 changes: 5 additions & 4 deletions Menus/SampleHotbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -114,15 +114,16 @@ 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;

base.Draw(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);
Expand Down
9 changes: 5 additions & 4 deletions UI/UIScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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);
}
}
Expand Down
12 changes: 6 additions & 6 deletions UI/UITextbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
Expand All @@ -300,16 +300,16 @@ 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;

base.Draw(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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -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\*
Expand Down

0 comments on commit a65add0

Please sign in to comment.