Skip to content

Commit 8424b09

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

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,30 @@ 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)
83+
params.Vsync = configs->vsync;
84+
#if (IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
85+
// This correspond to the program's class name, used by window managers and
86+
// desktop environments to group multiple instances with their desktop file
87+
params.ClassName = EPRO_TEXT("edopro");
88+
params.WindowCaption = EPRO_TEXT("Project Ignis: EDOPro");
89+
params.OGLES2ShaderPath = EPRO_TEXT("BUNDLED");
90+
params.WindowResizable = true;
91+
#if EDOPRO_WINDOWS
92+
params.WindowIcon = MAKEINTRESOURCE(1);
93+
#endif
94+
#if EDOPRO_LINUX
8495
if(configs->useWayland == 2) {
8596
if(!try_guess_wayland())
8697
configs->useWayland = 0;
8798
} else if(configs->useWayland == 1 && try_guess_wayland()) {
8899
params.DeviceType = irr::E_DEVICE_TYPE::EIDT_WAYLAND;
89100
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");
101+
"Keep in mind that it's still experimental and might be unstable.\n"
102+
"If you are getting any major issues, or the game doesn't start,\n"
103+
"you can manually disable this option from the system.conf file by toggling the useWayland option.\n"
104+
"Feel free to report any issues you encounter.\n");
94105
}
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;
99106
#endif
100-
params.Vsync = configs->vsync;
101-
if(configs->driver_type == irr::video::EDT_COUNT)
102-
params.DriverType = getDefaultDriver(params.DeviceType);
103-
else
104-
params.DriverType = configs->driver_type;
105-
#if (IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
106-
params.OGLES2ShaderPath = EPRO_TEXT("BUNDLED");
107-
params.WindowResizable = true;
108107
#if EDOPRO_MACOS
109108
params.UseIntegratedGPU = configs->useIntegratedGpu > 0;
110109
#endif
@@ -118,6 +117,10 @@ irr::IrrlichtDevice* GUIUtils::CreateDevice(GameConfig* configs) {
118117
params.AntiAlias = 0;
119118
params.WindowSize = {};
120119
#endif
120+
if(configs->driver_type == irr::video::EDT_COUNT)
121+
params.DriverType = getDefaultDriver(params.DeviceType);
122+
else
123+
params.DriverType = configs->driver_type;
121124
irr::IrrlichtDevice* device = irr::createDeviceEx(params);
122125
if(!device)
123126
throw std::runtime_error("Failed to create Irrlicht Engine device!");
@@ -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)