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
This commit is contained in:
stephena 2014-06-30 22:46:33 +00:00
parent 21339641d5
commit c8eed372db
5 changed files with 69 additions and 8 deletions

View File

@ -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

View File

@ -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.

View File

@ -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
{

View File

@ -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 ...

View File

@ -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