Probably Broke something...

This commit is contained in:
lewd-alt
2025-05-06 21:11:32 -07:00
parent 14fdcaf152
commit 449b976f0c
11 changed files with 114 additions and 188 deletions

View File

@@ -30,7 +30,8 @@ public class Lab
}
set
{
if (!Med.BaseControl.Contains(tb))
//TODO fix?
//if (!Med.BaseControl.Contains(tb))
{
SetText(value);
}
@@ -82,7 +83,8 @@ public class Lab
{
if (e.KeyCode == Keys.Return)
{
this.Med.BaseControl.Controls.Remove(tb);
//TODO fix?
//this.Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
e.SuppressKeyPress = true;
}
@@ -92,9 +94,10 @@ public class Lab
{
e.IsInputKey = true;
};
Med.BaseControl.Controls.Add(tb);
Med.BaseControl.Controls.Remove(tb);
((Control)Med.BaseControl).Resize += Lab_Resize;
//TODO fix?
//Med.BaseControl.Controls.Add(tb);
//Med.BaseControl.Controls.Remove(tb);
//((Control)Med.BaseControl).Resize += Lab_Resize;
}
Out[] array = new Out[1] { Shas.Get正方形() };
if (FramColor == Color.Empty || FramColor == Color.Transparent)
@@ -127,7 +130,8 @@ public class Lab
private void Lab_Resize(object sender, EventArgs e)
{
Med.BaseControl.Controls.Remove(tb);
//TODO fix?
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}
@@ -177,12 +181,13 @@ public class Lab
public bool Double(ref Color HitColor)
{
if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
{
tb.Text = parT.Text;
//TODO fix?
//if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
{
tb.Text = parT.Text;
parT.Text = "";
SetRectT();
Med.BaseControl.Controls.Add(tb);
//Med.BaseControl.Controls.Add(tb);
tb.SelectAll();
tb.Focus();
tb.BringToFront();
@@ -193,9 +198,10 @@ public class Lab
public void Click(ref Color HitColor)
{
if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
//TODO fix?
//if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
Med.BaseControl.Controls.Remove(tb);
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}
}
@@ -205,7 +211,8 @@ public class Lab
parT.Dispose();
if (Input)
{
((Control)Med.BaseControl).Resize -= Lab_Resize;
//TODO fix?
//((Control)Med.BaseControl).Resize -= Lab_Resize;
}
if (tb != null)
{

View File

@@ -14,7 +14,7 @@ public class Med
{
public static object obj;
private WPFImage baseControl;
private GlImage baseControl;
public double Unit = 1762.4;
@@ -84,9 +84,9 @@ public class Med
public bool ShowFPS;
public Control BaseControlC => baseControl;
//public Control BaseControlC => baseControl;
public WPFImage BaseControl => baseControl;
public GlImage BaseControl => baseControl;
public double ResMag => resMag;
@@ -109,7 +109,7 @@ public class Med
}
}
public Vector2D CursorPosition => ToBasePosition(baseControl.PointToClient(System.Windows.Forms.Cursor.Position));
public Vector2D CursorPosition => ToBasePosition(baseControl.GetCursorPoint()); //ToBasePosition(baseControl.PointToClient(System.Windows.Forms.Cursor.Position));
public Med()
{
@@ -151,7 +151,7 @@ public class Med
this.GetModes = GetModes;
}
public Size Setting(WPFImage BaseControl)
public Size Setting(GlImage BaseControl)
{
baseControl = BaseControl;
BaseSize = new Size((int)(Base.LocalWidth * Unit), (int)(Base.LocalHeight * Unit));
@@ -168,58 +168,7 @@ public class Med
Modes = GetModes(this);
BaseControl.Image.MouseDown += delegate(object s, System.Windows.Input.MouseButtonEventArgs e)
{
Point Position5 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg2 = MouseButtons.None;
switch (e.ChangedButton)
{
case System.Windows.Input.MouseButton.Left:
arg2 = MouseButtons.Left;
break;
case System.Windows.Input.MouseButton.Middle:
arg2 = MouseButtons.Middle;
break;
case System.Windows.Input.MouseButton.Right:
arg2 = MouseButtons.Right;
break;
case System.Windows.Input.MouseButton.XButton1:
arg2 = MouseButtons.XButton1;
break;
case System.Windows.Input.MouseButton.XButton2:
arg2 = MouseButtons.XButton2;
break;
}
Modes[mode].Down(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
BaseControl.Image.MouseUp += delegate(object s, System.Windows.Input.MouseButtonEventArgs e)
{
Point Position4 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg = MouseButtons.None;
switch (e.ChangedButton)
{
case System.Windows.Input.MouseButton.Left:
arg = MouseButtons.Left;
break;
case System.Windows.Input.MouseButton.Middle:
arg = MouseButtons.Middle;
break;
case System.Windows.Input.MouseButton.Right:
arg = MouseButtons.Right;
break;
case System.Windows.Input.MouseButton.XButton1:
arg = MouseButtons.XButton1;
break;
case System.Windows.Input.MouseButton.XButton2:
arg = MouseButtons.XButton2;
break;
}
Modes[mode].Up(arg, ToBasePosition(Position4), GetHitColor(ref Position4));
};
BaseControl.gl_img.Click = delegate (IntPtr window, GLFW.MouseButton button, InputState state, GLFW.ModifierKeys modifiers)
BaseControl.Click = delegate (IntPtr window, GLFW.MouseButton button, InputState state, GLFW.ModifierKeys modifiers)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
@@ -248,27 +197,13 @@ public class Med
(state == InputState.Press ? Modes[mode].Down : Modes[mode].Up)(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
BaseControl.Image.MouseMove += delegate
{
Point Position3 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.gl_img.Move = delegate (IntPtr window, double x, double y)
BaseControl.Move = delegate (IntPtr window, double x, double y)
{
Point Position3 = new Point((int)x, (int)y);
Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.Image.MouseLeave += delegate
{
Point Position2 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
};
BaseControl.gl_img.Leave = delegate (IntPtr window, bool entered)
BaseControl.Leave = delegate (IntPtr window, bool entered)
{
if (!entered)
{
@@ -279,13 +214,7 @@ public class Med
}
};
BaseControl.Image.MouseWheel += delegate(object s, MouseWheelEventArgs e)
{
Point Position = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), e.Delta, GetHitColor(ref Position));
};
BaseControl.gl_img.Scroll = delegate (IntPtr window, double xo, double yo)
BaseControl.Scroll = delegate (IntPtr window, double xo, double yo)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
@@ -294,44 +223,7 @@ public class Med
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
};
((Control)BaseControl).Resize += delegate
{
if (BaseSize.Width >= BaseSize.Height)
{
double num = (double)BaseSize.Width / (double)BaseSize.Height;
if ((double)baseControl.ClientSize.Width / (double)baseControl.ClientSize.Height <= num)
{
resMag = (double)BaseSize.Width / (double)baseControl.ClientSize.Width;
resVector.X = 0.0;
resVector.Y = ((double)baseControl.ClientSize.Height - (double)BaseSize.Height / resMag) * 0.5;
}
else
{
resMag = (double)BaseSize.Height / (double)baseControl.ClientSize.Height;
resVector.X = ((double)baseControl.ClientSize.Width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
}
else
{
double num2 = (double)BaseSize.Height / (double)BaseSize.Width;
if ((double)baseControl.ClientSize.Height / (double)baseControl.ClientSize.Width <= num2)
{
resMag = (double)BaseSize.Height / (double)baseControl.ClientSize.Height;
resVector.X = ((double)baseControl.ClientSize.Width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
else
{
resMag = (double)BaseSize.Width / (double)baseControl.ClientSize.Width;
resVector.X = 0.0;
resVector.Y = ((double)baseControl.ClientSize.Height - (double)BaseSize.Height / resMag) * 0.5;
}
}
};
BaseControl.gl_img.Resize = delegate (IntPtr window, int width, int height)
BaseControl.Resize = delegate (IntPtr window, int width, int height)
{
//TODO mess with viewport
if (BaseSize.Width >= BaseSize.Height)
@@ -455,7 +347,8 @@ public class Med
if (ShowFPS)
{
baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
//TODO fix
//baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
}
Application.DoEvents();
baseControl.PollEvents();
@@ -498,7 +391,9 @@ public class Med
public void InvokeL(Action a)
{
baseControl.Invoke(a);
//TODO this look right?
a();
//baseControl.Invoke(a);
}
public Color GetUniqueColor()

View File

@@ -1,20 +1,18 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Forms;
namespace _2DGAMELIB;
public class UI : Form
public class UI //: Form
{
private Med Med;
private IContainer components;
private WPFImage wpfImage1;
private GlImage wpfImage1;
private System.Windows.Controls.Image hostedComponent1;
@@ -24,14 +22,15 @@ public class UI : Form
public UI(Med Med)
{
InitializeComponent();
this.Med = Med;
this.Med = Med;
InitializeComponent();
}
private void UI_Load(object sender, EventArgs e)
{
base.ClientSize = Med.Setting(wpfImage1);
base.ClientSize = new Size(1024, 768);
//base.ClientSize =
Med.Setting(wpfImage1);
//base.ClientSize = new Size(1024, 768);
try
{
if (!File.Exists(ConfigPath))
@@ -50,7 +49,7 @@ public class UI : Form
}
if (BigWindow)
{
base.ClientSize = new Size(1280, 960);
//base.ClientSize = new Size(1280, 960);
}
UI_Resize(null, null);
}
@@ -62,11 +61,12 @@ public class UI : Form
private void UI_Resize(object sender, EventArgs e)
{
wpfImage1.ImageSetting();
wpfImage1.Image.Width = (double)base.ClientSize.Width * Med.DpiX;
wpfImage1.Image.Height = (double)base.ClientSize.Height * Med.DpiY;
//wpfImage1.ImageSetting();
//wpfImage1.Image.Width = (double)base.ClientSize.Width * Med.DpiX;
//wpfImage1.Image.Height = (double)base.ClientSize.Height * Med.DpiY;
}
/*
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
@@ -74,15 +74,17 @@ public class UI : Form
components.Dispose();
}
base.Dispose(disposing);
}
}*/
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_2DGAMELIB.UI));
this.wpfImage1 = new _2DGAMELIB.WPFImage();
this.wpfImage1 = new GlImage();
this.hostedComponent1 = new System.Windows.Controls.Image();
base.SuspendLayout();
//base.SuspendLayout();
/*
this.wpfImage1.BackColor = System.Drawing.Color.Black;
this.wpfImage1.Dock = System.Windows.Forms.DockStyle.Fill;
this.wpfImage1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
@@ -90,24 +92,29 @@ public class UI : Form
this.wpfImage1.Name = "wpfImage1";
this.wpfImage1.Text = "wpfImage1";
this.wpfImage1.TabIndex = 0;
this.wpfImage1.Child = this.hostedComponent1;
this.Text = "UI";
this.wpfImage1.Child = this.hostedComponent1;*/
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.Controls.Add(this.wpfImage1);
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
base.Name = "UI";
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
//this.Text = "UI";
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
//base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
//base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//base.Controls.Add(this.wpfImage1);
//base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
//base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
//base.Name = "UI";
//base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
//base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
//beauty
this.wpfImage1.gl_img.Closing = delegate () { UI_FormClosing(null, null); };
this.wpfImage1.Closing = delegate () { UI_FormClosing(null, null); };
base.Load += new System.EventHandler(UI_Load);
base.Resize += new System.EventHandler(UI_Resize);
base.ResumeLayout(false);
//TODO fix?
//base.Load += new System.EventHandler(UI_Load);
UI_Load(null, null);
//base.Resize += new System.EventHandler(UI_Resize);
//base.ResumeLayout(false);
}
}

View File

@@ -28,17 +28,23 @@ public class GlImage
return __refvalue(destRef, GLFW.Window);
}
private GLFW.Window window;
uint shader_program;
uint texture;
uint vertex_buf;
uint vao;
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);
return new System.Drawing.Point((int)x, (int)y);
}
public delegate void ShouldCloseCallback();
public ShouldCloseCallback Closing = delegate () { };
@@ -192,6 +198,7 @@ void main()
}
}
/*
public class WPFImage : ElementHost
{
public GlImage gl_img;
@@ -287,3 +294,4 @@ public class WPFImage : ElementHost
}
}
*/