daily update on 20240613 by nitload youmu[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[C[4
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
@@ -47,7 +48,7 @@ namespace StgSharp.Logic
|
||||
|
||||
private int _frameCount;
|
||||
private int _frameSpeed;
|
||||
private ViewPort context;
|
||||
private ViewPort viewPortDisplay;
|
||||
|
||||
internal IntPtr monitor;
|
||||
|
||||
@@ -57,7 +58,11 @@ namespace StgSharp.Logic
|
||||
|
||||
protected ViewModelBase(int frameSpeed)
|
||||
{
|
||||
context = new ViewPort();
|
||||
viewPortDisplay = new ViewPort(
|
||||
name: "Hello, Stg#!",
|
||||
size: (800, 600),
|
||||
monitor: IntPtr.Zero
|
||||
);
|
||||
allView = new List<View>();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
@@ -76,11 +81,12 @@ namespace StgSharp.Logic
|
||||
() =>
|
||||
{
|
||||
};
|
||||
_globalKeyAction = new Dictionary<KeyTrigger, Action>();
|
||||
}
|
||||
|
||||
public ViewModelBase(ViewPort vbinding, int framespeed)
|
||||
{
|
||||
context = vbinding;
|
||||
viewPortDisplay = vbinding;
|
||||
allView = new List<View>();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
@@ -88,10 +94,14 @@ namespace StgSharp.Logic
|
||||
fpsCountProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
/*
|
||||
Console.Clear();
|
||||
Console.WriteLine(FrameSpeed);
|
||||
/**/
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
};
|
||||
long frameLength = (FrameSpeed > 0) ? ((1000L * 1000L) / FrameSpeed) : 0;
|
||||
long frameLength = (framespeed > 0) ? ((1000L * 1000L) / framespeed) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(
|
||||
frameLength, TimeSpanProvider.DefaultProvider
|
||||
);
|
||||
@@ -99,6 +109,7 @@ namespace StgSharp.Logic
|
||||
() =>
|
||||
{
|
||||
};
|
||||
_globalKeyAction = new Dictionary<KeyTrigger, Action>();
|
||||
}
|
||||
|
||||
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
|
||||
@@ -110,19 +121,19 @@ namespace StgSharp.Logic
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get => context.Height;
|
||||
set { context.Height = value; }
|
||||
get => viewPortDisplay.Height;
|
||||
set { viewPortDisplay.Height = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => context.Name;
|
||||
get => viewPortDisplay.Name;
|
||||
}
|
||||
|
||||
public bool ShouldClose
|
||||
{
|
||||
get => InternalIO.glfwWindowShouldClose(context.ViewPortID) != 0;
|
||||
set => InternalIO.glfwSetWindowShouldClose(context.ViewPortID, value ? 1 : 0);
|
||||
get => InternalIO.glfwWindowShouldClose(viewPortDisplay.ViewPortID) != 0;
|
||||
set => InternalIO.glfwSetWindowShouldClose(viewPortDisplay.ViewPortID, value ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +148,7 @@ namespace StgSharp.Logic
|
||||
Height = (int)value.Y;
|
||||
if (WindowID != IntPtr.Zero)
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(context.ViewPortID, Width, Height);
|
||||
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,20 +158,20 @@ namespace StgSharp.Logic
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get => context.Width;
|
||||
get => viewPortDisplay.Width;
|
||||
set
|
||||
{
|
||||
context.Width = value;
|
||||
viewPortDisplay.Width = value;
|
||||
if (WindowID != IntPtr.Zero)
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(context.ViewPortID, Width, Height);
|
||||
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe IntPtr WindowID
|
||||
{
|
||||
get => context.ViewPortID;
|
||||
get => viewPortDisplay.ViewPortID;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +181,7 @@ namespace StgSharp.Logic
|
||||
set
|
||||
{
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(context.ViewPortID, handlerPtr);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(viewPortDisplay.ViewPortID, handlerPtr);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1044
|
||||
@@ -186,7 +197,7 @@ namespace StgSharp.Logic
|
||||
public void SetSize(vec2d size)
|
||||
{
|
||||
this.Size = size;
|
||||
InternalIO.glfwSetWindowSize(this.context.ViewPortID, (int)size.X, (int)size.Y);
|
||||
InternalIO.glfwSetWindowSize(this.viewPortDisplay.ViewPortID, (int)size.X, (int)size.Y);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +214,7 @@ namespace StgSharp.Logic
|
||||
public void SetSizeLimit(vec2d minSize, vec2d maxSize)
|
||||
{
|
||||
InternalIO.glfwSetWindowSizeLimits(
|
||||
this.context.ViewPortID,
|
||||
this.viewPortDisplay.ViewPortID,
|
||||
(int)minSize.X,
|
||||
(int)minSize.Y,
|
||||
(int)maxSize.X,
|
||||
@@ -221,7 +232,7 @@ namespace StgSharp.Logic
|
||||
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
|
||||
{
|
||||
//TODO 重做form的尺寸极限控制
|
||||
InternalIO.glfwSetWindowSizeLimits(this.context.ViewPortID, minWidth, minHeight, maxWidth, maxHeight);
|
||||
InternalIO.glfwSetWindowSizeLimits(this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth, maxHeight);
|
||||
}
|
||||
|
||||
#region Key Control
|
||||
@@ -243,7 +254,14 @@ namespace StgSharp.Logic
|
||||
|
||||
#endregion
|
||||
|
||||
protected abstract void BuildGlobalKeyControl();
|
||||
|
||||
private Dictionary<KeyTrigger, Action> _globalKeyAction;
|
||||
|
||||
protected Dictionary<KeyTrigger, Action> GlobalKeyAction
|
||||
{
|
||||
get => _globalKeyAction;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user