linting 2

This commit is contained in:
lewd-alt
2025-09-14 15:47:53 -07:00
parent 8fb31d38bb
commit bb3bf291e2
17 changed files with 98 additions and 447 deletions

View File

@@ -11,43 +11,33 @@ namespace _2DGAMELIB
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
{
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag, Strength);
}
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
strength = Strength;
disUnit = Unit * DisMag;
double num = 1.0 - Strength;
unitS = disUnit * num;
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
{
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
strength = Strength;
disUnit = Unit * DisMag;
double num = 1.0 - Strength;
unitS = disUnit * 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;
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;
}
public new void Draw(ParT ParT)
{
ParT.Draw(unitS, gd);
if (gh != null)
{
ParT.DrawH(hitUnit, gh);
}
}
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;
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;
}
public new void Draw(Pars Pars)
{

View File

@@ -50,24 +50,12 @@ namespace _2DGAMELIB
public Pars Pars => pars;
public But(Par Par, Action<But> Action)
{
pars = new Pars(Par);
this.Action = Action;
}
public But(ParT ParT, Action<But> Action)
{
pars = new Pars(ParT);
this.Action = Action;
}
public But(Pars Pars, Action<But> Action)
{
pars = Pars;
this.Action = Action;
}
public bool Move(ref Color HitColor)
{
if (Dra && !f2 && pars.IsHit(ref HitColor))
@@ -129,14 +117,6 @@ namespace _2DGAMELIB
}
}
public void Draw(AreM AreM)
{
if (dra)
{
AreM.Draw(pars);
}
}
public void SetHitColor(Med Med)
{
foreach (Par item in pars.EnumAllPar())

View File

@@ -201,22 +201,6 @@ namespace _2DGAMELIB
parss.Add(Pars);
}
public void Draws(Are Are)
{
foreach (Pars item in parss)
{
Are.Draw(item);
}
}
public void Draws(AreM AreM)
{
foreach (Pars item in parss)
{
AreM.Draw(item);
}
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();

View File

@@ -21,8 +21,6 @@ namespace _2DGAMELIB
public Dictionary<Pars, Par> pr;
public List<Dif> Difss => difs;
public int CountX => difs.Count;
public int CountY
@@ -366,26 +364,6 @@ namespace _2DGAMELIB
return difs.FirstOrDefault((Dif d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((Pars ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((Par e) => e.HitColor == HitColor);
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (Dif dif in difs)
{
list.AddRange(dif.GetHitTags(ref HitColor));
}
return list;
}
public List<Par> GetHitPars(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (Dif dif in difs)
{
list.AddRange(dif.GetHitPars(ref HitColor));
}
return list;
}
public bool IsHit(ref Color HitColor)
{
foreach (Dif dif in difs)

View File

@@ -240,10 +240,5 @@ namespace _2DGAMELIB
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
ret = Color.FromArgb(a, r, g, b);
}
public override string ToString()
{
return "H : " + H + " S : " + S + " V : " + V;
}
}
}

View File

@@ -39,30 +39,6 @@ namespace _2DGAMELIB
Difs1.JoinPA();
}
public void JoinPall()
{
foreach (Par item in Difs1.EnumJoinRoot)
{
Difs0.Current.GetPar(Path0).SetJointP(Index, item);
}
foreach (Pars item2 in Difs1.EnumAllPars())
{
Difs1.JoinPA(item2);
}
}
public void JoinPAall()
{
foreach (Par item in Difs1.EnumJoinRoot)
{
Difs0.Current.GetPar(Path0).SetJointPA(Index, item);
}
foreach (Pars item2 in Difs1.EnumAllPars())
{
Difs1.JoinPA(item2);
}
}
public void Set(JointS )
{
Difs0 = .Difs;

View File

@@ -117,33 +117,6 @@ namespace _2DGAMELIB
parT.OP[0].ps[3] = new Vector2D(0.0, parT.RectSize.Y);
}
public bool Double(ref Color HitColor)
{
//TODO fix?
//if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
/*{
tb.Text = parT.Text;
parT.Text = "";
SetRectT();
//Med.BaseControl.Controls.Add(tb);
tb.SelectAll();
tb.Focus();
tb.BringToFront();
return true;
}*/
return false;
}
public void Click(ref Color HitColor)
{
//TODO fix?
/*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}*/
}
public void Dispose()
{
parT.Dispose();

View File

@@ -1,52 +0,0 @@
using System;
namespace _2DGAMELIB
{
public static class Matrix
{
public static MatrixD RotationZ(this double angle)
{
MatrixD result = default(MatrixD);
result.M11 = System.Math.Cos(angle);
result.M12 = System.Math.Sin(angle);
result.M13 = 0.0;
result.M14 = 0.0;
result.M21 = 0.0 - result.M12;
result.M22 = result.M11;
result.M23 = 0.0;
result.M24 = 0.0;
result.M31 = 0.0;
result.M32 = 0.0;
result.M33 = 1.0;
result.M34 = 0.0;
result.M41 = 0.0;
result.M42 = 0.0;
result.M43 = 0.0;
result.M44 = 1.0;
return result;
}
public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
}
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out var r);
TransformCoordinate(ref r, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
}
}

View File

@@ -38,168 +38,6 @@ namespace _2DGAMELIB
public double M44;
public double this[int row, int col]
{
get
{
switch (row)
{
case 0:
switch (col)
{
case 0:
return M11;
case 1:
return M12;
case 2:
return M13;
case 3:
return M14;
default:
error(row, col);
return 0.0;
}
case 1:
switch (col)
{
case 0:
return M21;
case 1:
return M22;
case 2:
return M23;
case 3:
return M24;
default:
error(row, col);
return 0.0;
}
case 2:
switch (col)
{
case 0:
return M31;
case 1:
return M32;
case 2:
return M33;
case 3:
return M34;
default:
error(row, col);
return 0.0;
}
case 3:
switch (col)
{
case 0:
return M41;
case 1:
return M42;
case 2:
return M43;
case 3:
return M44;
default:
error(row, col);
return 0.0;
}
default:
error(row, col);
return 0.0;
}
}
set
{
switch (row)
{
case 0:
switch (col)
{
case 0:
M11 = value;
break;
case 1:
M12 = value;
break;
case 2:
M13 = value;
break;
case 3:
M14 = value;
break;
default:
error(row, col);
break;
}
break;
case 1:
switch (col)
{
case 0:
M21 = value;
break;
case 1:
M22 = value;
break;
case 2:
M23 = value;
break;
case 3:
M24 = value;
break;
default:
error(row, col);
break;
}
break;
case 2:
switch (col)
{
case 0:
M31 = value;
break;
case 1:
M32 = value;
break;
case 2:
M33 = value;
break;
case 3:
M34 = value;
break;
default:
error(row, col);
break;
}
break;
case 3:
switch (col)
{
case 0:
M41 = value;
break;
case 1:
M42 = value;
break;
case 2:
M43 = value;
break;
case 3:
M44 = value;
break;
default:
error(row, col);
break;
}
break;
default:
error(row, col);
break;
}
}
}
public MatrixD(double M11, double M12, double M13, double M14, double M21, double M22, double M23, double M24, double M31, double M32, double M33, double M34, double M41, double M42, double M43, double M44)
{
this.M11 = M11;
@@ -219,17 +57,5 @@ namespace _2DGAMELIB
this.M43 = M43;
this.M44 = M44;
}
private void error(int row, int col)
{
if (row < 0 || row > 3)
{
throw new ArgumentOutOfRangeException("row", "Rows and columns for matrices run from 0 to 3, inclusive.");
}
if (col < 0 || col > 3)
{
throw new ArgumentOutOfRangeException("col", "Rows and columns for matrices run from 0 to 3, inclusive.");
}
}
}
}

