Add project files.
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
// Utils.cs (patched)
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Speech.Synthesis;
|
||||
using System.Threading;
|
||||
|
||||
namespace Lua
|
||||
{
|
||||
static class Utils
|
||||
{
|
||||
public static readonly SpeechSynthesizer Tts = new SpeechSynthesizer();
|
||||
private static readonly object TtsLock = new object();
|
||||
|
||||
[DllImport("user32.dll")] public static extern short GetAsyncKeyState(int vKey);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern short GetKeyState(int keyCode);
|
||||
[DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo);
|
||||
public const uint MOUSEEVENTF_MOVE = 0x0001;
|
||||
|
||||
const int VK_CAPITAL = 0x14;
|
||||
static bool previousCapsState;
|
||||
|
||||
public static void InitializeCapsState()
|
||||
{
|
||||
previousCapsState = IsCapsLockOn();
|
||||
}
|
||||
|
||||
public static bool IsPressed(int vKey) => (GetAsyncKeyState(vKey) & 0x8000) != 0;
|
||||
public static bool IsCapsLockOn() => (GetKeyState(VK_CAPITAL) & 0x0001) != 0;
|
||||
public static void MoveMouse(int dx, int dy) => mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, UIntPtr.Zero);
|
||||
|
||||
public static void SafeSpeak(string text)
|
||||
{
|
||||
if (!ConfigLoader.ttsEnabled) return;
|
||||
|
||||
lock (TtsLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
Tts.SpeakAsyncCancelAll();
|
||||
Tts.SpeakAsync(text);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowCapsLockStatus()
|
||||
{
|
||||
Console.WriteLine(IsCapsLockOn()
|
||||
? "🚫 Recoil Control: OFF (CapsLock ON)"
|
||||
: $"✅ Recoil Control: ON (CapsLock OFF) | Current Set: {OperatorSets.CurrentSet}");
|
||||
}
|
||||
|
||||
public static void CheckCapsLockChange()
|
||||
{
|
||||
bool caps = IsCapsLockOn();
|
||||
if (caps != previousCapsState)
|
||||
{
|
||||
previousCapsState = caps;
|
||||
ShowCapsLockStatus();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisplayCurrentOperator(string action)
|
||||
{
|
||||
Console.WriteLine($"🎮 {action} | Current Operator: {OperatorSets.CurrentSet}");
|
||||
SafeSpeak(OperatorSets.CurrentSet);
|
||||
}
|
||||
|
||||
public static string ModeHeader()
|
||||
{
|
||||
return ConfigLoader.betaTest
|
||||
? $"🎯 Dev Mode Enabled | Current Set: {OperatorSets.CurrentSet}"
|
||||
: $"🚀 Standard Mode Enabled | Current Set: {OperatorSets.CurrentSet}";
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// NEW: Auto console clear when near bottom
|
||||
// -----------------------------------------------------
|
||||
public static void AutoClearIfNearBottom()
|
||||
{
|
||||
try
|
||||
{
|
||||
int current = Console.CursorTop;
|
||||
int limit = Console.WindowHeight - 2; // keep 2-row buffer
|
||||
|
||||
if (current >= limit)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.WriteLine(ModeHeader());
|
||||
ShowCapsLockStatus();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore if console unavailable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user