plugin ui
All checks were successful
Build / Compute Version (push) Successful in 17s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 3m5s
Build / Build Nuget package (NuGet) (push) Successful in 2m34s
Build / Build Nuget package (CringePlugins) (push) Successful in 2m56s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m52s
Build / Build Launcher (push) Successful in 3m52s

This commit is contained in:
zznty
2024-11-03 01:58:04 +07:00
parent 271e8a1dde
commit aac79af331
22 changed files with 573 additions and 40 deletions

View File

@@ -18,7 +18,7 @@
<Publicize Include="Sandbox.Game:Sandbox.Engine.Platform.Game.set_DrawThread" />
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.form" />
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.RenderThread_SizeChanged" />
<Publicize Include="VRage.Render11;VRage.Platform.Windows;VRage.Scripting" />
<Publicize Include="VRage.Render;VRage.Render11;VRage.Platform.Windows;VRage.Scripting" IncludeCompilerGeneratedMembers="false" />
</ItemGroup>
<ItemGroup>

View File

@@ -14,20 +14,18 @@ namespace CringeLauncher;
internal class ImGuiHandler : IDisposable
{
private readonly DeviceContext _deviceContext;
private DeviceContext? _deviceContext;
private static nint _wndproc;
public static ImGuiHandler? Instance;
public static RenderTargetView? Rtv;
private readonly IRootRenderComponent _renderHandler;
private readonly IRootRenderComponent _renderHandler = new RenderHandler();
public ImGuiHandler(nint windowHandle, Device1 device, DeviceContext deviceContext)
public void Init(nint windowHandle, Device1 device, DeviceContext deviceContext)
{
_deviceContext = deviceContext;
_renderHandler = new RenderHandler();
CreateContext();
var io = GetIO();
@@ -64,7 +62,7 @@ internal class ImGuiHandler : IDisposable
Render();
_deviceContext.ClearState();
_deviceContext!.ClearState();
_deviceContext.OutputMerger.SetRenderTargets(Rtv);
ImGui_ImplDX11_RenderDrawData(GetDrawData());
@@ -87,7 +85,7 @@ internal class ImGuiHandler : IDisposable
public void Dispose()
{
_deviceContext.Dispose();
_deviceContext?.Dispose();
_renderHandler.Dispose();
}
}

View File

@@ -101,8 +101,8 @@ public class Launcher : ICorePlugin
_renderComponent = new();
_renderComponent.Start(new(), InitEarlyWindow, MyVideoSettingsManager.Initialize(), MyPerGameSettings.MaxFrameRate);
_renderComponent.RenderThread.BeforeDraw += MyFpsManager.Update;
_renderComponent.RenderThread.SizeChanged += RenderThreadOnSizeChanged;
// this technically should wait for render thread init, but who cares
splash.ExecuteLoadingStages();
InitUgc();
@@ -118,21 +118,20 @@ public class Launcher : ICorePlugin
_renderComponent.RenderThread.UpdateSize();
}
private void RenderThreadOnSizeChanged(int width, int height, MyViewport viewport)
{
if (_renderComponent is not null)
_renderComponent.RenderThread.SizeChanged -= RenderThreadOnSizeChanged;
MyVRage.Platform.Windows.Window.ShowAndFocus();
}
public void Run() => _game?.Run();
private static IVRageWindow InitEarlyWindow()
private IVRageWindow InitEarlyWindow()
{
ImGuiHandler.Instance = new();
MyVRage.Platform.Windows.CreateWindow("Cringe Launcher", MyPerGameSettings.GameIcon, null);
MyVRage.Platform.Windows.Window.OnExit += MySandboxGame.ExitThreadSafe;
_renderComponent!.RenderThread.UpdateSize();
MyRenderProxy.RenderThread = _renderComponent.RenderThread;
MyVRage.Platform.Windows.Window.ShowAndFocus();
return MyVRage.Platform.Windows.Window;
}
@@ -157,7 +156,8 @@ public class Launcher : ICorePlugin
private static void InitThreadPool()
{
ParallelTasks.Parallel.Scheduler = new ThreadPoolScheduler();
// ParallelTasks.Parallel.Scheduler = new ThreadPoolScheduler();
MySandboxGame.InitMultithreading();
}
private static void ConfigureSettings()

View File

@@ -60,7 +60,7 @@ public static class SwapChainPatch
[HarmonyPostfix, HarmonyPatch(typeof(MyRender11), nameof(MyRender11.CreateDeviceInternal))]
private static void CreateDevicePostfix()
{
ImGuiHandler.Instance ??= new ImGuiHandler(WindowHandle, MyRender11.DeviceInstance, MyRender11.RC.DeviceContext);
ImGuiHandler.Instance?.Init(WindowHandle, MyRender11.DeviceInstance, MyRender11.RC.DeviceContext);
}
[HarmonyPrefix, HarmonyPatch(typeof(MyBackbuffer), MethodType.Constructor, typeof(SharpDX.Direct3D11.Resource))]

View File

@@ -8,6 +8,7 @@ using CringeTask = ParallelTasks.Task;
namespace CringeLauncher.Utils;
/*
public class ThreadPoolScheduler : IWorkScheduler
{
public void Schedule(CringeTask item)
@@ -82,4 +83,4 @@ internal class ThreadPoolWorkItemTask(CringeTask task) : IThreadPoolWorkItem
HkBaseSystem.QuitThread();
Debug.WriteLine($"Hk Shutdown for {Thread.CurrentThread.Name}");
}
}
}*/