View File

@@ -77,12 +77,12 @@ namespace _2DGAMELIB
private static Vector2D GetTP2()
{
return Matrix.TransformCoordinateBP(ref TP1, ref , ref m120);
return Math.TransformCoordinateBP(ref TP1, ref , ref m120);
}
private static Vector2D GetTP3()
{
return Matrix.TransformCoordinateBP(ref TP1, ref , ref m240);
return Math.TransformCoordinateBP(ref TP1, ref , ref m240);
}
public static Vector2D MulX(this Vector2D Vector, double X)

View File

@@ -1,28 +0,0 @@
using System.IO;
using System.Text;
namespace _2DGAMELIB
{
public static class Text
{
public static void ToText(this string str, string Path, Encoding Encoding)
{
using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding);
streamWriter.Write(str);
}
public static string FromText(this string Path)
{
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
return streamReader.ReadToEnd();
}
public static string[] ReadLines(this string Path)
{
return Path.FromText().Replace("\r", "").Split('\n');
}
}
}

View File

@@ -10,33 +10,6 @@ namespace _2DGAMELIB
public double Y;
public double this[int index]
{
get
{
return index switch
{
0 => X,
1 => Y,
_ => throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive."),
};
}
set
{
switch (index)
{
case 0:
X = value;
break;
case 1:
Y = value;
break;
default:
throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive.");
}
}
}
public Vector2D(int x, int y)
{
X = x;

View File

@@ -32,26 +32,14 @@ namespace _2DGAMELIB
return __refvalue(destRef, GLFW.Window);
}
public static unsafe IntPtr WindowToPtr(Window source)
{
var sourceRef = __makeref(source);
var dest = default(IntPtr);
var destRef = __makeref(dest);
*(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
return __refvalue(destRef, IntPtr);
}
public GLFW.Window window;
private uint shader_program;
private uint texture;
private uint vertex_buf;
private uint vao;
public GlImage() { }
public void ImageSetting() { }
public System.Drawing.Point GetCursorPoint() {
double x, y;
Glfw.GetCursorPosition(window, out x, out y);

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
namespace _2DGAMELIB
@@ -21,6 +22,26 @@ namespace _2DGAMELIB
{
return new PointF((float)Vector.X, (float)Vector.Y);
}
public static void ToText(this string str, string Path, Encoding Encoding)
{
using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding);
streamWriter.Write(str);
}
public static string FromText(this string Path)
{
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
return streamReader.ReadToEnd();
}
public static string[] ReadLines(this string Path)
{
return Path.FromText().Replace("\r", "").Split('\n');
}
}
public static class Math
@@ -115,5 +136,50 @@ namespace _2DGAMELIB
return System.Math.Min(Les - 1, System.Math.Max(Sta, Value));
}
public static MatrixD RotationZ(this double angle)
{
MatrixD result = default(MatrixD);
result.M11 = System.Math.Cos(angle);
result.M12 = System.Math.Sin(angle);
result.M13 = 0.0;
result.M14 = 0.0;
result.M21 = 0.0 - result.M12;
result.M22 = result.M11;
result.M23 = 0.0;
result.M24 = 0.0;
result.M31 = 0.0;
result.M32 = 0.0;
result.M33 = 1.0;
result.M34 = 0.0;
result.M41 = 0.0;
result.M42 = 0.0;
result.M43 = 0.0;
result.M44 = 1.0;
return result;
}
public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
}
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out var r);
TransformCoordinate(ref r, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
}
}