From 18f04ed2930c70cce6231148945cc24a1c662041 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 5 Aug 2006 00:54:22 +0200 Subject: [PATCH] rnd-20060805-1-src * added Rocks'n'Diamonds icon for use as window icon to SDL version --- ChangeLog | 1 + src/conftime.h | 2 +- src/init.c | 4 +++ src/libgame/sdl.c | 33 ++++++++++++++++++++ src/libgame/system.c | 3 +- src/libgame/system.h | 3 +- src/main.c | 6 ++-- src/main.h | 7 +++-- src/screens.c | 11 ++++--- src/tools.c | 73 +++++++++++++++++++++----------------------- 10 files changed, 93 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9602a817..2911205b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ queue to insert selected stuff into the Windows clipboard, which gets confused with the "Insert" key for jumping to the last editor cascade block in the element list) + * added Rocks'n'Diamonds icon for use as window icon to SDL version 2006-08-01 * added selection of preferred fullscreen mode to setup / graphics menu diff --git a/src/conftime.h b/src/conftime.h index c3718d63..c6479221 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-08-04 19:20]" +#define COMPILE_DATE_STRING "[2006-08-05 00:42]" diff --git a/src/init.c b/src/init.c index cb3703b4..48cd370b 100644 --- a/src/init.c +++ b/src/init.c @@ -4455,6 +4455,7 @@ void InitGfx() { char *filename_font_initial = NULL; Bitmap *bitmap_font_initial = NULL; + int font_height; int i, j; /* determine settings for initial font (for displaying startup messages) */ @@ -4514,8 +4515,11 @@ void InitGfx() InitFontGraphicInfo(); + font_height = getFontHeight(FC_RED); + DrawInitText(getProgramInitString(), 20, FC_YELLOW); DrawInitText(PROGRAM_COPYRIGHT_STRING, 50, FC_RED); + DrawInitText(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height, FC_RED); DrawInitText("Loading graphics:", 120, FC_GREEN); } diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index e478e8aa..732fc9be 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -15,6 +15,7 @@ #include "sound.h" #include "joystick.h" #include "misc.h" +#include "setup.h" #if defined(TARGET_SDL) @@ -60,6 +61,32 @@ static void setFullscreenParameters() } } +static void SDLSetWindowIcon(char *basename) +{ + char *filename = getCustomImageFilename(basename); + SDL_Surface *surface; + + if (filename == NULL) + { + Error(ERR_WARN, "SDLSetWindowIcon(): cannot find file '%s'", basename); + + return; + } + + if ((surface = IMG_Load(filename)) == NULL) + { + Error(ERR_WARN, "IMG_Load() failed: %s", SDL_GetError()); + + return; + } + + /* set transparent color */ + SDL_SetColorKey(surface, SDL_SRCCOLORKEY, + SDL_MapRGB(surface->format, 0x00, 0x00, 0x00)); + + SDL_WM_SetIcon(surface, NULL); +} + void SDLInitVideoDisplay(void) { putenv("SDL_VIDEO_CENTERED=1"); @@ -169,6 +196,9 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, } } + /* set window icon */ + SDLSetWindowIcon(program.sdl_icon_filename); + /* open SDL video output device (window or fullscreen mode) */ if (!SDLSetVideoMode(backbuffer, fullscreen)) Error(ERR_EXIT, "setting video mode failed"); @@ -1465,6 +1495,7 @@ Bitmap *SDLLoadImage(char *filename) if ((sdl_image_tmp = IMG_Load(filename)) == NULL) { SetError("IMG_Load(): %s", SDL_GetError()); + return NULL; } @@ -1472,6 +1503,7 @@ Bitmap *SDLLoadImage(char *filename) if ((new_bitmap->surface = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + return NULL; } @@ -1481,6 +1513,7 @@ Bitmap *SDLLoadImage(char *filename) if ((new_bitmap->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + return NULL; } diff --git a/src/libgame/system.c b/src/libgame/system.c index 709a3511..38e341b0 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -72,7 +72,7 @@ void InitProgramInfo(char *argv0, char *userdata_subdir, char *userdata_subdir_unix, char *program_title, char *window_title, char *icon_title, char *x11_icon_filename, char *x11_iconmask_filename, - char *msdos_cursor_filename, + char *sdl_icon_filename, char *msdos_cursor_filename, char *cookie_prefix, char *filename_prefix, int program_version) { @@ -89,6 +89,7 @@ void InitProgramInfo(char *argv0, program.x11_icon_filename = x11_icon_filename; program.x11_iconmask_filename = x11_iconmask_filename; + program.sdl_icon_filename = sdl_icon_filename; program.msdos_cursor_filename = msdos_cursor_filename; program.cookie_prefix = cookie_prefix; diff --git a/src/libgame/system.h b/src/libgame/system.h index 132e441e..662ca549 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -552,6 +552,7 @@ struct ProgramInfo char *x11_icon_filename; char *x11_iconmask_filename; + char *sdl_icon_filename; char *msdos_cursor_filename; char *cookie_prefix; @@ -1019,7 +1020,7 @@ extern int FrameCounter; /* function definitions */ void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *, - char *, char *, char *, char *, int); + char *, char *, char *, char *, char *, int); void InitExitFunction(void (*exit_function)(int)); void InitPlatformDependentStuff(void); diff --git a/src/main.c b/src/main.c index a663bbcf..6965363b 100644 --- a/src/main.c +++ b/src/main.c @@ -4688,9 +4688,11 @@ static void print_usage() int main(int argc, char *argv[]) { + char * window_title_string = getWindowTitleString(); + InitProgramInfo(argv[0], USERDATA_DIRECTORY, USERDATA_DIRECTORY_UNIX, - PROGRAM_TITLE_STRING, getWindowTitleString(), - ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, + PROGRAM_TITLE_STRING, window_title_string, ICON_TITLE_STRING, + X11_ICON_FILENAME, X11_ICONMASK_FILENAME, SDL_ICON_FILENAME, MSDOS_POINTER_FILENAME, COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); diff --git a/src/main.h b/src/main.h index 9f9b253d..07ce33fb 100644 --- a/src/main.h +++ b/src/main.h @@ -869,7 +869,7 @@ #define MICROLEVEL_XSIZE ((STD_LEV_FIELDX + 2) * MICRO_TILEX) #define MICROLEVEL_YSIZE ((STD_LEV_FIELDY + 2) * MICRO_TILEY) #define MICROLEVEL_XPOS (SX + (SXSIZE - MICROLEVEL_XSIZE) / 2) -#define MICROLEVEL_YPOS (SX + 12 * TILEY - MICRO_TILEY) +#define MICROLEVEL_YPOS (SY + 12 * TILEY - MICRO_TILEY) #define MICROLABEL1_YPOS (MICROLEVEL_YPOS - 36) #define MICROLABEL2_YPOS (MICROLEVEL_YPOS + MICROLEVEL_YSIZE + 7) @@ -1721,7 +1721,9 @@ #define PROGRAM_TITLE_STRING "Rocks'n'Diamonds" #define PROGRAM_AUTHOR_STRING "Holger Schemel" -#define PROGRAM_COPYRIGHT_STRING "Copyright ©1995-2006 by Holger Schemel" +#define PROGRAM_COPYRIGHT_STRING "Copyright ©1995-2006 by Holger Schemel" +#define PROGRAM_EMAIL_STRING "info@artsoft.org" +#define PROGRAM_WEBSITE_STRING "http://www.artsoft.org/" #define ICON_TITLE_STRING PROGRAM_TITLE_STRING #define COOKIE_PREFIX "ROCKSNDIAMONDS" @@ -1744,6 +1746,7 @@ #define X11_ICON_FILENAME "rocks_icon.xbm" #define X11_ICONMASK_FILENAME "rocks_iconmask.xbm" +#define SDL_ICON_FILENAME "rocks_icon_32x32.pcx" #define MSDOS_POINTER_FILENAME "mouse.pcx" /* file version numbers for resource files (levels, tapes, score, setup, etc.) diff --git a/src/screens.c b/src/screens.c index 8a44a96c..adcb8b8e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1789,7 +1789,7 @@ void DrawInfoScreen_Program() DrawTextSCentered(ystart + 1 * ystep, FONT_TEXT_2, "If you like it, send e-mail to:"); DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_3, - "info@artsoft.org"); + PROGRAM_EMAIL_STRING); DrawTextSCentered(ystart + 3 * ystep, FONT_TEXT_2, "or SnailMail to:"); DrawTextSCentered(ystart + 4 * ystep + 0, FONT_TEXT_3, @@ -1800,12 +1800,15 @@ void DrawInfoScreen_Program() "33604 Bielefeld"); DrawTextSCentered(ystart + 4 * ystep + 60, FONT_TEXT_3, "Germany"); - DrawTextSCentered(ystart + 7 * ystep, FONT_TEXT_2, + "More information and levels:"); + DrawTextSCentered(ystart + 8 * ystep, FONT_TEXT_3, + PROGRAM_WEBSITE_STRING); + DrawTextSCentered(ystart + 9 * ystep, FONT_TEXT_2, "If you have created new levels,"); - DrawTextSCentered(ystart + 8 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 10 * ystep, FONT_TEXT_2, "send them to me to include them!"); - DrawTextSCentered(ystart + 9 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 11 * ystep, FONT_TEXT_2, ":-)"); DrawTextSCentered(ybottom, FONT_TEXT_4, diff --git a/src/tools.c b/src/tools.c index c1a8cf0b..5313f930 100644 --- a/src/tools.c +++ b/src/tools.c @@ -44,7 +44,7 @@ static int el_act2crm(int, int); static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS]; static int request_gadget_id = -1; -static int preview_tilesize = TILEX / 8; +static int preview_tilesize = TILEX / 4; static char *print_if_not_empty(int element) { @@ -1572,42 +1572,34 @@ void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) redraw_mask |= REDRAW_FIELD; } -static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y, - int preview_size_x, int preview_size_y) +static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) { + boolean show_level_border = (BorderElement != EL_EMPTY); + int level_size_x = lev_fieldx + (show_level_border ? 2 : 0); + int level_size_y = lev_fieldy + (show_level_border ? 2 : 0); + int preview_size_x = MICROLEVEL_XSIZE / preview_tilesize; + int preview_size_y = MICROLEVEL_YSIZE / preview_tilesize; + int real_preview_size_x = MIN(level_size_x, preview_size_x); + int real_preview_size_y = MIN(level_size_y, preview_size_y); int x, y; DrawBackground(xpos, ypos, MICROLEVEL_XSIZE, MICROLEVEL_YSIZE); - if (lev_fieldx < preview_size_x) - xpos += (preview_size_x - lev_fieldx) / 2 * preview_tilesize; - if (lev_fieldy < preview_size_y) - ypos += (preview_size_y - lev_fieldy) / 2 * preview_tilesize; + xpos += (MICROLEVEL_XSIZE - real_preview_size_x * preview_tilesize) / 2; + ypos += (MICROLEVEL_YSIZE - real_preview_size_y * preview_tilesize) / 2; -#if 1 - xpos += MICRO_TILEX; - ypos += MICRO_TILEY; -#else - xpos += preview_tilesize; - ypos += preview_tilesize; -#endif - - for (x = -1; x <= preview_size_x; x++) + for (x = 0; x < real_preview_size_x; x++) { - for (y = -1; y <= preview_size_y; y++) + for (y = 0; y < real_preview_size_y; y++) { - int lx = from_x + x, ly = from_y + y; - - if (lx >= 0 && lx < lev_fieldx && - ly >= 0 && ly < lev_fieldy) - DrawPreviewElement(xpos + x * preview_tilesize, - ypos + y * preview_tilesize, - level.field[lx][ly], preview_tilesize); - else if (lx >= -1 && lx < lev_fieldx+1 && - ly >= -1 && ly < lev_fieldy+1 && BorderElement != EL_EMPTY) - DrawPreviewElement(xpos + x * preview_tilesize, - ypos + y * preview_tilesize, - getBorderElement(lx, ly), preview_tilesize); + int lx = from_x + x + (show_level_border ? -1 : 0); + int ly = from_y + y + (show_level_border ? -1 : 0); + int element = (IN_LEV_FIELD(lx, ly) ? level.field[lx][ly] : + getBorderElement(lx, ly)); + + DrawPreviewElement(xpos + x * preview_tilesize, + ypos + y * preview_tilesize, + element, preview_tilesize); } } @@ -1677,8 +1669,13 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) static unsigned long label_delay = 0; static int from_x, from_y, scroll_direction; static int label_state, label_counter; - int preview_size_x = STD_LEV_FIELDX * MICRO_TILESIZE / preview_tilesize; - int preview_size_y = STD_LEV_FIELDY * MICRO_TILESIZE / preview_tilesize; + int delay_factor = preview_tilesize / MICRO_TILESIZE; + unsigned long scroll_delay_value = MICROLEVEL_SCROLL_DELAY * delay_factor; + boolean show_level_border = (BorderElement != EL_EMPTY); + int level_size_x = lev_fieldx + (show_level_border ? 2 : 0); + int level_size_y = lev_fieldy + (show_level_border ? 2 : 0); + int preview_size_x = MICROLEVEL_XSIZE / preview_tilesize; + int preview_size_y = MICROLEVEL_YSIZE / preview_tilesize; int last_game_status = game_status; /* save current game status */ /* force PREVIEW font on preview level */ @@ -1691,8 +1688,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) label_state = 1; label_counter = 0; - DrawMicroLevelExt(xpos, ypos, from_x, from_y, - preview_size_x, preview_size_y); + DrawMicroLevelExt(xpos, ypos, from_x, from_y); DrawMicroLevelLabelExt(label_state); /* initialize delay counters */ @@ -1721,8 +1717,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) } /* scroll micro level, if needed */ - if ((lev_fieldx > preview_size_x || lev_fieldy > preview_size_y) && - DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY)) + if ((level_size_x > preview_size_x || level_size_y > preview_size_y) && + DelayReached(&scroll_delay, scroll_delay_value)) { switch (scroll_direction) { @@ -1734,7 +1730,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) break; case MV_RIGHT: - if (from_x < lev_fieldx - preview_size_x) + if (from_x < level_size_x - preview_size_x) from_x++; else scroll_direction = MV_DOWN; @@ -1748,7 +1744,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) break; case MV_DOWN: - if (from_y < lev_fieldy - preview_size_y) + if (from_y < level_size_y - preview_size_y) from_y++; else scroll_direction = MV_LEFT; @@ -1758,8 +1754,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) break; } - DrawMicroLevelExt(xpos, ypos, from_x, from_y, - preview_size_x, preview_size_y); + DrawMicroLevelExt(xpos, ypos, from_x, from_y); } /* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */ -- 2.34.1