Added more readable names for Are(RenderArea)

This commit is contained in:
Absolutely disgusting
2025-10-25 21:25:58 +04:00
parent 96a4535aa1
commit 4edeb09fe1
126 changed files with 568 additions and 577 deletions

View File

@@ -1,185 +0,0 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace _2DGAMELIB
{
public class Are : Rect
{
public Bitmap Dis;
public Bitmap Hit;
protected Graphics gd;
protected Graphics gh;
protected double unit;
protected double disUnit;
protected double hitUnit;
protected Size WH = System.Drawing.Size.Empty;
protected Size WHH = System.Drawing.Size.Empty;
protected Size WHA = System.Drawing.Size.Empty;
public Vector2D BasePoint = Dat.Vec2DZero;
public Vector2D Position = Dat.Vec2DZero;
public Graphics GD => gd;
public Graphics GH => gh;
public double Unit => unit;
public double DisUnit => disUnit;
public Are() { }
public Are(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
{
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag);
}
public Are(Med Med, bool Hit)
{
if (Hit)
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality, Med.HitAccuracy);
}
else
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality);
}
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag)
{
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
disUnit = Unit * DisMag;
WH.Width = (int)(base.LocalWidth * Unit);
WH.Height = (int)(base.LocalHeight * Unit);
WHA.Width = (int)(base.LocalWidth * disUnit);
WHA.Height = (int)(base.LocalHeight * disUnit);
Dis = new Bitmap((int)((double)WH.Width * DisMag), (int)((double)WH.Height * DisMag));
gd = Graphics.FromImage(Dis);
gd.SmoothingMode = SmoothingMode.None;
gd.PixelOffsetMode = PixelOffsetMode.HighSpeed;
gd.InterpolationMode = InterpolationMode.NearestNeighbor;
//needed for text or smthn
gd.CompositingMode = CompositingMode.SourceOver;
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
{
Setting(Unit, XRatio, YRatio, Size, DisMag);
hitUnit = Unit * HitMag;
WHH.Width = (int)(base.LocalWidth * hitUnit);
WHH.Height = (int)(base.LocalHeight * hitUnit);
Hit = new Bitmap(WHH.Width, WHH.Height);
gh = Graphics.FromImage(Hit);
gh.SmoothingMode = SmoothingMode.None;
gh.PixelOffsetMode = PixelOffsetMode.HighSpeed;
gh.InterpolationMode = InterpolationMode.NearestNeighbor;
gh.CompositingMode = CompositingMode.SourceOver;
}
public Vector2D GetPosition()
{
return new Vector2D(Position.X - BasePoint.X * XRatio * Size, Position.Y - BasePoint.Y * YRatio * Size);
}
public void Draw(Par Par)
{
Par.Draw(disUnit, gd);
if (gh != null)
{
Par.DrawH(hitUnit, gh);
}
}
public void Draw(ParT ParT)
{
ParT.Draw(disUnit, gd);
if (gh != null)
{
ParT.DrawH(hitUnit, gh);
}
}
public void Draw(Pars Pars)
{
Pars.Draw(disUnit, gd);
if (gh != null)
{
Pars.DrawH(hitUnit, gh);
}
}
public void Draw(Are Are)
{
Vector2D p = Are.GetPosition();
GD.DrawImage(Are.Dis, (float)(p.X * Are.disUnit), (float)(p.Y * Are.disUnit), Are.WHA.Width, Are.WHA.Height);
if (Are.gh != null && GH != null)
{
GH.DrawImage(Are.Hit, (int)(p.X * Are.hitUnit), (int)(p.Y * Are.hitUnit), Are.WHH.Width, Are.WHH.Height);
}
}
public void DrawTo(Graphics GD)
{
Vector2D p = GetPosition();
GD.DrawImage(Dis, (int)(p.X * unit), (int)(p.Y * unit), WH.Width, WH.Height);
}
public void DrawTo(Graphics GD, Graphics GH)
{
Vector2D p = GetPosition();
GD.DrawImage(Dis, (int)(p.X * unit), (int)(p.Y * unit), WH.Width, WH.Height);
if (gh != null)
{
GH.DrawImage(Hit, (int)(p.X * hitUnit), (int)(p.Y * hitUnit), WHH.Width, WHH.Height);
}
}
public void Clear()
{
gd.Clear(Color.Transparent);
if (gh != null)
{
gh.Clear(Color.Transparent);
}
}
public void Clear(Color Color)
{
gd.Clear(Color);
if (gh != null)
{
gh.Clear(Color.Transparent);
}
}
public void Dispose()
{
Dis.Dispose();
gd.Dispose();
if (Hit != null)
{
Hit.Dispose();
gh.Dispose();
}
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Drawing.Drawing2D;
namespace _2DGAMELIB
{
public class AreM : Are
public class AreM : RenderArea
{
private double strength;
@@ -13,38 +13,38 @@ namespace _2DGAMELIB
{
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
unitScale = Unit;
strength = Strength;
disUnit = Unit * DisMag;
displayUnitScale = Unit * DisMag;
double num = 1.0 - Strength;
unitS = disUnit * num;
unitS = displayUnitScale * num;
WH.Width = (int)(base.LocalWidth * Unit);
WH.Height = (int)(base.LocalHeight * Unit);
WHA.Width = (int)(base.LocalWidth * disUnit);
WHA.Height = (int)(base.LocalHeight * disUnit);
Dis = new Bitmap((int)((double)WH.Width * DisMag * num), (int)((double)WH.Height * DisMag * num));
gd = Graphics.FromImage(Dis);
gd.SmoothingMode = SmoothingMode.None;
gd.PixelOffsetMode = PixelOffsetMode.None;
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));
displayGraphics = Graphics.FromImage(DisplayLayer);
displayGraphics.SmoothingMode = SmoothingMode.None;
displayGraphics.PixelOffsetMode = PixelOffsetMode.None;
hitUnit = Unit * HitMag;
WHH.Width = (int)(base.LocalWidth * hitUnit);
WHH.Height = (int)(base.LocalHeight * hitUnit);
Hit = new Bitmap(WHH.Width, WHH.Height);
gh = Graphics.FromImage(Hit);
gh.SmoothingMode = SmoothingMode.None;
gh.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);
hitGraphics = Graphics.FromImage(HitLayer);
hitGraphics.SmoothingMode = SmoothingMode.None;
hitGraphics.PixelOffsetMode = PixelOffsetMode.None;
}
public new void Draw(Pars Pars)
{
Pars.Draw(unitS, gd);
if (gh != null)
Pars.Draw(unitS, displayGraphics);
if (hitGraphics != null)
{
Pars.DrawH(hitUnit, gh);
Pars.DrawH(hitUnitScale, hitGraphics);
}
}
}

