mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-18 05:01:13 +00:00
(svn r5872) - Feature: Add an icon to the SDL openttd executable.
This commit is contained in:
parent
00aaf8b8f1
commit
b1b0b26fc8
4
Makefile
4
Makefile
@ -616,6 +616,10 @@ endif
|
||||
ifdef USE_HOMEDIR
|
||||
CDEFS += -DUSE_HOMEDIR
|
||||
endif
|
||||
|
||||
ifdef ICON_DIR
|
||||
CDEFS += -DICON_DIR=\"$(ICON_DIR_PREFIXED)/\"
|
||||
endif
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
|
BIN
media/openttd.32.bmp
Normal file
BIN
media/openttd.32.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
5
sdl.c
5
sdl.c
@ -54,6 +54,11 @@ static const char sdl_files[] =
|
||||
M("SDL_VideoDriverName")
|
||||
M("SDL_ListModes")
|
||||
M("SDL_GetKeyState")
|
||||
M("SDL_LoadBMP_RW")
|
||||
M("SDL_RWFromFile")
|
||||
M("SDL_SetColorKey")
|
||||
M("SDL_WM_SetIcon")
|
||||
M("SDL_MapRGB")
|
||||
M("")
|
||||
;
|
||||
#undef M
|
||||
|
5
sdl.h
5
sdl.h
@ -41,6 +41,11 @@ void SdlClose(uint32 x);
|
||||
void (SDLCALL *SDL_VideoDriverName)(char *, int);
|
||||
SDL_Rect **(SDLCALL *SDL_ListModes)(void *, int);
|
||||
Uint8 *(SDLCALL *SDL_GetKeyState)(int *);
|
||||
SDL_Surface *(SDLCALL *SDL_LoadBMP_RW)(SDL_RWops *, int);
|
||||
SDL_RWops *(SDLCALL *SDL_RWFromFile)(const char *, const char *);
|
||||
int (SDLCALL *SDL_SetColorKey)(SDL_Surface *, Uint32, Uint32);
|
||||
void (SDLCALL *SDL_WM_SetIcon)(SDL_Surface *, Uint8 *);
|
||||
Uint32 (SDLCALL *SDL_MapRGB)(SDL_PixelFormat *, Uint8, Uint8, Uint8);
|
||||
} SDLProcs;
|
||||
|
||||
extern SDLProcs sdl_proc;
|
||||
|
@ -161,15 +161,36 @@ static int GetAvailableVideoMode(int *w, int *h)
|
||||
|
||||
extern const char _openttd_revision[];
|
||||
|
||||
#ifndef ICON_DIR
|
||||
#define ICON_DIR "media"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
/* Let's redefine the LoadBMP macro with because we are dynamically
|
||||
* loading SDL and need to 'SDL_CALL' all functions */
|
||||
#undef SDL_LoadBMP
|
||||
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_CALL SDL_RWFromFile(file, "rb"), 1)
|
||||
#endif
|
||||
|
||||
static bool CreateMainSurface(int w, int h)
|
||||
{
|
||||
SDL_Surface *newscreen;
|
||||
SDL_Surface *newscreen, *icon;
|
||||
char caption[50];
|
||||
|
||||
GetAvailableVideoMode(&w, &h);
|
||||
|
||||
DEBUG(driver, 1) ("sdl: using mode %dx%d", w, h);
|
||||
|
||||
/* Give the application an icon */
|
||||
icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");
|
||||
if (icon != NULL) {
|
||||
/* Get the colourkey, which will be magenta */
|
||||
uint32 rgbmap = SDL_CALL SDL_MapRGB(icon->format, 255, 0, 255);
|
||||
SDL_CALL SDL_SetColorKey(icon, SDL_SRCCOLORKEY, rgbmap);
|
||||
SDL_CALL SDL_WM_SetIcon(icon, NULL);
|
||||
SDL_CALL SDL_FreeSurface(icon);
|
||||
}
|
||||
|
||||
// DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK
|
||||
newscreen = SDL_CALL SDL_SetVideoMode(w, h, 8, SDL_SWSURFACE | SDL_HWPALETTE | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
|
||||
if (newscreen == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user