Added Debug Mode. In this mode overlay will not Hide the Console

Added API to change the FPS
new and improved sample demo
master 1.0.3
Zaafar Ahmed 7 years ago
parent bdf04544c2
commit df8e46aea2
  1. 22
      ClickableTransparentOverlay/Overlay.cs
  2. 76
      DriverProgram/Program.cs

@ -33,6 +33,7 @@ namespace ClickableTransparentOverlay
private static Vector2 futurePos; private static Vector2 futurePos;
private static Vector2 futureSize; private static Vector2 futureSize;
private static bool requireResize; private static bool requireResize;
private static bool debugMode;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Overlay"/> class. /// Initializes a new instance of the <see cref="Overlay"/> class.
@ -52,11 +53,15 @@ namespace ClickableTransparentOverlay
/// <param name="fps"> /// <param name="fps">
/// fps of the overlay /// fps of the overlay
/// </param> /// </param>
public Overlay(int x, int y, int width, int height, int fps) /// <param name="debug">
/// In this mode, overlay will not hide the Console
/// </param>
public Overlay(int x, int y, int width, int height, int fps, bool debug)
{ {
clearColor = new Vector4(0.00f, 0.00f, 0.00f, 0.00f); clearColor = new Vector4(0.00f, 0.00f, 0.00f, 0.00f);
myFps = fps; myFps = fps;
isClosed = false; isClosed = false;
debugMode = debug;
// Stuff related to (thread safe) resizing of SDL2Window // Stuff related to (thread safe) resizing of SDL2Window
requireResize = false; requireResize = false;
@ -97,10 +102,25 @@ namespace ClickableTransparentOverlay
{ {
uiThread.Start(); uiThread.Start();
hookController.EnableHooks(); hookController.EnableHooks();
if (!debugMode)
{
NativeMethods.HideConsoleWindow(); NativeMethods.HideConsoleWindow();
}
Application.Run(new ApplicationContext()); Application.Run(new ApplicationContext());
} }
/// <summary>
/// Set the overlay FPS.
/// </summary>
/// <param name="fps">
/// FPS to set
/// </param>
public void SetFps(int fps)
{
myFps = fps;
}
/// <summary> /// <summary>
/// Resizes the overlay /// Resizes the overlay
/// </summary> /// </summary>

@ -2,52 +2,66 @@
{ {
using ClickableTransparentOverlay; using ClickableTransparentOverlay;
using ImGuiNET; using ImGuiNET;
using System;
using System.Threading; using System.Threading;
class Program class Program
{ {
private static Overlay demo; private static bool isRunning = true;
private static int Width = 2560;
private static int Height = 1440;
private static int Fps = 144; private static int Fps = 144;
private static int RunFor = 10; private static int[] resizeHelper = new int[4] { 0, 0, 2560, 1440 };
static void Main(string[] args) private static int seconds = 5;
{ private static Overlay overlay = new Overlay(0, 0, 2560, 1440, Fps, false);
Console.Write("Enter Screen Width:");
Width = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Screen Height:"); private static void MainApplicationLogic()
Height = Convert.ToInt32(Console.ReadLine()); {
while (isRunning)
{
Thread.Sleep(10);
}
overlay.Dispose();
}
Console.Write("Enter Monitor Max FPS:"); static void Main(string[] args)
Fps = Convert.ToInt32(Console.ReadLine()); {
overlay.SubmitUI += RenderUi;
Thread p = new Thread(MainApplicationLogic);
p.Start();
overlay.Run();
p.Join();
}
Console.Write("You want to run this demo for X (seconds):"); private static void RenderUi(object sender, System.EventArgs e)
RunFor = Convert.ToInt32(Console.ReadLine()); {
if (isRunning)
{
ImGui.ShowDemoWindow(ref isRunning);
}
var EndDemo = new Thread(DistroyDemo); ImGui.Begin("SDL2Window Config", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize);
EndDemo.Start(); ImGui.Text($"Current FPS: {Fps}");
StartDemo(); if (ImGui.SliderInt("Set FPS", ref Fps, 30, 144))
{
overlay.SetFps(Fps);
} }
public static void StartDemo() ImGui.NewLine();
ImGui.Text($"Current Position: {resizeHelper[0]}, {resizeHelper[1]}");
ImGui.Text($"Current Size: {resizeHelper[2]}, {resizeHelper[3]}");
ImGui.SliderInt4("Set Position & Size", ref resizeHelper[0], 0, 3840);
if (ImGui.Button("Resize"))
{ {
demo = new Overlay(0, 0, Width, Height, Fps); overlay.Resize(resizeHelper[0], resizeHelper[1], resizeHelper[2], resizeHelper[3]);
demo.SubmitUI += (object sender, EventArgs e) => ImGui.ShowDemoWindow();
demo.Run();
} }
public static void DistroyDemo() ImGui.NewLine();
ImGui.DragInt("Set Hidden Time", ref seconds);
if (ImGui.Button("Hide for X Seconds"))
{ {
Thread.Sleep(RunFor * 1000); new Thread(() => { Thread.Sleep(seconds * 1000); overlay.Show(); }).Start();
demo.Resize(200, 200, 1024, 1024); overlay.Hide();
Thread.Sleep(RunFor * 1000); }
demo.Hide();
Thread.Sleep(RunFor * 1000); ImGui.End();
demo.Show();
Thread.Sleep(RunFor * 1000);
demo.Dispose();
} }
} }
} }
Loading…
Cancel
Save