Use native window/taskbar icons on Windows
This used to be a feature before the accurate-portable split, I'm just restoring it. Previously, while the EXE itself had a unique icon, the window and taskbar both used the generic 'small' icon, which the original EXE only used for the window. SDL2 gives us a way to assign separate icons to each, but it's a little clunky: it's Windows-only, requires the icons be in .ico format, and needs them to be embedded in the EXE as resource files. Also, for some reason, SDL2 doesn't let us refer to them by name - we have to use their numerical ID.
This commit is contained in:
parent
ad9e3c3e3b
commit
976e2425fc
4 changed files with 24 additions and 2 deletions
|
@ -221,7 +221,6 @@ set(RESOURCES
|
||||||
BITMAP/Credit18.bmp
|
BITMAP/Credit18.bmp
|
||||||
CURSOR/CURSOR_IKA.bmp
|
CURSOR/CURSOR_IKA.bmp
|
||||||
CURSOR/CURSOR_NORMAL.bmp
|
CURSOR/CURSOR_NORMAL.bmp
|
||||||
ICON/ICON_MINI.bmp
|
|
||||||
ORG/Access.org
|
ORG/Access.org
|
||||||
ORG/Anzen.org
|
ORG/Anzen.org
|
||||||
ORG/Balcony.org
|
ORG/Balcony.org
|
||||||
|
@ -277,6 +276,10 @@ else()
|
||||||
list(APPEND RESOURCES "BITMAP/pixel.bmp" "FONT/LiberationMono.ttf")
|
list(APPEND RESOURCES "BITMAP/pixel.bmp" "FONT/LiberationMono.ttf")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
list(APPEND RESOURCES "ICON/ICON_MINI.bmp")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(FIX_BUGS)
|
if(FIX_BUGS)
|
||||||
target_compile_definitions(CSE2 PRIVATE FIX_BUGS)
|
target_compile_definitions(CSE2 PRIVATE FIX_BUGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -58,8 +58,16 @@ BEGIN
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
0 ICON "ICON/0.ico"
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
|
// remains consistent on all systems.
|
||||||
|
0 ICON "ICON/0.ico"
|
||||||
|
1 ICON "ICON/ICON_MINI.ico"
|
||||||
#endif // Japanese resources
|
#endif // Japanese resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,11 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "0");
|
||||||
|
SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "1");
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
@ -274,11 +279,13 @@ int main(int argc, char *argv[])
|
||||||
size_t resource_size;
|
size_t resource_size;
|
||||||
SDL_RWops *rwops;
|
SDL_RWops *rwops;
|
||||||
|
|
||||||
|
#ifndef _WIN32 // On Windows, we use native icons instead (so we can give the taskbar and window separate icons, like the original EXE does)
|
||||||
resource_data = FindResource("ICON_MINI", "ICON", &resource_size);
|
resource_data = FindResource("ICON_MINI", "ICON", &resource_size);
|
||||||
rwops = SDL_RWFromConstMem(resource_data, resource_size);
|
rwops = SDL_RWFromConstMem(resource_data, resource_size);
|
||||||
SDL_Surface *icon_surface = SDL_LoadBMP_RW(rwops, 1);
|
SDL_Surface *icon_surface = SDL_LoadBMP_RW(rwops, 1);
|
||||||
SDL_SetWindowIcon(window, icon_surface);
|
SDL_SetWindowIcon(window, icon_surface);
|
||||||
SDL_FreeSurface(icon_surface);
|
SDL_FreeSurface(icon_surface);
|
||||||
|
#endif
|
||||||
|
|
||||||
resource_data = FindResource("CURSOR_NORMAL", "CURSOR", &resource_size);
|
resource_data = FindResource("CURSOR_NORMAL", "CURSOR", &resource_size);
|
||||||
rwops = SDL_RWFromConstMem(resource_data, resource_size);
|
rwops = SDL_RWFromConstMem(resource_data, resource_size);
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
#else
|
#else
|
||||||
#include "Resource/FONT/LiberationMono.ttf.h"
|
#include "Resource/FONT/LiberationMono.ttf.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _WIN32
|
||||||
#include "Resource/ICON/ICON_MINI.bmp.h"
|
#include "Resource/ICON/ICON_MINI.bmp.h"
|
||||||
|
#endif
|
||||||
#include "Resource/ORG/Access.org.h"
|
#include "Resource/ORG/Access.org.h"
|
||||||
#include "Resource/ORG/Anzen.org.h"
|
#include "Resource/ORG/Anzen.org.h"
|
||||||
#include "Resource/ORG/Balcony.org.h"
|
#include "Resource/ORG/Balcony.org.h"
|
||||||
|
@ -113,7 +115,9 @@ static const struct
|
||||||
#else
|
#else
|
||||||
{"FONT", "FONT", rLiberationMono, sizeof(rLiberationMono)},
|
{"FONT", "FONT", rLiberationMono, sizeof(rLiberationMono)},
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _WIN32
|
||||||
{"ICON", "ICON_MINI", rICON_MINI, sizeof(rICON_MINI)},
|
{"ICON", "ICON_MINI", rICON_MINI, sizeof(rICON_MINI)},
|
||||||
|
#endif
|
||||||
{"ORG", "ACCESS", rAccess, sizeof(rAccess)},
|
{"ORG", "ACCESS", rAccess, sizeof(rAccess)},
|
||||||
{"ORG", "ANZEN", rAnzen, sizeof(rAnzen)},
|
{"ORG", "ANZEN", rAnzen, sizeof(rAnzen)},
|
||||||
{"ORG", "BALCONY", rBalcony, sizeof(rBalcony)},
|
{"ORG", "BALCONY", rBalcony, sizeof(rBalcony)},
|
||||||
|
|
Loading…
Add table
Reference in a new issue