diff --git a/.gitignore b/.gitignore
index 0393442..41b749b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.o
-*.exe
\ No newline at end of file
+*.exe
+*.res
diff --git a/Makefile b/Makefile
index 385f538..c21b5f1 100644
--- a/Makefile
+++ b/Makefile
@@ -2,23 +2,20 @@ C_SOURCES = $(shell find ./ -type f -name '*.c')
C_OBJECTS = $(C_SOURCES:.c=.o)
CFLAGS = -std=c17 -Wno-int-conversion
-LFLAGS =
+LFLAGS = -lgdi32
# DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall
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)
$(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
$(info Compiling $<)
x86_64-w64-mingw32-gcc $(CFLAGS) $(DBGFLAGS) -c $< -o $@
clean:
- rm -f $(C_OBJECTS) build/bridge.exe
+ rm -f $(C_OBJECTS) build/bridge.exe bridge.res
diff --git a/bridge.ico b/bridge.ico
new file mode 100644
index 0000000..c597966
Binary files /dev/null and b/bridge.ico differ
diff --git a/bridge.manifest b/bridge.manifest
new file mode 100644
index 0000000..0aaf206
--- /dev/null
+++ b/bridge.manifest
@@ -0,0 +1,32 @@
+
+
+
+Simple bridge that allows you to use Discord Rich Presence with Wine games/software.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bridge.rc b/bridge.rc
new file mode 100644
index 0000000..cc48ccf
--- /dev/null
+++ b/bridge.rc
@@ -0,0 +1,44 @@
+#include
+#include
+#include
+
+#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
diff --git a/docs/assets/gui.png b/docs/assets/gui.png
index 6f7270f..fcd7103 100644
Binary files a/docs/assets/gui.png and b/docs/assets/gui.png differ
diff --git a/gui.c b/gui.c
index a3c25a3..837cdd0 100644
--- a/gui.c
+++ b/gui.c
@@ -36,8 +36,10 @@ VOID HandleStartButton(BOOL Silent)
RedrawWindow(item, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
print("Killing %#x, %#lx and waiting for %#lx\n", hIn, hOut, hBridge);
- TerminateThread(hIn, 0);
- TerminateThread(hOut, 0);
+ if (hIn != NULL)
+ TerminateThread(hIn, 0);
+ if (hOut != NULL)
+ TerminateThread(hOut, 0);
WaitForSingleObject(hBridge, INFINITE);
EnableWindow(item, TRUE);
@@ -162,6 +164,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
PostQuitMessage(0);
ExitProcess(0);
break;
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdcStatic = (HDC)wParam;
+ SetBkMode(hdcStatic, TRANSPARENT);
+ return (INT_PTR)(HBRUSH)GetStockObject(NULL_BRUSH);
+ }
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
@@ -204,8 +212,8 @@ VOID SetButtonStyles(INT *btnStartStyle, INT *btnRemoveStyle, INT *btnInstallSty
CloseServiceHandle(hSCManager);
}
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
+int WINAPI __WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow)
{
INT btnStartStyle, btnRemoveStyle, btnInstallStyle;
SetButtonStyles(&btnStartStyle, &btnRemoveStyle, &btnInstallStyle);
@@ -228,7 +236,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
assert(RegisterClassEx(&wc));
- hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
+ hwnd = CreateWindowEx(WS_EX_WINDOWEDGE,
szClassName,
"Discord RPC Bridge",
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME,
@@ -237,25 +245,43 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
400, 150,
NULL, NULL, hInstance, NULL);
- CreateWindow("STATIC", "Do you want to start, install or remove the bridge?",
- WS_CHILD | WS_VISIBLE | SS_CENTER,
- 0, 0, 400, 50,
- hwnd, (HMENU)4, hInstance, NULL);
+ HICON hIcon = LoadIcon(hInstance, "IDI_ICON_128");
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
- CreateWindow("BUTTON", "Start",
- btnStartStyle,
- 50, 50, 100, 30,
- hwnd, (HMENU)1, hInstance, NULL);
+ HWND hLbl4 = CreateWindowEx(WS_EX_TRANSPARENT,
+ "STATIC", "Do you want to start, install or remove the bridge?",
+ WS_CHILD | WS_VISIBLE | SS_CENTER,
+ 0, 15, 400, 25,
+ hwnd, (HMENU)4, hInstance, NULL);
- CreateWindow("BUTTON", "Install",
- btnInstallStyle,
- 150, 50, 100, 30,
- hwnd, (HMENU)2, hInstance, NULL);
+ HWND hbtn1 = CreateWindow("BUTTON", "Start",
+ btnStartStyle,
+ 40, 60, 100, 30,
+ hwnd, (HMENU)1, hInstance, NULL);
- CreateWindow("BUTTON", "Remove",
- btnRemoveStyle,
- 250, 50, 100, 30,
- hwnd, (HMENU)3, hInstance, NULL);
+ HWND hbtn2 = CreateWindow("BUTTON", "Install",
+ btnInstallStyle,
+ 150, 60, 100, 30,
+ 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);
UpdateWindow(hwnd);
@@ -272,5 +298,5 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
void CreateGUI()
{
ShowWindow(GetConsoleWindow(), SW_MINIMIZE);
- ExitProcess(WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOWNORMAL));
+ ExitProcess(__WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOWNORMAL));
}
diff --git a/main.c b/main.c
index 2fa40e9..833c8ae 100644
--- a/main.c
+++ b/main.c
@@ -327,3 +327,8 @@ int main(int argc, char *argv[])
fclose(g_logFile);
ExitProcess(0);
}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ return main(__argc, __argv);
+}