Added paddings. Added rename to vars. Deleted unused constructor
This commit is contained in:
@@ -9,7 +9,8 @@ namespace _2DGAMELIB
|
||||
|
||||
private double unitS;
|
||||
|
||||
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
|
||||
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength) :
|
||||
base(Unit, XRatio, YRatio, Size, DisMag, HitMag)
|
||||
{
|
||||
SetXYRatio(XRatio, YRatio);
|
||||
base.Size = Size;
|
||||
@@ -20,20 +21,20 @@ namespace _2DGAMELIB
|
||||
unitS = displayUnitScale * num;
|
||||
|
||||
|
||||
WH.Width = (int)(base.LocalWidth * Unit);
|
||||
WH.Height = (int)(base.LocalHeight * Unit);
|
||||
WHA.Width = (int)(base.LocalWidth * displayUnitScale);
|
||||
WHA.Height = (int)(base.LocalHeight * displayUnitScale);
|
||||
DisplayLayer = new Bitmap((int)((double)WH.Width * DisMag * num), (int)((double)WH.Height * DisMag * num));
|
||||
displayOutputSize.Width = (int)(base.LocalWidth * Unit);
|
||||
displayOutputSize.Height = (int)(base.LocalHeight * Unit);
|
||||
displayBufferSize.Width = (int)(base.LocalWidth * displayUnitScale);
|
||||
displayBufferSize.Height = (int)(base.LocalHeight * displayUnitScale);
|
||||
DisplayLayer = new Bitmap((int)((double)displayOutputSize.Width * DisMag * num), (int)((double)displayOutputSize.Height * DisMag * num));
|
||||
displayGraphics = Graphics.FromImage(DisplayLayer);
|
||||
displayGraphics.SmoothingMode = SmoothingMode.None;
|
||||
displayGraphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
|
||||
hitUnitScale = Unit * HitMag;
|
||||
WHH.Width = (int)(base.LocalWidth * hitUnitScale);
|
||||
WHH.Height = (int)(base.LocalHeight * hitUnitScale);
|
||||
HitLayer = new Bitmap(WHH.Width, WHH.Height);
|
||||
hitBufferSize.Width = (int)(base.LocalWidth * hitUnitScale);
|
||||
hitBufferSize.Height = (int)(base.LocalHeight * hitUnitScale);
|
||||
HitLayer = new Bitmap(hitBufferSize.Width, hitBufferSize.Height);
|
||||
hitGraphics = Graphics.FromImage(HitLayer);
|
||||
hitGraphics.SmoothingMode = SmoothingMode.None;
|
||||
hitGraphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
@@ -155,12 +155,29 @@ namespace _2DGAMELIB
|
||||
|
||||
public new void SetDefault()
|
||||
{
|
||||
base.SetDefault();
|
||||
font = new Font("", 1f);
|
||||
brusht = new SolidBrush(Color.Black);
|
||||
brushs = null;
|
||||
stringformat = new StringFormat();
|
||||
}
|
||||
base.SetDefault();
|
||||
|
||||
if (font != null)
|
||||
font.Dispose();
|
||||
|
||||
if (brusht != null)
|
||||
brusht.Dispose();
|
||||
|
||||
if (brushs != null)
|
||||
brushs.Dispose();
|
||||
|
||||
if (stringformat != null)
|
||||
stringformat.Dispose();
|
||||
|
||||
font = new Font("", 1f);
|
||||
brusht = new SolidBrush(Color.Black);
|
||||
brushs = null;
|
||||
stringformat = new StringFormat();
|
||||
|
||||
EditF = true;
|
||||
EditT = true;
|
||||
EditTS = true;
|
||||
}
|
||||
|
||||
public ParT()
|
||||
{
|
||||
@@ -174,23 +191,21 @@ namespace _2DGAMELIB
|
||||
private void CopyT(ParT ParT)
|
||||
{
|
||||
Copy(ParT);
|
||||
|
||||
fontSize = ParT.fontSize;
|
||||
|
||||
if (ParT.font != null)
|
||||
{
|
||||
Font = ParT.font.Copy();
|
||||
}
|
||||
|
||||
if (ParT.brusht != null)
|
||||
{
|
||||
TextBrush = ParT.brusht.Copy();
|
||||
}
|
||||
|
||||
if (ParT.brushs != null)
|
||||
{
|
||||
ShadBrush = ParT.brushs.Copy();
|
||||
}
|
||||
|
||||
if (ParT.stringformat != null)
|
||||
{
|
||||
StringFormat = ParT.stringformat.Copy();
|
||||
}
|
||||
|
||||
positionT = ParT.positionT;
|
||||
rectSize = ParT.rectSize;
|
||||
Text = ParT.Text;
|
||||
@@ -199,13 +214,11 @@ namespace _2DGAMELIB
|
||||
public new void Draw(double Unit, Graphics Graphics)
|
||||
{
|
||||
if (Edit)
|
||||
{
|
||||
EditT = true;
|
||||
}
|
||||
|
||||
if (EditS || EditPS)
|
||||
{
|
||||
EditTS = true;
|
||||
}
|
||||
|
||||
base.Draw(Unit, Graphics);
|
||||
DrawString(Unit, Graphics);
|
||||
}
|
||||
@@ -215,18 +228,23 @@ namespace _2DGAMELIB
|
||||
us = Unit * base.Size;
|
||||
usx = us * base.SizeX;
|
||||
usy = us * base.SizeY;
|
||||
|
||||
bp = base.BasePoint;
|
||||
bp.X *= usx;
|
||||
bp.Y *= usy;
|
||||
|
||||
a0 = base.Angle;
|
||||
a1 = System.Math.PI * a0 / 180.0;
|
||||
M11 = System.Math.Cos(a1);
|
||||
M12 = System.Math.Sin(a1);
|
||||
|
||||
v.X = bp.X * M11 + bp.Y * (0.0 - M12);
|
||||
v.Y = bp.X * M12 + bp.Y * M11;
|
||||
|
||||
p = base.Position;
|
||||
bp.X = p.X * Unit - v.X;
|
||||
bp.Y = p.Y * Unit - v.Y;
|
||||
|
||||
rect.X = (float)(positionT.X * us);
|
||||
rect.Y = (float)(positionT.Y * us);
|
||||
rect.Width = (float)(rectSize.X * us);
|
||||
@@ -261,12 +279,14 @@ namespace _2DGAMELIB
|
||||
Calculation(Unit);
|
||||
EditT = false;
|
||||
}
|
||||
|
||||
if (EditF || EditTS)
|
||||
{
|
||||
RebuildFont((float)(us * fontSize));
|
||||
EditF = false;
|
||||
EditTS = false;
|
||||
}
|
||||
|
||||
af = (float)a0;
|
||||
xf = (float)base.SizeX;
|
||||
yf = (float)base.SizeY;
|
||||
@@ -345,17 +365,18 @@ namespace _2DGAMELIB
|
||||
public void SetStringRectOutline(double Unit, Graphics Graphics)
|
||||
{
|
||||
Vector2D[] stringRectPoints = GetStringRectPoints(Unit, Graphics);
|
||||
Out @out = new Out
|
||||
{
|
||||
Tension = 0f
|
||||
};
|
||||
|
||||
Out @out = new Out { Tension = 0f };
|
||||
Vector2D vector2D = Dat.Vec2DZero - stringRectPoints[0];
|
||||
|
||||
double x = 0.05;
|
||||
double num = 0.025;
|
||||
@out.ps.Add(stringRectPoints[0].AddY(0.0 - num) + vector2D);
|
||||
@out.ps.Add(stringRectPoints[1].AddXY(x, 0.0 - num) + vector2D);
|
||||
|
||||
@out.ps.Add(stringRectPoints[0].AddY(-num) + vector2D);
|
||||
@out.ps.Add(stringRectPoints[1].AddXY(x, -num) + vector2D);
|
||||
@out.ps.Add(stringRectPoints[2].AddXY(x, num) + vector2D);
|
||||
@out.ps.Add(stringRectPoints[3].AddY(num) + vector2D);
|
||||
|
||||
base.OP.Add(@out);
|
||||
}
|
||||
public new void Dispose()
|
||||
|
||||
@@ -19,11 +19,9 @@ namespace _2DGAMELIB
|
||||
protected double displayUnitScale;
|
||||
protected double hitUnitScale;
|
||||
|
||||
private int DrawCals = 0;
|
||||
|
||||
protected Size WH = System.Drawing.Size.Empty;
|
||||
protected Size WHH = System.Drawing.Size.Empty;
|
||||
protected Size WHA = System.Drawing.Size.Empty;
|
||||
protected Size displayOutputSize = System.Drawing.Size.Empty;
|
||||
protected Size hitBufferSize = System.Drawing.Size.Empty;
|
||||
protected Size displayBufferSize = System.Drawing.Size.Empty;
|
||||
|
||||
public Vector2D BasePoint = Dat.Vec2DZero;
|
||||
public Vector2D Position = Dat.Vec2DZero;
|
||||
@@ -34,7 +32,6 @@ namespace _2DGAMELIB
|
||||
public double UnitScale => unitScale;
|
||||
public double DisplayUnitScale => displayUnitScale;
|
||||
|
||||
public RenderArea() { }
|
||||
public RenderArea(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
|
||||
{
|
||||
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag);
|
||||
@@ -58,11 +55,11 @@ namespace _2DGAMELIB
|
||||
base.Size = Size;
|
||||
unitScale = Unit;
|
||||
displayUnitScale = Unit * DisMag;
|
||||
WH.Width = (int)(base.LocalWidth * Unit);
|
||||
WH.Height = (int)(base.LocalHeight * Unit);
|
||||
WHA.Width = (int)(base.LocalWidth * displayUnitScale);
|
||||
WHA.Height = (int)(base.LocalHeight * displayUnitScale);
|
||||
DisplayLayer = new Bitmap((int)((double)WH.Width * DisMag), (int)((double)WH.Height * DisMag));
|
||||
displayOutputSize.Width = (int)(base.LocalWidth * Unit);
|
||||
displayOutputSize.Height = (int)(base.LocalHeight * Unit);
|
||||
displayBufferSize.Width = (int)(base.LocalWidth * displayUnitScale);
|
||||
displayBufferSize.Height = (int)(base.LocalHeight * displayUnitScale);
|
||||
DisplayLayer = new Bitmap((int)((double)displayOutputSize.Width * DisMag), (int)((double)displayOutputSize.Height * DisMag));
|
||||
displayGraphics = Graphics.FromImage(DisplayLayer);
|
||||
|
||||
|
||||
@@ -78,9 +75,9 @@ namespace _2DGAMELIB
|
||||
Setting(Unit, XRatio, YRatio, Size, DisMag);
|
||||
|
||||
hitUnitScale = Unit * HitMag;
|
||||
WHH.Width = (int)(base.LocalWidth * hitUnitScale);
|
||||
WHH.Height = (int)(base.LocalHeight * hitUnitScale);
|
||||
HitLayer = new Bitmap(WHH.Width, WHH.Height);
|
||||
hitBufferSize.Width = (int)(base.LocalWidth * hitUnitScale);
|
||||
hitBufferSize.Height = (int)(base.LocalHeight * hitUnitScale);
|
||||
HitLayer = new Bitmap(hitBufferSize.Width, hitBufferSize.Height);
|
||||
hitGraphics = Graphics.FromImage(HitLayer);
|
||||
|
||||
|
||||
@@ -131,30 +128,30 @@ namespace _2DGAMELIB
|
||||
int x = (int)(p.X * Are.displayUnitScale);
|
||||
int y = (int)(p.Y * Are.displayUnitScale);
|
||||
|
||||
if (Are.DisplayLayer.Width == Are.WHA.Width && Are.DisplayLayer.Height == Are.WHA.Height)
|
||||
if (Are.DisplayLayer.Width == Are.displayBufferSize.Width && Are.DisplayLayer.Height == Are.displayBufferSize.Height)
|
||||
DisplayGraphics.DrawImageUnscaled(Are.DisplayLayer, x, y);
|
||||
else
|
||||
DisplayGraphics.DrawImage(Are.DisplayLayer, x, y, Are.WHA.Width, Are.WHA.Height);
|
||||
DisplayGraphics.DrawImage(Are.DisplayLayer, x, y, Are.displayBufferSize.Width, Are.displayBufferSize.Height);
|
||||
|
||||
if (Are.hitGraphics != null && HitGraphics != null)
|
||||
{
|
||||
HitGraphics.DrawImage(Are.HitLayer, (int)(p.X * Are.hitUnitScale), (int)(p.Y * Are.hitUnitScale), Are.WHH.Width, Are.WHH.Height);
|
||||
HitGraphics.DrawImage(Are.HitLayer, (int)(p.X * Are.hitUnitScale), (int)(p.Y * Are.hitUnitScale), Are.hitBufferSize.Width, Are.hitBufferSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTo(Graphics GD)
|
||||
{
|
||||
Vector2D p = GetPosition();
|
||||
GD.DrawImage(DisplayLayer, (int)(p.X * unitScale), (int)(p.Y * unitScale), WH.Width, WH.Height);
|
||||
GD.DrawImage(DisplayLayer, (int)(p.X * unitScale), (int)(p.Y * unitScale), displayOutputSize.Width, displayOutputSize.Height);
|
||||
}
|
||||
|
||||
public void DrawTo(Graphics displayGraphics, Graphics hitGraphics)
|
||||
{
|
||||
Vector2D p = GetPosition();
|
||||
displayGraphics.DrawImage(DisplayLayer, (int)(p.X * unitScale), (int)(p.Y * unitScale), WH.Width, WH.Height);
|
||||
displayGraphics.DrawImage(DisplayLayer, (int)(p.X * unitScale), (int)(p.Y * unitScale), displayOutputSize.Width, displayOutputSize.Height);
|
||||
if (this.hitGraphics != null)
|
||||
{
|
||||
hitGraphics.DrawImage(HitLayer, (int)(p.X * hitUnitScale), (int)(p.Y * hitUnitScale), WHH.Width, WHH.Height);
|
||||
hitGraphics.DrawImage(HitLayer, (int)(p.X * hitUnitScale), (int)(p.Y * hitUnitScale), hitBufferSize.Width, hitBufferSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user