Skip to content

Commit 1ba4267

Browse files
committed
Set class name, icon and title via irrlicht creation params
1 parent 4b7c0ea commit 1ba4267

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

gframe/utils_gui.cpp

+32-23
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,34 @@ static inline irr::video::E_DRIVER_TYPE getDefaultDriver(irr::E_DEVICE_TYPE devi
8080
irr::IrrlichtDevice* GUIUtils::CreateDevice(GameConfig* configs) {
8181
irr::SIrrlichtCreationParameters params{};
8282
params.AntiAlias = configs->antialias;
83-
#if EDOPRO_LINUX && (IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
84-
if(configs->useWayland == 2) {
85-
if(!try_guess_wayland())
86-
configs->useWayland = 0;
87-
} else if(configs->useWayland == 1 && try_guess_wayland()) {
88-
params.DeviceType = irr::E_DEVICE_TYPE::EIDT_WAYLAND;
89-
epro::print("You're using the wayland device backend.\n"
90-
"Keep in mind that it's still experimental and might be unstable.\n"
91-
"If you are getting any major issues, or the game doesn't start,\n"
92-
"you can manually disable this option from the system.conf file by toggling the useWayland option.\n"
93-
"Feel free to report any issues you encounter.\n");
94-
}
95-
// This correspond to the program's class name, used by window managers and
96-
// desktop environments to group multiple instances with their desktop file
97-
char class_name[] = "edopro";
98-
params.PrivateData = class_name;
99-
#endif
10083
params.Vsync = configs->vsync;
10184
if(configs->driver_type == irr::video::EDT_COUNT)
10285
params.DriverType = getDefaultDriver(params.DeviceType);
10386
else
10487
params.DriverType = configs->driver_type;
10588
#if (IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
89+
// This correspond to the program's class name, used by window managers and
90+
// desktop environments to group multiple instances with their desktop file
91+
params.ClassName = EPRO_TEXT("edopro");
92+
params.WindowCaption = EPRO_TEXT("Project Ignis: EDOPro");
10693
params.OGLES2ShaderPath = EPRO_TEXT("BUNDLED");
10794
params.WindowResizable = true;
95+
#if EDOPRO_WINDOWS
96+
params.WindowIcon = MAKEINTRESOURCE(1);
97+
#endif
98+
#if EDOPRO_LINUX
99+
if(configs->useWayland == 2) {
100+
if(!try_guess_wayland())
101+
configs->useWayland = 0;
102+
} else if(configs->useWayland == 1 && try_guess_wayland()) {
103+
params.DeviceType = irr::E_DEVICE_TYPE::EIDT_WAYLAND;
104+
epro::print("You're using the wayland device backend.\n"
105+
"Keep in mind that it's still experimental and might be unstable.\n"
106+
"If you are getting any major issues, or the game doesn't start,\n"
107+
"you can manually disable this option from the system.conf file by toggling the useWayland option.\n"
108+
"Feel free to report any issues you encounter.\n");
109+
}
110+
#endif
108111
#if EDOPRO_MACOS
109112
params.UseIntegratedGPU = configs->useIntegratedGpu > 0;
110113
#endif
@@ -144,24 +147,30 @@ irr::IrrlichtDevice* GUIUtils::CreateDevice(GameConfig* configs) {
144147
#endif
145148
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
146149
driver->setTextureCreationFlag(irr::video::ETCF_OPTIMIZED_FOR_QUALITY, true);
147-
device->setWindowCaption(L"Project Ignis: EDOPro");
148150
#if !(IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
151+
device->setWindowCaption(L"Project Ignis: EDOPro");
149152
device->setResizable(true);
150-
#endif
151153
#if EDOPRO_WINDOWS
152154
auto hInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
153155
auto hSmallIcon = static_cast<HICON>(LoadImage(hInstance, MAKEINTRESOURCE(1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), LR_DEFAULTCOLOR));
154156
auto hBigIcon = static_cast<HICON>(LoadImage(hInstance, MAKEINTRESOURCE(1), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR));
155-
auto hWnd = GetWindowHandle(driver);
156-
SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hSmallIcon));
157-
SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hBigIcon));
157+
{
158+
auto hWnd = GetWindowHandle(driver);
159+
SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hSmallIcon));
160+
SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hBigIcon));
161+
}
162+
#endif
163+
#endif
164+
#if EDOPRO_WINDOWS
158165
if(gGameConfig->windowStruct.size()) {
159166
auto winstruct = base64_decode(gGameConfig->windowStruct);
160167
if(winstruct.size() == sizeof(WINDOWPLACEMENT)) {
161168
WINDOWPLACEMENT wp;
162169
memcpy(&wp, winstruct.data(), sizeof(WINDOWPLACEMENT));
163-
if(wp.length == sizeof(WINDOWPLACEMENT))
170+
if(wp.length == sizeof(WINDOWPLACEMENT)) {
171+
auto hWnd = GetWindowHandle(driver);
164172
SetWindowPlacement(hWnd, &wp);
173+
}
165174
}
166175
}
167176
#elif EDOPRO_MACOS

0 commit comments

Comments
 (0)