Files
FNF-i486-Engine/source/utils/PlatformUtil.hx
NAEL2XD 3822dd2425 thing
yes
2025-02-07 15:25:14 +01:00

117 lines
3.0 KiB
Haxe

package utils;
/*
VS DAVE WINDOWS/LINUX/MACOS UTIL
You can use this code while you give credit to it.
65% of the code written by chromasen
35% of the code written by Erizur (cross-platform and extra windows utils)
Windows: You need the Windows SDK (any version) to compile.
Linux: TODO
macOS: TODO
credits to the vs dave team right here uh yeah i love ya guys
*/
#if windows
@:cppFileCode('#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <winuser.h>
#include <dwmapi.h>
#include <strsafe.h>
#include <shellapi.h>
#include <iostream>
#include <string>
#pragma comment(lib, "Dwmapi")
#pragma comment(lib, "Shell32.lib")')
#elseif linux
@:cppFileCode('
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
')
#end
class PlatformUtil
{
#if windows
@:functionCode('
HWND hWnd = GetActiveWindow();
res = SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
if (res)
{
SetLayeredWindowAttributes(hWnd, RGB(1, 1, 1), 0, LWA_COLORKEY);
}
')
#elseif linux
/*
REQUIRES IMPORTING X11 LIBRARIES (Xlib, Xutil, Xatom) to run, even tho it doesnt work
@:functionCode('
Display* display = XOpenDisplay(NULL);
Window wnd;
Atom property = XInternAtom(display, "_NET_WM_WINDOW_OPACITY", False);
int revert;
if(property != None)
{
XGetInputFocus(display, &wnd, &revert);
unsigned long opacity = (0xff000000 / 0xffffffff) * 50;
XChangeProperty(display, wnd, property, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&opacity, 1);
XFlush(display);
}
XCloseDisplay(display);
')
*/
#end
static public function getWindowsTransparent(res:Int = 0) // Only works on windows, otherwise returns 0!
{
return res;
}
#if windows
@:functionCode('
LPCSTR lwDesc = desc.c_str();
res = MessageBox(
NULL,
lwDesc,
NULL,
MB_OK
);
')
#end
static public function sendFakeMsgBox(desc:String = "", res:Int = 0) // TODO: Linux and macOS (will do soon)
{
return res;
}
#if windows
@:functionCode('
HWND hWnd = GetActiveWindow();
res = SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) ^ WS_EX_LAYERED);
if (res)
{
SetLayeredWindowAttributes(hWnd, RGB(1, 1, 1), 1, LWA_COLORKEY);
}
')
#end
static public function getWindowsbackward(res:Int = 0) // Only works on windows, otherwise returns 0!
{
return res;
}
#if windows
@:functionCode('
std::string p(getenv("APPDATA"));
p.append("\\\\Microsoft\\\\Windows\\\\Themes\\\\TranscodedWallpaper");
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)p.c_str(), SPIF_UPDATEINIFILE);
')
#end
static public function updateWallpaper() { // Only works on windows, otherwise returns 0!
return null;
}
}