X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=build-scripts%2Fcreate_element_defs.pl;h=3f5693fe4de0ab304a9b38181bd8d4adae64ae78;hp=3c080a7a02e2262487675237673d40b0722eb067;hb=HEAD;hpb=7ecbe0a730dc19d8a46ffe6bbcb052f20d0c4152 diff --git a/build-scripts/create_element_defs.pl b/build-scripts/create_element_defs.pl index 3c080a7a..b75d86ac 100755 --- a/build-scripts/create_element_defs.pl +++ b/build-scripts/create_element_defs.pl @@ -6,7 +6,7 @@ # (c) 1995-2014 by Artsoft Entertainment # Holger Schemel # info@artsoft.org -# http://www.artsoft.org/ +# https://www.artsoft.org/ # ----------------------------------------------------------------------------- # create_element_defs.pl # ============================================================================= @@ -42,6 +42,8 @@ my $filename_conf_cus_c = 'conf_cus.c'; 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'; @@ -61,6 +63,8 @@ my $text_cus_c = 'values for graphics configuration (custom elements)'; 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'; @@ -72,6 +76,7 @@ my $text_act_c = 'values for active states of elements and fonts'; my $num_custom_elements = 256; my $num_group_elements = 32; +my $num_empty_elements = 16; my $char_skip = '---[SKIP]---'; @@ -243,12 +248,12 @@ sub print_file_header 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"; } @@ -259,7 +264,7 @@ sub print_file_footer $filename_def =~ s/\./_/; print "\n"; - print "#endif /* $filename_def */\n"; + print "#endif // $filename_def\n"; } sub get_tabs @@ -393,6 +398,28 @@ sub print_graphics_list } } + 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; @@ -473,6 +500,11 @@ sub print_sounds_list $sound =~ s/^/CLASS_/; # add class identifier } + # dirty hack for making "ABC[DEF]" work as a "special" suffix + $sound =~ s/([^_])\[/$1_/; + $sound =~ s/\[//; + $sound =~ s/\]//; + $sound = "SND_$sound"; my $define_text = "#define $sound"; @@ -531,6 +563,11 @@ sub print_music_list my $music = $_; + # dirty hack for making "ABC[DEF]" work as a "special" suffix + $music =~ s/([^_])\[/$1_/; + $music =~ s/\[//; + $music =~ s/\]//; + $music = "MUS_$music"; my $define_text = "#define $music"; @@ -727,6 +764,24 @@ sub print_group_elements_list 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 = @@ -889,6 +944,89 @@ sub print_group_graphics_list 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 = (); @@ -1074,7 +1212,7 @@ sub get_known_action_definitions 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; @@ -1101,7 +1239,7 @@ sub get_known_special_arg_definitions 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') { @@ -1160,7 +1298,7 @@ sub get_known_font_definitions 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; @@ -1573,7 +1711,7 @@ sub print_element_to_graphic_list { print_element_to_graphic_entry($element_without_action, $gfx_action, - '-1', + $gfx_direction, $gfx_crumbled, $graphic); } @@ -1644,6 +1782,15 @@ sub print_element_to_graphic_list 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"; @@ -1683,7 +1830,8 @@ sub print_element_to_special_graphic_list my @elements_with_editor_graphic = ( - 'char_space' + 'char_space', + 'steel_char_space' ); my @unknown_graphics = (); @@ -1814,6 +1962,17 @@ sub print_element_to_special_graphic_list $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) { @@ -2359,13 +2518,18 @@ sub print_image_config_vars # --- 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/^\[titlescreen_initial\]/titlescreen_initial_default/; + $var =~ s/^\[titlescreen\]/titlescreen_default/; $var =~ s/^\[titlemessage_initial\]/titlemessage_initial_default/; $var =~ s/^\[titlemessage\]/titlemessage_default/; - if ($var =~ /^titlemessage.*(\d)/ || + if ($var =~ /^titlescreen.*(\d)/ || + $var =~ /^titlemessage.*(\d)/ || $var =~ /^game.panel.key_(\d)/ || $var =~ /^game.panel.inventory_first_(\d)/ || $var =~ /^game.panel.inventory_last_(\d)/ || @@ -2403,12 +2567,12 @@ sub print_image_config_vars $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\]./; - if ($var =~ /^(menu.(enter|leave)_screen)(.[a-z_]+)$/) + if ($var =~ /^(menu.(enter|leave|next)_screen)(.[a-z_]+)$/) { $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3; } @@ -2424,6 +2588,17 @@ sub print_image_config_vars } print_image_config_var_entry("\"$token\"", "&$var"); + + if ($var =~ /^(title)_default/ || + $var =~ /^(title_initial)_default/ || + $var =~ /^(titlescreen.*)\[\d\]/ || + $var =~ /^(titlemessage.*)\[\d\]/) + { + my $prefix = $1; + $var =~ s/^$prefix/${prefix}_first/; + + print_image_config_var_entry("\"$token\"", "&$var"); + } } } @@ -2541,6 +2716,8 @@ sub main 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"; @@ -2588,6 +2765,14 @@ sub main { 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();