-#define COMPILE_DATE_STRING "[2002-09-07 12:06]"
+#define COMPILE_DATE_STRING "[2002-09-07 15:04]"
image_files = getCurrentImageList();
+ printf("--> %d\n", image_files[0].parameter[2]);
+
for(i=0; i<MAX_GRAPHICS; i++)
{
/* always start with reliable default values */
return image_info->file_list;
}
-void InitImageList(struct ConfigInfo *config_list, char *config_suffix_list[],
+void InitImageList(struct ConfigInfo *config_list,
+ struct ConfigInfo *config_suffix_list,
int num_file_list_entries)
{
int i;
image_info->num_file_list_entries = num_file_list_entries;
image_info->num_suffix_list_entries = 0;
- for (i=0; config_suffix_list[i] != NULL; i++)
+ for (i=0; config_suffix_list[i].token != NULL; i++)
image_info->num_suffix_list_entries++;
image_info->file_list =
struct FileInfo *getCurrentImageList();
-void InitImageList(struct ConfigInfo *, char **, int);
+void InitImageList(struct ConfigInfo *, struct ConfigInfo *, int);
void ReloadCustomImages();
void FreeAllImages();
return complete_path;
}
+static char *getStringCat2(char *s1, char *s2)
+{
+ char *complete_string = checked_malloc(strlen(s1) + strlen(s2) + 1);
+
+ sprintf(complete_string, "%s%s", s1, s2);
+ return complete_string;
+}
+
char *getStringCopy(char *s)
{
char *s_copy;
/* ========================================================================= */
struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
- char *suffix_list[],
+ struct ConfigInfo *suffix_list,
int num_file_list_entries)
{
struct FileInfo *file_list;
file_list = checked_calloc(num_file_list_entries * sizeof(struct FileInfo));
- for (i=0; suffix_list[i] != NULL; i++)
+ for (i=0; suffix_list[i].token != NULL; i++)
num_suffix_list_entries++;
- if (num_suffix_list_entries > 0)
+ /* always start with reliable default values */
+ for (i=0; i<num_file_list_entries; i++)
{
- for (i=0; i<num_file_list_entries; i++)
+ file_list[list_pos].token = NULL;
+ file_list[list_pos].default_filename = NULL;
+ file_list[list_pos].filename = NULL;
+
+ if (num_suffix_list_entries > 0)
{
- file_list[i].default_parameter =
- checked_calloc(num_suffix_list_entries * sizeof(int));
- file_list[i].parameter =
- checked_calloc(num_suffix_list_entries * sizeof(int));
+ int parameter_array_size = num_suffix_list_entries * sizeof(int);
+
+ file_list[i].default_parameter = checked_calloc(parameter_array_size);
+ file_list[i].parameter = checked_calloc(parameter_array_size);
for (j=0; j<num_suffix_list_entries; j++)
{
- file_list[i].default_parameter[j] = -1;
- file_list[i].parameter[j] = -1;
+ int default_parameter = atoi(suffix_list[j].value);
+
+ file_list[i].default_parameter[j] = default_parameter;
+ file_list[i].parameter[j] = default_parameter;
}
}
}
int len_config_token = strlen(config_list[i].token);
boolean is_file_entry = TRUE;
- for (j=0; suffix_list[j] != NULL; j++)
+ for (j=0; suffix_list[j].token != NULL; j++)
{
- int len_suffix = strlen(suffix_list[j]);
+ int len_suffix = strlen(suffix_list[j].token);
if (len_suffix < len_config_token &&
strcmp(&config_list[i].token[len_config_token - len_suffix],
- suffix_list[j]) == 0)
+ suffix_list[j].token) == 0)
{
file_list[list_pos].default_parameter[j] = atoi(config_list[i].value);
static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
{
+ struct FileInfo *file_list = artwork_info->file_list;
+ struct ConfigInfo *suffix_list = artwork_info->suffix_list;
int num_file_list_entries = artwork_info->num_file_list_entries;
int num_suffix_list_entries = artwork_info->num_suffix_list_entries;
- struct FileInfo *file_list = artwork_info->file_list;
char *filename = getCustomArtworkConfigFilename(artwork_info->type);
struct SetupFileList *setup_file_list;
int i, j;
/* always start with reliable default values */
for (i=0; i<num_file_list_entries; i++)
{
+ if (file_list[i].filename != NULL)
+ free(file_list[i].filename);
file_list[i].filename = NULL;
for (j=0; j<num_suffix_list_entries; j++)
- {
file_list[i].parameter[j] = file_list[i].default_parameter[j];
- }
}
if (filename == NULL)
if ((setup_file_list = loadSetupFileList(filename)))
{
for (i=0; i<num_file_list_entries; i++)
+ {
file_list[i].filename =
getStringCopy(getTokenValue(setup_file_list, file_list[i].token));
+ for (j=0; j<num_suffix_list_entries; j++)
+ {
+ char *token = getStringCat2(file_list[i].token, suffix_list[j].token);
+ char *value = getTokenValue(setup_file_list, token);
+
+ if (value != NULL)
+ file_list[i].parameter[j] = atoi(value);
+ }
+ }
+
freeSetupFileList(setup_file_list);
#if 0
boolean FileIsMusic(char *);
boolean FileIsArtworkType(char *, int);
-struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, char **, int);
+struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
+ struct ConfigInfo *, int);
void ReloadCustomArtworkList(struct ArtworkListInfo *);
void FreeCustomArtworkList(struct ArtworkListInfo *);
return sound_info->file_list;
}
-void InitSoundList(struct ConfigInfo *config_list, char *config_suffix_list[],
+void InitSoundList(struct ConfigInfo *config_list,
+ struct ConfigInfo *config_suffix_list,
int num_file_list_entries)
{
int i;
sound_info->num_file_list_entries = num_file_list_entries;
sound_info->num_suffix_list_entries = 0;
- for (i=0; config_suffix_list[i] != NULL; i++)
+ for (i=0; config_suffix_list[i].token != NULL; i++)
sound_info->num_suffix_list_entries++;
sound_info->file_list =
void StopSounds(void);
void StopSoundExt(int, int);
struct FileInfo *getCurrentSoundList();
-void InitSoundList(struct ConfigInfo *, char **, int);
+void InitSoundList(struct ConfigInfo *, struct ConfigInfo *, int);
void InitReloadSounds(char *);
void InitReloadMusic(char *);
void FreeAllSounds(void);
int num_suffix_list_entries;
struct FileInfo *file_list; /* static artwork file array */
- char **suffix_list; /* parameter suffixes array */
+ struct ConfigInfo *suffix_list; /* parameter suffixes array */
struct ListNodeInfo **artwork_list; /* static artwork node array */
"gate.wav"
};
-char *image_config_suffix[] =
+struct ConfigInfo image_config_suffix[] =
{
- ".frame_xpos",
- ".frame_ypos",
- ".num_frames",
- NULL
+ { ".frame_xpos", "0" },
+ { ".frame_ypos", "0" },
+ { ".num_frames", "1" },
+
+ { NULL, NULL }
};
-char *sound_config_suffix[] =
+struct ConfigInfo sound_config_suffix[] =
{
- NULL
+ { NULL, NULL }
};
struct ConfigInfo image_config[] =
{ "robot_wheel.frame_xpos", "0" },
{ "robot_wheel.num_frames", "4" },
- { NULL, NULL },
+ { NULL, NULL }
};
struct ConfigInfo sound_config[] =
{ "[not used]", "boom.wav" },
#endif
- { NULL, NULL },
+ { NULL, NULL }
};
struct FileInfo *image_files;
extern struct ElementInfo element_info[];
extern struct GraphicInfo graphic_info[];
extern struct ConfigInfo image_config[], sound_config[];
+extern struct ConfigInfo image_config_suffix[], sound_config_suffix[];
extern struct FileInfo *image_files, *sound_files;
-extern char *image_config_suffix[], *sound_config_suffix[];
/* often used screen positions */
#define SX 8