View File

@@ -109,7 +109,7 @@ namespace _2DGAMELIB
return false;
}
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
if (dra)
{

View File

@@ -57,7 +57,7 @@ namespace _2DGAMELIB
}
}
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
foreach (But value in buts.Values)
{

View File

@@ -285,7 +285,7 @@ namespace _2DGAMELIB
}
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
Are.Draw(Current);
}

View File

@@ -7,7 +7,7 @@ namespace _2DGAMELIB
{
private ParT parT;
private Are Are;
private RenderArea Are;
private double Width;
@@ -33,17 +33,17 @@ namespace _2DGAMELIB
SetRect();
}
public Lab(Are Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor)
public Lab(RenderArea Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor)
{
Setting(Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor);
}
public Lab(Are Are, string Name, Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, Color TextColor, Color ShadColor, Color BackColor, Color FramColor)
public Lab(RenderArea Are, string Name, Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, Color TextColor, Color ShadColor, Color BackColor, Color FramColor)
{
Setting(Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor);
}
private void Setting(Are Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor)
private void Setting(RenderArea Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor)
{
this.Are = Are;
this.Width = Width;
@@ -98,7 +98,7 @@ namespace _2DGAMELIB
if (!string.IsNullOrEmpty(parT.Text))
{
parT.RectSize = new Vector2D(Width, 10.0);
Vector2D_2 stringRect = parT.GetStringRect(Are.DisUnit, Are.GD);
Vector2D_2 stringRect = parT.GetStringRect(Are.DisplayUnitScale, Are.DisplayGraphics);
double x = ((stringRect.v2.X > Min) ? stringRect.v2.X : Min) + 0.07;
parT.RectSize = new Vector2D(x, stringRect.v2.Y);
}

View File

@@ -9,11 +9,11 @@ namespace _2DGAMELIB
private Med Med;
private Are Are;
private RenderArea Are;
public Lab this[string Name] => labs[Name];
public Labs(Med Med, Are Are)
public Labs(Med Med, RenderArea Are)
{
this.Med = Med;
this.Are = Are;
@@ -24,7 +24,7 @@ namespace _2DGAMELIB
labs.Add(Name, new Lab(Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor));
}
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
foreach (Lab value in labs.Values)
{

View File

@@ -324,7 +324,7 @@ namespace _2DGAMELIB
}
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
//Note: this is terribly slow...
//would be better to not copy the entire frame

View File

@@ -204,7 +204,7 @@ namespace _2DGAMELIB
public void Draw(Are Are)
public void Draw(RenderArea Are)
{
foreach (Difs value in Difss.Values)
{

View File

@@ -0,0 +1,176 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace _2DGAMELIB
{
//Render Area
public class RenderArea : Rect
{
//Display Layer
public Bitmap DisplayLayer;
//Hit Layer
public Bitmap HitLayer;
protected Graphics displayGraphics;
protected Graphics hitGraphics;
protected double unitScale;
protected double displayUnitScale;
protected double hitUnitScale;
protected Size WH = System.Drawing.Size.Empty;
protected Size WHH = System.Drawing.Size.Empty;
protected Size WHA = System.Drawing.Size.Empty;
public Vector2D BasePoint = Dat.Vec2DZero;
public Vector2D Position = Dat.Vec2DZero;
public Graphics DisplayGraphics => displayGraphics;
public Graphics HitGraphics => hitGraphics;
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);
}
public RenderArea(Med Med, bool Hit)
{
if (Hit)
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality, Med.HitAccuracy);
}
else
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality);
}
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag)
{
SetXYRatio(XRatio, YRatio);
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));
displayGraphics = Graphics.FromImage(DisplayLayer);
displayGraphics.SmoothingMode = SmoothingMode.None;
displayGraphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
displayGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
//needed for text or smthn
displayGraphics.CompositingMode = CompositingMode.SourceOver;
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
{
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);
hitGraphics = Graphics.FromImage(HitLayer);
hitGraphics.SmoothingMode = SmoothingMode.None;
hitGraphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
hitGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
hitGraphics.CompositingMode = CompositingMode.SourceOver;
}
public Vector2D GetPosition()
{
return new Vector2D(Position.X - BasePoint.X * XRatio * Size, Position.Y - BasePoint.Y * YRatio * Size);
}
public void Draw(Par Par)
{
Par.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
Par.DrawH(hitUnitScale, hitGraphics);
}
}
public void Draw(ParT ParT)
{
ParT.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
ParT.DrawH(hitUnitScale, hitGraphics);
}
}
public void Draw(Pars Pars)
{
Pars.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
Pars.DrawH(hitUnitScale, hitGraphics);
}
}
public void Draw(RenderArea Are)
{
Vector2D p = Are.GetPosition();
DisplayGraphics.DrawImage(Are.DisplayLayer, (float)(p.X * Are.displayUnitScale), (float)(p.Y * Are.displayUnitScale), Are.WHA.Width, Are.WHA.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);
}
}
public void DrawTo(Graphics GD)
{
Vector2D p = GetPosition();
GD.DrawImage(DisplayLayer, (int)(p.X * unitScale), (int)(p.Y * unitScale), WH.Width, WH.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);
if (this.hitGraphics != null)
{
hitGraphics.DrawImage(HitLayer, (int)(p.X * hitUnitScale), (int)(p.Y * hitUnitScale), WHH.Width, WHH.Height);
}
}
public void Clear()
{
displayGraphics.Clear(Color.Transparent);
if (hitGraphics != null)
{
hitGraphics.Clear(Color.Transparent);
}
}
public void Clear(Color Color)
{
displayGraphics.Clear(Color);
if (hitGraphics != null)
{
hitGraphics.Clear(Color.Transparent);
}
}
public void Dispose()
{
DisplayLayer.Dispose();
displayGraphics.Dispose();
if (HitLayer != null)
{
HitLayer.Dispose();
hitGraphics.Dispose();
}
}
}
}

View File

@@ -50,12 +50,12 @@ namespace _2DGAMELIB
Graphics.DrawImage(Start, r, 0, 0, w, h, GraphicsUnit.Pixel, ia);
}
public void DrawStart(Are Are)
public void DrawStart(RenderArea Are)
{
Are.DrawTo(GS);
}
public void DrawEnd(Are Are)
public void DrawEnd(RenderArea Are)
{
Are.DrawTo(GE);
}