# (c) 1995-2014 by Artsoft Entertainment
# Holger Schemel
# info@artsoft.org
-# http://www.artsoft.org/
+# https://www.artsoft.org/
# -----------------------------------------------------------------------------
# create_element_defs.pl
# =============================================================================
my $filename_conf_cus_h = 'conf_cus.h';
my $filename_conf_grp_c = 'conf_grp.c';
my $filename_conf_grp_h = 'conf_grp.h';
+my $filename_conf_emp_c = 'conf_emp.c';
+my $filename_conf_emp_h = 'conf_emp.h';
my $filename_conf_e2g_c = 'conf_e2g.c';
my $filename_conf_esg_c = 'conf_esg.c';
my $filename_conf_e2s_c = 'conf_e2s.c';
my $text_cus_h = 'values for elements configuration (custom elements)';
my $text_grp_c = 'values for graphics configuration (group elements)';
my $text_grp_h = 'values for elements configuration (group elements)';
+my $text_emp_c = 'values for graphics configuration (empty elements)';
+my $text_emp_h = 'values for elements configuration (empty elements)';
my $text_e2g_c = 'values for element/graphics mapping configuration (normal)';
my $text_esg_c = 'values for element/graphics mapping configuration (special)';
my $text_e2s_c = 'values for element/sounds mapping configuration';
my $num_custom_elements = 256;
my $num_group_elements = 32;
+my $num_empty_elements = 16;
my $char_skip = '---[SKIP]---';
close FILE;
print "\n";
- print "/* ----- $text_auto ----- */\n";
+ print "// ------- $text_auto -------\n";
print "\n";
print "#ifndef $filename_def\n";
print "#define $filename_def\n";
print "\n";
- print "/* $comment */\n";
+ print "// $comment\n";
print "\n";
}
$filename_def =~ s/\./_/;
print "\n";
- print "#endif /* $filename_def */\n";
+ print "#endif // $filename_def\n";
}
sub get_tabs
}
}
+ if (/^\#include "conf_emp.c"/) # dump list of empty elements
+ {
+ for (my $nr = 0; $nr < $num_empty_elements; $nr++)
+ {
+ my $line = sprintf("#define IMG_EMPTY_SPACE_%d", $nr + 1);
+
+ my $tabs = get_tabs($line, $max_num_tabs);
+
+ print "$line$tabs$i\n";
+
+ $i++;
+
+ $line = sprintf("#define IMG_EMPTY_SPACE_%d_EDITOR", $nr + 1);
+
+ $tabs = get_tabs($line, $max_num_tabs);
+
+ print "$line$tabs$i\n";
+
+ $i++;
+ }
+ }
+
if (!contains_image_file($_)) # skip all lines without image file
{
next;
print_file_footer($filename_conf_grp_c);
}
+sub print_empty_elements_list
+{
+ print_file_header($filename_conf_emp_h, $text_emp_h);
+
+ for (my $i = 0; $i < $num_empty_elements; $i++)
+ {
+ my $left = sprintf("#define EL_EMPTY_SPACE_%d", $i + 1);
+
+ my $tabs_left = get_tabs($left, 5);
+
+ my $right = "(EL_EMPTY_SPACE_START + $i)";
+
+ print "$left$tabs_left$right\n";
+ }
+
+ print_file_footer($filename_conf_emp_c);
+}
+
sub print_custom_graphics_list
{
my @extensions1 =
print_file_footer($filename_conf_grp_c);
}
+sub print_empty_graphics_list
+{
+ my @extensions1 =
+ (
+ '',
+ '.xpos',
+ '.ypos',
+ '.frames',
+ );
+ my @extensions2 =
+ (
+ '',
+ '.xpos',
+ '.ypos',
+ );
+
+ my $num_non_empty_elements = $num_custom_elements + $num_group_elements;
+
+ print_file_header($filename_conf_emp_c, $text_emp_c);
+
+ for (my $i = 0; $i < $num_empty_elements; $i++)
+ {
+ foreach my $ext (@extensions1)
+ {
+ my $left = sprintf(" \{ \"empty_space_%d$ext\",", $i + 1);
+
+ my $tabs_left = get_tabs($left, 6);
+
+ # my $right = ($ext eq '' ? 'RocksDC.png' :
+ my $right = ($ext eq '' ? 'RocksCE.png' :
+ $ext eq '.frames' ? '1' : '0');
+
+ if ($ext eq '.xpos')
+ {
+ # $right = 4;
+ $right = int($i % 16);
+ }
+ elsif ($ext eq '.ypos')
+ {
+ # $right = 15;
+ $right = int($i / 16) + int($num_non_empty_elements / 16);
+ }
+
+ $right = "\"$right\"";
+
+ my $tabs_right = get_tabs($right, 3);
+
+ print "$left$tabs_left$right$tabs_right},\n";
+ }
+
+ foreach my $ext (@extensions2)
+ {
+ my $left = sprintf(" \{ \"empty_space_%d.EDITOR$ext\",", $i + 1);
+
+ my $tabs_left = get_tabs($left, 6);
+
+ # my $right = ($ext eq '' ? 'RocksDC.png' : '0');
+ my $right = ($ext eq '' ? 'RocksCE.png' : '0');
+
+ if ($ext eq '.xpos')
+ {
+ # $right = 14;
+ $right = int($i % 16) + 16;
+ }
+ elsif ($ext eq '.ypos')
+ {
+ # $right = 15;
+ $right = int($i / 16) + int($num_non_empty_elements / 16);
+ }
+
+ $right = "\"$right\"";
+
+ my $tabs_right = get_tabs($right, 3);
+
+ print "$left$tabs_left$right$tabs_right},\n";
+ }
+
+ print "\n";
+ }
+
+ print_file_footer($filename_conf_emp_c);
+}
+
sub get_known_element_definitions_ALTERNATIVE
{
my %known_element = ();
chomp; # cut trailing newline
# process line with action definition
- if (/^\#define ACTION_([A-Z0-9_]+)\s/)
+ if (/^ ACTION_([A-Z0-9_]+)[, ]/)
{
$known_action{$1} = 1;
chomp; # cut trailing newline
# process line with special arg definition
- if (/^\#define GFX_SPECIAL_ARG_([A-Z0-9_]+)\s/)
+ if (/^ GFX_SPECIAL_ARG_([A-Z0-9_]+)[, ]/)
{
if ($1 eq 'CRUMBLED')
{
chomp; # cut trailing newline
# process line with font definition
- if (/^\#define (FONT_[A-Z0-9_]+)\s/)
+ if (/^ (FONT_[A-Z0-9_]+)[, ]/)
{
$known_font{$1} = 1;
print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
}
+ # dump list of empty elements
+ for (my $i = 0; $i < $num_empty_elements; $i++)
+ {
+ my $element = sprintf("EL_EMPTY_SPACE_%d", $i + 1);
+ my $graphic = sprintf("IMG_EMPTY_SPACE_%d", $i + 1);
+
+ print_element_to_graphic_entry($element, '-1', '-1', '-1', $graphic);
+ }
+
print_element_to_graphic_entry('-1', '-1', '-1', '-1', '-1');
print "};\n";
my @elements_with_editor_graphic =
(
- 'char_space'
+ 'char_space',
+ 'steel_char_space'
);
my @unknown_graphics = ();
$graphic);
}
+ # dump list of empty element editor graphics
+ for (my $i = 0; $i < $num_empty_elements; $i++)
+ {
+ my $element = sprintf("EL_EMPTY_SPACE_%d", $i + 1);
+ my $graphic = sprintf("IMG_EMPTY_SPACE_%d_EDITOR", $i + 1);
+
+ print_element_to_special_graphic_entry($element,
+ 'GFX_SPECIAL_ARG_EDITOR',
+ $graphic);
+ }
+
# dump other special editor graphics
foreach my $token (@elements_with_editor_graphic)
{
# --- some prefix replacements ---
$var =~ s/^main\./menu.main./;
+ $var =~ s/^setup\./menu.setup./;
+ $var =~ s/^scores\./menu.scores./;
$var =~ s/^\[player\]\./game.player_/;
$var =~ s/^\[title_initial\]/title_initial_default/;
$var =~ s/^\[title\]/title_default/;
$var =~ s/\.draw_order$/.sort_priority/;
$var =~ s/\.font_[a-z]+$/.font_alt/;
- $var =~ s/\.INFO\[([A-Z]+)\]$/_info\[GFX_SPECIAL_ARG_INFO_$1\]/;
- $var =~ s/\.SETUP\[([A-Z0-9_]+)\]$/_setup\[GFX_SPECIAL_ARG_SETUP_$1\]/;
+ $var =~ s/\.INFO\[([A-Z]+)\](.*)$/_info\[GFX_SPECIAL_ARG_INFO_$1\]$2/;
+ $var =~ s/\.SETUP\[([A-Z0-9_]+)\](.*)$/_setup\[GFX_SPECIAL_ARG_SETUP_$1\]$2/;
$var =~ s/\.([A-Z]+)$/\[GFX_SPECIAL_ARG_$1\]/;
$var =~ s/\.([A-Z]+)\./\[GFX_SPECIAL_ARG_$1\]./;
print "- '$filename_conf_cus_h'\n";
print "- '$filename_conf_grp_c'\n";
print "- '$filename_conf_grp_h'\n";
+ print "- '$filename_conf_emp_c'\n";
+ print "- '$filename_conf_emp_h'\n";
print "- '$filename_conf_e2g_c'\n";
print "- '$filename_conf_esg_c'\n";
print "- '$filename_conf_fnt_c'\n";
{
print_group_elements_list();
}
+ elsif ($ARGV[0] eq $filename_conf_emp_c)
+ {
+ print_empty_graphics_list();
+ }
+ elsif ($ARGV[0] eq $filename_conf_emp_h)
+ {
+ print_empty_elements_list();
+ }
elsif ($ARGV[0] eq $filename_conf_e2g_c)
{
print_element_to_graphic_list();