my $text_fnt_c = 'values for font/graphics mapping configuration';
my $text_g2s_c = 'values for gamemode/sound mapping configuration';
my $text_g2m_c = 'values for gamemode/music mapping configuration';
-my $text_var_c = 'values for image and layout parameter configuration';
+my $text_var_c = 'values for graphics and sound parameter configuration';
my $text_act_c = 'values for active states of elements and fonts';
my $num_custom_elements = 256;
print " },\n";
}
-sub print_image_config_var_entry
+sub print_config_var_entry
{
my ($token, $var) = @_;
print_file_footer($filename_conf_g2m_c);
}
-sub print_image_config_vars
+sub print_config_vars
{
# ---------- read graphic file definitions ----------
$var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
}
- print_image_config_var_entry("\"$token\"", "&$var");
+ print_config_var_entry("\"$token\"", "&$var");
if ($var =~ /^(title)_default/ ||
$var =~ /^(title_initial)_default/ ||
my $prefix = $1;
$var =~ s/^$prefix/${prefix}_first/;
- print_image_config_var_entry("\"$token\"", "&$var");
+ print_config_var_entry("\"$token\"", "&$var");
}
}
}
- print_image_config_var_entry('NULL', 'NULL');
+ print_config_var_entry('NULL', 'NULL');
+
+ print "};\n";
+
+ close FILE;
+
+
+ # ---------- read sound file definitions ----------
+
+ $filename = "$src_path/conf_snd.c";
+
+ open(FILE, "$filename") ||
+ fail("cannot open file '$filename' for reading");
+
+ print "struct TokenIntPtrInfo sound_config_vars[] =\n";
+ print "{\n";
+
+ $start_parsing = 0;
+
+ while (<FILE>)
+ {
+ chomp; # cut trailing newline
+
+ if (/CONFIG_VARS_START/) # keyword to start parsing file
+ {
+ $start_parsing = 1;
+ }
+
+ if (!$start_parsing)
+ {
+ next;
+ }
+
+ if (/^\s*\{\s*\"([^\"]+)\"/) # config token found
+ {
+ my $token = $1;
+ my $var = $token;
+
+ print_config_var_entry("\"$token\"", "&$var");
+ }
+ }
+
+ print_config_var_entry('NULL', 'NULL');
print "};\n";
}
elsif ($ARGV[0] eq $filename_conf_var_c)
{
- print_image_config_vars();
+ print_config_vars();
}
elsif ($ARGV[0] eq $filename_conf_act_c)
{
InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics();
}
+void InitSoundSettings_FromHash(SetupFileHash *setup_file_hash,
+ boolean ignore_defaults)
+{
+ int i;
+
+ for (i = 0; sound_config_vars[i].token != NULL; i++)
+ {
+ char *value = getHashEntry(setup_file_hash, sound_config_vars[i].token);
+
+ // (ignore definitions set to "[DEFAULT]" which are already initialized)
+ if (ignore_defaults && strEqual(value, ARG_DEFAULT))
+ continue;
+
+ if (value != NULL)
+ *sound_config_vars[i].value =
+ get_token_parameter_value(sound_config_vars[i].token, value);
+ }
+}
+
+void InitSoundSettings_Static(void)
+{
+ // always start with reliable default values from static default config
+ InitSoundSettings_FromHash(sound_config_hash, FALSE);
+}
+
+static void LoadSoundSettingsFromFilename(char *filename)
+{
+ SetupFileHash *setup_file_hash;
+
+ if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
+ return;
+
+ // read (and overwrite with) values that may be specified in config file
+ InitSoundSettings_FromHash(setup_file_hash, TRUE);
+
+ freeSetupFileHash(setup_file_hash);
+}
+
+void LoadSoundSettings(void)
+{
+ char *filename_base = UNDEFINED_FILENAME, *filename_local;
+
+ InitSoundSettings_Static();
+
+ if (!GFX_OVERRIDE_ARTWORK(ARTWORK_TYPE_SOUNDS))
+ {
+ // first look for special settings configured in level series config
+ filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_SOUNDS);
+
+ if (fileExists(filename_base))
+ LoadSoundSettingsFromFilename(filename_base);
+ }
+
+ filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_SOUNDS);
+
+ if (filename_local != NULL && !strEqual(filename_base, filename_local))
+ LoadSoundSettingsFromFilename(filename_local);
+}
+
void LoadUserDefinedEditorElementList(int **elements, int *num_elements)
{
char *filename = getEditorSetupFilename();
void InitMenuDesignSettings_Static(void);
void LoadMenuDesignSettings(void);
void LoadMenuDesignSettings_AfterGraphics(void);
+void InitSoundSettings_FromHash(SetupFileHash *, boolean);
+void InitSoundSettings_Static(void);
+void LoadSoundSettings(void);
void LoadUserDefinedEditorElementList(int **, int *);
void LoadMusicInfo(void);
void LoadHelpAnimInfo(void);
image_config[i].token,
image_config[i].value);
+ // create hash from sound config list
+ sound_config_hash = newSetupFileHash();
+ for (i = 0; sound_config[i].token != NULL; i++)
+ setHashEntry(sound_config_hash,
+ sound_config[i].token,
+ sound_config[i].value);
+
// create hash from element token list
element_token_hash = newSetupFileHash();
for (i = 0; element_name_info[i].token_name != NULL; i++)
// dynamically determine list of sound tokens to be ignored
num_ignore_sound_tokens = num_ignore_generic_tokens;
+ for (i = 0; sound_config_vars[i].token != NULL; i++)
+ num_ignore_sound_tokens++;
ignore_sound_tokens =
checked_malloc((num_ignore_sound_tokens + 1) * sizeof(char *));
for (i = 0; i < num_ignore_generic_tokens; i++)
ignore_sound_tokens[i] = ignore_generic_tokens[i];
+ for (i = 0; i < num_ignore_sound_tokens - num_ignore_generic_tokens; i++)
+ ignore_sound_tokens[num_ignore_generic_tokens + i] =
+ sound_config_vars[i].token;
ignore_sound_tokens[num_ignore_sound_tokens] = NULL;
// dynamically determine list of music tokens to be ignored
redraw_mask = REDRAW_ALL;
}
+static void InitSnd(void)
+{
+ InitSoundSettings_Static();
+
+ // read settings for initial sounds from default custom artwork config
+ char *snd_config_filename = getPath3(options.sounds_directory,
+ SND_DEFAULT_SUBDIR,
+ SOUNDSINFO_FILENAME);
+
+ if (fileExists(snd_config_filename))
+ {
+ SetupFileHash *setup_file_hash = loadSetupFileHash(snd_config_filename);
+
+ if (setup_file_hash)
+ {
+ // read values from custom sounds config file
+ InitSoundSettings_FromHash(setup_file_hash, FALSE);
+
+ freeSetupFileHash(setup_file_hash);
+ }
+ }
+}
+
static void InitLevelInfo(void)
{
LoadLevelInfo(); // global level info
InitReloadCustomSounds();
print_timestamp_time("InitReloadCustomSounds");
+ LoadSoundSettings();
+ print_timestamp_time("LoadSoundSettings");
+
ReinitializeSounds();
print_timestamp_time("ReinitializeSounds");
print_timestamp_time("[init element properties stuff]");
InitGfx();
+ InitSnd();
print_timestamp_time("InitGfx");
SetupFileHash *helptext_info = NULL;
SetupFileHash *image_config_hash = NULL;
+SetupFileHash *sound_config_hash = NULL;
SetupFileHash *element_token_hash = NULL;
SetupFileHash *graphic_token_hash = NULL;
SetupFileHash *font_token_hash = NULL;
extern struct ElementDirectionInfo element_direction_info[];
extern struct SpecialSuffixInfo special_suffix_info[];
extern struct TokenIntPtrInfo image_config_vars[];
+extern struct TokenIntPtrInfo sound_config_vars[];
extern struct FontInfo font_info[];
extern struct GlobalAnimInfo global_anim_info[];
extern struct GlobalAnimNameInfo global_anim_name_info[];
extern struct HelpAnimInfo *helpanim_info;
extern SetupFileHash *helptext_info;
extern SetupFileHash *image_config_hash;
+extern SetupFileHash *sound_config_hash;
extern SetupFileHash *element_token_hash;
extern SetupFileHash *graphic_token_hash;
extern SetupFileHash *font_token_hash;