From: Holger Schemel Date: Sat, 22 Nov 2003 02:36:54 +0000 (+0100) Subject: rnd-20031122-1-src X-Git-Tag: 3.0.8^2~20 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8a1c6f39577584e0479ed638ed8b3df11d74f561;p=rocksndiamonds.git rnd-20031122-1-src --- diff --git a/src/conf_e2g.c b/src/conf_e2g.c index e17b2fac..34ea8a3f 100644 --- a/src/conf_e2g.c +++ b/src/conf_e2g.c @@ -885,10 +885,18 @@ element_to_graphic[] = EL_AMOEBA_GROWING, -1, -1, FALSE, IMG_AMOEBA_GROWING }, + { + EL_AMOEBA, ACTION_GROWING, -1, FALSE, + IMG_AMOEBA_GROWING + }, { EL_AMOEBA_SHRINKING, -1, -1, FALSE, IMG_AMOEBA_SHRINKING }, + { + EL_AMOEBA, ACTION_SHRINKING, -1, FALSE, + IMG_AMOEBA_SHRINKING + }, { EL_AMOEBA_WET, -1, -1, FALSE, IMG_AMOEBA_WET @@ -897,6 +905,10 @@ element_to_graphic[] = EL_AMOEBA_DROPPING, -1, -1, FALSE, IMG_AMOEBA_DROPPING }, + { + EL_AMOEBA, ACTION_DROPPING, -1, FALSE, + IMG_AMOEBA_DROPPING + }, { EL_AMOEBA_DRY, -1, -1, FALSE, IMG_AMOEBA_DRY diff --git a/src/conftime.h b/src/conftime.h index b4b0a87d..a3595d1d 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-11-21 02:35]" +#define COMPILE_DATE_STRING "[2003-11-22 03:36]" diff --git a/src/files.c b/src/files.c index 779a6751..51e2c44d 100644 --- a/src/files.c +++ b/src/files.c @@ -2859,11 +2859,12 @@ static struct MusicFileInfo *get_music_file_info(char *basename) } token_to_value_ptr[] = { - { "title", &tmp_music_file_info.title }, - { "artist", &tmp_music_file_info.artist }, - { "album", &tmp_music_file_info.album }, - { "year", &tmp_music_file_info.year }, - { NULL, NULL }, + { "context", &tmp_music_file_info.context }, + { "title", &tmp_music_file_info.title }, + { "artist", &tmp_music_file_info.artist }, + { "album", &tmp_music_file_info.album }, + { "year", &tmp_music_file_info.year }, + { NULL, NULL }, }; int i; @@ -2914,8 +2915,7 @@ static struct MusicFileInfo *get_music_file_info(char *basename) { char *value = getHashEntry(setup_file_hash, token_to_value_ptr[i].token); - if (value != NULL) - *token_to_value_ptr[i].value_ptr = getStringCopy(value); + *token_to_value_ptr[i].value_ptr = getStringCopy(value); /* may be NULL */ } new_music_file_info = checked_calloc(sizeof(struct MusicFileInfo)); @@ -3018,3 +3018,203 @@ void LoadMusicInfo() printf("::: title == '%s'\n", next->title); #endif } + +void add_info_animation(int element, int action, int direction, int delay, + int *num_list_entries) +{ + struct InfoAnimationInfo *new_list_entry; + (*num_list_entries)++; + + info_animation_info = + checked_realloc(info_animation_info, + *num_list_entries * sizeof(struct InfoAnimationInfo)); + new_list_entry = &info_animation_info[*num_list_entries - 1]; + + new_list_entry->element = element; + new_list_entry->action = action; + new_list_entry->direction = direction; + new_list_entry->delay = delay; +} + +void print_unknown_token(char *filename, char *token, int token_nr) +{ + if (token_nr == 0) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "warning: unknown token(s) found in config file:"); + Error(ERR_RETURN, "- config file: '%s'", filename); + } + + Error(ERR_RETURN, "- token: '%s'", token); +} + +void print_unknown_token_end(int token_nr) +{ + if (token_nr > 0) + Error(ERR_RETURN_LINE, "-"); +} + +void LoadInfoAnimations() +{ + char *filename = getElementInfoFilename(); + SetupFileList *setup_file_list, *list; + SetupFileHash *element_hash, *action_hash, *direction_hash; + int num_list_entries = 0; + int num_unknown_tokens = 0; + int i; + + if ((setup_file_list = loadSetupFileList(filename)) == NULL) + return; + + element_hash = newSetupFileHash(); + action_hash = newSetupFileHash(); + direction_hash = newSetupFileHash(); + + for (i=0; i < MAX_NUM_ELEMENTS; i++) + setHashEntry(element_hash, element_info[i].token_name, itoa(i)); + + for (i=0; i < NUM_ACTIONS; i++) + setHashEntry(action_hash, element_action_info[i].suffix, + itoa(element_action_info[i].value)); + + for (i=0; i < NUM_DIRECTIONS; i++) + setHashEntry(direction_hash, element_direction_info[i].suffix, + itoa(element_direction_info[i].value)); + + for (list = setup_file_list; list != NULL; list = list->next) + { + char *element_token, *action_token, *direction_token; + char *element_value, *action_value, *direction_value; + int delay = atoi(list->value); + + if (strcmp(list->token, "end") == 0) + { + add_info_animation(-1, -1, -1, -1, &num_list_entries); + + continue; + } + + element_token = list->token; + element_value = getHashEntry(element_hash, element_token); + + if (element_value != NULL) + { + /* element found */ + add_info_animation(atoi(element_value), -1, -1, + delay, &num_list_entries); + + continue; + } + + if (strchr(element_token, '.') == NULL) + { + /* no further suffixes found -- this is not an element */ + print_unknown_token(filename, list->token, num_unknown_tokens++); + + continue; + } + + action_token = strchr(element_token, '.'); + element_token = getStringCopy(element_token); + *strchr(element_token, '.') = '\0'; + + element_value = getHashEntry(element_hash, element_token); + + if (element_value == NULL) + { + /* this is not an element */ + print_unknown_token(filename, list->token, num_unknown_tokens++); + free(element_token); + + continue; + } + + action_value = getHashEntry(action_hash, action_token); + + if (action_value != NULL) + { + /* action found */ + add_info_animation(atoi(element_value), atoi(action_value), -1, + delay, &num_list_entries); + free(element_token); + + continue; + } + + direction_token = action_token; + direction_value = getHashEntry(direction_hash, direction_token); + + if (direction_value != NULL) + { + /* direction found */ + add_info_animation(atoi(element_value), -1, atoi(direction_value), + delay, &num_list_entries); + free(element_token); + + continue; + } + + if (strchr(action_token + 1, '.') == NULL) + { + /* no further suffixes found -- this is not an action or direction */ + print_unknown_token(filename, list->token, num_unknown_tokens++); + free(element_token); + + continue; + } + + direction_token = strchr(action_token + 1, '.'); + action_token = getStringCopy(action_token); + *strchr(action_token + 1, '.') = '\0'; + + action_value = getHashEntry(action_hash, action_token); + + if (action_value == NULL) + { + /* this is not an action */ + print_unknown_token(filename, list->token, num_unknown_tokens++); + free(element_token); + free(action_token); + + continue; + } + + direction_value = getHashEntry(direction_hash, direction_token); + + if (direction_value != NULL) + { + /* direction found */ + add_info_animation(atoi(element_value), atoi(action_value), + atoi(direction_value), + delay, &num_list_entries); + free(element_token); + free(action_token); + + continue; + } + + print_unknown_token(filename, list->token, num_unknown_tokens++); + + free(element_token); + free(action_token); + } + + print_unknown_token_end(num_unknown_tokens); + + add_info_animation(-999, -999, -999, -999, &num_list_entries); + + freeSetupFileList(setup_file_list); + freeSetupFileHash(element_hash); + freeSetupFileHash(action_hash); + freeSetupFileHash(direction_hash); + +#if 0 + /* TEST ONLY */ + for (i=0; i < num_list_entries; i++) + printf("::: %d, %d, %d => %d\n", + info_animation_info[i].element, + info_animation_info[i].action, + info_animation_info[i].direction, + info_animation_info[i].delay); +#endif +} diff --git a/src/files.h b/src/files.h index 0da4cc2d..844503a0 100644 --- a/src/files.h +++ b/src/files.h @@ -42,5 +42,6 @@ void LoadCustomElementDescriptions(); void LoadSpecialMenuDesignSettings(); void LoadUserDefinedEditorElementList(int **, int *); void LoadMusicInfo(); +void LoadInfoAnimations(); #endif /* FILES_H */ diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 3ba6745d..446fb1e4 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -417,6 +417,18 @@ char *getEditorSetupFilename() return filename; } +char *getElementInfoFilename() +{ + static char *filename = NULL; + + if (filename != NULL) + free(filename); + + filename = getPath2(getCurrentLevelDir(), ELEMENTINFO_FILENAME); + + return filename; +} + static char *getCorrectedArtworkBasename(char *basename) { char *basename_corrected = basename; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 9939437a..85ec5db1 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -197,6 +197,7 @@ char *getTapeFilename(int); char *getScoreFilename(int); char *getSetupFilename(void); char *getEditorSetupFilename(void); +char *getElementInfoFilename(void); char *getImageFilename(char *); char *getCustomImageFilename(char *); char *getCustomSoundFilename(char *); diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 26142811..8fb94919 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1934,7 +1934,7 @@ void LoadCustomMusic_NoConf(void) if (music_already_used) continue; -#if 1 +#if 0 if (FileIsSound(basename) || FileIsMusic(basename)) printf("DEBUG: loading music '%s' ...\n", basename); #endif diff --git a/src/libgame/system.h b/src/libgame/system.h index ec1b5250..3abbbd76 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -228,6 +228,7 @@ #define SETUP_FILENAME "setup.conf" #define LEVELSETUP_FILENAME "levelsetup.conf" #define EDITORSETUP_FILENAME "editorsetup.conf" +#define ELEMENTINFO_FILENAME "elementinfo.conf" #define LEVELINFO_FILENAME "levelinfo.conf" #define GRAPHICSINFO_FILENAME "graphicsinfo.conf" #define SOUNDSINFO_FILENAME "soundsinfo.conf" @@ -240,6 +241,7 @@ #define SETUP_FILENAME "setup.cnf" #define LEVELSETUP_FILENAME "lvlsetup.cnf" #define EDITORSETUP_FILENAME "edsetup.conf" +#define ELEMENTINFO_FILENAME "eleminfo.conf" #define LEVELINFO_FILENAME "lvlinfo.cnf" #define GRAPHICSINFO_FILENAME "gfxinfo.cnf" #define SOUNDSINFO_FILENAME "sndinfo.cnf" diff --git a/src/main.c b/src/main.c index d9319c5c..4032019b 100644 --- a/src/main.c +++ b/src/main.c @@ -105,6 +105,7 @@ struct GraphicInfo *graphic_info = NULL; struct SoundInfo *sound_info = NULL; struct MusicInfo *music_info = NULL; struct MusicFileInfo *music_file_info = NULL; +struct InfoAnimationInfo *info_animation_info = NULL; /* ------------------------------------------------------------------------- */ @@ -3476,12 +3477,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] = "-" }, { - "nut_breaking", + "nut.breaking", "-", "-" }, { - "diamond_breaking", + "diamond.breaking", "-", "-" }, @@ -3496,12 +3497,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] = "-" }, { - "amoeba_growing", + "amoeba.growing", "-", "-" }, { - "amoeba_shrinking", + "amoeba.shrinking", "-", "-" }, @@ -3640,6 +3641,11 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] = "-", "-" }, + { + "amoeba", + "amoeba", + "-" + }, { "[default]", "default", diff --git a/src/main.h b/src/main.h index 3bbb2652..ebcfb39d 100644 --- a/src/main.h +++ b/src/main.h @@ -882,12 +882,13 @@ #define EL_DYNABOMB_PLAYER_4 (EL_FIRST_DUMMY + 17) #define EL_SHIELD_NORMAL_ACTIVE (EL_FIRST_DUMMY + 18) #define EL_SHIELD_DEADLY_ACTIVE (EL_FIRST_DUMMY + 19) -#define EL_DEFAULT (EL_FIRST_DUMMY + 20) -#define EL_BD_DEFAULT (EL_FIRST_DUMMY + 21) -#define EL_SP_DEFAULT (EL_FIRST_DUMMY + 22) -#define EL_SB_DEFAULT (EL_FIRST_DUMMY + 23) +#define EL_AMOEBA (EL_FIRST_DUMMY + 20) +#define EL_DEFAULT (EL_FIRST_DUMMY + 21) +#define EL_BD_DEFAULT (EL_FIRST_DUMMY + 22) +#define EL_SP_DEFAULT (EL_FIRST_DUMMY + 23) +#define EL_SB_DEFAULT (EL_FIRST_DUMMY + 24) -#define MAX_NUM_ELEMENTS (EL_FIRST_DUMMY + 24) +#define MAX_NUM_ELEMENTS (EL_FIRST_DUMMY + 25) /* values for graphics/sounds action types */ @@ -1514,6 +1515,15 @@ struct SpecialSuffixInfo int value; }; +struct InfoAnimationInfo +{ + int element; + int action; + int direction; + + int delay; +}; + #if 0 extern GC tile_clip_gc; @@ -1608,6 +1618,7 @@ extern struct GraphicInfo *graphic_info; extern struct SoundInfo *sound_info; extern struct MusicInfo *music_info; extern struct MusicFileInfo *music_file_info; +extern struct InfoAnimationInfo *info_animation_info; extern struct ConfigInfo image_config[]; extern struct ConfigInfo sound_config[]; extern struct ConfigInfo music_config[]; diff --git a/src/screens.c b/src/screens.c index a6b259d9..328f6893 100644 --- a/src/screens.c +++ b/src/screens.c @@ -516,6 +516,7 @@ static long helpscreen_state; static int helpscreen_step[MAX_HELPSCREEN_ELS]; static int helpscreen_frame[MAX_HELPSCREEN_ELS]; +#if 0 static int helpscreen_action[] = { IMG_PLAYER_1_MOVING_DOWN, 16, @@ -725,6 +726,8 @@ static int helpscreen_action[] = HA_END }; +#endif + static char *helpscreen_eltext[][2] = { {"THE HERO:", "(Is _this_ guy good old Rockford?)"}, @@ -792,6 +795,7 @@ static char *helpscreen_eltext[][2] = }; static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *)); +#if 0 static char *helpscreen_music[][3] = { { "Alchemy", "Ian Boddy", "Drive" }, @@ -802,73 +806,98 @@ static char *helpscreen_music[][3] = { "Voyager", "The Alan Parsons Project","Pyramid" }, { "Twilight Painter", "Tangerine Dream", "Heartbreakers" } }; +#endif + static int num_helpscreen_music = 7; static int helpscreen_musicpos; -#if 0 -void OLD_DrawHelpScreenElAction(int start) +#if 1 +void DrawHelpScreenElAction(int start) { int i = 0, j = 0; - int frame, graphic; - int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4; + int xstart = mSX + 16; + int ystart = mSY + 64 + 2 * 32; + int ystep = TILEY + 4; + int element, action, direction; + int graphic; + int delay; + int sync_frame; - while(helpscreen_action[j] != HA_END) + while (info_animation_info[j].element != -999) { - if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els) + if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els) break; - else if (i=start && helpscreen_delay[i-start]) - helpscreen_delay[i-start]--; - - while(helpscreen_action[j] != HA_NEXT) + while (info_animation_info[j].element != -1) j++; + j++; i++; + continue; } - j += 3*helpscreen_step[i-start]; - graphic = helpscreen_action[j++]; + j += helpscreen_step[i - start]; + + element = info_animation_info[j].element; + action = info_animation_info[j].action; + direction = info_animation_info[j].direction; + + if (action != -1 && direction != -1) + graphic = el_act_dir2img(element, action, direction); + else if (action != -1) + graphic = el_act2img(element, action); + else if (direction != -1) + graphic = el_act2img(element, direction); + else + graphic = el2img(element); + + delay = info_animation_info[j++].delay; + + if (delay == -1) + delay = 1000000; - if (helpscreen_frame[i-start]) + if (helpscreen_frame[i - start] == 0) { - frame = helpscreen_action[j++] - helpscreen_frame[i-start]; - helpscreen_frame[i-start]--; + sync_frame = 0; + helpscreen_frame[i - start] = delay - 1; } else { - frame = 0; - helpscreen_frame[i-start] = helpscreen_action[j++]-1; + sync_frame = delay - helpscreen_frame[i - start]; + helpscreen_frame[i - start]--; } - helpscreen_delay[i-start] = helpscreen_action[j++] - 1; - - if (helpscreen_action[j] == HA_NEXT) + if (info_animation_info[j].element == -1) { - if (!helpscreen_frame[i-start]) - helpscreen_step[i-start] = 0; + if (!helpscreen_frame[i - start]) + helpscreen_step[i - start] = 0; } else { - if (!helpscreen_frame[i-start]) - helpscreen_step[i-start]++; - while(helpscreen_action[j] != HA_NEXT) + if (!helpscreen_frame[i - start]) + helpscreen_step[i - start]++; + while(info_animation_info[j].element != -1) j++; } + j++; - DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame); + ClearRectangleOnBackground(drawto, xstart, ystart + (i - start) * ystep, + TILEX, TILEY); + DrawGraphicAnimationExt(drawto, xstart, ystart + (i - start) * ystep, + graphic, sync_frame, USE_MASKING); + i++; } - for(i=2;i<16;i++) - { - MarkTileDirty(0,i); - MarkTileDirty(1,i); - } + redraw_mask |= REDRAW_FIELD; + + FrameCounter++; } -#endif + +#else void DrawHelpScreenElAction(int start) { @@ -953,6 +982,7 @@ void DrawHelpScreenElAction(int start) FrameCounter++; } +#endif void DrawHelpScreenElText(int start) { @@ -1095,8 +1125,14 @@ void DrawHelpScreen() helpscreen_musicpos = 0; helpscreen_state = 0; + LoadInfoAnimations(); LoadMusicInfo(); + num_helpscreen_els = 0; + for (i=0; info_animation_info[i].element != -999; i++) + if (info_animation_info[i].element == -1) + num_helpscreen_els++; + num_helpscreen_music = 0; for (list = music_file_info; list != NULL; list = list->next) num_helpscreen_music++;