3 # =============================================================================
4 # create_element_defs.pl
5 # -----------------------------------------------------------------------------
6 # 2002-09-19 holger.schemel@mediaways.net
7 # =============================================================================
12 # =============================================================================
13 # C O N F I G U R A T I O N S E C T I O N
14 # =============================================================================
17 my $src_path = "$base_path/src";
19 if (-d "../src") # we're already inside "src" directory
25 # -----------------------------------------------------------------------------
27 # -----------------------------------------------------------------------------
29 my $filename_header_tmpl = "$src_path/header.tmpl";
31 my $filename_conf_gfx_h = 'conf_gfx.h';
32 my $filename_conf_snd_h = 'conf_snd.h';
33 my $filename_conf_mus_h = 'conf_mus.h';
34 my $filename_conf_chr_c = 'conf_chr.c';
35 my $filename_conf_chr_h = 'conf_chr.h';
36 my $filename_conf_cus_c = 'conf_cus.c';
37 my $filename_conf_cus_h = 'conf_cus.h';
38 my $filename_conf_grp_c = 'conf_grp.c';
39 my $filename_conf_grp_h = 'conf_grp.h';
40 my $filename_conf_e2g_c = 'conf_e2g.c';
41 my $filename_conf_esg_c = 'conf_esg.c';
42 my $filename_conf_e2s_c = 'conf_e2s.c';
43 my $filename_conf_fnt_c = 'conf_fnt.c';
44 my $filename_conf_g2s_c = 'conf_g2s.c';
45 my $filename_conf_g2m_c = 'conf_g2m.c';
46 my $filename_conf_var_c = 'conf_var.c';
47 my $filename_conf_act_c = 'conf_act.c';
49 my $text_auto = 'this file was automatically generated -- do not edit by hand';
50 my $text_gfx_h = 'values for graphics configuration (normal elements)';
51 my $text_snd_h = 'values for sounds configuration';
52 my $text_mus_h = 'values for music configuration';
53 my $text_chr_c = 'values for graphics configuration (character elements)';
54 my $text_chr_h = 'values for elements configuration (character elements)';
55 my $text_cus_c = 'values for graphics configuration (custom elements)';
56 my $text_cus_h = 'values for elements configuration (custom elements)';
57 my $text_grp_c = 'values for graphics configuration (group elements)';
58 my $text_grp_h = 'values for elements configuration (group elements)';
59 my $text_e2g_c = 'values for element/graphics mapping configuration (normal)';
60 my $text_esg_c = 'values for element/graphics mapping configuration (special)';
61 my $text_e2s_c = 'values for element/sounds mapping configuration';
62 my $text_fnt_c = 'values for font/graphics mapping configuration';
63 my $text_g2s_c = 'values for gamemode/sound mapping configuration';
64 my $text_g2m_c = 'values for gamemode/music mapping configuration';
65 my $text_var_c = 'values for image and layout parameter configuration';
66 my $text_act_c = 'values for active states of elements and fonts';
68 my $num_custom_elements = 256;
69 my $num_group_elements = 32;
71 my $char_skip = '---[SKIP]---';
162 # -----------------------------------------------------------------------------
164 # -----------------------------------------------------------------------------
170 # =============================================================================
172 # =============================================================================
176 my ($error_msg) = @_;
178 print STDERR "ERROR: ";
179 print STDERR "$error_msg\n";
184 my ($error_msg) = @_;
186 print STDERR "FATAL ";
192 sub contains_image_file
196 return ($line =~ /\".+\.png\"/ ||
197 $line =~ /UNDEFINED_FILENAME/);
200 sub contains_sound_file
204 return ($line =~ /\".+\.wav\"/ ||
205 $line =~ /UNDEFINED_FILENAME/);
208 sub contains_music_file
212 return ($line =~ /\".+\.wav\"/ ||
213 $line =~ /\".+\.mod\"/ ||
214 $line =~ /\".+\.mp3\"/ ||
215 $line =~ /UNDEFINED_FILENAME/);
218 sub print_file_header
220 my ($filename, $comment) = @_;
221 my $filename_tmpl = 'xxxxxxxx.x';
222 my $filename_text = $filename;
223 my $filename_def = uc($filename);
224 $filename_def =~ s/\./_/;
226 $filename_text .= ' ' x (length($filename_tmpl) - length($filename_text));
228 open(FILE, "$filename_header_tmpl") ||
229 fail("cannot open file '$filename_header_tmpl' for reading");
233 s/$filename_tmpl/$filename_text/;
241 print "/* ----- $text_auto ----- */\n";
243 print "#ifndef $filename_def\n";
244 print "#define $filename_def\n";
246 print "/* $comment */\n";
250 sub print_file_footer
253 my $filename_def = uc($filename);
254 $filename_def =~ s/\./_/;
257 print "#endif /* $filename_def */\n";
262 my ($text, $max_num_tabs) = @_;
264 my $num_tabs = $max_num_tabs - int(length($text) / 8);
266 if ($num_tabs < 1) # at least one tab needed as separator
271 return "\t" x $num_tabs;
274 sub print_graphics_list
276 my $filename = "$src_path/conf_gfx.c";
278 print_file_header($filename_conf_gfx_h, $text_gfx_h);
280 open(FILE, "$filename") ||
281 fail("cannot open file '$filename' for reading");
283 my $max_num_tabs = 7;
288 chomp; # cut trailing newline
290 if (/^\#include "conf_chr.c"/) # dump list of character elements
292 foreach my $char (@chars)
296 $prefix =~ s/^/#define IMG_CHAR_/;
298 my $tabs = get_tabs($prefix, $max_num_tabs);
300 if ($char ne $char_skip)
302 print "$prefix$tabs$i\n";
307 if (lc($char) eq 'space')
309 $prefix =~ s/$/_EDITOR/;
311 my $tabs = get_tabs($prefix, $max_num_tabs);
313 print "$prefix$tabs$i\n";
319 foreach my $char (@chars)
323 $prefix =~ s/^/#define IMG_STEEL_CHAR_/;
325 my $tabs = get_tabs($prefix, $max_num_tabs);
327 if ($char ne $char_skip)
329 print "$prefix$tabs$i\n";
334 if (lc($char) eq 'space')
336 $prefix =~ s/$/_EDITOR/;
338 my $tabs = get_tabs($prefix, $max_num_tabs);
340 print "$prefix$tabs$i\n";
347 if (/^\#include "conf_cus.c"/) # dump list of custom elements
349 for (my $nr = 0; $nr < $num_custom_elements; $nr++)
351 my $line = sprintf("#define IMG_CUSTOM_%d", $nr + 1);
353 my $tabs = get_tabs($line, $max_num_tabs);
355 print "$line$tabs$i\n";
359 $line = sprintf("#define IMG_CUSTOM_%d_EDITOR", $nr + 1);
361 $tabs = get_tabs($line, $max_num_tabs);
363 print "$line$tabs$i\n";
369 if (/^\#include "conf_grp.c"/) # dump list of group elements
371 for (my $nr = 0; $nr < $num_group_elements; $nr++)
373 my $line = sprintf("#define IMG_GROUP_%d", $nr + 1);
375 my $tabs = get_tabs($line, $max_num_tabs);
377 print "$line$tabs$i\n";
381 $line = sprintf("#define IMG_GROUP_%d_EDITOR", $nr + 1);
383 $tabs = get_tabs($line, $max_num_tabs);
385 print "$line$tabs$i\n";
391 if (!contains_image_file($_)) # skip all lines without image file
396 s/(.*)/uc($1)/eg; # convert all characters to upper case
397 s/\./_/g; # replace all '.' with '_'
399 s/^ \{ \"/#define IMG_/; # convert line
400 s/\",.*$//; # convert line
402 # dirty hack for making "ABC[DEF]" work as a "special" suffix
405 # dirty hack for making "[default]" work as an element name
409 my $tabs = get_tabs($_, $max_num_tabs);
416 my $summary = '#define NUM_IMAGE_FILES';
417 my $tabs = get_tabs($summary, $max_num_tabs);
419 print "\n$summary$tabs$i\n";
423 print_file_footer($filename_conf_gfx_h);
426 sub print_sounds_list
428 my %known_element = get_known_element_definitions();
430 my $filename = "$src_path/conf_snd.c";
432 print_file_header($filename_conf_snd_h, $text_snd_h);
434 open(FILE, "$filename") ||
435 fail("cannot open file '$filename' for reading");
437 my $max_num_tabs = 7;
442 chomp; # cut trailing newline
444 if (!contains_sound_file($_)) # skip all lines without sound file
449 if (/\[not used\]/ ||
451 /wav[^\}]*$/) # skip all lines without sound file
456 s/(.*)/uc($1)/eg; # convert all characters to upper case
457 s/\./_/g; # replace all '.' with '_'
464 if ($sound =~ /^\[.+\]/)
466 $sound =~ s/\[//; # element class sound; begin ...
467 $sound =~ s/\]//; # ... and end of definition token
468 $sound =~ s/^/CLASS_/; # add class identifier
471 $sound = "SND_$sound";
473 my $define_text = "#define $sound";
474 my $tabs = get_tabs($define_text, $max_num_tabs);
476 print "$define_text$tabs$i\n";
481 my $summary = '#define NUM_SOUND_FILES';
482 my $tabs = get_tabs($summary, $max_num_tabs);
484 print "\n$summary$tabs$i\n";
488 print_file_footer($filename_conf_snd_h);
493 my %known_prefix = get_known_music_prefix_definitions();
495 my $filename = "$src_path/conf_mus.c";
497 print_file_header($filename_conf_mus_h, $text_mus_h);
499 open(FILE, "$filename") ||
500 fail("cannot open file '$filename' for reading");
502 my $max_num_tabs = 7;
507 chomp; # cut trailing newline
509 if (!contains_music_file($_)) # skip all lines without music file
514 if (/\[not used\]/ ||
516 /wav[^\}]*$/) # skip all lines without music file
521 s/(.*)/uc($1)/eg; # convert all characters to upper case
522 s/\./_/g; # replace all '.' with '_'
529 $music = "MUS_$music";
531 my $define_text = "#define $music";
532 my $tabs = get_tabs($define_text, $max_num_tabs);
534 print "$define_text$tabs$i\n";
539 my $summary = '#define NUM_MUSIC_FILES';
540 my $tabs = get_tabs($summary, $max_num_tabs);
542 print "\n$summary$tabs$i\n";
546 print_file_footer($filename_conf_mus_h);
549 sub print_chars_elements_list
551 print_file_header($filename_conf_chr_h, $text_chr_h);
555 foreach my $char (@chars)
557 my $left = "#define EL_CHAR_$char";
559 my $tabs_left = get_tabs($left, 5);
561 my $right = sprintf("(EL_CHAR_ASCII0 + %d)", $i + 32);
563 if ($char ne $char_skip)
565 print "$left$tabs_left$right\n";
573 foreach my $char (@chars)
575 my $left = "#define EL_STEEL_CHAR_$char";
577 my $tabs_left = get_tabs($left, 5);
579 my $right = sprintf("(EL_STEEL_CHAR_ASCII0 + %d)", $i + 32);
581 if ($char ne $char_skip)
583 print "$left$tabs_left$right\n";
589 print_file_footer($filename_conf_chr_c);
592 sub print_chars_graphics_list_line
594 my ($token, $x, $y) = @_;
604 my $basename = ($token =~ /^steel_char/ ? 'RocksFontDC' : 'RocksFontEM' );
606 foreach my $ext (@extensions)
608 my $left = " \{ \"$token$ext\",";
610 my $tabs_left = get_tabs($left, 6);
612 my $right = ($ext eq '' ? $basename . '.png' :
613 $ext eq '.frames' ? '1' : '0');
619 elsif ($ext eq '.ypos')
624 $right = "\"$right\"";
626 my $tabs_right = get_tabs($right, 3);
628 print "$left$tabs_left$right$tabs_right},\n";
632 sub print_chars_graphics_list
634 print_file_header($filename_conf_chr_c, $text_chr_c);
638 foreach my $char (@chars)
640 if ($char ne $char_skip)
643 my $y = int($i / 16);
645 print_chars_graphics_list_line(lc("char_$char"), $x, $y);
648 if (lc($char) eq 'space')
650 print_chars_graphics_list_line("char_space.EDITOR", 7, 4);
653 if ($char ne $char_skip)
663 foreach my $char (@chars)
665 if ($char ne $char_skip)
668 my $y = int($i / 16);
670 print_chars_graphics_list_line(lc("steel_char_$char"), $x, $y);
673 if (lc($char) eq 'space')
675 print_chars_graphics_list_line("steel_char_space.EDITOR", 7, 4);
678 if ($char ne $char_skip)
686 print_file_footer($filename_conf_chr_c);
689 sub print_custom_elements_list
691 print_file_header($filename_conf_cus_h, $text_cus_h);
693 for (my $i = 0; $i < $num_custom_elements; $i++)
695 my $left = sprintf("#define EL_CUSTOM_%d", $i + 1);
697 my $tabs_left = get_tabs($left, 5);
699 my $right = "(EL_CUSTOM_START + $i)";
701 print "$left$tabs_left$right\n";
704 print_file_footer($filename_conf_cus_c);
707 sub print_group_elements_list
709 print_file_header($filename_conf_grp_h, $text_grp_h);
711 for (my $i = 0; $i < $num_group_elements; $i++)
713 my $left = sprintf("#define EL_GROUP_%d", $i + 1);
715 my $tabs_left = get_tabs($left, 5);
717 my $right = "(EL_GROUP_START + $i)";
719 print "$left$tabs_left$right\n";
722 print_file_footer($filename_conf_grp_c);
725 sub print_custom_graphics_list
741 print_file_header($filename_conf_cus_c, $text_cus_c);
743 for (my $i = 0; $i < $num_custom_elements; $i++)
745 foreach my $ext (@extensions1)
747 my $left = sprintf(" \{ \"custom_%d$ext\",", $i + 1);
749 my $tabs_left = get_tabs($left, 6);
751 # my $right = ($ext eq '' ? 'RocksElements.png' :
752 my $right = ($ext eq '' ? 'RocksCE.png' :
753 $ext eq '.frames' ? '1' : '0');
758 $right = int($i % 16);
760 elsif ($ext eq '.ypos')
763 $right = int($i / 16);
766 $right = "\"$right\"";
768 my $tabs_right = get_tabs($right, 3);
770 print "$left$tabs_left$right$tabs_right},\n";
773 foreach my $ext (@extensions2)
775 my $left = sprintf(" \{ \"custom_%d.EDITOR$ext\",", $i + 1);
777 my $tabs_left = get_tabs($left, 6);
779 # my $right = ($ext eq '' ? 'RocksElements.png' : '0');
780 my $right = ($ext eq '' ? 'RocksCE.png' : '0');
785 $right = int($i % 16) + 16;
787 elsif ($ext eq '.ypos')
790 $right = int($i / 16);
793 $right = "\"$right\"";
795 my $tabs_right = get_tabs($right, 3);
797 print "$left$tabs_left$right$tabs_right},\n";
803 print_file_footer($filename_conf_cus_c);
806 sub print_group_graphics_list
822 print_file_header($filename_conf_grp_c, $text_grp_c);
824 for (my $i = 0; $i < $num_group_elements; $i++)
826 foreach my $ext (@extensions1)
828 my $left = sprintf(" \{ \"group_%d$ext\",", $i + 1);
830 my $tabs_left = get_tabs($left, 6);
832 # my $right = ($ext eq '' ? 'RocksDC.png' :
833 my $right = ($ext eq '' ? 'RocksCE.png' :
834 $ext eq '.frames' ? '1' : '0');
839 $right = int($i % 16);
841 elsif ($ext eq '.ypos')
844 $right = int($i / 16) + int($num_custom_elements / 16);
847 $right = "\"$right\"";
849 my $tabs_right = get_tabs($right, 3);
851 print "$left$tabs_left$right$tabs_right},\n";
854 foreach my $ext (@extensions2)
856 my $left = sprintf(" \{ \"group_%d.EDITOR$ext\",", $i + 1);
858 my $tabs_left = get_tabs($left, 6);
860 # my $right = ($ext eq '' ? 'RocksDC.png' : '0');
861 my $right = ($ext eq '' ? 'RocksCE.png' : '0');
866 $right = int($i % 16) + 16;
868 elsif ($ext eq '.ypos')
871 $right = int($i / 16) + int($num_custom_elements / 16);
874 $right = "\"$right\"";
876 my $tabs_right = get_tabs($right, 3);
878 print "$left$tabs_left$right$tabs_right},\n";
884 print_file_footer($filename_conf_grp_c);
887 sub get_known_element_definitions_ALTERNATIVE
889 my %known_element = ();
891 my $filename = "$src_path/main.h";
893 open(FILE, "$filename") ||
894 fail("cannot open file '$filename' for reading");
898 chomp; # cut trailing newline
900 # process line with element definition
901 if (/^\#define (EL_[A-Z0-9_]+)\s/)
903 $known_element{$1} = 1;
905 # print STDERR "known_element: '$1'\n";
911 return %known_element;
914 sub get_known_element_definitions
916 my %known_element = ();
918 my $filename = "$src_path/main.c";
920 open(FILE, "$filename") ||
921 fail("cannot open file '$filename' for reading");
923 my $element_name = '';
924 my $line_is_element_name = 0;
929 chomp; # cut trailing newline
931 if (/ELEMENT_INFO_START/) # keyword to start parsing file
936 elsif (/ELEMENT_INFO_END/) # keyword to stop parsing file
947 $line_is_element_name = 1;
949 elsif ($line_is_element_name)
951 # process line with element name definition
952 if (/^\s+\"(.+)\",?\s*$/)
954 $element_name = 'EL_' . uc($1);
956 # dirty hack for making "[default]" work as an element name
957 $element_name =~ s/\[//;
958 $element_name =~ s/\]//;
960 # change '.' to '_' for elements like "dynamite.active"
961 $element_name =~ s/\./_/g;
963 $known_element{$element_name} = 1;
965 # printf STDERR "::: known element '$element_name'\n";
968 $line_is_element_name = 0;
974 return %known_element;
977 sub get_known_element_class_definitions
979 my %known_element_class = ();
981 my $filename = "$src_path/main.c";
983 open(FILE, "$filename") ||
984 fail("cannot open file '$filename' for reading");
986 my $element_name = '';
987 my $element_class = '';
988 my $line_is_element_name = 0;
989 my $line_is_element_class = 0;
994 chomp; # cut trailing newline
996 if (/ELEMENT_INFO_START/) # keyword to start parsing file
1001 elsif (/ELEMENT_INFO_END/) # keyword to stop parsing file
1012 $line_is_element_name = 1;
1014 elsif ($line_is_element_name)
1016 # process line with element name definition
1017 if (/^\s+\"(.+)\",?\s*$/)
1019 $element_name = 'EL_' . uc($1);
1021 # dirty hack for making "[default]" work as an element name
1022 $element_name =~ s/\[//;
1023 $element_name =~ s/\]//;
1025 # change '.' to '_' for elements like "dynamite.active"
1026 $element_name =~ s/\./_/g;
1029 $line_is_element_name = 0;
1030 $line_is_element_class = 1;
1032 elsif ($line_is_element_class)
1034 # process line with element class definition
1035 if (/^\s+\"(.+)\",?\s*$/)
1037 $element_class = 'EL_CLASS_' . uc($1);
1039 if (!defined($known_element_class{$element_class}))
1041 $known_element_class{$element_class} = $element_name;
1044 $known_element_class{$element_name} = $element_class;
1046 # print STDERR "known_element_class: '$element_name' => '$element_class'\n";
1049 $line_is_element_class = 0;
1055 return %known_element_class;
1058 sub get_known_action_definitions
1060 my %known_action = ();
1062 my $filename = "$src_path/main.h";
1064 open(FILE, "$filename") ||
1065 fail("cannot open file '$filename' for reading");
1069 chomp; # cut trailing newline
1071 # process line with action definition
1072 if (/^\#define ACTION_([A-Z0-9_]+)\s/)
1074 $known_action{$1} = 1;
1076 # print STDERR "known_action: '$1'\n";
1082 return %known_action;
1085 sub get_known_special_arg_definitions
1087 my %known_special_arg = ();
1089 my $filename = "$src_path/main.h";
1091 open(FILE, "$filename") ||
1092 fail("cannot open file '$filename' for reading");
1096 chomp; # cut trailing newline
1098 # process line with special arg definition
1099 if (/^\#define GFX_SPECIAL_ARG_([A-Z0-9_]+)\s/)
1101 if ($1 eq 'CRUMBLED')
1106 $known_special_arg{$1} = 1;
1108 # print STDERR "known_special_arg: '$1'\n";
1114 return %known_special_arg;
1117 sub get_known_button_definitions
1119 my %known_button = ();
1121 my $filename = "$src_path/conf_gfx.h";
1123 open(FILE, "$filename") ||
1124 fail("cannot open file '$filename' for reading");
1128 chomp; # cut trailing newline
1130 # process line with button definition
1131 if (/^\#define (IMG_MENU_BUTTON[A-Z0-9_]*)\s/)
1133 $known_button{$1} = 1;
1135 # print STDERR "known_button: '$1'\n";
1141 return %known_button;
1144 sub get_known_font_definitions
1146 my %known_font = ();
1148 my $filename = "$src_path/main.h";
1150 open(FILE, "$filename") ||
1151 fail("cannot open file '$filename' for reading");
1155 chomp; # cut trailing newline
1157 # process line with font definition
1158 if (/^\#define (FONT_[A-Z0-9_]+)\s/)
1160 $known_font{$1} = 1;
1162 # print STDERR "known_font: '$1'\n";
1171 sub get_known_sound_prefix_definitions
1173 my %known_sound_prefix = ( 'background' => 1 );
1175 return %known_sound_prefix;
1178 sub get_known_music_prefix_definitions
1180 my %known_music_prefix = ();
1182 my $filename = "$src_path/main.c";
1184 open(FILE, "$filename") ||
1185 fail("cannot open file '$filename' for reading");
1187 my $prefix_name = '';
1192 chomp; # cut trailing newline
1194 if (/MusicPrefixInfo/) # keyword to start parsing file
1199 elsif (/NULL/ && !$skip_line) # keyword to stop parsing file
1208 if (/^\s+{\s+\"(.+)\"/)
1210 my $music_prefix = $1;
1212 $known_music_prefix{$music_prefix} = 1;
1214 # printf STDERR "::: known music prefix '$music_prefix'\n";
1220 return %known_music_prefix;
1223 sub print_element_to_graphic_entry
1225 my ($element, $action, $direction, $crumbled, $graphic) = @_;
1227 my $num_tabs = 5 - int((length($element) + 4 + 1) / 8);
1228 my $tabs = "\t" x $num_tabs;
1234 $crumbled = ($crumbled == 1 ? 'TRUE' : 'FALSE');
1237 print " $element,$tabs$action, $direction, $crumbled,\n";
1238 print " $graphic\n";
1242 sub print_element_to_special_graphic_entry
1244 my ($element, $special, $graphic) = @_;
1246 my $num_tabs = 6 - int((length($element) + 4 + 1) / 8);
1247 my $tabs = "\t" x $num_tabs;
1254 print " $element,$tabs$special,\n";
1255 print " $graphic\n";
1259 sub print_font_to_graphic_entry
1261 my ($font, $special, $graphic) = @_;
1263 my $num_tabs = 6 - int((length($font) + 4 + 1) / 8);
1264 my $tabs = "\t" x $num_tabs;
1271 print " $font,$tabs$special,\n";
1272 print " $graphic\n";
1276 sub print_element_to_sound_entry
1278 my ($element, $is_class, $action, $sound) = @_;
1280 my $element_plus_is_class = "$element, $is_class";
1282 my $num_tabs = 6 - int((length($element_plus_is_class) + 4 + 1) / 8);
1283 my $tabs = "\t" x $num_tabs;
1290 print " $element_plus_is_class,$tabs$action,\n";
1295 sub print_gamemode_to_sound_entry
1297 my ($gamemode, $sound) = @_;
1300 print " $gamemode,\n";
1305 sub print_gamemode_to_music_entry
1307 my ($gamemode, $music) = @_;
1310 print " $gamemode,\n";
1315 sub print_image_config_var_entry
1317 my ($token, $var) = @_;
1325 sub print_active_state_entry
1327 my ($token, $token_active) = @_;
1331 print " $token_active\n";
1335 sub print_element_to_graphic_list
1337 my %graphic_without_element =
1339 'IMG_FLAMES_1_LEFT' => 1,
1340 'IMG_FLAMES_2_LEFT' => 1,
1341 'IMG_FLAMES_3_LEFT' => 1,
1342 'IMG_FLAMES_1_RIGHT' => 1,
1343 'IMG_FLAMES_2_RIGHT' => 1,
1344 'IMG_FLAMES_3_RIGHT' => 1,
1345 'IMG_FLAMES_1_UP' => 1,
1346 'IMG_FLAMES_2_UP' => 1,
1347 'IMG_FLAMES_3_UP' => 1,
1348 'IMG_FLAMES_1_DOWN' => 1,
1349 'IMG_FLAMES_2_DOWN' => 1,
1350 'IMG_FLAMES_3_DOWN' => 1,
1351 'IMG_TWINKLE_BLUE' => 1,
1352 'IMG_TWINKLE_WHITE' => 1,
1355 my %additional_mappings =
1357 # file elements which are mapped to runtime elements when playing
1359 # 'EL_EM_KEY_1_FILE' => 'IMG_EM_KEY_1',
1360 # 'EL_EM_KEY_2_FILE' => 'IMG_EM_KEY_2',
1361 # 'EL_EM_KEY_3_FILE' => 'IMG_EM_KEY_3',
1362 # 'EL_EM_KEY_4_FILE' => 'IMG_EM_KEY_4',
1364 # new elements which still have no graphic
1365 # 'EL_DOOR_WHITE', => 'IMG_CHAR_QUESTION',
1366 # 'EL_DOOR_WHITE_GRAY', => 'IMG_CHAR_QUESTION',
1367 # 'EL_KEY_WHITE', => 'IMG_CHAR_QUESTION',
1368 # 'EL_SIGN_RADIOACTIVITY', => 'IMG_CHAR_QUESTION',
1369 # 'EL_SIGN_WHEELCHAIR', => 'IMG_CHAR_QUESTION',
1370 # 'EL_SIGN_PARKING', => 'IMG_CHAR_QUESTION',
1371 # 'EL_SIGN_ONEWAY', => 'IMG_CHAR_QUESTION',
1372 # 'EL_SIGN_HEART', => 'IMG_CHAR_QUESTION',
1373 # 'EL_SIGN_TRIANGLE', => 'IMG_CHAR_QUESTION',
1374 # 'EL_SIGN_ROUND', => 'IMG_CHAR_QUESTION',
1375 # 'EL_SIGN_EXIT', => 'IMG_CHAR_QUESTION',
1376 # 'EL_SIGN_YINYANG', => 'IMG_CHAR_QUESTION',
1377 # 'EL_SIGN_OTHER', => 'IMG_CHAR_QUESTION',
1378 'EL_SIGN_UNUSED_1', => 'IMG_CHAR_QUESTION',
1379 'EL_SIGN_UNUSED_2', => 'IMG_CHAR_QUESTION',
1380 'EL_DX_UNKNOWN_15', => 'IMG_CHAR_QUESTION',
1381 'EL_DX_UNKNOWN_42', => 'IMG_CHAR_QUESTION',
1383 # file elements with direction which is not defined
1384 'EL_BD_BUTTERFLY_LEFT' => 'IMG_BD_BUTTERFLY',
1385 'EL_BD_BUTTERFLY_RIGHT' => 'IMG_BD_BUTTERFLY',
1386 'EL_BD_BUTTERFLY_UP' => 'IMG_BD_BUTTERFLY',
1387 'EL_BD_BUTTERFLY_DOWN' => 'IMG_BD_BUTTERFLY',
1388 'EL_BD_FIREFLY_LEFT' => 'IMG_BD_FIREFLY',
1389 'EL_BD_FIREFLY_RIGHT' => 'IMG_BD_FIREFLY',
1390 'EL_BD_FIREFLY_UP' => 'IMG_BD_FIREFLY',
1391 'EL_BD_FIREFLY_DOWN' => 'IMG_BD_FIREFLY',
1394 my @unknown_graphics = ();
1395 my %known_element = get_known_element_definitions();
1396 my %known_action = get_known_action_definitions();
1397 my %known_special_arg = get_known_special_arg_definitions();
1398 my %known_direction =
1410 # ---------- read graphic file definitions ----------
1412 my $filename = "$src_path/conf_gfx.c";
1414 print_file_header($filename_conf_e2g_c, $text_e2g_c);
1416 open(FILE, "$filename") ||
1417 fail("cannot open file '$filename' for reading");
1419 print "static struct\n";
1421 print " int element;\n";
1422 print " int action;\n";
1423 print " int direction;\n";
1424 print " boolean crumbled;\n";
1426 print " int graphic;\n";
1428 print "element_to_graphic[] =\n";
1433 chomp; # cut trailing newline
1435 if (/NO_MORE_ELEMENT_IMAGES/) # keyword to stop parsing file
1440 if (!contains_image_file($_)) # skip all lines without image file
1445 s/^ \{ \"//; # cut all leading ...
1446 s/\",.*$//; # ... and trailing garbage
1448 s/\[(\d+)\]/_$1/; # convert "[1]" to "_1" etc.
1450 s/\[//; # dirty hack for making "[default]" ...
1451 s/\]//; # ... work as an element name
1455 if ($token =~ /\.([^\.]+)$/ && defined($known_special_arg{$1}))
1457 next; # skip all special definitions
1460 $token = uc($token); # convert all characters to upper case
1462 my $gfx_action_default = '-1';
1463 my $gfx_action = $gfx_action_default;
1465 my $gfx_direction_default = '-1';
1466 my $gfx_direction = $gfx_direction_default;
1468 my $gfx_crumbled = '0';
1470 my $object = $token;
1475 if ($object =~ /^(.*)\.([A-Z0-9]+)$/ && $2 eq 'CRUMBLED')
1480 $gfx_crumbled = '1';
1483 if ($object =~ /^(.*)\.([A-Z0-9]+)$/ && defined($known_direction{$2}))
1488 $gfx_direction = "MV_BIT_$direction";
1489 $gfx_direction_default = $gfx_direction;
1492 if ($object =~ /^(.*)\.([A-Z0-9_]+)$/ && defined($known_action{$2}))
1497 $gfx_action = "ACTION_$action";
1498 $gfx_action_default = $gfx_action;
1502 $object =~ s/\./_/g; # needed for "invisible_sand.active.digging"
1504 # print STDERR "'$token' => '$object', '$action', '$direction'\n";
1506 my $full_element = "EL_$token";
1507 my $base_element = "EL_$object";
1509 my $element = $base_element;
1510 my $graphic = "IMG_$token";
1512 my $element_without_crumbled = $full_element;
1513 $element_without_crumbled =~ s/_$crumbled$//;
1515 my $element_without_direction = $element_without_crumbled;
1516 $element_without_direction =~ s/_$direction$//;
1518 my $element_without_action = $element_without_direction;
1519 $element_without_action =~ s/_$action$//;
1521 if (defined($known_element{$full_element}))
1523 $element = $full_element;
1525 $gfx_action_default = '-1';
1526 $gfx_direction_default = '-1';
1529 if ($element_without_action eq $element || $action eq '')
1531 $element_without_action = '';
1534 if ($element_without_direction eq $element || $direction eq '')
1536 $element_without_direction = '';
1539 if ($element_without_crumbled eq $element || $crumbled eq '')
1541 $element_without_crumbled = '';
1544 if (defined($graphic_without_element{$graphic}))
1549 if (!defined($known_element{$element}))
1551 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1553 push @unknown_graphics, $graphic;
1558 if (defined($known_element{$element}))
1560 print_element_to_graphic_entry($element,
1561 $gfx_action_default,
1562 $gfx_direction_default,
1567 if (defined($known_element{$element_without_action}))
1569 print_element_to_graphic_entry($element_without_action,
1576 if (defined($known_element{$element_without_direction}))
1578 print_element_to_graphic_entry($element_without_direction,
1585 if (defined($known_element{$element_without_crumbled}))
1587 print_element_to_graphic_entry($element_without_crumbled,
1595 # dump list of additional elements
1596 foreach my $element (sort keys %additional_mappings)
1598 print_element_to_graphic_entry($element, '-1', '-1', '-1',
1599 $additional_mappings{$element});
1602 # dump list of character elements
1603 foreach my $char (@chars)
1605 my $element = "EL_CHAR_$char";
1606 my $graphic = "IMG_CHAR_$char";
1608 if ($char ne $char_skip)
1610 print_element_to_graphic_entry($element, '-1', '-1', '-1',$graphic);
1613 foreach my $char (@chars)
1615 my $element = "EL_STEEL_CHAR_$char";
1616 my $graphic = "IMG_STEEL_CHAR_$char";
1618 if ($char ne $char_skip)
1620 print_element_to_graphic_entry($element, '-1', '-1', '-1',$graphic);
1624 # dump list of custom elements
1625 for (my $i = 0; $i < $num_custom_elements; $i++)
1627 my $element = sprintf("EL_CUSTOM_%d", $i + 1);
1628 my $graphic = sprintf("IMG_CUSTOM_%d", $i + 1);
1630 print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
1633 # dump list of group elements
1634 for (my $i = 0; $i < $num_group_elements; $i++)
1636 my $element = sprintf("EL_GROUP_%d", $i + 1);
1637 my $graphic = sprintf("IMG_GROUP_%d", $i + 1);
1639 print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
1642 print_element_to_graphic_entry('-1', '-1', '-1', '-1', '-1');
1648 if (scalar(@unknown_graphics) > 0)
1650 print STDERR "-" x 79 . "\n";
1651 print STDERR "The following graphics cannot be associated with any element:\n";
1653 foreach my $graphic (@unknown_graphics)
1655 print STDERR "- $graphic\n";
1658 print STDERR "-" x 79 . "\n";
1661 print_file_footer($filename_conf_e2g_c);
1664 sub print_element_to_special_graphic_list
1666 my %graphic_without_element =
1668 'IMG_GLOBAL_DOOR' => 1,
1671 my %additional_mappings =
1673 # old elements which are mapped to other elements when playing
1674 #'EL_BUG' => 'IMG_BUG_RIGHT',
1675 #'EL_SPACESHIP' => 'IMG_SPACESHIP_RIGHT',
1676 #'EL_PACMAN' => 'IMG_PACMAN_RIGHT',
1679 my @elements_with_editor_graphic =
1684 my @unknown_graphics = ();
1685 my %known_element = get_known_element_definitions();
1686 my %known_special_arg = get_known_special_arg_definitions();
1688 # ---------- read graphic file definitions ----------
1690 my $filename = "$src_path/conf_gfx.c";
1692 print_file_header($filename_conf_esg_c, $text_esg_c);
1694 open(FILE, "$filename") ||
1695 fail("cannot open file '$filename' for reading");
1697 print "static struct\n";
1699 print " int element;\n";
1700 print " int special;\n";
1702 print " int graphic;\n";
1704 print "element_to_special_graphic[] =\n";
1709 chomp; # cut trailing newline
1711 if (/NO_MORE_ELEMENT_IMAGES/) # keyword to stop parsing file
1716 if (!contains_image_file($_)) # skip all lines without image file
1721 s/^ \{ \"//; # cut all leading ...
1722 s/\",.*$//; # ... and trailing garbage
1728 if ($token =~ /^font\./) # skip all font definitions
1733 if ($token =~ /^background\./) # skip all background image definitions
1738 if ($token =~ /^(.*)\.([^\.]+)$/ &&
1739 defined($known_special_arg{$2}))
1742 $special = "GFX_SPECIAL_ARG_" . $2;
1746 next; # skip all default definitions
1749 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
1750 $object =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
1753 $object =~ s/\./_/g;
1755 # print STDERR "'$token' => '$object'\n";
1757 my $element = "EL_$object";
1758 my $graphic = "IMG_$token";
1760 if (defined($graphic_without_element{$graphic}))
1765 if (!defined($known_element{$element}))
1767 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1769 push @unknown_graphics, $graphic;
1774 print_element_to_special_graphic_entry($element,
1779 # dump list of additional elements
1780 foreach my $element (sort keys %additional_mappings)
1782 print_element_to_special_graphic_entry($element,
1783 'GFX_SPECIAL_ARG_EDITOR',
1784 $additional_mappings{$element});
1785 print_element_to_special_graphic_entry($element,
1786 'GFX_SPECIAL_ARG_PREVIEW',
1787 $additional_mappings{$element});
1790 # dump list of custom element editor graphics
1791 for (my $i = 0; $i < $num_custom_elements; $i++)
1793 my $element = sprintf("EL_CUSTOM_%d", $i + 1);
1794 my $graphic = sprintf("IMG_CUSTOM_%d_EDITOR", $i + 1);
1796 print_element_to_special_graphic_entry($element,
1797 'GFX_SPECIAL_ARG_EDITOR',
1801 # dump list of group element editor graphics
1802 for (my $i = 0; $i < $num_group_elements; $i++)
1804 my $element = sprintf("EL_GROUP_%d", $i + 1);
1805 my $graphic = sprintf("IMG_GROUP_%d_EDITOR", $i + 1);
1807 print_element_to_special_graphic_entry($element,
1808 'GFX_SPECIAL_ARG_EDITOR',
1812 # dump other special editor graphics
1813 foreach my $token (@elements_with_editor_graphic)
1815 my $element = 'EL_' . uc($token);
1816 my $graphic = 'IMG_' . uc($token) . '_EDITOR';
1818 print_element_to_special_graphic_entry($element,
1819 'GFX_SPECIAL_ARG_EDITOR',
1823 print_element_to_special_graphic_entry('-1', '-1', '-1');
1829 if (scalar(@unknown_graphics) > 0)
1831 print STDERR "-" x 79 . "\n";
1832 print STDERR "The following graphics cannot be associated with any element:\n";
1834 foreach my $graphic (@unknown_graphics)
1836 print STDERR "- $graphic\n";
1839 print STDERR "-" x 79 . "\n";
1842 print_file_footer($filename_conf_esg_c);
1845 sub print_element_to_sound_list
1847 my %sound_without_action =
1849 'SND_AMOEBA_TURNING_TO_GEM' => 1,
1850 'SND_AMOEBA_TURNING_TO_ROCK' => 1,
1851 'SND_BD_AMOEBA_TURNING_TO_GEM' => 1,
1852 'SND_BD_AMOEBA_TURNING_TO_ROCK' => 1,
1854 # no special case anymore after adding action ".splashing"
1855 # 'SND_ACID_SPLASHING' => 1,
1858 my @unknown_sounds = ();
1859 my %known_element = get_known_element_definitions();
1860 my %known_element_class = get_known_element_class_definitions();
1861 my %known_action = get_known_action_definitions();
1863 # ---------- read sound file definitions ----------
1865 my $filename = "$src_path/conf_snd.c";
1867 print_file_header($filename_conf_e2s_c, $text_e2s_c);
1869 open(FILE, "$filename") ||
1870 fail("cannot open file '$filename' for reading");
1872 print "static struct\n";
1874 print " int element;\n";
1875 print " boolean is_class;\n";
1876 print " int action;\n";
1878 print " int sound;\n";
1880 print "element_to_sound[] =\n";
1885 chomp; # cut trailing newline
1887 if (/NO_MORE_ELEMENT_SOUNDS/) # keyword to stop parsing file
1892 if (!contains_sound_file($_)) # skip all lines without sound file
1897 s/^ \{ \"//; # cut all leading ...
1898 s/\",.*$//; # ... and trailing garbage
1902 $token = uc($token); # convert all characters to upper case
1904 my $snd_action_default = '-1';
1905 my $snd_action = $snd_action_default;
1907 my $object = $token;
1910 if ($object =~ /^(.*)\.([A-Z0-9_]+)$/ && defined($known_action{$2}))
1915 $snd_action = "ACTION_$action";
1916 $snd_action_default = $snd_action;
1920 $object =~ s/\./_/g; # needed for "invisible_sand.active.digging"
1922 if ($object =~ /^\[(.+)\]$/)
1924 $object = 'CLASS_' . $1;
1927 # print STDERR "'$token' => '$object', '$action'\n";
1929 my $full_element = "EL_$token";
1930 my $base_element = "EL_$object";
1932 my $element = $base_element;
1935 if ($sound =~ /^\[.+\]/)
1937 $sound =~ s/\[//; # element class sound; begin ...
1938 $sound =~ s/\]//; # ... and end of definition token
1939 $sound =~ s/^/CLASS_/; # add class identifier
1942 $sound = "SND_$sound";
1944 my $element_without_action = $full_element;
1945 $element_without_action =~ s/_$action$//;
1947 my $element_class_without_action = $full_element;
1948 $element_without_action =~ s/_$action$//;
1950 if (defined($known_element_class{$full_element}))
1952 $element = $full_element;
1954 $snd_action_default = '-1';
1957 if ($element_without_action eq $element || $action eq '')
1959 $element_without_action = '';
1962 if (defined($sound_without_action{$sound}))
1967 if (!defined($known_element{$element}) &&
1968 !defined($known_element_class{$element}))
1970 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1972 push @unknown_sounds, $sound;
1977 if (!($element =~ /_CLASS_/) &&
1978 defined($known_element{$element}))
1980 print_element_to_sound_entry($element, "FALSE",
1981 $snd_action_default,
1985 if (!($element =~ /_CLASS_/) &&
1986 defined($known_element{$element_without_action}))
1988 print_element_to_sound_entry($element_without_action, "FALSE",
1993 if ($element =~ /_CLASS_/ &&
1994 defined($known_element_class{$element}))
1996 my $class_element = $known_element_class{$element};
1998 print_element_to_sound_entry($class_element, "TRUE",
1999 $snd_action_default,
2003 if ($element =~ /_CLASS_/ &&
2004 defined($known_element_class{$element_without_action}))
2006 my $class_element = $known_element_class{$element_without_action};
2008 print_element_to_sound_entry($class_element, "TRUE",
2014 print_element_to_sound_entry('-1', '-1', '-1', '-1');
2020 if (scalar(@unknown_sounds) > 0)
2022 print STDERR "-" x 79 . "\n";
2023 print STDERR "The following sounds cannot be associated with any element or element class:\n";
2025 foreach my $sound (@unknown_sounds)
2027 print STDERR "- $sound\n";
2030 print STDERR "-" x 79 . "\n";
2033 print_file_footer($filename_conf_e2s_c);
2036 sub print_font_to_graphic_list
2038 my @unknown_graphics = ();
2039 my %known_font = get_known_font_definitions();
2040 my %known_special_arg = get_known_special_arg_definitions();
2042 # ---------- read graphic file definitions ----------
2044 my $filename = "$src_path/conf_gfx.c";
2046 print_file_header($filename_conf_fnt_c, $text_fnt_c);
2048 open(FILE, "$filename") ||
2049 fail("cannot open file '$filename' for reading");
2051 print "static struct\n";
2053 print " int font_nr;\n";
2054 print " int special;\n";
2056 print " int graphic;\n";
2058 print "font_to_graphic[] =\n";
2063 chomp; # cut trailing newline
2065 if (!contains_image_file($_)) # skip all lines without image file
2070 s/^ \{ \"//; # cut all leading ...
2071 s/\",.*$//; # ... and trailing garbage
2078 if ($token =~ /^(font\..*)$/)
2083 if ($token =~ /^(.*)\.([^\.]+)$/ &&
2084 defined($known_special_arg{$2}))
2087 $special = "GFX_SPECIAL_ARG_" . $2;
2092 next; # skip all non-font definitions
2095 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2096 $font =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2101 # print STDERR "'$token' => '$font'\n";
2103 $graphic = "IMG_$token";
2105 if (!defined($known_font{$font}))
2107 # print STDERR "----- ERROR: unknown font '$font' -----\n";
2109 push @unknown_graphics, $graphic;
2114 print_font_to_graphic_entry($font,
2119 print_font_to_graphic_entry('-1', '-1', '-1');
2125 if (scalar(@unknown_graphics) > 0)
2127 print STDERR "-" x 79 . "\n";
2128 print STDERR "The following graphics cannot be associated with any font:\n";
2130 foreach my $graphic (@unknown_graphics)
2132 print STDERR "- $graphic\n";
2135 print STDERR "-" x 79 . "\n";
2138 print_file_footer($filename_conf_fnt_c);
2141 sub print_gamemode_to_sound_list
2143 my %known_prefix = get_known_sound_prefix_definitions();
2144 my %known_special_arg = get_known_special_arg_definitions();
2146 # ---------- read music file definitions ----------
2148 my $filename = "$src_path/conf_snd.c";
2150 print_file_header($filename_conf_g2s_c, $text_g2s_c);
2152 open(FILE, "$filename") ||
2153 fail("cannot open file '$filename' for reading");
2155 print "static struct\n";
2157 print " int gamemode;\n";
2159 print " int sound;\n";
2161 print "gamemode_to_sound[] =\n";
2166 chomp; # cut trailing newline
2168 if (!contains_sound_file($_)) # skip all lines without sound file
2178 s/^ \{ \"//; # cut all leading ...
2179 s/\",.*$//; # ... and trailing garbage
2183 # my $level = -1; # ???
2185 if (defined($known_prefix{$token}))
2187 # no special arg defined
2189 elsif ($token =~ /^(.*)\.([^\.]+)$/ &&
2190 defined($known_prefix{$1}) &&
2191 defined($known_special_arg{$2}))
2193 $gamemode = "GFX_SPECIAL_ARG_" . $2;
2200 # if ($token =~ /^(.*)\./ &&
2201 # !defined($known_prefix{$1}))
2206 # if ($token =~ /^(.*)\.([^\.]+)$/ &&
2207 # defined($known_special_arg{$2}))
2209 # $gamemode = "GFX_SPECIAL_ARG_" . $2;
2212 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2215 my $sound = "SND_$token";
2217 # print STDERR "'$token' => '$sound'\n";
2219 print_gamemode_to_sound_entry($gamemode, $sound);
2222 print_gamemode_to_sound_entry('-1', '-1');
2228 print_file_footer($filename_conf_g2s_c);
2231 sub print_gamemode_to_music_list
2233 my %known_prefix = get_known_music_prefix_definitions();
2234 my %known_special_arg = get_known_special_arg_definitions();
2236 # ---------- read music file definitions ----------
2238 my $filename = "$src_path/conf_mus.c";
2240 print_file_header($filename_conf_g2m_c, $text_g2m_c);
2242 open(FILE, "$filename") ||
2243 fail("cannot open file '$filename' for reading");
2245 print "static struct\n";
2247 print " int gamemode;\n";
2249 print " int music;\n";
2251 print "gamemode_to_music[] =\n";
2256 chomp; # cut trailing newline
2258 if (!contains_music_file($_)) # skip all lines without music file
2263 s/^ \{ \"//; # cut all leading ...
2264 s/\",.*$//; # ... and trailing garbage
2269 if (defined($known_prefix{$token}))
2271 # no special arg defined
2273 elsif ($token =~ /^(.*)\.([^\.]+)$/ &&
2274 defined($known_prefix{$1}) &&
2275 defined($known_special_arg{$2}))
2277 $gamemode = "GFX_SPECIAL_ARG_" . $2;
2284 # my $prefix = $token;
2285 # $prefix =~ s/\..*$//;
2287 ## if ($token =~ /^(.*)\./ &&
2288 ## !defined($known_prefix{$1}))
2289 # if (!defined($known_prefix{$prefix}))
2294 # if ($token =~ /^(.*)\.([^\.]+)$/ &&
2295 # defined($known_special_arg{$2}))
2297 # $gamemode = "GFX_SPECIAL_ARG_" . $2;
2300 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2303 my $music = "MUS_$token";
2305 # print STDERR "'$token' => '$music'\n";
2307 print_gamemode_to_music_entry($gamemode, $music);
2310 print_gamemode_to_music_entry('-1', '-1');
2316 print_file_footer($filename_conf_g2m_c);
2319 sub print_image_config_vars
2321 # ---------- read graphic file definitions ----------
2323 my $filename = "$src_path/conf_gfx.c";
2325 print_file_header($filename_conf_var_c, $text_var_c);
2327 open(FILE, "$filename") ||
2328 fail("cannot open file '$filename' for reading");
2330 print "struct TokenIntPtrInfo image_config_vars[] =\n";
2333 my $start_parsing = 0;
2337 chomp; # cut trailing newline
2339 if (/CONFIG_VARS_START/) # keyword to start parsing file
2344 if (!$start_parsing)
2349 if (/^\s*\{\s*\"([^\"]+)\"/) # config token found
2354 # --- some prefix replacements ---
2356 $var =~ s/^main\./menu.main./;
2357 $var =~ s/^\[player\]\./game.player_/;
2358 $var =~ s/^\[title_initial\]/title_initial_default/;
2359 $var =~ s/^\[title\]/title_default/;
2360 $var =~ s/^\[titlemessage_initial\]/titlemessage_initial_default/;
2361 $var =~ s/^\[titlemessage\]/titlemessage_default/;
2363 if ($var =~ /^titlemessage.*(\d)/ ||
2364 $var =~ /^game.panel.key_(\d)/ ||
2365 $var =~ /^game.panel.inventory_first_(\d)/ ||
2366 $var =~ /^game.panel.inventory_last_(\d)/ ||
2367 $var =~ /^game.panel.conveyor_belt_(\d)\./ ||
2368 $var =~ /^game.panel.element_(\d)\./ ||
2369 $var =~ /^game.panel.graphic_(\d)\./ ||
2370 $var =~ /^game.panel.ce_score_(\d)\./)
2373 my $array_pos = int($number) - 1;
2374 $var =~ s/_$number/\[$array_pos\]/;
2376 elsif ($var =~ /^game.panel.conveyor_belt_(\d)(_switch)/ ||
2377 $var =~ /^game.panel.element_(\d)(_count)/ ||
2378 $var =~ /^game.panel.ce_score_(\d)(_element)/)
2382 my $array_pos = int($number) - 1;
2383 $var =~ s/_$number$suffix/$suffix\[$array_pos\]/;
2386 # --- some suffix replacements ---
2388 $var =~ s/^(menu\.main\..*)\.chars$/$1.size/;
2389 $var =~ s/^(game\.panel\..*)\.chars$/$1.size/;
2390 $var =~ s/^(game\.panel\..*)\.tile_size$/$1.size/;
2391 $var =~ s/^(request\.button\..*)\.tile_size$/$1.size/;
2392 $var =~ s/\.digits$/.size/;
2393 $var =~ s/\.element$/.id/;
2394 $var =~ s/\.draw_order$/.sort_priority/;
2396 $var =~ s/\.font_[a-z]+$/.font_alt/;
2397 $var =~ s/\.INFO\[([A-Z]+)\]$/_info\[GFX_SPECIAL_ARG_INFO_$1\]/;
2398 $var =~ s/\.SETUP\[([A-Z0-9_]+)\]$/_setup\[GFX_SPECIAL_ARG_SETUP_$1\]/;
2399 $var =~ s/\.([A-Z]+)$/\[GFX_SPECIAL_ARG_$1\]/;
2400 $var =~ s/\.([A-Z]+)\./\[GFX_SPECIAL_ARG_$1\]./;
2402 if ($var =~ /^(menu.(enter|leave)_screen)(.[a-z_]+)$/)
2404 $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
2407 if ($var =~ /^menu.(draw_[xy]offset|list_size)$/)
2409 $var .= "[GFX_SPECIAL_ARG_DEFAULT]";
2412 if ($var =~ /^(viewport.(playfield|door_[12]))(.[a-z_]+)$/)
2414 $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
2417 print_image_config_var_entry("\"$token\"", "&$var");
2421 print_image_config_var_entry('NULL', 'NULL');
2427 print_file_footer($filename_conf_var_c);
2430 sub print_active_states
2432 # ---------- read graphic file definitions ----------
2434 my %known_element = get_known_element_definitions();
2435 my %known_button = get_known_button_definitions();
2436 my %known_font = get_known_font_definitions();
2438 print_file_header($filename_conf_act_c, $text_act_c);
2440 print "static struct\n";
2442 print " int element;\n";
2443 print " int element_active;\n";
2445 print "element_with_active_state[] =\n";
2448 foreach my $element (sort keys %known_element)
2450 my $element_active = $element . '_ACTIVE';
2452 if (defined($known_element{$element_active}))
2454 print_active_state_entry($element, $element_active);
2458 print_active_state_entry('-1', '-1');
2464 print "static struct\n";
2466 print " int button;\n";
2467 print " int button_active;\n";
2469 print "button_with_active_state[] =\n";
2472 foreach my $button (sort keys %known_button)
2474 my $button_active = $button . '_ACTIVE';
2476 if (defined($known_button{$button_active}))
2478 print_active_state_entry($button, $button_active);
2482 print_active_state_entry('-1', '-1');
2488 print "static struct\n";
2490 print " int font_nr;\n";
2491 print " int font_nr_active;\n";
2493 print "font_with_active_state[] =\n";
2496 foreach my $font (sort keys %known_font)
2498 my $font_active = $font . '_ACTIVE';
2500 if (defined($known_font{$font_active}))
2502 print_active_state_entry($font, $font_active);
2506 print_active_state_entry('-1', '-1');
2510 print_file_footer($filename_conf_act_c);
2514 # =============================================================================
2515 # M A I N - P R O G R A M
2516 # =============================================================================
2520 my $argc = scalar(@ARGV);
2522 if ($argc == 0 || $ARGV[0] eq '-h' || $ARGV[0] eq '--help')
2524 print "Usage: $0 <file>\n\n";
2525 print "Choose <file> from the following list:\n";
2526 print "- '$filename_conf_gfx_h'\n";
2527 print "- '$filename_conf_snd_h'\n";
2528 print "- '$filename_conf_mus_h'\n";
2529 print "- '$filename_conf_chr_c'\n";
2530 print "- '$filename_conf_chr_h'\n";
2531 print "- '$filename_conf_cus_c'\n";
2532 print "- '$filename_conf_cus_h'\n";
2533 print "- '$filename_conf_grp_c'\n";
2534 print "- '$filename_conf_grp_h'\n";
2535 print "- '$filename_conf_e2g_c'\n";
2536 print "- '$filename_conf_esg_c'\n";
2537 print "- '$filename_conf_fnt_c'\n";
2538 print "- '$filename_conf_g2s_c'\n";
2539 print "- '$filename_conf_g2m_c'\n";
2540 print "- '$filename_conf_var_c'\n";
2541 print "- '$filename_conf_act_c'\n";
2546 if ($ARGV[0] eq $filename_conf_gfx_h)
2548 print_graphics_list();
2550 elsif ($ARGV[0] eq $filename_conf_snd_h)
2552 print_sounds_list();
2554 elsif ($ARGV[0] eq $filename_conf_mus_h)
2558 elsif ($ARGV[0] eq $filename_conf_chr_c)
2560 print_chars_graphics_list();
2562 elsif ($ARGV[0] eq $filename_conf_chr_h)
2564 print_chars_elements_list();
2566 elsif ($ARGV[0] eq $filename_conf_cus_c)
2568 print_custom_graphics_list();
2570 elsif ($ARGV[0] eq $filename_conf_cus_h)
2572 print_custom_elements_list();
2574 elsif ($ARGV[0] eq $filename_conf_grp_c)
2576 print_group_graphics_list();
2578 elsif ($ARGV[0] eq $filename_conf_grp_h)
2580 print_group_elements_list();
2582 elsif ($ARGV[0] eq $filename_conf_e2g_c)
2584 print_element_to_graphic_list();
2586 elsif ($ARGV[0] eq $filename_conf_esg_c)
2588 print_element_to_special_graphic_list();
2590 elsif ($ARGV[0] eq $filename_conf_e2s_c)
2592 print_element_to_sound_list();
2594 elsif ($ARGV[0] eq $filename_conf_fnt_c)
2596 print_font_to_graphic_list();
2598 elsif ($ARGV[0] eq $filename_conf_g2s_c)
2600 print_gamemode_to_sound_list();
2602 elsif ($ARGV[0] eq $filename_conf_g2m_c)
2604 print_gamemode_to_music_list();
2606 elsif ($ARGV[0] eq $filename_conf_var_c)
2608 print_image_config_vars();
2610 elsif ($ARGV[0] eq $filename_conf_act_c)
2612 print_active_states();
2616 print "Unknown option '$ARGV[0]'.\n";