3 # =============================================================================
4 # Rocks'n'Diamonds - McDuffin Strikes Back!
5 # -----------------------------------------------------------------------------
6 # (c) 1995-2014 by Artsoft Entertainment
9 # http://www.artsoft.org/
10 # -----------------------------------------------------------------------------
11 # create_element_defs.pl
12 # =============================================================================
17 # =============================================================================
18 # C O N F I G U R A T I O N S E C T I O N
19 # =============================================================================
22 my $src_path = "$base_path/src";
24 if (-d "../src") # we're already inside "src" directory
30 # -----------------------------------------------------------------------------
32 # -----------------------------------------------------------------------------
34 my $filename_header_tmpl = "$src_path/header.tmpl";
36 my $filename_conf_gfx_h = 'conf_gfx.h';
37 my $filename_conf_snd_h = 'conf_snd.h';
38 my $filename_conf_mus_h = 'conf_mus.h';
39 my $filename_conf_chr_c = 'conf_chr.c';
40 my $filename_conf_chr_h = 'conf_chr.h';
41 my $filename_conf_cus_c = 'conf_cus.c';
42 my $filename_conf_cus_h = 'conf_cus.h';
43 my $filename_conf_grp_c = 'conf_grp.c';
44 my $filename_conf_grp_h = 'conf_grp.h';
45 my $filename_conf_e2g_c = 'conf_e2g.c';
46 my $filename_conf_esg_c = 'conf_esg.c';
47 my $filename_conf_e2s_c = 'conf_e2s.c';
48 my $filename_conf_fnt_c = 'conf_fnt.c';
49 my $filename_conf_g2s_c = 'conf_g2s.c';
50 my $filename_conf_g2m_c = 'conf_g2m.c';
51 my $filename_conf_var_c = 'conf_var.c';
52 my $filename_conf_act_c = 'conf_act.c';
54 my $text_auto = 'this file was automatically generated -- do not edit by hand';
55 my $text_gfx_h = 'values for graphics configuration (normal elements)';
56 my $text_snd_h = 'values for sounds configuration';
57 my $text_mus_h = 'values for music configuration';
58 my $text_chr_c = 'values for graphics configuration (character elements)';
59 my $text_chr_h = 'values for elements configuration (character elements)';
60 my $text_cus_c = 'values for graphics configuration (custom elements)';
61 my $text_cus_h = 'values for elements configuration (custom elements)';
62 my $text_grp_c = 'values for graphics configuration (group elements)';
63 my $text_grp_h = 'values for elements configuration (group elements)';
64 my $text_e2g_c = 'values for element/graphics mapping configuration (normal)';
65 my $text_esg_c = 'values for element/graphics mapping configuration (special)';
66 my $text_e2s_c = 'values for element/sounds mapping configuration';
67 my $text_fnt_c = 'values for font/graphics mapping configuration';
68 my $text_g2s_c = 'values for gamemode/sound mapping configuration';
69 my $text_g2m_c = 'values for gamemode/music mapping configuration';
70 my $text_var_c = 'values for image and layout parameter configuration';
71 my $text_act_c = 'values for active states of elements and fonts';
73 my $num_custom_elements = 256;
74 my $num_group_elements = 32;
76 my $char_skip = '---[SKIP]---';
167 # -----------------------------------------------------------------------------
169 # -----------------------------------------------------------------------------
175 # =============================================================================
177 # =============================================================================
181 my ($error_msg) = @_;
183 print STDERR "ERROR: ";
184 print STDERR "$error_msg\n";
189 my ($error_msg) = @_;
191 print STDERR "FATAL ";
197 sub contains_image_file
201 return ($line =~ /\".+\.png\"/ ||
202 $line =~ /UNDEFINED_FILENAME/);
205 sub contains_sound_file
209 return ($line =~ /\".+\.wav\"/ ||
210 $line =~ /UNDEFINED_FILENAME/);
213 sub contains_music_file
217 return ($line =~ /\".+\.wav\"/ ||
218 $line =~ /\".+\.mod\"/ ||
219 $line =~ /\".+\.mp3\"/ ||
220 $line =~ /UNDEFINED_FILENAME/);
223 sub print_file_header
225 my ($filename, $comment) = @_;
226 my $filename_tmpl = 'xxxxxxxx.x';
227 my $filename_text = $filename;
228 my $filename_def = uc($filename);
229 $filename_def =~ s/\./_/;
231 $filename_text .= ' ' x (length($filename_tmpl) - length($filename_text));
233 open(FILE, "$filename_header_tmpl") ||
234 fail("cannot open file '$filename_header_tmpl' for reading");
238 s/$filename_tmpl/$filename_text/;
246 print "/* ----- $text_auto ----- */\n";
248 print "#ifndef $filename_def\n";
249 print "#define $filename_def\n";
251 print "/* $comment */\n";
255 sub print_file_footer
258 my $filename_def = uc($filename);
259 $filename_def =~ s/\./_/;
262 print "#endif /* $filename_def */\n";
267 my ($text, $max_num_tabs) = @_;
269 my $num_tabs = $max_num_tabs - int(length($text) / 8);
271 if ($num_tabs < 1) # at least one tab needed as separator
276 return "\t" x $num_tabs;
279 sub print_graphics_list
281 my $filename = "$src_path/conf_gfx.c";
283 print_file_header($filename_conf_gfx_h, $text_gfx_h);
285 open(FILE, "$filename") ||
286 fail("cannot open file '$filename' for reading");
288 my $max_num_tabs = 7;
293 chomp; # cut trailing newline
295 if (/^\#include "conf_chr.c"/) # dump list of character elements
297 foreach my $char (@chars)
301 $prefix =~ s/^/#define IMG_CHAR_/;
303 my $tabs = get_tabs($prefix, $max_num_tabs);
305 if ($char ne $char_skip)
307 print "$prefix$tabs$i\n";
312 if (lc($char) eq 'space')
314 $prefix =~ s/$/_EDITOR/;
316 my $tabs = get_tabs($prefix, $max_num_tabs);
318 print "$prefix$tabs$i\n";
324 foreach my $char (@chars)
328 $prefix =~ s/^/#define IMG_STEEL_CHAR_/;
330 my $tabs = get_tabs($prefix, $max_num_tabs);
332 if ($char ne $char_skip)
334 print "$prefix$tabs$i\n";
339 if (lc($char) eq 'space')
341 $prefix =~ s/$/_EDITOR/;
343 my $tabs = get_tabs($prefix, $max_num_tabs);
345 print "$prefix$tabs$i\n";
352 if (/^\#include "conf_cus.c"/) # dump list of custom elements
354 for (my $nr = 0; $nr < $num_custom_elements; $nr++)
356 my $line = sprintf("#define IMG_CUSTOM_%d", $nr + 1);
358 my $tabs = get_tabs($line, $max_num_tabs);
360 print "$line$tabs$i\n";
364 $line = sprintf("#define IMG_CUSTOM_%d_EDITOR", $nr + 1);
366 $tabs = get_tabs($line, $max_num_tabs);
368 print "$line$tabs$i\n";
374 if (/^\#include "conf_grp.c"/) # dump list of group elements
376 for (my $nr = 0; $nr < $num_group_elements; $nr++)
378 my $line = sprintf("#define IMG_GROUP_%d", $nr + 1);
380 my $tabs = get_tabs($line, $max_num_tabs);
382 print "$line$tabs$i\n";
386 $line = sprintf("#define IMG_GROUP_%d_EDITOR", $nr + 1);
388 $tabs = get_tabs($line, $max_num_tabs);
390 print "$line$tabs$i\n";
396 if (!contains_image_file($_)) # skip all lines without image file
401 s/(.*)/uc($1)/eg; # convert all characters to upper case
402 s/\./_/g; # replace all '.' with '_'
404 s/^ \{ \"/#define IMG_/; # convert line
405 s/\",.*$//; # convert line
407 # dirty hack for making "ABC[DEF]" work as a "special" suffix
410 # dirty hack for making "[default]" work as an element name
414 my $tabs = get_tabs($_, $max_num_tabs);
421 my $summary = '#define NUM_IMAGE_FILES';
422 my $tabs = get_tabs($summary, $max_num_tabs);
424 print "\n$summary$tabs$i\n";
428 print_file_footer($filename_conf_gfx_h);
431 sub print_sounds_list
433 my %known_element = get_known_element_definitions();
435 my $filename = "$src_path/conf_snd.c";
437 print_file_header($filename_conf_snd_h, $text_snd_h);
439 open(FILE, "$filename") ||
440 fail("cannot open file '$filename' for reading");
442 my $max_num_tabs = 7;
447 chomp; # cut trailing newline
449 if (!contains_sound_file($_)) # skip all lines without sound file
454 if (/\[not used\]/ ||
456 /wav[^\}]*$/) # skip all lines without sound file
461 s/(.*)/uc($1)/eg; # convert all characters to upper case
462 s/\./_/g; # replace all '.' with '_'
469 if ($sound =~ /^\[.+\]/)
471 $sound =~ s/\[//; # element class sound; begin ...
472 $sound =~ s/\]//; # ... and end of definition token
473 $sound =~ s/^/CLASS_/; # add class identifier
476 $sound = "SND_$sound";
478 my $define_text = "#define $sound";
479 my $tabs = get_tabs($define_text, $max_num_tabs);
481 print "$define_text$tabs$i\n";
486 my $summary = '#define NUM_SOUND_FILES';
487 my $tabs = get_tabs($summary, $max_num_tabs);
489 print "\n$summary$tabs$i\n";
493 print_file_footer($filename_conf_snd_h);
498 my %known_prefix = get_known_music_prefix_definitions();
500 my $filename = "$src_path/conf_mus.c";
502 print_file_header($filename_conf_mus_h, $text_mus_h);
504 open(FILE, "$filename") ||
505 fail("cannot open file '$filename' for reading");
507 my $max_num_tabs = 7;
512 chomp; # cut trailing newline
514 if (!contains_music_file($_)) # skip all lines without music file
519 if (/\[not used\]/ ||
521 /wav[^\}]*$/) # skip all lines without music file
526 s/(.*)/uc($1)/eg; # convert all characters to upper case
527 s/\./_/g; # replace all '.' with '_'
534 $music = "MUS_$music";
536 my $define_text = "#define $music";
537 my $tabs = get_tabs($define_text, $max_num_tabs);
539 print "$define_text$tabs$i\n";
544 my $summary = '#define NUM_MUSIC_FILES';
545 my $tabs = get_tabs($summary, $max_num_tabs);
547 print "\n$summary$tabs$i\n";
551 print_file_footer($filename_conf_mus_h);
554 sub print_chars_elements_list
556 print_file_header($filename_conf_chr_h, $text_chr_h);
560 foreach my $char (@chars)
562 my $left = "#define EL_CHAR_$char";
564 my $tabs_left = get_tabs($left, 5);
566 my $right = sprintf("(EL_CHAR_ASCII0 + %d)", $i + 32);
568 if ($char ne $char_skip)
570 print "$left$tabs_left$right\n";
578 foreach my $char (@chars)
580 my $left = "#define EL_STEEL_CHAR_$char";
582 my $tabs_left = get_tabs($left, 5);
584 my $right = sprintf("(EL_STEEL_CHAR_ASCII0 + %d)", $i + 32);
586 if ($char ne $char_skip)
588 print "$left$tabs_left$right\n";
594 print_file_footer($filename_conf_chr_c);
597 sub print_chars_graphics_list_line
599 my ($token, $x, $y) = @_;
609 my $basename = ($token =~ /^steel_char/ ? 'RocksFontDC' : 'RocksFontEM' );
611 foreach my $ext (@extensions)
613 my $left = " \{ \"$token$ext\",";
615 my $tabs_left = get_tabs($left, 6);
617 my $right = ($ext eq '' ? $basename . '.png' :
618 $ext eq '.frames' ? '1' : '0');
624 elsif ($ext eq '.ypos')
629 $right = "\"$right\"";
631 my $tabs_right = get_tabs($right, 3);
633 print "$left$tabs_left$right$tabs_right},\n";
637 sub print_chars_graphics_list
639 print_file_header($filename_conf_chr_c, $text_chr_c);
643 foreach my $char (@chars)
645 if ($char ne $char_skip)
648 my $y = int($i / 16);
650 print_chars_graphics_list_line(lc("char_$char"), $x, $y);
653 if (lc($char) eq 'space')
655 print_chars_graphics_list_line("char_space.EDITOR", 7, 4);
658 if ($char ne $char_skip)
668 foreach my $char (@chars)
670 if ($char ne $char_skip)
673 my $y = int($i / 16);
675 print_chars_graphics_list_line(lc("steel_char_$char"), $x, $y);
678 if (lc($char) eq 'space')
680 print_chars_graphics_list_line("steel_char_space.EDITOR", 7, 4);
683 if ($char ne $char_skip)
691 print_file_footer($filename_conf_chr_c);
694 sub print_custom_elements_list
696 print_file_header($filename_conf_cus_h, $text_cus_h);
698 for (my $i = 0; $i < $num_custom_elements; $i++)
700 my $left = sprintf("#define EL_CUSTOM_%d", $i + 1);
702 my $tabs_left = get_tabs($left, 5);
704 my $right = "(EL_CUSTOM_START + $i)";
706 print "$left$tabs_left$right\n";
709 print_file_footer($filename_conf_cus_c);
712 sub print_group_elements_list
714 print_file_header($filename_conf_grp_h, $text_grp_h);
716 for (my $i = 0; $i < $num_group_elements; $i++)
718 my $left = sprintf("#define EL_GROUP_%d", $i + 1);
720 my $tabs_left = get_tabs($left, 5);
722 my $right = "(EL_GROUP_START + $i)";
724 print "$left$tabs_left$right\n";
727 print_file_footer($filename_conf_grp_c);
730 sub print_custom_graphics_list
746 print_file_header($filename_conf_cus_c, $text_cus_c);
748 for (my $i = 0; $i < $num_custom_elements; $i++)
750 foreach my $ext (@extensions1)
752 my $left = sprintf(" \{ \"custom_%d$ext\",", $i + 1);
754 my $tabs_left = get_tabs($left, 6);
756 # my $right = ($ext eq '' ? 'RocksElements.png' :
757 my $right = ($ext eq '' ? 'RocksCE.png' :
758 $ext eq '.frames' ? '1' : '0');
763 $right = int($i % 16);
765 elsif ($ext eq '.ypos')
768 $right = int($i / 16);
771 $right = "\"$right\"";
773 my $tabs_right = get_tabs($right, 3);
775 print "$left$tabs_left$right$tabs_right},\n";
778 foreach my $ext (@extensions2)
780 my $left = sprintf(" \{ \"custom_%d.EDITOR$ext\",", $i + 1);
782 my $tabs_left = get_tabs($left, 6);
784 # my $right = ($ext eq '' ? 'RocksElements.png' : '0');
785 my $right = ($ext eq '' ? 'RocksCE.png' : '0');
790 $right = int($i % 16) + 16;
792 elsif ($ext eq '.ypos')
795 $right = int($i / 16);
798 $right = "\"$right\"";
800 my $tabs_right = get_tabs($right, 3);
802 print "$left$tabs_left$right$tabs_right},\n";
808 print_file_footer($filename_conf_cus_c);
811 sub print_group_graphics_list
827 print_file_header($filename_conf_grp_c, $text_grp_c);
829 for (my $i = 0; $i < $num_group_elements; $i++)
831 foreach my $ext (@extensions1)
833 my $left = sprintf(" \{ \"group_%d$ext\",", $i + 1);
835 my $tabs_left = get_tabs($left, 6);
837 # my $right = ($ext eq '' ? 'RocksDC.png' :
838 my $right = ($ext eq '' ? 'RocksCE.png' :
839 $ext eq '.frames' ? '1' : '0');
844 $right = int($i % 16);
846 elsif ($ext eq '.ypos')
849 $right = int($i / 16) + int($num_custom_elements / 16);
852 $right = "\"$right\"";
854 my $tabs_right = get_tabs($right, 3);
856 print "$left$tabs_left$right$tabs_right},\n";
859 foreach my $ext (@extensions2)
861 my $left = sprintf(" \{ \"group_%d.EDITOR$ext\",", $i + 1);
863 my $tabs_left = get_tabs($left, 6);
865 # my $right = ($ext eq '' ? 'RocksDC.png' : '0');
866 my $right = ($ext eq '' ? 'RocksCE.png' : '0');
871 $right = int($i % 16) + 16;
873 elsif ($ext eq '.ypos')
876 $right = int($i / 16) + int($num_custom_elements / 16);
879 $right = "\"$right\"";
881 my $tabs_right = get_tabs($right, 3);
883 print "$left$tabs_left$right$tabs_right},\n";
889 print_file_footer($filename_conf_grp_c);
892 sub get_known_element_definitions_ALTERNATIVE
894 my %known_element = ();
896 my $filename = "$src_path/main.h";
898 open(FILE, "$filename") ||
899 fail("cannot open file '$filename' for reading");
903 chomp; # cut trailing newline
905 # process line with element definition
906 if (/^\#define (EL_[A-Z0-9_]+)\s/)
908 $known_element{$1} = 1;
910 # print STDERR "known_element: '$1'\n";
916 return %known_element;
919 sub get_known_element_definitions
921 my %known_element = ();
923 my $filename = "$src_path/main.c";
925 open(FILE, "$filename") ||
926 fail("cannot open file '$filename' for reading");
928 my $element_name = '';
929 my $line_is_element_name = 0;
934 chomp; # cut trailing newline
936 if (/ELEMENT_INFO_START/) # keyword to start parsing file
941 elsif (/ELEMENT_INFO_END/) # keyword to stop parsing file
952 $line_is_element_name = 1;
954 elsif ($line_is_element_name)
956 # process line with element name definition
957 if (/^\s+\"(.+)\",?\s*$/)
959 $element_name = 'EL_' . uc($1);
961 # dirty hack for making "[default]" work as an element name
962 $element_name =~ s/\[//;
963 $element_name =~ s/\]//;
965 # change '.' to '_' for elements like "dynamite.active"
966 $element_name =~ s/\./_/g;
968 $known_element{$element_name} = 1;
970 # printf STDERR "::: known element '$element_name'\n";
973 $line_is_element_name = 0;
979 return %known_element;
982 sub get_known_element_class_definitions
984 my %known_element_class = ();
986 my $filename = "$src_path/main.c";
988 open(FILE, "$filename") ||
989 fail("cannot open file '$filename' for reading");
991 my $element_name = '';
992 my $element_class = '';
993 my $line_is_element_name = 0;
994 my $line_is_element_class = 0;
999 chomp; # cut trailing newline
1001 if (/ELEMENT_INFO_START/) # keyword to start parsing file
1006 elsif (/ELEMENT_INFO_END/) # keyword to stop parsing file
1017 $line_is_element_name = 1;
1019 elsif ($line_is_element_name)
1021 # process line with element name definition
1022 if (/^\s+\"(.+)\",?\s*$/)
1024 $element_name = 'EL_' . uc($1);
1026 # dirty hack for making "[default]" work as an element name
1027 $element_name =~ s/\[//;
1028 $element_name =~ s/\]//;
1030 # change '.' to '_' for elements like "dynamite.active"
1031 $element_name =~ s/\./_/g;
1034 $line_is_element_name = 0;
1035 $line_is_element_class = 1;
1037 elsif ($line_is_element_class)
1039 # process line with element class definition
1040 if (/^\s+\"(.+)\",?\s*$/)
1042 $element_class = 'EL_CLASS_' . uc($1);
1044 if (!defined($known_element_class{$element_class}))
1046 $known_element_class{$element_class} = $element_name;
1049 $known_element_class{$element_name} = $element_class;
1051 # print STDERR "known_element_class: '$element_name' => '$element_class'\n";
1054 $line_is_element_class = 0;
1060 return %known_element_class;
1063 sub get_known_action_definitions
1065 my %known_action = ();
1067 my $filename = "$src_path/main.h";
1069 open(FILE, "$filename") ||
1070 fail("cannot open file '$filename' for reading");
1074 chomp; # cut trailing newline
1076 # process line with action definition
1077 if (/^\#define ACTION_([A-Z0-9_]+)\s/)
1079 $known_action{$1} = 1;
1081 # print STDERR "known_action: '$1'\n";
1087 return %known_action;
1090 sub get_known_special_arg_definitions
1092 my %known_special_arg = ();
1094 my $filename = "$src_path/main.h";
1096 open(FILE, "$filename") ||
1097 fail("cannot open file '$filename' for reading");
1101 chomp; # cut trailing newline
1103 # process line with special arg definition
1104 if (/^\#define GFX_SPECIAL_ARG_([A-Z0-9_]+)\s/)
1106 if ($1 eq 'CRUMBLED')
1111 $known_special_arg{$1} = 1;
1113 # print STDERR "known_special_arg: '$1'\n";
1119 return %known_special_arg;
1122 sub get_known_button_definitions
1124 my %known_button = ();
1126 my $filename = "$src_path/conf_gfx.h";
1128 open(FILE, "$filename") ||
1129 fail("cannot open file '$filename' for reading");
1133 chomp; # cut trailing newline
1135 # process line with button definition
1136 if (/^\#define (IMG_MENU_BUTTON[A-Z0-9_]*)\s/)
1138 $known_button{$1} = 1;
1140 # print STDERR "known_button: '$1'\n";
1146 return %known_button;
1149 sub get_known_font_definitions
1151 my %known_font = ();
1153 my $filename = "$src_path/main.h";
1155 open(FILE, "$filename") ||
1156 fail("cannot open file '$filename' for reading");
1160 chomp; # cut trailing newline
1162 # process line with font definition
1163 if (/^\#define (FONT_[A-Z0-9_]+)\s/)
1165 $known_font{$1} = 1;
1167 # print STDERR "known_font: '$1'\n";
1176 sub get_known_sound_prefix_definitions
1178 my %known_sound_prefix = ( 'background' => 1 );
1180 return %known_sound_prefix;
1183 sub get_known_music_prefix_definitions
1185 my %known_music_prefix = ();
1187 my $filename = "$src_path/main.c";
1189 open(FILE, "$filename") ||
1190 fail("cannot open file '$filename' for reading");
1192 my $prefix_name = '';
1197 chomp; # cut trailing newline
1199 if (/MusicPrefixInfo/) # keyword to start parsing file
1204 elsif (/NULL/ && !$skip_line) # keyword to stop parsing file
1213 if (/^\s+{\s+\"(.+)\"/)
1215 my $music_prefix = $1;
1217 $known_music_prefix{$music_prefix} = 1;
1219 # printf STDERR "::: known music prefix '$music_prefix'\n";
1225 return %known_music_prefix;
1228 sub print_element_to_graphic_entry
1230 my ($element, $action, $direction, $crumbled, $graphic) = @_;
1232 my $num_tabs = 5 - int((length($element) + 4 + 1) / 8);
1233 my $tabs = "\t" x $num_tabs;
1239 $crumbled = ($crumbled == 1 ? 'TRUE' : 'FALSE');
1242 print " $element,$tabs$action, $direction, $crumbled,\n";
1243 print " $graphic\n";
1247 sub print_element_to_special_graphic_entry
1249 my ($element, $special, $graphic) = @_;
1251 my $num_tabs = 6 - int((length($element) + 4 + 1) / 8);
1252 my $tabs = "\t" x $num_tabs;
1259 print " $element,$tabs$special,\n";
1260 print " $graphic\n";
1264 sub print_font_to_graphic_entry
1266 my ($font, $special, $graphic) = @_;
1268 my $num_tabs = 6 - int((length($font) + 4 + 1) / 8);
1269 my $tabs = "\t" x $num_tabs;
1276 print " $font,$tabs$special,\n";
1277 print " $graphic\n";
1281 sub print_element_to_sound_entry
1283 my ($element, $is_class, $action, $sound) = @_;
1285 my $element_plus_is_class = "$element, $is_class";
1287 my $num_tabs = 6 - int((length($element_plus_is_class) + 4 + 1) / 8);
1288 my $tabs = "\t" x $num_tabs;
1295 print " $element_plus_is_class,$tabs$action,\n";
1300 sub print_gamemode_to_sound_entry
1302 my ($gamemode, $sound) = @_;
1305 print " $gamemode,\n";
1310 sub print_gamemode_to_music_entry
1312 my ($gamemode, $music) = @_;
1315 print " $gamemode,\n";
1320 sub print_image_config_var_entry
1322 my ($token, $var) = @_;
1330 sub print_active_state_entry
1332 my ($token, $token_active) = @_;
1336 print " $token_active\n";
1340 sub print_element_to_graphic_list
1342 my %graphic_without_element =
1344 'IMG_FLAMES_1_LEFT' => 1,
1345 'IMG_FLAMES_2_LEFT' => 1,
1346 'IMG_FLAMES_3_LEFT' => 1,
1347 'IMG_FLAMES_1_RIGHT' => 1,
1348 'IMG_FLAMES_2_RIGHT' => 1,
1349 'IMG_FLAMES_3_RIGHT' => 1,
1350 'IMG_FLAMES_1_UP' => 1,
1351 'IMG_FLAMES_2_UP' => 1,
1352 'IMG_FLAMES_3_UP' => 1,
1353 'IMG_FLAMES_1_DOWN' => 1,
1354 'IMG_FLAMES_2_DOWN' => 1,
1355 'IMG_FLAMES_3_DOWN' => 1,
1356 'IMG_TWINKLE_BLUE' => 1,
1357 'IMG_TWINKLE_WHITE' => 1,
1360 my %additional_mappings =
1362 # file elements which are mapped to runtime elements when playing
1364 # 'EL_EM_KEY_1_FILE' => 'IMG_EM_KEY_1',
1365 # 'EL_EM_KEY_2_FILE' => 'IMG_EM_KEY_2',
1366 # 'EL_EM_KEY_3_FILE' => 'IMG_EM_KEY_3',
1367 # 'EL_EM_KEY_4_FILE' => 'IMG_EM_KEY_4',
1369 # new elements which still have no graphic
1370 # 'EL_DOOR_WHITE', => 'IMG_CHAR_QUESTION',
1371 # 'EL_DOOR_WHITE_GRAY', => 'IMG_CHAR_QUESTION',
1372 # 'EL_KEY_WHITE', => 'IMG_CHAR_QUESTION',
1373 # 'EL_SIGN_RADIOACTIVITY', => 'IMG_CHAR_QUESTION',
1374 # 'EL_SIGN_WHEELCHAIR', => 'IMG_CHAR_QUESTION',
1375 # 'EL_SIGN_PARKING', => 'IMG_CHAR_QUESTION',
1376 # 'EL_SIGN_ONEWAY', => 'IMG_CHAR_QUESTION',
1377 # 'EL_SIGN_HEART', => 'IMG_CHAR_QUESTION',
1378 # 'EL_SIGN_TRIANGLE', => 'IMG_CHAR_QUESTION',
1379 # 'EL_SIGN_ROUND', => 'IMG_CHAR_QUESTION',
1380 # 'EL_SIGN_EXIT', => 'IMG_CHAR_QUESTION',
1381 # 'EL_SIGN_YINYANG', => 'IMG_CHAR_QUESTION',
1382 # 'EL_SIGN_OTHER', => 'IMG_CHAR_QUESTION',
1383 'EL_SIGN_UNUSED_1', => 'IMG_CHAR_QUESTION',
1384 'EL_SIGN_UNUSED_2', => 'IMG_CHAR_QUESTION',
1385 'EL_DX_UNKNOWN_15', => 'IMG_CHAR_QUESTION',
1386 'EL_DX_UNKNOWN_42', => 'IMG_CHAR_QUESTION',
1388 # file elements with direction which is not defined
1389 'EL_BD_BUTTERFLY_LEFT' => 'IMG_BD_BUTTERFLY',
1390 'EL_BD_BUTTERFLY_RIGHT' => 'IMG_BD_BUTTERFLY',
1391 'EL_BD_BUTTERFLY_UP' => 'IMG_BD_BUTTERFLY',
1392 'EL_BD_BUTTERFLY_DOWN' => 'IMG_BD_BUTTERFLY',
1393 'EL_BD_FIREFLY_LEFT' => 'IMG_BD_FIREFLY',
1394 'EL_BD_FIREFLY_RIGHT' => 'IMG_BD_FIREFLY',
1395 'EL_BD_FIREFLY_UP' => 'IMG_BD_FIREFLY',
1396 'EL_BD_FIREFLY_DOWN' => 'IMG_BD_FIREFLY',
1399 my @unknown_graphics = ();
1400 my %known_element = get_known_element_definitions();
1401 my %known_action = get_known_action_definitions();
1402 my %known_special_arg = get_known_special_arg_definitions();
1403 my %known_direction =
1415 # ---------- read graphic file definitions ----------
1417 my $filename = "$src_path/conf_gfx.c";
1419 print_file_header($filename_conf_e2g_c, $text_e2g_c);
1421 open(FILE, "$filename") ||
1422 fail("cannot open file '$filename' for reading");
1424 print "static struct\n";
1426 print " int element;\n";
1427 print " int action;\n";
1428 print " int direction;\n";
1429 print " boolean crumbled;\n";
1431 print " int graphic;\n";
1433 print "element_to_graphic[] =\n";
1438 chomp; # cut trailing newline
1440 if (/NO_MORE_ELEMENT_IMAGES/) # keyword to stop parsing file
1445 if (!contains_image_file($_)) # skip all lines without image file
1450 s/^ \{ \"//; # cut all leading ...
1451 s/\",.*$//; # ... and trailing garbage
1453 s/\[(\d+)\]/_$1/; # convert "[1]" to "_1" etc.
1455 s/\[//; # dirty hack for making "[default]" ...
1456 s/\]//; # ... work as an element name
1460 if ($token =~ /\.([^\.]+)$/ && defined($known_special_arg{$1}))
1462 next; # skip all special definitions
1465 $token = uc($token); # convert all characters to upper case
1467 my $gfx_action_default = '-1';
1468 my $gfx_action = $gfx_action_default;
1470 my $gfx_direction_default = '-1';
1471 my $gfx_direction = $gfx_direction_default;
1473 my $gfx_crumbled = '0';
1475 my $object = $token;
1480 if ($object =~ /^(.*)\.([A-Z0-9]+)$/ && $2 eq 'CRUMBLED')
1485 $gfx_crumbled = '1';
1488 if ($object =~ /^(.*)\.([A-Z0-9]+)$/ && defined($known_direction{$2}))
1493 $gfx_direction = "MV_BIT_$direction";
1494 $gfx_direction_default = $gfx_direction;
1497 if ($object =~ /^(.*)\.([A-Z0-9_]+)$/ && defined($known_action{$2}))
1502 $gfx_action = "ACTION_$action";
1503 $gfx_action_default = $gfx_action;
1507 $object =~ s/\./_/g; # needed for "invisible_sand.active.digging"
1509 # print STDERR "'$token' => '$object', '$action', '$direction'\n";
1511 my $full_element = "EL_$token";
1512 my $base_element = "EL_$object";
1514 my $element = $base_element;
1515 my $graphic = "IMG_$token";
1517 my $element_without_crumbled = $full_element;
1518 $element_without_crumbled =~ s/_$crumbled$//;
1520 my $element_without_direction = $element_without_crumbled;
1521 $element_without_direction =~ s/_$direction$//;
1523 my $element_without_action = $element_without_direction;
1524 $element_without_action =~ s/_$action$//;
1526 if (defined($known_element{$full_element}))
1528 $element = $full_element;
1530 $gfx_action_default = '-1';
1531 $gfx_direction_default = '-1';
1534 if ($element_without_action eq $element || $action eq '')
1536 $element_without_action = '';
1539 if ($element_without_direction eq $element || $direction eq '')
1541 $element_without_direction = '';
1544 if ($element_without_crumbled eq $element || $crumbled eq '')
1546 $element_without_crumbled = '';
1549 if (defined($graphic_without_element{$graphic}))
1554 if (!defined($known_element{$element}))
1556 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1558 push @unknown_graphics, $graphic;
1563 if (defined($known_element{$element}))
1565 print_element_to_graphic_entry($element,
1566 $gfx_action_default,
1567 $gfx_direction_default,
1572 if (defined($known_element{$element_without_action}))
1574 print_element_to_graphic_entry($element_without_action,
1581 if (defined($known_element{$element_without_direction}))
1583 print_element_to_graphic_entry($element_without_direction,
1590 if (defined($known_element{$element_without_crumbled}))
1592 print_element_to_graphic_entry($element_without_crumbled,
1600 # dump list of additional elements
1601 foreach my $element (sort keys %additional_mappings)
1603 print_element_to_graphic_entry($element, '-1', '-1', '-1',
1604 $additional_mappings{$element});
1607 # dump list of character elements
1608 foreach my $char (@chars)
1610 my $element = "EL_CHAR_$char";
1611 my $graphic = "IMG_CHAR_$char";
1613 if ($char ne $char_skip)
1615 print_element_to_graphic_entry($element, '-1', '-1', '-1',$graphic);
1618 foreach my $char (@chars)
1620 my $element = "EL_STEEL_CHAR_$char";
1621 my $graphic = "IMG_STEEL_CHAR_$char";
1623 if ($char ne $char_skip)
1625 print_element_to_graphic_entry($element, '-1', '-1', '-1',$graphic);
1629 # dump list of custom elements
1630 for (my $i = 0; $i < $num_custom_elements; $i++)
1632 my $element = sprintf("EL_CUSTOM_%d", $i + 1);
1633 my $graphic = sprintf("IMG_CUSTOM_%d", $i + 1);
1635 print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
1638 # dump list of group elements
1639 for (my $i = 0; $i < $num_group_elements; $i++)
1641 my $element = sprintf("EL_GROUP_%d", $i + 1);
1642 my $graphic = sprintf("IMG_GROUP_%d", $i + 1);
1644 print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
1647 print_element_to_graphic_entry('-1', '-1', '-1', '-1', '-1');
1653 if (scalar(@unknown_graphics) > 0)
1655 print STDERR "-" x 79 . "\n";
1656 print STDERR "The following graphics cannot be associated with any element:\n";
1658 foreach my $graphic (@unknown_graphics)
1660 print STDERR "- $graphic\n";
1663 print STDERR "-" x 79 . "\n";
1666 print_file_footer($filename_conf_e2g_c);
1669 sub print_element_to_special_graphic_list
1671 my %graphic_without_element =
1673 'IMG_GLOBAL_DOOR' => 1,
1676 my %additional_mappings =
1678 # old elements which are mapped to other elements when playing
1679 #'EL_BUG' => 'IMG_BUG_RIGHT',
1680 #'EL_SPACESHIP' => 'IMG_SPACESHIP_RIGHT',
1681 #'EL_PACMAN' => 'IMG_PACMAN_RIGHT',
1684 my @elements_with_editor_graphic =
1689 my @unknown_graphics = ();
1690 my %known_element = get_known_element_definitions();
1691 my %known_special_arg = get_known_special_arg_definitions();
1693 # ---------- read graphic file definitions ----------
1695 my $filename = "$src_path/conf_gfx.c";
1697 print_file_header($filename_conf_esg_c, $text_esg_c);
1699 open(FILE, "$filename") ||
1700 fail("cannot open file '$filename' for reading");
1702 print "static struct\n";
1704 print " int element;\n";
1705 print " int special;\n";
1707 print " int graphic;\n";
1709 print "element_to_special_graphic[] =\n";
1714 chomp; # cut trailing newline
1716 if (/NO_MORE_ELEMENT_IMAGES/) # keyword to stop parsing file
1721 if (!contains_image_file($_)) # skip all lines without image file
1726 s/^ \{ \"//; # cut all leading ...
1727 s/\",.*$//; # ... and trailing garbage
1733 if ($token =~ /^font\./) # skip all font definitions
1738 if ($token =~ /^background\./) # skip all background image definitions
1743 if ($token =~ /^(.*)\.([^\.]+)$/ &&
1744 defined($known_special_arg{$2}))
1747 $special = "GFX_SPECIAL_ARG_" . $2;
1751 next; # skip all default definitions
1754 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
1755 $object =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
1758 $object =~ s/\./_/g;
1760 # print STDERR "'$token' => '$object'\n";
1762 my $element = "EL_$object";
1763 my $graphic = "IMG_$token";
1765 if (defined($graphic_without_element{$graphic}))
1770 if (!defined($known_element{$element}))
1772 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1774 push @unknown_graphics, $graphic;
1779 print_element_to_special_graphic_entry($element,
1784 # dump list of additional elements
1785 foreach my $element (sort keys %additional_mappings)
1787 print_element_to_special_graphic_entry($element,
1788 'GFX_SPECIAL_ARG_EDITOR',
1789 $additional_mappings{$element});
1790 print_element_to_special_graphic_entry($element,
1791 'GFX_SPECIAL_ARG_PREVIEW',
1792 $additional_mappings{$element});
1795 # dump list of custom element editor graphics
1796 for (my $i = 0; $i < $num_custom_elements; $i++)
1798 my $element = sprintf("EL_CUSTOM_%d", $i + 1);
1799 my $graphic = sprintf("IMG_CUSTOM_%d_EDITOR", $i + 1);
1801 print_element_to_special_graphic_entry($element,
1802 'GFX_SPECIAL_ARG_EDITOR',
1806 # dump list of group element editor graphics
1807 for (my $i = 0; $i < $num_group_elements; $i++)
1809 my $element = sprintf("EL_GROUP_%d", $i + 1);
1810 my $graphic = sprintf("IMG_GROUP_%d_EDITOR", $i + 1);
1812 print_element_to_special_graphic_entry($element,
1813 'GFX_SPECIAL_ARG_EDITOR',
1817 # dump other special editor graphics
1818 foreach my $token (@elements_with_editor_graphic)
1820 my $element = 'EL_' . uc($token);
1821 my $graphic = 'IMG_' . uc($token) . '_EDITOR';
1823 print_element_to_special_graphic_entry($element,
1824 'GFX_SPECIAL_ARG_EDITOR',
1828 print_element_to_special_graphic_entry('-1', '-1', '-1');
1834 if (scalar(@unknown_graphics) > 0)
1836 print STDERR "-" x 79 . "\n";
1837 print STDERR "The following graphics cannot be associated with any element:\n";
1839 foreach my $graphic (@unknown_graphics)
1841 print STDERR "- $graphic\n";
1844 print STDERR "-" x 79 . "\n";
1847 print_file_footer($filename_conf_esg_c);
1850 sub print_element_to_sound_list
1852 my %sound_without_action =
1854 'SND_AMOEBA_TURNING_TO_GEM' => 1,
1855 'SND_AMOEBA_TURNING_TO_ROCK' => 1,
1856 'SND_BD_AMOEBA_TURNING_TO_GEM' => 1,
1857 'SND_BD_AMOEBA_TURNING_TO_ROCK' => 1,
1859 # no special case anymore after adding action ".splashing"
1860 # 'SND_ACID_SPLASHING' => 1,
1863 my @unknown_sounds = ();
1864 my %known_element = get_known_element_definitions();
1865 my %known_element_class = get_known_element_class_definitions();
1866 my %known_action = get_known_action_definitions();
1868 # ---------- read sound file definitions ----------
1870 my $filename = "$src_path/conf_snd.c";
1872 print_file_header($filename_conf_e2s_c, $text_e2s_c);
1874 open(FILE, "$filename") ||
1875 fail("cannot open file '$filename' for reading");
1877 print "static struct\n";
1879 print " int element;\n";
1880 print " boolean is_class;\n";
1881 print " int action;\n";
1883 print " int sound;\n";
1885 print "element_to_sound[] =\n";
1890 chomp; # cut trailing newline
1892 if (/NO_MORE_ELEMENT_SOUNDS/) # keyword to stop parsing file
1897 if (!contains_sound_file($_)) # skip all lines without sound file
1902 s/^ \{ \"//; # cut all leading ...
1903 s/\",.*$//; # ... and trailing garbage
1907 $token = uc($token); # convert all characters to upper case
1909 my $snd_action_default = '-1';
1910 my $snd_action = $snd_action_default;
1912 my $object = $token;
1915 if ($object =~ /^(.*)\.([A-Z0-9_]+)$/ && defined($known_action{$2}))
1920 $snd_action = "ACTION_$action";
1921 $snd_action_default = $snd_action;
1925 $object =~ s/\./_/g; # needed for "invisible_sand.active.digging"
1927 if ($object =~ /^\[(.+)\]$/)
1929 $object = 'CLASS_' . $1;
1932 # print STDERR "'$token' => '$object', '$action'\n";
1934 my $full_element = "EL_$token";
1935 my $base_element = "EL_$object";
1937 my $element = $base_element;
1940 if ($sound =~ /^\[.+\]/)
1942 $sound =~ s/\[//; # element class sound; begin ...
1943 $sound =~ s/\]//; # ... and end of definition token
1944 $sound =~ s/^/CLASS_/; # add class identifier
1947 $sound = "SND_$sound";
1949 my $element_without_action = $full_element;
1950 $element_without_action =~ s/_$action$//;
1952 my $element_class_without_action = $full_element;
1953 $element_without_action =~ s/_$action$//;
1955 if (defined($known_element_class{$full_element}))
1957 $element = $full_element;
1959 $snd_action_default = '-1';
1962 if ($element_without_action eq $element || $action eq '')
1964 $element_without_action = '';
1967 if (defined($sound_without_action{$sound}))
1972 if (!defined($known_element{$element}) &&
1973 !defined($known_element_class{$element}))
1975 # print STDERR "----- ERROR: unknown element '$element' -----\n";
1977 push @unknown_sounds, $sound;
1982 if (!($element =~ /_CLASS_/) &&
1983 defined($known_element{$element}))
1985 print_element_to_sound_entry($element, "FALSE",
1986 $snd_action_default,
1990 if (!($element =~ /_CLASS_/) &&
1991 defined($known_element{$element_without_action}))
1993 print_element_to_sound_entry($element_without_action, "FALSE",
1998 if ($element =~ /_CLASS_/ &&
1999 defined($known_element_class{$element}))
2001 my $class_element = $known_element_class{$element};
2003 print_element_to_sound_entry($class_element, "TRUE",
2004 $snd_action_default,
2008 if ($element =~ /_CLASS_/ &&
2009 defined($known_element_class{$element_without_action}))
2011 my $class_element = $known_element_class{$element_without_action};
2013 print_element_to_sound_entry($class_element, "TRUE",
2019 print_element_to_sound_entry('-1', '-1', '-1', '-1');
2025 if (scalar(@unknown_sounds) > 0)
2027 print STDERR "-" x 79 . "\n";
2028 print STDERR "The following sounds cannot be associated with any element or element class:\n";
2030 foreach my $sound (@unknown_sounds)
2032 print STDERR "- $sound\n";
2035 print STDERR "-" x 79 . "\n";
2038 print_file_footer($filename_conf_e2s_c);
2041 sub print_font_to_graphic_list
2043 my @unknown_graphics = ();
2044 my %known_font = get_known_font_definitions();
2045 my %known_special_arg = get_known_special_arg_definitions();
2047 # ---------- read graphic file definitions ----------
2049 my $filename = "$src_path/conf_gfx.c";
2051 print_file_header($filename_conf_fnt_c, $text_fnt_c);
2053 open(FILE, "$filename") ||
2054 fail("cannot open file '$filename' for reading");
2056 print "static struct\n";
2058 print " int font_nr;\n";
2059 print " int special;\n";
2061 print " int graphic;\n";
2063 print "font_to_graphic[] =\n";
2068 chomp; # cut trailing newline
2070 if (!contains_image_file($_)) # skip all lines without image file
2075 s/^ \{ \"//; # cut all leading ...
2076 s/\",.*$//; # ... and trailing garbage
2083 if ($token =~ /^(font\..*)$/)
2088 if ($token =~ /^(.*)\.([^\.]+)$/ &&
2089 defined($known_special_arg{$2}))
2092 $special = "GFX_SPECIAL_ARG_" . $2;
2097 next; # skip all non-font definitions
2100 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2101 $font =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2106 # print STDERR "'$token' => '$font'\n";
2108 $graphic = "IMG_$token";
2110 if (!defined($known_font{$font}))
2112 # print STDERR "----- ERROR: unknown font '$font' -----\n";
2114 push @unknown_graphics, $graphic;
2119 print_font_to_graphic_entry($font,
2124 print_font_to_graphic_entry('-1', '-1', '-1');
2130 if (scalar(@unknown_graphics) > 0)
2132 print STDERR "-" x 79 . "\n";
2133 print STDERR "The following graphics cannot be associated with any font:\n";
2135 foreach my $graphic (@unknown_graphics)
2137 print STDERR "- $graphic\n";
2140 print STDERR "-" x 79 . "\n";
2143 print_file_footer($filename_conf_fnt_c);
2146 sub print_gamemode_to_sound_list
2148 my %known_prefix = get_known_sound_prefix_definitions();
2149 my %known_special_arg = get_known_special_arg_definitions();
2151 # ---------- read music file definitions ----------
2153 my $filename = "$src_path/conf_snd.c";
2155 print_file_header($filename_conf_g2s_c, $text_g2s_c);
2157 open(FILE, "$filename") ||
2158 fail("cannot open file '$filename' for reading");
2160 print "static struct\n";
2162 print " int gamemode;\n";
2164 print " int sound;\n";
2166 print "gamemode_to_sound[] =\n";
2171 chomp; # cut trailing newline
2173 if (!contains_sound_file($_)) # skip all lines without sound file
2183 s/^ \{ \"//; # cut all leading ...
2184 s/\",.*$//; # ... and trailing garbage
2188 # my $level = -1; # ???
2190 if (defined($known_prefix{$token}))
2192 # no special arg defined
2194 elsif ($token =~ /^(.*)\.([^\.]+)$/ &&
2195 defined($known_prefix{$1}) &&
2196 defined($known_special_arg{$2}))
2198 $gamemode = "GFX_SPECIAL_ARG_" . $2;
2205 # if ($token =~ /^(.*)\./ &&
2206 # !defined($known_prefix{$1}))
2211 # if ($token =~ /^(.*)\.([^\.]+)$/ &&
2212 # defined($known_special_arg{$2}))
2214 # $gamemode = "GFX_SPECIAL_ARG_" . $2;
2217 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2220 my $sound = "SND_$token";
2222 # print STDERR "'$token' => '$sound'\n";
2224 print_gamemode_to_sound_entry($gamemode, $sound);
2227 print_gamemode_to_sound_entry('-1', '-1');
2233 print_file_footer($filename_conf_g2s_c);
2236 sub print_gamemode_to_music_list
2238 my %known_prefix = get_known_music_prefix_definitions();
2239 my %known_special_arg = get_known_special_arg_definitions();
2241 # ---------- read music file definitions ----------
2243 my $filename = "$src_path/conf_mus.c";
2245 print_file_header($filename_conf_g2m_c, $text_g2m_c);
2247 open(FILE, "$filename") ||
2248 fail("cannot open file '$filename' for reading");
2250 print "static struct\n";
2252 print " int gamemode;\n";
2254 print " int music;\n";
2256 print "gamemode_to_music[] =\n";
2261 chomp; # cut trailing newline
2263 if (!contains_music_file($_)) # skip all lines without music file
2268 s/^ \{ \"//; # cut all leading ...
2269 s/\",.*$//; # ... and trailing garbage
2274 if (defined($known_prefix{$token}))
2276 # no special arg defined
2278 elsif ($token =~ /^(.*)\.([^\.]+)$/ &&
2279 defined($known_prefix{$1}) &&
2280 defined($known_special_arg{$2}))
2282 $gamemode = "GFX_SPECIAL_ARG_" . $2;
2289 # my $prefix = $token;
2290 # $prefix =~ s/\..*$//;
2292 ## if ($token =~ /^(.*)\./ &&
2293 ## !defined($known_prefix{$1}))
2294 # if (!defined($known_prefix{$prefix}))
2299 # if ($token =~ /^(.*)\.([^\.]+)$/ &&
2300 # defined($known_special_arg{$2}))
2302 # $gamemode = "GFX_SPECIAL_ARG_" . $2;
2305 $token =~ s/(.*)/uc($1)/eg; # convert all characters to upper case
2308 my $music = "MUS_$token";
2310 # print STDERR "'$token' => '$music'\n";
2312 print_gamemode_to_music_entry($gamemode, $music);
2315 print_gamemode_to_music_entry('-1', '-1');
2321 print_file_footer($filename_conf_g2m_c);
2324 sub print_image_config_vars
2326 # ---------- read graphic file definitions ----------
2328 my $filename = "$src_path/conf_gfx.c";
2330 print_file_header($filename_conf_var_c, $text_var_c);
2332 open(FILE, "$filename") ||
2333 fail("cannot open file '$filename' for reading");
2335 print "struct TokenIntPtrInfo image_config_vars[] =\n";
2338 my $start_parsing = 0;
2342 chomp; # cut trailing newline
2344 if (/CONFIG_VARS_START/) # keyword to start parsing file
2349 if (!$start_parsing)
2354 if (/^\s*\{\s*\"([^\"]+)\"/) # config token found
2359 # --- some prefix replacements ---
2361 $var =~ s/^main\./menu.main./;
2362 $var =~ s/^\[player\]\./game.player_/;
2363 $var =~ s/^\[title_initial\]/title_initial_default/;
2364 $var =~ s/^\[title\]/title_default/;
2365 $var =~ s/^\[titlemessage_initial\]/titlemessage_initial_default/;
2366 $var =~ s/^\[titlemessage\]/titlemessage_default/;
2368 if ($var =~ /^titlemessage.*(\d)/ ||
2369 $var =~ /^game.panel.key_(\d)/ ||
2370 $var =~ /^game.panel.inventory_first_(\d)/ ||
2371 $var =~ /^game.panel.inventory_last_(\d)/ ||
2372 $var =~ /^game.panel.conveyor_belt_(\d)\./ ||
2373 $var =~ /^game.panel.element_(\d)\./ ||
2374 $var =~ /^game.panel.graphic_(\d)\./ ||
2375 $var =~ /^game.panel.ce_score_(\d)\./)
2378 my $array_pos = int($number) - 1;
2379 $var =~ s/_$number/\[$array_pos\]/;
2381 elsif ($var =~ /^game.panel.conveyor_belt_(\d)(_switch)/ ||
2382 $var =~ /^game.panel.element_(\d)(_count)/ ||
2383 $var =~ /^game.panel.ce_score_(\d)(_element)/)
2387 my $array_pos = int($number) - 1;
2388 $var =~ s/_$number$suffix/$suffix\[$array_pos\]/;
2391 # --- some suffix replacements ---
2393 $var =~ s/^(menu\.main\..*)\.chars$/$1.size/;
2394 $var =~ s/^(tape\.text\..*)\.chars$/$1.size/;
2395 $var =~ s/^(game\.panel\..*)\.chars$/$1.size/;
2396 $var =~ s/^(game\.panel\..*)\.tile_size$/$1.size/;
2397 $var =~ s/^(request\.button\..*)\.tile_size$/$1.size/;
2398 $var =~ s/\.digits$/.size/;
2399 $var =~ s/\.2nd_offset$/.offset2/;
2400 $var =~ s/\.2nd_xoffset$/.xoffset2/;
2401 $var =~ s/\.2nd_yoffset$/.yoffset2/;
2402 $var =~ s/\.element$/.id/;
2403 $var =~ s/\.draw_order$/.sort_priority/;
2405 $var =~ s/\.font_[a-z]+$/.font_alt/;
2406 $var =~ s/\.INFO\[([A-Z]+)\]$/_info\[GFX_SPECIAL_ARG_INFO_$1\]/;
2407 $var =~ s/\.SETUP\[([A-Z0-9_]+)\]$/_setup\[GFX_SPECIAL_ARG_SETUP_$1\]/;
2408 $var =~ s/\.([A-Z]+)$/\[GFX_SPECIAL_ARG_$1\]/;
2409 $var =~ s/\.([A-Z]+)\./\[GFX_SPECIAL_ARG_$1\]./;
2411 if ($var =~ /^(menu.(enter|leave)_screen)(.[a-z_]+)$/)
2413 $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
2416 if ($var =~ /^menu.(draw_[xy]offset|list_size)$/)
2418 $var .= "[GFX_SPECIAL_ARG_DEFAULT]";
2421 if ($var =~ /^(viewport.(playfield|door_[12]))(.[a-z_]+)$/)
2423 $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
2426 print_image_config_var_entry("\"$token\"", "&$var");
2430 print_image_config_var_entry('NULL', 'NULL');
2436 print_file_footer($filename_conf_var_c);
2439 sub print_active_states
2441 # ---------- read graphic file definitions ----------
2443 my %known_element = get_known_element_definitions();
2444 my %known_button = get_known_button_definitions();
2445 my %known_font = get_known_font_definitions();
2447 print_file_header($filename_conf_act_c, $text_act_c);
2449 print "static struct\n";
2451 print " int element;\n";
2452 print " int element_active;\n";
2454 print "element_with_active_state[] =\n";
2457 foreach my $element (sort keys %known_element)
2459 my $element_active = $element . '_ACTIVE';
2461 if (defined($known_element{$element_active}))
2463 print_active_state_entry($element, $element_active);
2467 print_active_state_entry('-1', '-1');
2473 print "static struct\n";
2475 print " int button;\n";
2476 print " int button_active;\n";
2478 print "button_with_active_state[] =\n";
2481 foreach my $button (sort keys %known_button)
2483 my $button_active = $button . '_ACTIVE';
2485 if (defined($known_button{$button_active}))
2487 print_active_state_entry($button, $button_active);
2491 print_active_state_entry('-1', '-1');
2497 print "static struct\n";
2499 print " int font_nr;\n";
2500 print " int font_nr_active;\n";
2502 print "font_with_active_state[] =\n";
2505 foreach my $font (sort keys %known_font)
2507 my $font_active = $font . '_ACTIVE';
2509 if (defined($known_font{$font_active}))
2511 print_active_state_entry($font, $font_active);
2515 print_active_state_entry('-1', '-1');
2519 print_file_footer($filename_conf_act_c);
2523 # =============================================================================
2524 # M A I N - P R O G R A M
2525 # =============================================================================
2529 my $argc = scalar(@ARGV);
2531 if ($argc == 0 || $ARGV[0] eq '-h' || $ARGV[0] eq '--help')
2533 print "Usage: $0 <file>\n\n";
2534 print "Choose <file> from the following list:\n";
2535 print "- '$filename_conf_gfx_h'\n";
2536 print "- '$filename_conf_snd_h'\n";
2537 print "- '$filename_conf_mus_h'\n";
2538 print "- '$filename_conf_chr_c'\n";
2539 print "- '$filename_conf_chr_h'\n";
2540 print "- '$filename_conf_cus_c'\n";
2541 print "- '$filename_conf_cus_h'\n";
2542 print "- '$filename_conf_grp_c'\n";
2543 print "- '$filename_conf_grp_h'\n";
2544 print "- '$filename_conf_e2g_c'\n";
2545 print "- '$filename_conf_esg_c'\n";
2546 print "- '$filename_conf_fnt_c'\n";
2547 print "- '$filename_conf_g2s_c'\n";
2548 print "- '$filename_conf_g2m_c'\n";
2549 print "- '$filename_conf_var_c'\n";
2550 print "- '$filename_conf_act_c'\n";
2555 if ($ARGV[0] eq $filename_conf_gfx_h)
2557 print_graphics_list();
2559 elsif ($ARGV[0] eq $filename_conf_snd_h)
2561 print_sounds_list();
2563 elsif ($ARGV[0] eq $filename_conf_mus_h)
2567 elsif ($ARGV[0] eq $filename_conf_chr_c)
2569 print_chars_graphics_list();
2571 elsif ($ARGV[0] eq $filename_conf_chr_h)
2573 print_chars_elements_list();
2575 elsif ($ARGV[0] eq $filename_conf_cus_c)
2577 print_custom_graphics_list();
2579 elsif ($ARGV[0] eq $filename_conf_cus_h)
2581 print_custom_elements_list();
2583 elsif ($ARGV[0] eq $filename_conf_grp_c)
2585 print_group_graphics_list();
2587 elsif ($ARGV[0] eq $filename_conf_grp_h)
2589 print_group_elements_list();
2591 elsif ($ARGV[0] eq $filename_conf_e2g_c)
2593 print_element_to_graphic_list();
2595 elsif ($ARGV[0] eq $filename_conf_esg_c)
2597 print_element_to_special_graphic_list();
2599 elsif ($ARGV[0] eq $filename_conf_e2s_c)
2601 print_element_to_sound_list();
2603 elsif ($ARGV[0] eq $filename_conf_fnt_c)
2605 print_font_to_graphic_list();
2607 elsif ($ARGV[0] eq $filename_conf_g2s_c)
2609 print_gamemode_to_sound_list();
2611 elsif ($ARGV[0] eq $filename_conf_g2m_c)
2613 print_gamemode_to_music_list();
2615 elsif ($ARGV[0] eq $filename_conf_var_c)
2617 print_image_config_vars();
2619 elsif ($ARGV[0] eq $filename_conf_act_c)
2621 print_active_states();
2625 print "Unknown option '$ARGV[0]'.\n";