From c8eed372dba3e2eff5df52798800928b47ec7b74 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 30 Jun 2014 22:46:33 +0000 Subject: [PATCH] Updated Windows code to specifically load an icon, otherwise the default window title icon is used. For the Windows release packages, the VS 2013 runtime libraries are now installed with Stella, so the user doesn't need to manually install vcredist. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2944 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/FrameBufferSDL2.cxx | 62 ++++++++++++++++++++++++++++++++++ src/common/FrameBufferSDL2.hxx | 2 +- src/emucore/FrameBuffer.cxx | 5 ++- src/windows/Create_Builds.bat | 4 +-- src/windows/stella.iss | 4 +-- 5 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index 51ccc5ccc..5130e7dd5 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -164,6 +164,7 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode, myOSystem.logMessage(msg, 0); return false; } + setWindowIcon(); } Uint32 renderFlags = SDL_RENDERER_ACCELERATED; @@ -251,6 +252,67 @@ void FrameBufferSDL2::postFrameUpdate() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferSDL2::setWindowIcon() +{ +#if defined(BSPF_WINDOWS) // Currently only needed for Windows + #include "stella.xpm" // The Stella icon + + // Set the window icon + uInt32 w, h, ncols, nbytes; + uInt32 rgba[256], icon[32 * 32]; + uInt8 mask[32][4]; + + sscanf(stella_icon[0], "%u %u %u %u", &w, &h, &ncols, &nbytes); + if((w != 32) || (h != 32) || (ncols > 255) || (nbytes > 1)) + { + myOSystem.logMessage("ERROR: Couldn't load the application icon.", 0); + return; + } + + for(uInt32 i = 0; i < ncols; i++) + { + unsigned char code; + char color[32]; + uInt32 col; + + sscanf(stella_icon[1 + i], "%c c %s", &code, color); + if(!strcmp(color, "None")) + col = 0x00000000; + else if(!strcmp(color, "black")) + col = 0xFF000000; + else if (color[0] == '#') + { + sscanf(color + 1, "%06x", &col); + col |= 0xFF000000; + } + else + { + myOSystem.logMessage("ERROR: Couldn't load the application icon.", 0); + return; + } + rgba[code] = col; + } + + memset(mask, 0, sizeof(mask)); + for(h = 0; h < 32; h++) + { + const char* line = stella_icon[1 + ncols + h]; + for(w = 0; w < 32; w++) + { + icon[w + 32 * h] = rgba[(int)line[w]]; + if(rgba[(int)line[w]] & 0xFF000000) + mask[h][w >> 3] |= 1 << (7 - (w & 0x07)); + } + } + + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32, + 32 * 4, 0xFF0000, 0x00FF00, 0x0000FF, 0xFF000000); + SDL_SetWindowIcon(myWindow, surface); + SDL_FreeSurface(surface); +#endif +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBSurface* FrameBufferSDL2::createSurface(uInt32 w, uInt32 h, const uInt32* data) const diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index c72a4e252..cc0737e0f 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -152,7 +152,7 @@ class FrameBufferSDL2 : public FrameBuffer /** Set the icon for the main SDL window. */ - void setWindowIcon() { } // Not currently needed on any supported systems + void setWindowIcon(); /** This method is called to provide information about the FrameBuffer. diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 6bd80be2d..0c7f5b034 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -251,11 +251,10 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, myMsg.surface = surface(surfaceID); } - // Take care of some items that are only done once per framebuffer creation. - if(myInitializedCount == 1) + // Print initial usage message, but only print it later if the status has changed + if (myInitializedCount == 1) { myOSystem.logMessage(about(), 1); - setWindowIcon(); } else { diff --git a/src/windows/Create_Builds.bat b/src/windows/Create_Builds.bat index 67817a6d8..9bfcbb290 100644 --- a/src/windows/Create_Builds.bat +++ b/src/windows/Create_Builds.bat @@ -87,13 +87,13 @@ mkdir %STELLA_DIR%\docs if %BUILD_32% == 1 ( echo Copying 32-bit files ... copy %RELEASE_32%\Stella.exe %STELLA_DIR%\32-bit - copy %RELEASE_32%\SDL2.dll %STELLA_DIR%\32-bit + copy %RELEASE_32%\*.dll %STELLA_DIR%\32-bit ) if %BUILD_64% == 1 ( echo Copying 64-bit files ... copy %RELEASE_64%\Stella.exe %STELLA_DIR%\64-bit - copy %RELEASE_64%\SDL2.dll %STELLA_DIR%\64-bit + copy %RELEASE_64%\*.dll %STELLA_DIR%\64-bit ) echo Copying DOC files ... diff --git a/src/windows/stella.iss b/src/windows/stella.iss index 03fd9f1e0..56ae86fdc 100755 --- a/src/windows/stella.iss +++ b/src/windows/stella.iss @@ -22,11 +22,11 @@ ArchitecturesAllowed=x64 Name: "eng"; MessagesFile: "compiler:Default.isl" [Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; [Files] Source: "{#STELLA_PATH}\Stella.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#STELLA_PATH}\SDL2.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#STELLA_PATH}\*.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#STELLA_DOCPATH}\*"; DestDir: "{app}\docs"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files