Skip to content

Commit 27820b0

Browse files
authored
found a cool library
1 parent b9e2505 commit 27820b0

File tree

6 files changed

+11
-34
lines changed

6 files changed

+11
-34
lines changed

.github/workflows/pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
haxelib install firetongue
5050
haxelib install hxgamemode
5151
haxelib install hxdiscord_rpc
52+
haxelib install hxWindowColorMode
5253
haxelib install hxcpp-debug-server
5354
haxelib install extension-androidtools
5455
haxelib install dox

Project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<haxelib name="hscript" />
6969
<haxelib name="polymod" />
7070
<haxelib name="firetongue" />
71+
<haxelib name="hxWindowColorMode" />
7172
<haxelib name="hxgamemode" if="linux" />
7273
<haxelib name="hxdiscord_rpc" if="desktop" />
7374
<haxelib name="hxcpp-debug-server" if="desktop debug" />

docs/docs.hxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-L firetongue
1010
-L hxgamemode
1111
-L hxdiscord_rpc
12+
-L hxWindowColorMode
1213
-L hxcpp-debug-server
1314
-L jsonpath
1415
-L jsonpatch

haxelibs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
"name": "hxgamemode",
7979
"type": "haxelib"
8080
},
81+
{
82+
"name": "hxWindowColorMode",
83+
"type": "haxelib"
84+
},
8185
{
8286
"name": "extension-androidtools",
8387
"type": "haxelib"

source/Main.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import jta.debug.FPS;
55
import jta.video.GlobalVideo;
66
import jta.video.VideoHandler;
77
import jta.video.WebmHandler;
8+
import hxwindowmode.WindowColorMode;
89
#if hxgamemode
910
import hxgamemode.GamemodeClient;
1011
#end
@@ -96,6 +97,9 @@ class Main extends openfl.display.Sprite
9697

9798
jta.util.WindowUtil.init();
9899

100+
WindowColorMode.setDarkMode();
101+
WindowColorMode.redrawWindowHeader();
102+
99103
Lib.current.stage.align = openfl.display.StageAlign.TOP_LEFT;
100104
Lib.current.stage.quality = openfl.display.StageQuality.LOW;
101105
Lib.current.stage.scaleMode = openfl.display.StageScaleMode.NO_SCALE;
@@ -109,10 +113,6 @@ class Main extends openfl.display.Sprite
109113
{
110114
super();
111115

112-
#if windows
113-
jta.api.native.WindowsAPI.darkMode(true);
114-
#end
115-
116116
#if hxdiscord_rpc
117117
jta.api.DiscordClient.load();
118118
#end

source/jta/api/native/WindowsAPI.hx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,11 @@ import lime.app.Application;
66
* Class for Windows API-related functions.
77
*/
88
#if windows
9-
@:buildXml('
10-
<target id="haxe">
11-
<lib name="dwmapi.lib" if="windows" />
12-
</target>
13-
')
149
@:cppFileCode('
1510
#include <Windows.h>
16-
#include <dwmapi.h>
17-
#include <winuser.h>
18-
19-
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
20-
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 // support for windows 11
21-
#endif
2211
')
2312
class WindowsAPI
2413
{
25-
@:functionCode('
26-
int darkMode = enable ? 1 : 0;
27-
HWND window = GetActiveWindow();
28-
if (S_OK != DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, reinterpret_cast<LPCVOID>(&darkMode), sizeof(darkMode)))
29-
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, reinterpret_cast<LPCVOID>(&darkMode), sizeof(darkMode));
30-
')
31-
public static function setDarkMode(enable:Bool):Void {}
32-
33-
/**
34-
* Enables or disables dark mode for the current application window.
35-
* @param enable Whether to enable or disable dark mode.
36-
*/
37-
public static function darkMode(enable:Bool):Void
38-
{
39-
setDarkMode(enable);
40-
Application.current.window.borderless = true;
41-
Application.current.window.borderless = false;
42-
}
43-
4414
@:functionCode('
4515
int result = MessageBox(GetActiveWindow(), message, caption, icon | MB_SETFOREGROUND);
4616
')

0 commit comments

Comments
 (0)