From 2ffc7d13be24ed07f4dcb9a77924450f16597720 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 28 Sep 2003 19:58:10 +0200 Subject: [PATCH] rnd-20030928-1-src --- src/conf_fnt.c | 32 ++--- src/conf_gfx.c | 81 ++++++----- src/conf_gfx.h | 67 +++++---- src/conftime.h | 2 +- src/init.c | 11 -- src/libgame/gadgets.c | 2 +- src/libgame/text.c | 6 +- src/libgame/text.h | 2 +- src/main.c | 4 + src/main.h | 32 +++-- src/tools.c | 307 ++++++------------------------------------ 11 files changed, 164 insertions(+), 382 deletions(-) diff --git a/src/conf_fnt.c b/src/conf_fnt.c index 764bec14..b00d432f 100644 --- a/src/conf_fnt.c +++ b/src/conf_fnt.c @@ -75,10 +75,6 @@ font_to_graphic[] = FONT_TEXT_1, GFX_SPECIAL_ARG_PREVIEW, IMG_FONT_TEXT_1_PREVIEW }, - { - FONT_TEXT_1, GFX_SPECIAL_ARG_PLAYING, - IMG_FONT_TEXT_1_PLAYING - }, { FONT_TEXT_1, GFX_SPECIAL_ARG_SCORES, IMG_FONT_TEXT_1_SCORES @@ -99,10 +95,6 @@ font_to_graphic[] = FONT_TEXT_2, GFX_SPECIAL_ARG_PREVIEW, IMG_FONT_TEXT_2_PREVIEW }, - { - FONT_TEXT_2, GFX_SPECIAL_ARG_PLAYING, - IMG_FONT_TEXT_2_PLAYING - }, { FONT_TEXT_2, GFX_SPECIAL_ARG_SCORES, IMG_FONT_TEXT_2_SCORES @@ -123,10 +115,6 @@ font_to_graphic[] = FONT_TEXT_3, GFX_SPECIAL_ARG_PREVIEW, IMG_FONT_TEXT_3_PREVIEW }, - { - FONT_TEXT_3, GFX_SPECIAL_ARG_PLAYING, - IMG_FONT_TEXT_3_PLAYING - }, { FONT_TEXT_3, GFX_SPECIAL_ARG_SCORES, IMG_FONT_TEXT_3_SCORES @@ -143,10 +131,6 @@ font_to_graphic[] = FONT_TEXT_4, GFX_SPECIAL_ARG_LEVELS, IMG_FONT_TEXT_4_LEVELS }, - { - FONT_TEXT_4, GFX_SPECIAL_ARG_PLAYING, - IMG_FONT_TEXT_4_PLAYING - }, { FONT_TEXT_4, GFX_SPECIAL_ARG_SCORES, IMG_FONT_TEXT_4_SCORES @@ -155,6 +139,22 @@ font_to_graphic[] = FONT_TEXT_4_ACTIVE, GFX_SPECIAL_ARG_SCORES, IMG_FONT_TEXT_4_ACTIVE_SCORES }, + { + FONT_ENVELOPE_1, -1, + IMG_FONT_ENVELOPE_1 + }, + { + FONT_ENVELOPE_2, -1, + IMG_FONT_ENVELOPE_2 + }, + { + FONT_ENVELOPE_3, -1, + IMG_FONT_ENVELOPE_3 + }, + { + FONT_ENVELOPE_4, -1, + IMG_FONT_ENVELOPE_4 + }, { FONT_INPUT_1, -1, IMG_FONT_INPUT_1 diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 46527737..d5075af0 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -3278,11 +3278,6 @@ struct ConfigInfo image_config[] = { "font.text_1.PREVIEW.y", "160" }, { "font.text_1.PREVIEW.width", "16" }, { "font.text_1.PREVIEW.height", "16" }, - { "font.text_1.PLAYING", "RocksFontEM.pcx" }, - { "font.text_1.PLAYING.x", "0" }, - { "font.text_1.PLAYING.y", "160" }, - { "font.text_1.PLAYING.width", "16" }, - { "font.text_1.PLAYING.height", "16" }, { "font.text_1.SCORES", "RocksFontMedium.pcx" }, { "font.text_1.SCORES.x", "0" }, { "font.text_1.SCORES.y", "480" }, @@ -3308,11 +3303,6 @@ struct ConfigInfo image_config[] = { "font.text_2.PREVIEW.y", "160" }, { "font.text_2.PREVIEW.width", "16" }, { "font.text_2.PREVIEW.height", "16" }, - { "font.text_2.PLAYING", "RocksFontEM.pcx" }, - { "font.text_2.PLAYING.x", "0" }, - { "font.text_2.PLAYING.y", "160" }, - { "font.text_2.PLAYING.width", "16" }, - { "font.text_2.PLAYING.height", "16" }, { "font.text_2.SCORES", "RocksFontBig.pcx" }, { "font.text_2.SCORES.x", "0" }, { "font.text_2.SCORES.y", "320" }, @@ -3338,11 +3328,6 @@ struct ConfigInfo image_config[] = { "font.text_3.PREVIEW.y", "160" }, { "font.text_3.PREVIEW.width", "16" }, { "font.text_3.PREVIEW.height", "16" }, - { "font.text_3.PLAYING", "RocksFontEM.pcx" }, - { "font.text_3.PLAYING.x", "0" }, - { "font.text_3.PLAYING.y", "160" }, - { "font.text_3.PLAYING.width", "16" }, - { "font.text_3.PLAYING.height", "16" }, { "font.text_3.SCORES", "RocksFontMedium.pcx" }, { "font.text_3.SCORES.x", "0" }, { "font.text_3.SCORES.y", "480" }, @@ -3363,11 +3348,6 @@ struct ConfigInfo image_config[] = { "font.text_4.LEVELS.y", "480" }, { "font.text_4.LEVELS.width", "16" }, { "font.text_4.LEVELS.height", "32" }, - { "font.text_4.PLAYING", "RocksFontEM.pcx" }, - { "font.text_4.PLAYING.x", "0" }, - { "font.text_4.PLAYING.y", "160" }, - { "font.text_4.PLAYING.width", "16" }, - { "font.text_4.PLAYING.height", "16" }, { "font.text_4.SCORES", "RocksFontMedium.pcx" }, { "font.text_4.SCORES.x", "0" }, { "font.text_4.SCORES.y", "480" }, @@ -3379,6 +3359,27 @@ struct ConfigInfo image_config[] = { "font.text_4.active.SCORES.width", "16" }, { "font.text_4.active.SCORES.height", "32" }, + { "font.envelope_1", "RocksFontEM.pcx" }, + { "font.envelope_1.x", "0" }, + { "font.envelope_1.y", "160" }, + { "font.envelope_1.width", "16" }, + { "font.envelope_1.height", "16" }, + { "font.envelope_2", "RocksFontEM.pcx" }, + { "font.envelope_2.x", "0" }, + { "font.envelope_2.y", "160" }, + { "font.envelope_2.width", "16" }, + { "font.envelope_2.height", "16" }, + { "font.envelope_3", "RocksFontEM.pcx" }, + { "font.envelope_3.x", "0" }, + { "font.envelope_3.y", "160" }, + { "font.envelope_3.width", "16" }, + { "font.envelope_3.height", "16" }, + { "font.envelope_4", "RocksFontEM.pcx" }, + { "font.envelope_4.x", "0" }, + { "font.envelope_4.y", "160" }, + { "font.envelope_4.width", "16" }, + { "font.envelope_4.height", "16" }, + { "font.input_1", "RocksFontSmall.pcx" }, { "font.input_1.x", "0" }, { "font.input_1.y", "210" }, @@ -3470,18 +3471,34 @@ struct ConfigInfo image_config[] = { "editor.element_border_input.xpos", "0" }, { "editor.element_border_input.ypos", "0" }, - { "game.envelope.background", "RocksScreen.pcx" }, - { "game.envelope.background.x", "0" }, - { "game.envelope.background.y", "0" }, - { "game.envelope.background.width", "560" }, - { "game.envelope.background.height", "560" }, - { "game.envelope.background.anim_mode", "default" }, - { "game.envelope.background.draw_masked", "false" }, - - { "game.envelope_1.background", UNDEFINED_FILENAME }, - { "game.envelope_2.background", UNDEFINED_FILENAME }, - { "game.envelope_3.background", UNDEFINED_FILENAME }, - { "game.envelope_4.background", UNDEFINED_FILENAME }, + { "background.envelope_1", "RocksScreen.pcx" }, + { "background.envelope_1.x", "0" }, + { "background.envelope_1.y", "0" }, + { "background.envelope_1.width", "560" }, + { "background.envelope_1.height", "560" }, + { "background.envelope_1.anim_mode", "default" }, + { "background.envelope_1.draw_masked", "false" }, + { "background.envelope_2", "RocksScreen.pcx" }, + { "background.envelope_2.x", "0" }, + { "background.envelope_2.y", "0" }, + { "background.envelope_2.width", "560" }, + { "background.envelope_2.height", "560" }, + { "background.envelope_2.anim_mode", "default" }, + { "background.envelope_2.draw_masked", "false" }, + { "background.envelope_3", "RocksScreen.pcx" }, + { "background.envelope_3.x", "0" }, + { "background.envelope_3.y", "0" }, + { "background.envelope_3.width", "560" }, + { "background.envelope_3.height", "560" }, + { "background.envelope_3.anim_mode", "default" }, + { "background.envelope_3.draw_masked", "false" }, + { "background.envelope_4", "RocksScreen.pcx" }, + { "background.envelope_4.x", "0" }, + { "background.envelope_4.y", "0" }, + { "background.envelope_4.width", "560" }, + { "background.envelope_4.height", "560" }, + { "background.envelope_4.anim_mode", "default" }, + { "background.envelope_4.draw_masked", "false" }, { "background", UNDEFINED_FILENAME }, { "background.MAIN", UNDEFINED_FILENAME }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index b1688cfb..4340e221 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1251,26 +1251,26 @@ #define IMG_FONT_TEXT_1 1230 #define IMG_FONT_TEXT_1_LEVELS 1231 #define IMG_FONT_TEXT_1_PREVIEW 1232 -#define IMG_FONT_TEXT_1_PLAYING 1233 -#define IMG_FONT_TEXT_1_SCORES 1234 -#define IMG_FONT_TEXT_1_ACTIVE_SCORES 1235 -#define IMG_FONT_TEXT_2 1236 -#define IMG_FONT_TEXT_2_LEVELS 1237 -#define IMG_FONT_TEXT_2_PREVIEW 1238 -#define IMG_FONT_TEXT_2_PLAYING 1239 -#define IMG_FONT_TEXT_2_SCORES 1240 -#define IMG_FONT_TEXT_2_ACTIVE_SCORES 1241 -#define IMG_FONT_TEXT_3 1242 -#define IMG_FONT_TEXT_3_LEVELS 1243 -#define IMG_FONT_TEXT_3_PREVIEW 1244 -#define IMG_FONT_TEXT_3_PLAYING 1245 -#define IMG_FONT_TEXT_3_SCORES 1246 -#define IMG_FONT_TEXT_3_ACTIVE_SCORES 1247 -#define IMG_FONT_TEXT_4 1248 -#define IMG_FONT_TEXT_4_LEVELS 1249 -#define IMG_FONT_TEXT_4_PLAYING 1250 -#define IMG_FONT_TEXT_4_SCORES 1251 -#define IMG_FONT_TEXT_4_ACTIVE_SCORES 1252 +#define IMG_FONT_TEXT_1_SCORES 1233 +#define IMG_FONT_TEXT_1_ACTIVE_SCORES 1234 +#define IMG_FONT_TEXT_2 1235 +#define IMG_FONT_TEXT_2_LEVELS 1236 +#define IMG_FONT_TEXT_2_PREVIEW 1237 +#define IMG_FONT_TEXT_2_SCORES 1238 +#define IMG_FONT_TEXT_2_ACTIVE_SCORES 1239 +#define IMG_FONT_TEXT_3 1240 +#define IMG_FONT_TEXT_3_LEVELS 1241 +#define IMG_FONT_TEXT_3_PREVIEW 1242 +#define IMG_FONT_TEXT_3_SCORES 1243 +#define IMG_FONT_TEXT_3_ACTIVE_SCORES 1244 +#define IMG_FONT_TEXT_4 1245 +#define IMG_FONT_TEXT_4_LEVELS 1246 +#define IMG_FONT_TEXT_4_SCORES 1247 +#define IMG_FONT_TEXT_4_ACTIVE_SCORES 1248 +#define IMG_FONT_ENVELOPE_1 1249 +#define IMG_FONT_ENVELOPE_2 1250 +#define IMG_FONT_ENVELOPE_3 1251 +#define IMG_FONT_ENVELOPE_4 1252 #define IMG_FONT_INPUT_1 1253 #define IMG_FONT_INPUT_1_MAIN 1254 #define IMG_FONT_INPUT_1_ACTIVE 1255 @@ -1290,20 +1290,19 @@ #define IMG_GLOBAL_DOOR 1269 #define IMG_EDITOR_ELEMENT_BORDER 1270 #define IMG_EDITOR_ELEMENT_BORDER_INPUT 1271 -#define IMG_GAME_ENVELOPE_BACKGROUND 1272 -#define IMG_GAME_ENVELOPE_1_BACKGROUND 1273 -#define IMG_GAME_ENVELOPE_2_BACKGROUND 1274 -#define IMG_GAME_ENVELOPE_3_BACKGROUND 1275 -#define IMG_GAME_ENVELOPE_4_BACKGROUND 1276 -#define IMG_BACKGROUND 1277 -#define IMG_BACKGROUND_MAIN 1278 -#define IMG_BACKGROUND_LEVELS 1279 -#define IMG_BACKGROUND_SCORES 1280 -#define IMG_BACKGROUND_EDITOR 1281 -#define IMG_BACKGROUND_INFO 1282 -#define IMG_BACKGROUND_SETUP 1283 -#define IMG_BACKGROUND_DOOR 1284 +#define IMG_BACKGROUND_ENVELOPE_1 1272 +#define IMG_BACKGROUND_ENVELOPE_2 1273 +#define IMG_BACKGROUND_ENVELOPE_3 1274 +#define IMG_BACKGROUND_ENVELOPE_4 1275 +#define IMG_BACKGROUND 1276 +#define IMG_BACKGROUND_MAIN 1277 +#define IMG_BACKGROUND_LEVELS 1278 +#define IMG_BACKGROUND_SCORES 1279 +#define IMG_BACKGROUND_EDITOR 1280 +#define IMG_BACKGROUND_INFO 1281 +#define IMG_BACKGROUND_SETUP 1282 +#define IMG_BACKGROUND_DOOR 1283 -#define NUM_IMAGE_FILES 1285 +#define NUM_IMAGE_FILES 1284 #endif /* CONF_GFX_H */ diff --git a/src/conftime.h b/src/conftime.h index 5f389b34..6f208927 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-09-27 18:33]" +#define COMPILE_DATE_STRING "[2003-09-28 19:55]" diff --git a/src/init.c b/src/init.c index 1af2f48e..8ec25b1d 100644 --- a/src/init.c +++ b/src/init.c @@ -748,16 +748,11 @@ static int get_element_from_token(char *token) static void set_graphic_parameters(int graphic, char **parameter_raw) { Bitmap *src_bitmap = getBitmapFromImageID(graphic); - boolean special_envelope_graphic; int parameter[NUM_GFX_ARGS]; int anim_frames_per_row = 1, anim_frames_per_col = 1; int anim_frames_per_line = 1; int i; - special_envelope_graphic = (graphic == IMG_GAME_ENVELOPE_BACKGROUND || - (graphic >= IMG_GAME_ENVELOPE_1_BACKGROUND && - graphic <= IMG_GAME_ENVELOPE_4_BACKGROUND)); - /* get integer values from string parameters */ for (i=0; i < NUM_GFX_ARGS; i++) { @@ -847,8 +842,6 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) graphic_info[graphic].anim_delay = 1; graphic_info[graphic].anim_mode = parameter[GFX_ARG_ANIM_MODE]; - if (graphic_info[graphic].anim_frames == 1 && !special_envelope_graphic) - graphic_info[graphic].anim_mode = ANIM_NONE; /* automatically determine correct start frame, if not defined */ if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE) @@ -884,10 +877,6 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) /* this is only used for drawing envelope graphics */ graphic_info[graphic].draw_masked = parameter[GFX_ARG_DRAW_MASKED]; - - /* global envelope settings override specific settings, if undefined */ - if (special_envelope_graphic && graphic_info[graphic].bitmap == NULL) - graphic_info[graphic] = graphic_info[IMG_GAME_ENVELOPE_BACKGROUND]; } static void InitGraphicInfo() diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index dd9d2883..3f56f44e 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -358,7 +358,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* gadget text value */ DrawTextToTextArea(gi->x + border_x, gi->y + border_y, - gi->textarea.value, font_nr, + gi->textarea.value, font_nr, gi->textarea.xsize, gi->textarea.xsize, gi->textarea.ysize, BLIT_ON_BACKGROUND); diff --git a/src/libgame/text.c b/src/libgame/text.c index c5406657..f41635ae 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -326,7 +326,7 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, } } -void DrawTextToTextArea(int x, int y, char *text, int font_nr, +void DrawTextToTextArea(int x, int y, char *text, int font_nr, int line_length, int area_xsize, int area_ysize, int mask_mode) { int area_line = 0; @@ -340,10 +340,10 @@ void DrawTextToTextArea(int x, int y, char *text, int font_nr, char buffer[MAX_OUTPUT_LINESIZE + 1]; int i; - for (i=0; i < area_xsize && *text; i++) + for (i=0; i < line_length && *text; i++) if ((buffer[i] = *text++) == '\n') break; - buffer[i] = '\0'; + buffer[MIN(i, area_xsize)] = '\0'; DrawTextExt(drawto, x, y + area_line * font_height, buffer, font_nr, mask_mode); diff --git a/src/libgame/text.h b/src/libgame/text.h index bde8ba9d..dc29e283 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -66,6 +66,6 @@ void DrawTextF(int, int, int, char *, ...); void DrawTextFCentered(int, int, char *, ...); void DrawText(int, int, char *, int); void DrawTextExt(DrawBuffer *, int, int, char *, int, int); -void DrawTextToTextArea(int, int, char *, int, int, int, int); +void DrawTextToTextArea(int, int, char *, int, int, int, int, int); #endif /* TEXT_H */ diff --git a/src/main.c b/src/main.c index 309f1ec9..19942e8d 100644 --- a/src/main.c +++ b/src/main.c @@ -3783,6 +3783,10 @@ struct FontInfo font_info[NUM_FONTS + 1] = { "font.text_2" }, { "font.text_3" }, { "font.text_4" }, + { "font.envelope_1" }, + { "font.envelope_2" }, + { "font.envelope_3" }, + { "font.envelope_4" }, { "font.input_1.active" }, { "font.input_2.active" }, { "font.input_1" }, diff --git a/src/main.h b/src/main.h index ef25bdde..d779c97e 100644 --- a/src/main.h +++ b/src/main.h @@ -989,20 +989,24 @@ #define FONT_TEXT_2 13 #define FONT_TEXT_3 14 #define FONT_TEXT_4 15 -#define FONT_INPUT_1_ACTIVE 16 -#define FONT_INPUT_2_ACTIVE 17 -#define FONT_INPUT_1 18 -#define FONT_INPUT_2 19 -#define FONT_OPTION_OFF 20 -#define FONT_OPTION_ON 21 -#define FONT_VALUE_1 22 -#define FONT_VALUE_2 23 -#define FONT_VALUE_OLD 24 -#define FONT_LEVEL_NUMBER 25 -#define FONT_TAPE_RECORDER 26 -#define FONT_GAME_INFO 27 - -#define NUM_FONTS 28 +#define FONT_ENVELOPE_1 16 +#define FONT_ENVELOPE_2 17 +#define FONT_ENVELOPE_3 18 +#define FONT_ENVELOPE_4 19 +#define FONT_INPUT_1_ACTIVE 20 +#define FONT_INPUT_2_ACTIVE 21 +#define FONT_INPUT_1 22 +#define FONT_INPUT_2 23 +#define FONT_OPTION_OFF 24 +#define FONT_OPTION_ON 25 +#define FONT_VALUE_1 26 +#define FONT_VALUE_2 27 +#define FONT_VALUE_OLD 28 +#define FONT_LEVEL_NUMBER 29 +#define FONT_TAPE_RECORDER 30 +#define FONT_GAME_INFO 31 + +#define NUM_FONTS 32 #define NUM_INITIAL_FONTS 4 /* values for game_status (must match special image configuration suffixes) */ diff --git a/src/tools.c b/src/tools.c index 3f4cff15..a2d051fb 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1561,7 +1561,7 @@ void DrawEnvelopeBackground(int envelope_nr, int startx, int starty, { int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); - int graphic = IMG_GAME_ENVELOPE_1_BACKGROUND + envelope_nr; + int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; Bitmap *src_bitmap; int src_x, src_y; int dst_x = SX + startx + x * font_width; @@ -1599,73 +1599,34 @@ void DrawEnvelopeBackground(int envelope_nr, int startx, int starty, dst_x, dst_y); } -#if 1 - -void AnimateEnvelope(int envelope_nr) +void AnimateEnvelope(int envelope_nr, int anim_mode, int action) { -} - -void ShowEnvelope(int envelope_nr) -{ - int element = EL_ENVELOPE_1 + envelope_nr; - int graphic = IMG_GAME_ENVELOPE_1_BACKGROUND + envelope_nr; - int sound_opening = element_info[element].sound[ACTION_OPENING]; - int sound_closing = element_info[element].sound[ACTION_CLOSING]; + int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; boolean draw_masked = graphic_info[graphic].draw_masked; - int anim_mode = graphic_info[graphic].anim_mode; int mask_mode = (draw_masked ? BLIT_MASKED : BLIT_ON_BACKGROUND); - int font_nr = FONT_TEXT_1 + envelope_nr; - int font_width = getFontWidth(font_nr); - int font_height = getFontHeight(font_nr); boolean ffwd_delay = (tape.playing && tape.fast_forward); unsigned long anim_delay = 0; int anim_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay); - int wait_delay_value = (ffwd_delay ? 500 : 1000); - int start_pos_vertically = 0; - int i, x, y; - - game.envelope_active = TRUE; - - if (anim_mode != ANIM_NONE) - PlaySoundStereo(sound_opening, SOUND_MIDDLE); - - if (anim_mode == ANIM_DEFAULT) - { - /* open envelope window horizontally */ - for (i = 0; i <= level.envelope_xsize[envelope_nr]; i++) - { - int xsize = i + 2; - int ysize = 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value / 2); - } - } - - if (anim_mode == ANIM_NONE) - start_pos_vertically = level.envelope_ysize[envelope_nr]; + int font_nr = FONT_ENVELOPE_1 + envelope_nr; + int font_width = getFontWidth(font_nr); + int font_height = getFontHeight(font_nr); + int max_xsize = level.envelope_xsize[envelope_nr]; + int max_ysize = level.envelope_ysize[envelope_nr]; + int xstart = (anim_mode & ANIM_VERTICAL ? max_xsize : 0); + int ystart = (anim_mode & ANIM_HORIZONTAL ? max_ysize : 0); + int xend = max_xsize; + int yend = (anim_mode != ANIM_DEFAULT ? max_ysize : 0); + int xstep = (xstart < xend ? 1 : 0); + int ystep = (ystart < yend || xstep == 0 ? 1 : 0); + int x, y; - /* open envelope window vertically */ - for (i = start_pos_vertically; i <= level.envelope_ysize[envelope_nr]; i++) + for (x=xstart, y=ystart; x <= xend && y <= yend; x += xstep, y += ystep) { - int xsize = level.envelope_xsize[envelope_nr] + 2; - int ysize = i + 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; + int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2; + int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2; + int sx = (SXSIZE - xsize * font_width) / 2; + int sy = (SYSIZE - ysize * font_height) / 2; + int xx, yy; SetDrawtoField(DRAW_BUFFERED); @@ -1673,243 +1634,53 @@ void ShowEnvelope(int envelope_nr) SetDrawtoField(DRAW_BACKBUFFER); - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); + for (yy=0; yy < ysize; yy++) for (xx=0; xx < xsize; xx++) + DrawEnvelopeBackground(envelope_nr, sx,sy, xx,yy, xsize, ysize, font_nr); - DrawTextToTextArea(SX + startx + font_width, SY + starty + font_height, - level.envelope_text[envelope_nr], font_nr, - level.envelope_xsize[envelope_nr], i, mask_mode); + DrawTextToTextArea(SX + sx + font_width, SY + sy + font_height, + level.envelope_text[envelope_nr], font_nr, max_xsize, + xsize - 2, ysize - 2, mask_mode); redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; BackToFront(); - WaitUntilDelayReached(&anim_delay, anim_delay_value); + WaitUntilDelayReached(&anim_delay, anim_delay_value / 2); } - - if (tape.playing) - Delay(wait_delay_value); - else - WaitForEventToContinue(); - - if (anim_mode != ANIM_NONE) - PlaySoundStereo(sound_closing, SOUND_MIDDLE); - - if (anim_mode != ANIM_NONE) - { - /* close envelope window vertically */ - for (i = level.envelope_ysize[envelope_nr]; i >= 0; i--) - { - int xsize = level.envelope_xsize[envelope_nr] + 2; - int ysize = i + 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - DrawTextToTextArea(SX + startx + font_width, SY + starty + font_height, - level.envelope_text[envelope_nr], font_nr, - level.envelope_xsize[envelope_nr], i, mask_mode); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value); - } - } - - if (anim_mode == ANIM_DEFAULT) - { - /* close envelope window horizontally */ - for (i = level.envelope_xsize[envelope_nr]; i >= 0; i--) - { - int xsize = i + 2; - int ysize = 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value / 2); - } - } - - game.envelope_active = FALSE; - - SetDrawtoField(DRAW_BUFFERED); - - redraw_mask |= REDRAW_FIELD; - BackToFront(); } -#else - void ShowEnvelope(int envelope_nr) { int element = EL_ENVELOPE_1 + envelope_nr; - int graphic = IMG_GAME_ENVELOPE_1_BACKGROUND + envelope_nr; + int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; int sound_opening = element_info[element].sound[ACTION_OPENING]; int sound_closing = element_info[element].sound[ACTION_CLOSING]; - boolean draw_masked = graphic_info[graphic].draw_masked; - int anim_mode = graphic_info[graphic].anim_mode; - int mask_mode = (draw_masked ? BLIT_MASKED : BLIT_ON_BACKGROUND); - int font_nr = FONT_TEXT_1; - int font_width = getFontWidth(font_nr); - int font_height = getFontHeight(font_nr); boolean ffwd_delay = (tape.playing && tape.fast_forward); - unsigned long anim_delay = 0; - int anim_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay); int wait_delay_value = (ffwd_delay ? 500 : 1000); - int start_pos_vertically = 0; - int i, x, y; + int anim_mode = graphic_info[graphic].anim_mode; + int main_anim_mode = (anim_mode == ANIM_NONE ? ANIM_VERTICAL|ANIM_HORIZONTAL: + anim_mode == ANIM_DEFAULT ? ANIM_VERTICAL : anim_mode); - game.envelope_active = TRUE; + game.envelope_active = TRUE; /* needed for RedrawPlayfield() events */ - if (anim_mode != ANIM_NONE) - PlaySoundStereo(sound_opening, SOUND_MIDDLE); + PlaySoundStereo(sound_opening, SOUND_MIDDLE); if (anim_mode == ANIM_DEFAULT) - { - /* open envelope window horizontally */ - for (i = 0; i <= level.envelope_xsize[envelope_nr]; i++) - { - int xsize = i + 2; - int ysize = 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value / 2); - } - } - - if (anim_mode == ANIM_NONE) - start_pos_vertically = level.envelope_ysize[envelope_nr]; - - /* open envelope window vertically */ - for (i = start_pos_vertically; i <= level.envelope_ysize[envelope_nr]; i++) - { - int xsize = level.envelope_xsize[envelope_nr] + 2; - int ysize = i + 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); + AnimateEnvelope(envelope_nr, ANIM_DEFAULT, ACTION_OPENING); - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - DrawTextToTextArea(SX + startx + font_width, SY + starty + font_height, - level.envelope_text[envelope_nr], FONT_TEXT_1, - level.envelope_xsize[envelope_nr], i, mask_mode); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value); - } + AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_OPENING); if (tape.playing) Delay(wait_delay_value); else WaitForEventToContinue(); - if (anim_mode != ANIM_NONE) - PlaySoundStereo(sound_closing, SOUND_MIDDLE); + PlaySoundStereo(sound_closing, SOUND_MIDDLE); if (anim_mode != ANIM_NONE) - { - /* close envelope window vertically */ - for (i = level.envelope_ysize[envelope_nr]; i >= 0; i--) - { - int xsize = level.envelope_xsize[envelope_nr] + 2; - int ysize = i + 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - DrawTextToTextArea(SX + startx + font_width, SY + starty + font_height, - level.envelope_text[envelope_nr], FONT_TEXT_1, - level.envelope_xsize[envelope_nr], i, mask_mode); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value); - } - } + AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_CLOSING); if (anim_mode == ANIM_DEFAULT) - { - /* close envelope window horizontally */ - for (i = level.envelope_xsize[envelope_nr]; i >= 0; i--) - { - int xsize = i + 2; - int ysize = 2; - int startx = (SXSIZE - xsize * font_width) / 2; - int starty = (SYSIZE - ysize * font_height) / 2; - - SetDrawtoField(DRAW_BUFFERED); - - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - - SetDrawtoField(DRAW_BACKBUFFER); - - for (y=0; y < ysize; y++) for (x=0; x < xsize; x++) - DrawEnvelopeBackground(envelope_nr, startx, starty, x, y, xsize, ysize, - font_nr); - - redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; - BackToFront(); - - WaitUntilDelayReached(&anim_delay, anim_delay_value / 2); - } - } + AnimateEnvelope(envelope_nr, ANIM_DEFAULT, ACTION_CLOSING); game.envelope_active = FALSE; @@ -1919,8 +1690,6 @@ void ShowEnvelope(int envelope_nr) BackToFront(); } -#endif - void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { Bitmap *src_bitmap = graphic_info[graphic].bitmap; -- 2.34.1