mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-25 14:04:37 +00:00
Enable Visual Styles
This commit is contained in:
parent
a6a12720ad
commit
77c3dabf79
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
|
*.res
|
||||||
|
11
Makefile
11
Makefile
@ -2,23 +2,20 @@ C_SOURCES = $(shell find ./ -type f -name '*.c')
|
|||||||
C_OBJECTS = $(C_SOURCES:.c=.o)
|
C_OBJECTS = $(C_SOURCES:.c=.o)
|
||||||
|
|
||||||
CFLAGS = -std=c17 -Wno-int-conversion
|
CFLAGS = -std=c17 -Wno-int-conversion
|
||||||
LFLAGS =
|
LFLAGS = -lgdi32
|
||||||
|
|
||||||
# DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall
|
# DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
# This is valid only if this directory is a subdirectory of drive_c
|
|
||||||
install: build
|
|
||||||
cp build/bridge.exe ../bridge.exe
|
|
||||||
|
|
||||||
build: $(C_OBJECTS)
|
build: $(C_OBJECTS)
|
||||||
$(info Linking)
|
$(info Linking)
|
||||||
x86_64-w64-mingw32-gcc $(C_OBJECTS) $(LFLAGS) $(DBGFLAGS) -o build/bridge.exe
|
x86_64-w64-mingw32-windres bridge.rc -O coff -o bridge.res
|
||||||
|
x86_64-w64-mingw32-gcc $(C_OBJECTS) bridge.res $(LFLAGS) $(DBGFLAGS) -o build/bridge.exe
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
x86_64-w64-mingw32-gcc $(CFLAGS) $(DBGFLAGS) -c $< -o $@
|
x86_64-w64-mingw32-gcc $(CFLAGS) $(DBGFLAGS) -c $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(C_OBJECTS) build/bridge.exe
|
rm -f $(C_OBJECTS) build/bridge.exe bridge.res
|
||||||
|
BIN
bridge.ico
Normal file
BIN
bridge.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
32
bridge.manifest
Normal file
32
bridge.manifest
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<assemblyIdentity
|
||||||
|
version="1.0.0.0"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
name="EnderIce2.rpc-bridge"
|
||||||
|
type="win32"
|
||||||
|
/>
|
||||||
|
<description>Simple bridge that allows you to use Discord Rich Presence with Wine games/software.</description>
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity
|
||||||
|
type="win32"
|
||||||
|
name="Microsoft.Windows.Common-Controls"
|
||||||
|
version="6.0.0.0"
|
||||||
|
processorArchitecture="*"
|
||||||
|
publicKeyToken="6595b64144ccf1df"
|
||||||
|
language="*"
|
||||||
|
/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel
|
||||||
|
level="asInvoker"
|
||||||
|
uiAccess="false"
|
||||||
|
/>
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
44
bridge.rc
Normal file
44
bridge.rc
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <windef.h>
|
||||||
|
#include <winuser.h>
|
||||||
|
#include <winresrc.h>
|
||||||
|
|
||||||
|
#define VER_VERSION 1,1,0,0
|
||||||
|
#define VER_VERSION_STR "1.1\0"
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define VER_DEBUG 0
|
||||||
|
#else
|
||||||
|
#define VER_DEBUG VS_FF_DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION VER_VERSION
|
||||||
|
PRODUCTVERSION VER_VERSION
|
||||||
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
|
FILEOS VOS_NT_WINDOWS32
|
||||||
|
FILETYPE VFT_APP
|
||||||
|
FILESUBTYPE VFT2_UNKNOWN
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904E4"
|
||||||
|
BEGIN
|
||||||
|
VALUE "FileDescription", "Simple bridge that allows you to use Discord Rich Presence with Wine games/software."
|
||||||
|
VALUE "FileVersion", VER_VERSION_STR
|
||||||
|
VALUE "InternalName", "bridge"
|
||||||
|
VALUE "LegalCopyright", "Copyright (c) 2024 EnderIce2"
|
||||||
|
VALUE "OriginalFilename", "bridge.exe"
|
||||||
|
VALUE "ProductName", "rpc-bridge"
|
||||||
|
VALUE "ProductVersion", VER_VERSION_STR
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1252
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
IDI_ICON_128 ICON "bridge.ico"
|
||||||
|
|
||||||
|
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST bridge.manifest
|
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 10 KiB |
70
gui.c
70
gui.c
@ -36,8 +36,10 @@ VOID HandleStartButton(BOOL Silent)
|
|||||||
RedrawWindow(item, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
RedrawWindow(item, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
||||||
|
|
||||||
print("Killing %#x, %#lx and waiting for %#lx\n", hIn, hOut, hBridge);
|
print("Killing %#x, %#lx and waiting for %#lx\n", hIn, hOut, hBridge);
|
||||||
TerminateThread(hIn, 0);
|
if (hIn != NULL)
|
||||||
TerminateThread(hOut, 0);
|
TerminateThread(hIn, 0);
|
||||||
|
if (hOut != NULL)
|
||||||
|
TerminateThread(hOut, 0);
|
||||||
WaitForSingleObject(hBridge, INFINITE);
|
WaitForSingleObject(hBridge, INFINITE);
|
||||||
|
|
||||||
EnableWindow(item, TRUE);
|
EnableWindow(item, TRUE);
|
||||||
@ -162,6 +164,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
break;
|
break;
|
||||||
|
case WM_CTLCOLORSTATIC:
|
||||||
|
{
|
||||||
|
HDC hdcStatic = (HDC)wParam;
|
||||||
|
SetBkMode(hdcStatic, TRANSPARENT);
|
||||||
|
return (INT_PTR)(HBRUSH)GetStockObject(NULL_BRUSH);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
@ -204,8 +212,8 @@ VOID SetButtonStyles(INT *btnStartStyle, INT *btnRemoveStyle, INT *btnInstallSty
|
|||||||
CloseServiceHandle(hSCManager);
|
CloseServiceHandle(hSCManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
int WINAPI __WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
LPSTR lpCmdLine, int nCmdShow)
|
LPSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
INT btnStartStyle, btnRemoveStyle, btnInstallStyle;
|
INT btnStartStyle, btnRemoveStyle, btnInstallStyle;
|
||||||
SetButtonStyles(&btnStartStyle, &btnRemoveStyle, &btnInstallStyle);
|
SetButtonStyles(&btnStartStyle, &btnRemoveStyle, &btnInstallStyle);
|
||||||
@ -228,7 +236,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
|
|
||||||
assert(RegisterClassEx(&wc));
|
assert(RegisterClassEx(&wc));
|
||||||
|
|
||||||
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
|
hwnd = CreateWindowEx(WS_EX_WINDOWEDGE,
|
||||||
szClassName,
|
szClassName,
|
||||||
"Discord RPC Bridge",
|
"Discord RPC Bridge",
|
||||||
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME,
|
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME,
|
||||||
@ -237,25 +245,43 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
400, 150,
|
400, 150,
|
||||||
NULL, NULL, hInstance, NULL);
|
NULL, NULL, hInstance, NULL);
|
||||||
|
|
||||||
CreateWindow("STATIC", "Do you want to start, install or remove the bridge?",
|
HICON hIcon = LoadIcon(hInstance, "IDI_ICON_128");
|
||||||
WS_CHILD | WS_VISIBLE | SS_CENTER,
|
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
||||||
0, 0, 400, 50,
|
|
||||||
hwnd, (HMENU)4, hInstance, NULL);
|
|
||||||
|
|
||||||
CreateWindow("BUTTON", "Start",
|
HWND hLbl4 = CreateWindowEx(WS_EX_TRANSPARENT,
|
||||||
btnStartStyle,
|
"STATIC", "Do you want to start, install or remove the bridge?",
|
||||||
50, 50, 100, 30,
|
WS_CHILD | WS_VISIBLE | SS_CENTER,
|
||||||
hwnd, (HMENU)1, hInstance, NULL);
|
0, 15, 400, 25,
|
||||||
|
hwnd, (HMENU)4, hInstance, NULL);
|
||||||
|
|
||||||
CreateWindow("BUTTON", "Install",
|
HWND hbtn1 = CreateWindow("BUTTON", "Start",
|
||||||
btnInstallStyle,
|
btnStartStyle,
|
||||||
150, 50, 100, 30,
|
40, 60, 100, 30,
|
||||||
hwnd, (HMENU)2, hInstance, NULL);
|
hwnd, (HMENU)1, hInstance, NULL);
|
||||||
|
|
||||||
CreateWindow("BUTTON", "Remove",
|
HWND hbtn2 = CreateWindow("BUTTON", "Install",
|
||||||
btnRemoveStyle,
|
btnInstallStyle,
|
||||||
250, 50, 100, 30,
|
150, 60, 100, 30,
|
||||||
hwnd, (HMENU)3, hInstance, NULL);
|
hwnd, (HMENU)2, hInstance, NULL);
|
||||||
|
|
||||||
|
HWND hbtn3 = CreateWindow("BUTTON", "Remove",
|
||||||
|
btnRemoveStyle,
|
||||||
|
260, 60, 100, 30,
|
||||||
|
hwnd, (HMENU)3, hInstance, NULL);
|
||||||
|
|
||||||
|
HDC hDC = GetDC(hwnd);
|
||||||
|
int nHeight = -MulDiv(11, GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
||||||
|
|
||||||
|
HFONT hFont = CreateFont(nHeight, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
|
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||||
|
DEFAULT_PITCH | FF_DONTCARE, TEXT("Segoe UI"));
|
||||||
|
ReleaseDC(hwnd, hDC);
|
||||||
|
|
||||||
|
SendMessage(hwnd, WM_SETFONT, hFont, TRUE);
|
||||||
|
SendMessage(hLbl4, WM_SETFONT, hFont, TRUE);
|
||||||
|
SendMessage(hbtn1, WM_SETFONT, hFont, TRUE);
|
||||||
|
SendMessage(hbtn2, WM_SETFONT, hFont, TRUE);
|
||||||
|
SendMessage(hbtn3, WM_SETFONT, hFont, TRUE);
|
||||||
|
|
||||||
ShowWindow(hwnd, nCmdShow);
|
ShowWindow(hwnd, nCmdShow);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
@ -272,5 +298,5 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
void CreateGUI()
|
void CreateGUI()
|
||||||
{
|
{
|
||||||
ShowWindow(GetConsoleWindow(), SW_MINIMIZE);
|
ShowWindow(GetConsoleWindow(), SW_MINIMIZE);
|
||||||
ExitProcess(WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOWNORMAL));
|
ExitProcess(__WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOWNORMAL));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user