no more windows?

This commit is contained in:
lewd-alt
2025-05-07 10:25:45 -07:00
parent 449b976f0c
commit eecd2a0399
34 changed files with 358 additions and 425 deletions

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Documents;
namespace _2DGAMELIB;

View File

@@ -2,9 +2,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.NetworkInformation;
using System.IO;
using System.Windows.Documents;
using Newtonsoft.Json;
namespace _2DGAMELIB;

View File

@@ -1,6 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _2DGAMELIB;
@@ -18,8 +17,6 @@ public class Lab
private double Min;
private TextBox tb;
public ParT ParT => parT;
public string Text
@@ -46,6 +43,7 @@ public class Lab
public Lab(Med Med, 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, bool Input)
{
//Note: Input is always false
Setting(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input);
}
@@ -60,45 +58,7 @@ public class Lab
this.Are = Are;
this.Width = Width;
this.Input = Input;
if (Input)
{
tb = new TextBox();
tb.WordWrap = true;
tb.Multiline = true;
tb.Text = Text;
tb.ForeColor = TextColor;
tb.BackColor = Color.FromArgb(255, BackColor);
tb.KeyUp += delegate
{
lock (Med.obj)
{
SetText(tb.Text);
parT.Text = "";
SetRectT();
}
};
tb.KeyDown += delegate(object s, KeyEventArgs e)
{
lock (Med.obj)
{
if (e.KeyCode == Keys.Return)
{
//TODO fix?
//this.Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
e.SuppressKeyPress = true;
}
}
};
tb.PreviewKeyDown += delegate(object s, PreviewKeyDownEventArgs e)
{
e.IsInputKey = true;
};
//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)
{
@@ -132,7 +92,7 @@ public class Lab
{
//TODO fix?
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
//SetText(tb.Text);
}
public void SetHitColor(Med Med)
@@ -166,24 +126,27 @@ public class Lab
private void SetRectT()
{
/*
double resMag = Med.ResMag;
Vector2D vector2D = (parT.Position + Are.GetPosition()) * Med.Unit / resMag + Med.ResVector;
tb.Location = new Point((int)vector2D.X - 1, (int)vector2D.Y - 1);
double num = parT.Size * Med.Unit;
if (tb.Font != null)
{
tb.Font.Dispose();
}
tb.Font = new Font(parT.Font.FontFamily, (float)(parT.FontSize * num / resMag));
Vector2D vector2D2 = parT.RectSize * num / resMag;
tb.Size = new Size((int)(vector2D2.X + 2.0), (int)(vector2D2.Y + 10.0));
tb.Size = new Size((int)(vector2D2.X + 2.0), (int)(vector2D2.Y + 10.0));*/
}
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();
@@ -192,18 +155,18 @@ public class Lab
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))
/*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}
}*/
}
public void Dispose()
@@ -214,9 +177,5 @@ public class Lab
//TODO fix?
//((Control)Med.BaseControl).Resize -= Lab_Resize;
}
if (tb != null)
{
tb.Dispose();
}
}
}

View File

