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 futureSize;
private static bool requireResize;
private static bool debugMode;
/// <summary>
/// Initializes a new instance of the <see cref="Overlay"/> class.
@ -52,11 +53,15 @@ namespace ClickableTransparentOverlay
/// <param name="fps">
/// fps of the overlay
/// </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);
myFps = fps;
isClosed = false;
debugMode = debug;
// Stuff related to (thread safe) resizing of SDL2Window
requireResize = false;
@ -97,10 +102,25 @@ namespace ClickableTransparentOverlay
{
uiThread.Start();
hookController.EnableHooks();
if (!debugMode)
{
NativeMethods.HideConsoleWindow();
}
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>
/// Resizes the overlay
/// </summary>

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