From c38b8938950533926b72af227c38513fe665a8f6 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 30 Nov 2002 12:51:40 +0100 Subject: [PATCH] rnd-20021130-2-src --- src/conftime.h | 2 +- src/init.c | 53 ++++++++++++++++++++++++++++++++++++++-------- src/libgame/misc.c | 38 +++++++++++++++++++++++++++++++-- src/libgame/text.c | 33 +++++++++++++++++------------ src/libgame/text.h | 8 ++++--- 5 files changed, 105 insertions(+), 29 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index 90d054cb..e6ac22f0 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-11-30 00:17]" +#define COMPILE_DATE_STRING "[2002-11-30 12:50]" diff --git a/src/init.c b/src/init.c index 88806e9e..42e502dc 100644 --- a/src/init.c +++ b/src/init.c @@ -199,16 +199,11 @@ static void ReinitializeGraphics() InitGraphicInfo(); /* initialize graphic info from config file */ - InitFontInfo(new_graphic_info[IMG_MENU_FONT_BIG].bitmap, + InitFontInfo(bitmap_font_initial, + new_graphic_info[IMG_MENU_FONT_BIG].bitmap, new_graphic_info[IMG_MENU_FONT_MEDIUM].bitmap, new_graphic_info[IMG_MENU_FONT_SMALL].bitmap, new_graphic_info[IMG_MENU_FONT_EM].bitmap); - - if (bitmap_font_initial) - { - FreeBitmap(bitmap_font_initial); - bitmap_font_initial = NULL; - } } static void InitImages() @@ -435,7 +430,7 @@ void InitGfx() #else bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]); - InitFontInfo(NULL, NULL, bitmap_font_initial, NULL); + InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL); #endif DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW); @@ -491,11 +486,21 @@ void ReloadCustomArtwork() static boolean last_override_level_graphics = FALSE; static boolean last_override_level_sounds = FALSE; static boolean last_override_level_music = FALSE; - /* identifier for new artwork; default: artwork configured in setup */ char *gfx_new_identifier = artwork.gfx_current->identifier; char *snd_new_identifier = artwork.snd_current->identifier; char *mus_new_identifier = artwork.mus_current->identifier; + boolean redraw_screen = FALSE; + + if (leveldir_current_identifier == NULL) + leveldir_current_identifier = leveldir_current->identifier; + +#if 0 + printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier, + leveldir_current->graphics_set); + printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier, + leveldir_current->identifier); +#endif #if 0 printf("graphics --> '%s' ('%s')\n", @@ -547,6 +552,11 @@ void ReloadCustomArtwork() if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 || last_override_level_graphics != setup.override_level_graphics) { +#if 0 + printf("CHANGED GFX: '%s' -> '%s'\n", + artwork.gfx_current_identifier, gfx_new_identifier); +#endif + #if 0 int i; #endif @@ -567,14 +577,23 @@ void ReloadCustomArtwork() FreeTileClipmasks(); InitTileClipmasks(); + +#if 0 InitGfxBackground(); /* force redraw of (open or closed) door graphics */ SetDoorState(DOOR_OPEN_ALL); CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); +#endif +#if 0 artwork.gfx_current_identifier = gfx_new_identifier; +#else + artwork.gfx_current_identifier = artwork.gfx_current->identifier; +#endif last_override_level_graphics = setup.override_level_graphics; + + redraw_screen = TRUE; } if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 || @@ -587,6 +606,8 @@ void ReloadCustomArtwork() artwork.snd_current_identifier = snd_new_identifier; last_override_level_sounds = setup.override_level_sounds; + + redraw_screen = TRUE; } if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 || @@ -599,6 +620,17 @@ void ReloadCustomArtwork() artwork.mus_current_identifier = mus_new_identifier; last_override_level_music = setup.override_level_music; + + redraw_screen = TRUE; + } + + if (redraw_screen) + { + InitGfxBackground(); + + /* force redraw of (open or closed) door graphics */ + SetDoorState(DOOR_OPEN_ALL); + CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); } #if 0 @@ -2587,6 +2619,9 @@ void CloseAllAndExit(int exit_value) FreeBitmap(pix[i]); #endif + if (bitmap_font_initial) + FreeBitmap(bitmap_font_initial); + CloseVideoDisplay(); ClosePlatformDependantStuff(); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 7637dc2d..910a7e95 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1536,9 +1536,23 @@ static void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info, static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, struct ListNodeInfo **listnode, - char *filename) + char *basename) { + char *init_text[] = + { "", + "Loading graphics:", + "Loading sounds:", + "Loading music:" + }; + ListNode *node; + char *filename = getCustomArtworkFilename(basename, artwork_info->type); + + if (filename == NULL) + { + Error(ERR_WARN, "cannot find artwork file '%s'", basename); + return; + } /* check if the old and the new artwork file are the same */ if (*listnode && strcmp((*listnode)->source_filename, filename) == 0) @@ -1566,8 +1580,14 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, *listnode = (struct ListNodeInfo *)node->content; (*listnode)->num_references++; + + return; } - else if ((*listnode = artwork_info->load_artwork(filename)) != NULL) + + DrawInitText(init_text[artwork_info->type], 120, FC_GREEN); + DrawInitText(basename, 150, FC_YELLOW); + + if ((*listnode = artwork_info->load_artwork(filename)) != NULL) { #if 0 printf("[adding new artwork '%s']\n", filename); @@ -1583,7 +1603,9 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, struct ListNodeInfo **listnode, char *basename) { +#if 0 char *filename = getCustomArtworkFilename(basename, artwork_info->type); +#endif #if 0 printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename); @@ -1595,6 +1617,7 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, return; } +#if 0 if (filename == NULL) { Error(ERR_WARN, "cannot find artwork file '%s'", basename); @@ -1602,6 +1625,9 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, } replaceArtworkListEntry(artwork_info, listnode, filename); +#else + replaceArtworkListEntry(artwork_info, listnode, basename); +#endif } static void LoadArtworkToList(struct ArtworkListInfo *artwork_info, @@ -1627,6 +1653,7 @@ static void LoadArtworkToList(struct ArtworkListInfo *artwork_info, void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) { +#if 0 static struct { char *text; @@ -1639,6 +1666,7 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) { "Loading sounds:", TRUE }, { "Loading music:", TRUE } }; +#endif int num_file_list_entries = artwork_info->num_file_list_entries; struct FileInfo *file_list = artwork_info->file_list; @@ -1646,8 +1674,10 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) LoadArtworkConfig(artwork_info); +#if 0 if (draw_init[artwork_info->type].do_it) DrawInitText(draw_init[artwork_info->type].text, 120, FC_GREEN); +#endif #if 0 printf("DEBUG: reloading %d artwork files ...\n", num_file_list_entries); @@ -1655,8 +1685,10 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) for(i=0; itype].do_it) DrawInitText(file_list[i].token, 150, FC_YELLOW); +#endif LoadArtworkToList(artwork_info, file_list[i].filename, i); @@ -1665,7 +1697,9 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) #endif } +#if 0 draw_init[artwork_info->type].do_it = FALSE; +#endif /* printf("list size == %d\n", getNumNodes(artwork_info->content_list)); diff --git a/src/libgame/text.c b/src/libgame/text.c index 2fdd2c20..231fab19 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -28,9 +28,11 @@ struct FontInfo font; /* font functions */ /* ========================================================================= */ -void InitFontInfo(Bitmap *bitmap_big, Bitmap *bitmap_medium, +void InitFontInfo(Bitmap *bitmap_initial, + Bitmap *bitmap_big, Bitmap *bitmap_medium, Bitmap *bitmap_small, Bitmap *bitmap_tile) { + font.bitmap_initial = bitmap_initial; font.bitmap_big = bitmap_big; font.bitmap_medium = bitmap_medium; font.bitmap_small = bitmap_small; @@ -39,31 +41,33 @@ void InitFontInfo(Bitmap *bitmap_big, Bitmap *bitmap_medium, int getFontWidth(int font_size, int font_type) { - return (font_size == FS_BIG ? FONT1_XSIZE : - font_size == FS_MEDIUM ? FONT6_XSIZE : - font_type == FC_SPECIAL1 ? FONT3_XSIZE : + return (font_type == FC_SPECIAL1 ? FONT3_XSIZE : font_type == FC_SPECIAL2 ? FONT4_XSIZE : font_type == FC_SPECIAL3 ? FONT5_XSIZE : + font_size == FS_BIG ? FONT1_XSIZE : + font_size == FS_MEDIUM ? FONT6_XSIZE : + font_size == FS_SMALL ? FONT2_XSIZE : FONT2_XSIZE); } int getFontHeight(int font_size, int font_type) { - return (font_size == FS_BIG ? FONT1_YSIZE : - font_size == FS_MEDIUM ? FONT6_YSIZE : - font_type == FC_SPECIAL1 ? FONT3_YSIZE : + return (font_type == FC_SPECIAL1 ? FONT3_YSIZE : font_type == FC_SPECIAL2 ? FONT4_YSIZE : font_type == FC_SPECIAL3 ? FONT5_YSIZE : + font_size == FS_BIG ? FONT1_YSIZE : + font_size == FS_MEDIUM ? FONT6_YSIZE : + font_size == FS_SMALL ? FONT2_YSIZE : FONT2_YSIZE); } void DrawInitText(char *text, int ypos, int color) { - if (window && font.bitmap_small) + if (window && font.bitmap_initial) { ClearRectangle(window, 0, ypos, video.width, FONT2_YSIZE); DrawTextExt(window, (video.width - strlen(text) * FONT2_XSIZE)/2, - ypos, text, FS_SMALL, color); + ypos, text, FS_INITIAL, color); FlushDisplay(); } } @@ -104,15 +108,15 @@ void DrawText(int x, int y, char *text, int font_size, int font_type) redraw_mask |= REDRAW_DOOR_1; } -void DrawTextExt(DrawBuffer *bitmap, int x, int y, - char *text, int font_size, int font_type) +void DrawTextExt(DrawBuffer *bitmap, int x, int y, char *text, + int font_size, int font_type) { Bitmap *font_bitmap; int font_width, font_height, font_starty; boolean print_inverse = FALSE; - if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM) - font_size = FS_SMALL; + if (font_size != FS_BIG && font_size != FS_MEDIUM && font_size != FS_SMALL) + font_size = FS_INITIAL; if (font_type < FC_RED || font_type > FC_SPECIAL3) font_type = FC_RED; @@ -123,7 +127,7 @@ void DrawTextExt(DrawBuffer *bitmap, int x, int y, font_size == FS_BIG ? font.bitmap_big : font_size == FS_MEDIUM ? font.bitmap_medium : font_size == FS_SMALL ? font.bitmap_small : - font.bitmap_small); + font.bitmap_initial); if (font_bitmap == NULL) return; @@ -133,6 +137,7 @@ void DrawTextExt(DrawBuffer *bitmap, int x, int y, else font_starty = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : font_size == FS_MEDIUM ? FONT6_YSIZE : + font_size == FS_SMALL ? FONT2_YSIZE : FONT2_YSIZE) * FONT_LINES_PER_FONT); diff --git a/src/libgame/text.h b/src/libgame/text.h index cd2f04d5..44cdbf15 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -18,10 +18,11 @@ /* font types */ -#define FS_SMALL 0 +#define FS_INITIAL 0 #define FS_BIG 1 #define FS_MEDIUM 2 -#define FS_TILE 3 +#define FS_SMALL 3 +#define FS_TILE 4 /* font colors */ #define FC_RED 0 @@ -56,6 +57,7 @@ struct FontInfo { + Bitmap *bitmap_initial; Bitmap *bitmap_big; Bitmap *bitmap_medium; Bitmap *bitmap_small; @@ -63,7 +65,7 @@ struct FontInfo }; -void InitFontInfo(Bitmap *, Bitmap *, Bitmap *, Bitmap *); +void InitFontInfo(Bitmap *, Bitmap *, Bitmap *, Bitmap *, Bitmap *); int getFontWidth(int, int); int getFontHeight(int, int); void DrawInitText(char *, int, int); -- 2.34.1