From: Holger Schemel Date: Tue, 2 Dec 2003 01:47:56 +0000 (+0100) Subject: rnd-20031202-1-src X-Git-Tag: 3.0.8^2~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b645a25fff77d62a36c744fa4047a3c0e5929341;p=rocksndiamonds.git rnd-20031202-1-src * fixed bug with wrong default impact sound for colored emeralds * added several sub-screens for the info screen --- diff --git a/ChangeLog b/ChangeLog index 37d8c79d..c1376eac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-12-02 + * fixed bug with wrong default impact sound for colored emeralds + +2003-11-30 + * added several sub-screens for the info screen 2003-11-25 * added configurable "bored" and "sleeping" animations for the player diff --git a/src/conf_dem.c b/src/conf_dem.c index d9050854..7f844618 100644 --- a/src/conf_dem.c +++ b/src/conf_dem.c @@ -29,7 +29,18 @@ struct ConfigInfo helpanim_config[] = { "player_1.pushing.right", "16" }, { "end", "" }, - { "sand", "-1" }, + { "sand", "50" }, + { "sand.digging.left", "8" }, + { "empty_space", "10" }, + { "sand", "50" }, + { "sand.digging.right", "8" }, + { "empty_space", "10" }, + { "sand", "50" }, + { "sand.digging.up", "8" }, + { "empty_space", "10" }, + { "sand", "50" }, + { "sand.digging.down", "8" }, + { "empty_space", "10" }, { "end", "" }, { "empty_space", "-1" }, @@ -134,18 +145,30 @@ struct ConfigInfo helpanim_config[] = { "char_cursor", "10" }, { "end", "" }, - { "emerald", "-1" }, + { "emerald", "50" }, + { "emerald.collecting", "8" }, + { "empty_space", "10" }, { "end", "" }, - { "diamond", "-1" }, + { "diamond", "50" }, + { "diamond.collecting", "8" }, + { "empty_space", "10" }, { "end", "" }, - { "bd_diamond", "-1" }, + { "bd_diamond", "50" }, + { "bd_diamond.collecting", "8" }, + { "empty_space", "10" }, { "end", "" }, { "emerald_yellow", "50" }, + { "emerald_yellow.collecting", "8" }, + { "empty_space", "10" }, { "emerald_red", "50" }, + { "emerald_red.collecting", "8" }, + { "empty_space", "10" }, { "emerald_purple", "50" }, + { "emerald_purple.collecting", "8" }, + { "empty_space", "10" }, { "end", "" }, { "bd_rock", "-1" }, diff --git a/src/conf_e2s.c b/src/conf_e2s.c index de238576..9b293d5b 100644 --- a/src/conf_e2s.c +++ b/src/conf_e2s.c @@ -237,12 +237,12 @@ element_to_sound[] = SND_SAND_DIGGING }, { - EL_EMERALD, FALSE, ACTION_COLLECTING, - SND_EMERALD_COLLECTING + EL_EMERALD, TRUE, ACTION_COLLECTING, + SND_CLASS_EMERALD_COLLECTING }, { - EL_EMERALD, FALSE, ACTION_IMPACT, - SND_EMERALD_IMPACT + EL_EMERALD, TRUE, ACTION_IMPACT, + SND_CLASS_EMERALD_IMPACT }, { EL_DIAMOND, FALSE, ACTION_COLLECTING, diff --git a/src/conf_snd.c b/src/conf_snd.c index deb105e2..cd9869b0 100644 --- a/src/conf_snd.c +++ b/src/conf_snd.c @@ -88,8 +88,8 @@ struct ConfigInfo sound_config[] = { "[player].moving", "empty.wav" }, { "[player].moving.mode_loop", "false" }, { "sand.digging", "schlurf.wav" }, - { "emerald.collecting", "pong.wav" }, - { "emerald.impact", "pling.wav" }, + { "[emerald].collecting", "pong.wav" }, + { "[emerald].impact", "pling.wav" }, { "diamond.collecting", "pong.wav" }, { "diamond.impact", "pling.wav" }, { "diamond.breaking", "quirk.wav" }, diff --git a/src/conf_snd.h b/src/conf_snd.h index 10abc084..28081553 100644 --- a/src/conf_snd.h +++ b/src/conf_snd.h @@ -68,8 +68,8 @@ #define SND_CLASS_SOKOBAN_EMPTYING 47 #define SND_CLASS_PLAYER_MOVING 48 #define SND_SAND_DIGGING 49 -#define SND_EMERALD_COLLECTING 50 -#define SND_EMERALD_IMPACT 51 +#define SND_CLASS_EMERALD_COLLECTING 50 +#define SND_CLASS_EMERALD_IMPACT 51 #define SND_DIAMOND_COLLECTING 52 #define SND_DIAMOND_IMPACT 53 #define SND_DIAMOND_BREAKING 54 diff --git a/src/conftime.h b/src/conftime.h index 6d445a38..0380064c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-11-30 15:29]" +#define COMPILE_DATE_STRING "[2003-12-02 02:40]" diff --git a/src/editor.c b/src/editor.c index 2a26c09f..e7d70349 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5547,6 +5547,26 @@ static boolean PrintInfoText(char *text, int font_nr, int start_line) return TRUE; } +#if 1 + +static int PrintElementDescriptionFromFile(char *filename, int start_line) +{ + int font_nr = FONT_TEXT_2; + int font_width = getFontWidth(font_nr); + int font_height = getFontHeight(font_nr); + int pad_x = ED_SETTINGS_XPOS(0); + int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE; + int sx = SX + pad_x; + int sy = SY + pad_y + start_line * font_height; + int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width; + int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1; + + return DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line, + max_lines_per_screen); +} + +#else + static int PrintElementDescriptionFromFile(char *filename, int start_line) { int font_nr = FONT_TEXT_2; @@ -5634,6 +5654,8 @@ static int PrintElementDescriptionFromFile(char *filename, int start_line) return (current_line - start_line); } +#endif + static void DrawPropertiesTabulatorGadgets() { struct GadgetInfo *gd_gi = level_editor_gadget[GADGET_ID_PROPERTIES_INFO]; diff --git a/src/events.c b/src/events.c index 8cb7c51d..ffd02895 100644 --- a/src/events.c +++ b/src/events.c @@ -377,7 +377,7 @@ void HandleButton(int mx, int my, int button) if (HandleGadgets(mx, my, button)) { /* do not handle this button event anymore */ - mx = my = 0; + mx = my = -32; /* force mouse event to be outside screen tiles */ } switch(game_status) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 05978dd4..f9063d5d 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -441,6 +441,34 @@ char *getHelpTextFilename() return filename; } +char *getLevelSetInfoFilename() +{ + static char *filename = NULL; + char *basenames[] = + { + "readme", + "readme.txt", + "README", + "README.txt", + "README.TXT", + + NULL + }; + int i; + + for (i = 0; basenames[i] != NULL; i++) + { + if (filename != NULL) + free(filename); + + filename = getPath2(getCurrentLevelDir(), basenames[i]); + if (fileExists(filename)) + return filename; + } + + return NULL; +} + static char *getCorrectedArtworkBasename(char *basename) { char *basename_corrected = basename; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 2220e714..7d99fec3 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -201,6 +201,7 @@ char *getSetupFilename(void); char *getEditorSetupFilename(void); char *getHelpAnimFilename(void); char *getHelpTextFilename(void); +char *getLevelSetInfoFilename(void); char *getImageFilename(char *); char *getCustomImageFilename(char *); char *getCustomSoundFilename(char *); diff --git a/src/libgame/text.c b/src/libgame/text.c index 132016de..6fd43735 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -367,7 +367,7 @@ void DrawTextToTextArea(int x, int y, char *text, int font_nr, int line_length, boolean RenderLineToBuffer(char **src_buffer_ptr, char *dst_buffer, int *dst_buffer_len, boolean last_line_was_empty, - int max_chars_per_line) + int line_length) { char *text_ptr = *src_buffer_ptr; char *buffer = dst_buffer; @@ -406,7 +406,7 @@ boolean RenderLineToBuffer(char **src_buffer_ptr, char *dst_buffer, if (buffer_len > 0 || !last_line_was_empty) buffer_filled = TRUE; } - else if (word_len < max_chars_per_line - buffer_len) + else if (word_len < line_length - buffer_len) { /* word fits into text buffer -- add word */ @@ -428,9 +428,9 @@ boolean RenderLineToBuffer(char **src_buffer_ptr, char *dst_buffer, { /* word does not fit at all into empty text buffer -- cut word */ - strncpy(buffer, text_ptr, max_chars_per_line); - buffer[max_chars_per_line] = '\0'; - text_ptr += max_chars_per_line; + strncpy(buffer, text_ptr, line_length); + buffer[line_length] = '\0'; + text_ptr += line_length; buffer_filled = TRUE; } @@ -464,3 +464,83 @@ void DrawTextWrapped(int x, int y, char *text, int font_nr, int line_length, current_line++; } } + +int DrawTextFromFile(int x, int y, char *filename, int font_nr, + int line_length, int max_lines) +{ + int font_height = getFontHeight(font_nr); + char line[MAX_LINE_LEN]; + char buffer[line_length + 1]; + int buffer_len; + int current_line = 0; + FILE *file; + + if (current_line >= max_lines) + return 0; + + if (filename == NULL) + return 0; + + if (!(file = fopen(filename, MODE_READ))) + return 0; + + buffer[0] = '\0'; + buffer_len = 0; + + while (!feof(file) && current_line < max_lines) + { + char *line_ptr; + boolean last_line_was_empty = TRUE; + + /* read next line of input file */ + if (!fgets(line, MAX_LINE_LEN, file)) + break; + + /* skip comments (lines directly beginning with '#') */ + if (line[0] == '#') + continue; + + /* cut trailing newline from input line */ + for (line_ptr = line; *line_ptr; line_ptr++) + { + if (*line_ptr == '\n' || *line_ptr == '\r') + { + *line_ptr = '\0'; + break; + } + } + + if (strlen(line) == 0) /* special case: force empty line */ + strcpy(line, "\n"); + + line_ptr = line; + + while (*line_ptr && current_line < max_lines) + { + boolean buffer_filled = RenderLineToBuffer(&line_ptr, + buffer, &buffer_len, + last_line_was_empty, + line_length); + if (buffer_filled) + { + DrawText(x, y + current_line * font_height, buffer, font_nr); + current_line++; + + last_line_was_empty = (buffer_len == 0); + + buffer[0] = '\0'; + buffer_len = 0; + } + } + } + + fclose(file); + + if (buffer_len > 0 && current_line < max_lines) + { + DrawText(x, y + current_line * font_height, buffer, font_nr); + current_line++; + } + + return current_line; +} diff --git a/src/libgame/text.h b/src/libgame/text.h index 10c91d24..0c5c7586 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -71,5 +71,6 @@ void DrawTextExt(DrawBuffer *, int, int, char *, int, int); void DrawTextToTextArea(int, int, char *, int, int, int, int, int); boolean RenderLineToBuffer(char **, char *, int *, boolean, int); void DrawTextWrapped(int, int, char *, int, int, int); +int DrawTextFromFile(int, int, char *, int, int, int); #endif /* TEXT_H */ diff --git a/src/screens.c b/src/screens.c index 23bfc0c4..015cbd48 100644 --- a/src/screens.c +++ b/src/screens.c @@ -51,8 +51,9 @@ #define INFO_MODE_MUSIC 2 #define INFO_MODE_CREDITS 3 #define INFO_MODE_PROGRAM 4 +#define INFO_MODE_LEVELSET 5 -#define MAX_INFO_MODES 5 +#define MAX_INFO_MODES 6 /* for various menu stuff */ #define MAX_INFO_ELEMENTS_ON_SCREEN 10 @@ -323,7 +324,8 @@ void DrawMainMenu() } for (i = 0; i < 8; i++) - initCursor(i, (i == 1 || i == 6 ? IMG_MENU_BUTTON_RIGHT :IMG_MENU_BUTTON)); + initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_RIGHT : + IMG_MENU_BUTTON)); drawCursorXY(level_width/32 + 4, 1, IMG_MENU_BUTTON_LEFT); drawCursorXY(level_width/32 + 8, 1, IMG_MENU_BUTTON_RIGHT); @@ -439,7 +441,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) DelayReached(&level_delay, 0); /* reset delay counter */ } } - else if (IN_GFX_SCREEN(mx, my) && + else if (IN_VIS_FIELD(x, y) && y >= 0 && y <= 7 && (y != 1 || x < 10)) { if (button) @@ -561,6 +563,12 @@ static void execInfoProgram() DrawInfoScreen(); } +static void execInfoLevelSet() +{ + info_mode = INFO_MODE_LEVELSET; + DrawInfoScreen(); +} + static void execExitInfo() { game_status = GAME_MODE_MAIN; @@ -573,6 +581,7 @@ static struct TokenInfo info_info_main[] = { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" }, { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" }, { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" }, + { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execExitInfo, "Exit" }, @@ -678,7 +687,7 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) y += dy; } - if (IN_GFX_SCREEN(mx, my) && + if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY) { if (button) @@ -724,7 +733,7 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) ClearWindow(); DrawHeadline(); - DrawTextSCentered(100, FONT_TEXT_1, "The game elements:"); + DrawTextSCentered(100, FONT_TEXT_1, "The Game Elements:"); DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4, "Press any key or button for next page"); @@ -811,8 +820,6 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) FrameCounter++; } -#if 1 - static char *getHelpText(int element, int action, int direction) { char token[MAX_LINE_LEN]; @@ -830,12 +837,18 @@ static char *getHelpText(int element, int action, int direction) void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) { +#if 0 int font_nr = FONT_TEXT_2; - int max_chars_per_line = 34; - int max_lines_per_text = 2; - int sx = mSX + 56; +#else + int font_nr = FONT_LEVEL_NUMBER; +#endif + int font_width = getFontWidth(font_nr); + int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX; int sy = mSY + 65 + 2 * 32 + 1; int ystep = TILEY + 4; + int pad_x = sx - SX; + int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width; + int max_lines_per_text = 2; char *text = NULL; if (action != -1 && direction != -1) /* element.action.direction */ @@ -860,48 +873,6 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) max_chars_per_line, max_lines_per_text); } -#else - -void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) -{ - int font_nr = FONT_TEXT_2; - int max_chars_per_line = 34; - int max_lines_per_text = 2; - int sx = mSX + 56; - int sy = mSY + 65 + 2 * 32 + 1; - int ystep = TILEY + 4; - char *text; - - /* 1st try: get text for base element */ - text = getHashEntry(helptext_info, element_info[element].token_name); - - if (text == NULL) - { - /* 2nd try: get text for element/action/direction */ - char token[MAX_LINE_LEN]; - - strcpy(token, element_info[element].token_name); - - if (action != -1) - strcat(token, element_action_info[action].suffix); - - if (direction != -1) - strcat(token, element_direction_info[MV_DIR_BIT(direction)].suffix); - - text = getHashEntry(helptext_info, token); - - if (text == NULL) - text = "No description available"; - } - - if (strlen(text) <= max_chars_per_line) /* only one line of text */ - sy += getFontHeight(font_nr) / 2; - - DrawTextWrapped(sx, sy + ypos * ystep, text, font_nr, - max_chars_per_line, max_lines_per_text); -} -#endif - void DrawInfoScreen_Elements() { LoadHelpAnimInfo(); @@ -1036,7 +1007,7 @@ void HandleInfoScreen_Music(int button) ClearWindow(); DrawHeadline(); - DrawTextSCentered(100, FONT_TEXT_1, "The game background music:"); + DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Music:"); DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title); @@ -1110,7 +1081,7 @@ void DrawInfoScreen_Program() ClearWindow(); DrawHeadline(); - DrawTextSCentered(100, FONT_TEXT_1, "Program information:"); + DrawTextSCentered(100, FONT_TEXT_1, "Program Information:"); DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "This game is Freeware!"); @@ -1165,6 +1136,66 @@ void HandleInfoScreen_Program(int button) } } +void DrawInfoScreen_LevelSet() +{ + int ystart = 150; + int ybottom = SYSIZE - 20; + char *filename = getLevelSetInfoFilename(); +#if 0 + int font_nr = FONT_TEXT_2; +#else + int font_nr = FONT_LEVEL_NUMBER; +#endif + int font_width = getFontWidth(font_nr); + int font_height = getFontHeight(font_nr); + int pad_x = 32; + int pad_y = ystart; + int sx = SX + pad_x; + int sy = SY + pad_y; + int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width; + int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1; + + ClearWindow(); + DrawHeadline(); + + DrawTextSCentered(100, FONT_TEXT_1, "Level Set Information:"); + + DrawTextSCentered(ybottom, FONT_TEXT_4, + "Press any key or button for info menu"); + + if (filename != NULL) + DrawTextFromFile(sx, sy, filename, font_nr, max_chars_per_line, + max_lines_per_screen); + else + DrawTextSCentered(ystart, FONT_TEXT_2, + "No information for this level set."); +} + +void HandleInfoScreen_LevelSet(int button) +{ + int button_released = !button; + + if (button == MB_MENU_LEAVE) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + if (button_released) + { + FadeSoundsAndMusic(); + + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + } + else + { + PlayMenuSoundIfLoop(); + } +} + void DrawInfoScreen() { SetMainBackgroundImage(IMG_BACKGROUND_INFO); @@ -1177,6 +1208,8 @@ void DrawInfoScreen() DrawInfoScreen_Credits(); else if (info_mode == INFO_MODE_PROGRAM) DrawInfoScreen_Program(); + else if (info_mode == INFO_MODE_LEVELSET) + DrawInfoScreen_LevelSet(); else DrawInfoScreen_Main(); @@ -1197,6 +1230,8 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button) HandleInfoScreen_Credits(button); else if (info_mode == INFO_MODE_PROGRAM) HandleInfoScreen_Program(button); + else if (info_mode == INFO_MODE_LEVELSET) + HandleInfoScreen_LevelSet(button); else HandleInfoScreen_Main(mx, my, dx, dy, button); @@ -1549,7 +1584,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, return; } - if (IN_GFX_SCREEN(mx, my) && + if (IN_VIS_FIELD(x, y) && mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && y >= 0 && y < num_page_entries) { @@ -2204,7 +2239,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) y += dy; } - if (IN_GFX_SCREEN(mx, my) && + if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info && setup_info[y].type & ~TYPE_SKIP_ENTRY) { if (button) @@ -2409,7 +2444,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1); } - if (IN_GFX_SCREEN(mx, my) && + if (IN_VIS_FIELD(x, y) && y == 0 && ((x < 10 && !button) || ((x == 10 || x == 12) && button))) { static unsigned long delay = 0; @@ -2421,7 +2456,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) drawPlayerSetupInputInfo(player_nr); } - else if (IN_GFX_SCREEN(mx, my) && + else if (IN_VIS_FIELD(x, y) && y >= pos_start && y <= pos_end && !(y >= pos_empty1 && y <= pos_empty2)) {