@@ -3,10 +3,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Net.Http.Headers;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Input;
namespace _2DGAMELIB;
@@ -186,10 +183,10 @@ public class Med
arg2 = MouseButtons.Right;
break;
case GLFW.MouseButton.Button4:
arg2 = MouseButtons.XButton1;
arg2 = MouseButtons.Button4;
break;
case GLFW.MouseButton.Button5:
arg2 = MouseButtons.XButton2;
arg2 = MouseButtons.Button5;
break;
}
@@ -200,7 +197,7 @@ public class Med
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));
Modes[mode].Move(BaseControl.GetMouseButtons(), ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.Leave = delegate (IntPtr window, bool entered)
@@ -210,7 +207,7 @@ public class Med
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position2 = new Point((int)x, (int)y);
Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
Modes[mode].Leave(BaseControl.GetMouseButtons(), ToBasePosition(Position2), GetHitColor(ref Position2));
}
};
@@ -220,7 +217,7 @@ public class Med
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position = new Point((int)x, (int)y);
//Note: yo may be inverted
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
Modes[mode].Wheel(BaseControl.GetMouseButtons(), ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
};
BaseControl.Resize = delegate (IntPtr window, int width, int height)
@@ -339,24 +336,13 @@ public class Med
while (Drive)
{
long frame_start = FPSF.sw.ElapsedMilliseconds;
FPSF.FPSFixed(action);
long frame_end = FPSF.sw.ElapsedMilliseconds;
if (ShowFPS)
{
//TODO fix
//baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
baseControl.SetTitle(UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2));
}
Application.DoEvents();
baseControl.PollEvents();
long frame_update_end = FPSF.sw.ElapsedMilliseconds;
//System.Diagnostics.Debug.WriteLine("frame time: {0:D}", frame_end - frame_start);
//System.Diagnostics.Debug.WriteLine("event time: {0:D}", frame_update_end - frame_end);
}
}
@@ -375,7 +361,8 @@ public class Med
{
if (cur)
{
System.Windows.Forms.Cursor.Hide();
//TODO fix?
//System.Windows.Forms.Cursor.Hide();
cur = false;
}
}
@@ -383,9 +370,10 @@ public class Med
public void CursorShow()
{
if (!cur)
{
System.Windows.Forms.Cursor.Show();
cur = true;
{
//TODO fix?
//System.Windows.Forms.Cursor.Show();
cur = true;
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _2DGAMELIB;

View File

@@ -2,10 +2,8 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _2DGAMELIB;

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace _2DGAMELIB;

View File

@@ -3,11 +3,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Media.Animation;
namespace _2DGAMELIB;

View File

@@ -2,10 +2,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Windows.Documents;
namespace _2DGAMELIB;

View File

@@ -1,11 +1,11 @@
using System;
using System.Windows.Media;
namespace _2DGAMELIB;
public class SoundPlayer
{
public MediaPlayer mp = new MediaPlayer();
//Todo Fix
//public MediaPlayer mp = new MediaPlayer();
private bool l;
@@ -23,53 +23,36 @@ public class SoundPlayer
{
if (l != value)
{
mp.MediaEnded += loop;
//mp.MediaEnded += loop;
}
}
else if (l != value)
{
mp.MediaEnded -= loop;
//mp.MediaEnded -= loop;
}
l = value;
}
}
public SoundPlayer(string Path)
{
mp.Open(new Uri(Path));
mp.Volume = 1.0;
}
public SoundPlayer(string Path, bool Loop)
{
mp.Open(new Uri(Path));
//mp.Open(new Uri(Path));
this.Loop = Loop;
mp.Volume = 1.0;
}
private void loop(object s, EventArgs e)
{
mp.Position = ts;
mp.Play();
//mp.Volume = 1.0;
}
public void Play()
{
mp.Play();
//mp.Play();
}
public void Stop()
{
mp.Stop();
}
public void Pause()
{
mp.Pause();
//mp.Stop();
}
public void Close()
{
mp.Close();
//mp.Close();
}
}

View File

@@ -2,7 +2,6 @@ using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace _2DGAMELIB;
@@ -14,7 +13,7 @@ public class UI //: Form
private GlImage wpfImage1;
private System.Windows.Controls.Image hostedComponent1;
//private System.Windows.Controls.Image hostedComponent1;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
@@ -54,7 +53,7 @@ public class UI //: Form
UI_Resize(null, null);
}
private void UI_FormClosing(object sender, FormClosingEventArgs e)
private void UI_FormClosing()
{
Med.Drive = false;
}
@@ -80,7 +79,7 @@ public class UI //: Form
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_2DGAMELIB.UI));
this.wpfImage1 = new GlImage();
this.hostedComponent1 = new System.Windows.Controls.Image();
//this.hostedComponent1 = new System.Windows.Controls.Image();
//base.SuspendLayout();
@@ -109,7 +108,7 @@ public class UI //: Form
//base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
//beauty
this.wpfImage1.Closing = delegate () { UI_FormClosing(null, null); };
this.wpfImage1.Closing = delegate () { UI_FormClosing(); };
//TODO fix?
//base.Load += new System.EventHandler(UI_Load);

View File

@@ -3,18 +3,20 @@ using OpenGL;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace _2DGAMELIB;
public enum MouseButtons {
None = 0,
Left = 1,
Right = 2,
Middle = 4,
Button4 = 8,
Button5 = 16
}
public class GlImage
{
@@ -45,6 +47,27 @@ public class GlImage
return new System.Drawing.Point((int)x, (int)y);
}
public MouseButtons GetMouseButtons() {
MouseButtons btns = 0;
if (Glfw.GetMouseButton(window, MouseButton.Left) == InputState.Press)
btns |= MouseButtons.Left;
if (Glfw.GetMouseButton(window, MouseButton.Right) == InputState.Press)
btns |= MouseButtons.Right;
if (Glfw.GetMouseButton(window, MouseButton.Middle) == InputState.Press)
btns |= MouseButtons.Middle;
if (Glfw.GetMouseButton(window, MouseButton.Button4) == InputState.Press)
btns |= MouseButtons.Button4;
if (Glfw.GetMouseButton(window, MouseButton.Button5) == InputState.Press)
btns |= MouseButtons.Button5;
return btns;
}
public delegate void ShouldCloseCallback();
public ShouldCloseCallback Closing = delegate () { };
@@ -54,6 +77,10 @@ public class GlImage
public MouseCallback Scroll = delegate (IntPtr window, double x, double y) { };
public MouseEnterCallback Leave = delegate (IntPtr window, bool entered) { };
public void SetTitle(string title) {
Glfw.SetWindowTitle(window, title);
}
public void PollEvents() {
Glfw.PollEvents();
if (Glfw.WindowShouldClose(window))