diff --git a/icons/app.rc b/icons/app.rc index d2d4df8..d069a6f 100644 --- a/icons/app.rc +++ b/icons/app.rc @@ -1,2 +1,2 @@ -APP_ICON_B ICON "appb.ico" -APP_ICON_K ICON "appk.ico" \ No newline at end of file +1 ICON "appb.ico" +2 ICON "appk.ico" \ No newline at end of file diff --git a/src/main/main.cpp b/src/main/main.cpp index cec3735..ffe023a 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -57,6 +57,8 @@ #include #include #include "SDL_syswm.h" +#define APP_ICON_B 1 +#define APP_ICON_K 2 #endif #include "../../lib/rt64/src/contrib/stb/stb_image.h" @@ -150,9 +152,6 @@ ultramodern::renderer::WindowHandle create_window(ultramodern::gfx_callbacks_t:: #endif window = SDL_CreateWindow("Banjo: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, flags); -#if defined(__linux__) - SetImageAsIcon("icons/app.png", window); -#endif if (window == nullptr) { exit_error("Failed to create window: %s\n", SDL_GetError()); @@ -162,6 +161,15 @@ ultramodern::renderer::WindowHandle create_window(ultramodern::gfx_callbacks_t:: SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(window, &wmInfo); +#if defined(_WIN32) + // There's a 50/50 chance to choose the icon where the smallest variant is either Banjo or Kazooie alone. + bool choose_kazooie_icon = (rand() % 2 == 0); + HICON new_icon = LoadIcon(GetModuleHandle(NULL), choose_kazooie_icon ? MAKEINTRESOURCE(APP_ICON_K) : MAKEINTRESOURCE(APP_ICON_B)); + SendMessage(wmInfo.info.win.window, WM_SETICON, ICON_SMALL2, (LPARAM)(new_icon)); +#elif defined(__linux__) + SetImageAsIcon("icons/app.png", window); +#endif + #if defined(_WIN32) return ultramodern::renderer::WindowHandle{ wmInfo.info.win.window, GetCurrentThreadId() }; #elif defined(__linux__) || defined(__ANDROID__) @@ -573,6 +581,9 @@ int main(int argc, char** argv) { fprintf(stderr, "Failed to preload executable!\n"); } + // Initialize random seed for icon easter egg. + std::srand(std::time(nullptr)); + #ifdef _WIN32 // Set up high resolution timing period. timeBeginPeriod(1);