support --smooth option for blueprints

develop
myk002 2022-10-12 10:10:53 -07:00
parent cc61d4a82a
commit 598f2c4b12
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
4 changed files with 45 additions and 3 deletions

@ -103,6 +103,10 @@ Options
to surround the parameter string in double quotes:
``"-s10,10,central stairs"`` or ``--playback-start "10,10,central stairs"``
or ``"--playback-start=10,10,central stairs"``.
``--smooth``
Record all smooth tiles in the ``smooth`` phase. If this parameter is not
specified, only tiles that will later be carved into fortifications or
engraved will be smoothed.
``-t``, ``--splitby <strategy>``
Split blueprints into multiple files. See the `Splitting output into
multiple files`_ section below for details. If not specified, defaults to

@ -76,6 +76,8 @@ struct blueprint_options {
// base name to use for generated files
string name;
// whether to capture all smoothed tiles
bool smooth = false;
// whether to capture engravings and smooth the tiles that will be engraved
bool engrave = false;
@ -103,6 +105,7 @@ static const struct_field_info blueprint_options_fields[] = {
{ struct_field_info::PRIMITIVE, "height", offsetof(blueprint_options, height), &df::identity_traits<int32_t>::identity, 0, 0 },
{ struct_field_info::PRIMITIVE, "depth", offsetof(blueprint_options, depth), &df::identity_traits<int32_t>::identity, 0, 0 },
{ struct_field_info::PRIMITIVE, "name", offsetof(blueprint_options, name), df::identity_traits<string>::get(), 0, 0 },
{ struct_field_info::PRIMITIVE, "smooth", offsetof(blueprint_options, smooth), &df::identity_traits<bool>::identity, 0, 0 },
{ struct_field_info::PRIMITIVE, "engrave", offsetof(blueprint_options, engrave), &df::identity_traits<bool>::identity, 0, 0 },
{ struct_field_info::PRIMITIVE, "auto_phase", offsetof(blueprint_options, auto_phase), &df::identity_traits<bool>::identity, 0, 0 },
{ struct_field_info::PRIMITIVE, "dig", offsetof(blueprint_options, dig), &df::identity_traits<bool>::identity, 0, 0 },
@ -219,7 +222,7 @@ static const char * get_tile_smooth_minimal(const df::coord &pos,
return NULL;
}
static const char * get_tile_smooth(const df::coord &pos,
static const char * get_tile_smooth_with_engravings(const df::coord &pos,
const tile_context &tc) {
const char * smooth_minimal = get_tile_smooth_minimal(pos, tc);
if (smooth_minimal)
@ -244,6 +247,30 @@ static const char * get_tile_smooth(const df::coord &pos,
return NULL;
}
static const char * get_tile_smooth_all(const df::coord &pos,
const tile_context &tc) {
const char * smooth_minimal = get_tile_smooth_minimal(pos, tc);
if (smooth_minimal)
return smooth_minimal;
df::tiletype *tt = Maps::getTileType(pos);
if (!tt)
return NULL;
switch (tileShape(*tt))
{
case tiletype_shape::FLOOR:
case tiletype_shape::WALL:
if (tileSpecial(*tt) == tiletype_special::SMOOTH)
return "s";
break;
default:
break;
}
return NULL;
}
static const char * get_track_str(const char *prefix, df::tiletype tt) {
TileDirection tdir = tileDirection(tt);
@ -1096,9 +1123,13 @@ static bool do_transform(color_ostream &out,
vector<blueprint_processor> processors;
get_tile_fn* smooth_get_tile_fn = get_tile_smooth_minimal;
if (opts.engrave) smooth_get_tile_fn = get_tile_smooth_with_engravings;
if (opts.smooth) smooth_get_tile_fn = get_tile_smooth_all;
add_processor(processors, opts, "dig", "dig", opts.dig, get_tile_dig);
add_processor(processors, opts, "dig", "smooth", opts.carve,
opts.engrave ? get_tile_smooth : get_tile_smooth_minimal);
smooth_get_tile_fn);
add_processor(processors, opts, "dig", "carve", opts.carve,
opts.engrave ? get_tile_carve : get_tile_carve_minimal);
add_processor(processors, opts, "build", "build", opts.build,

@ -123,6 +123,7 @@ local function process_args(opts, args)
{'h', 'help', handler=function() opts.help = true end},
{'s', 'playback-start', hasArg=true,
handler=function(optarg) parse_start(opts, optarg) end},
{nil, 'smooth', handler=function() opts.smooth = true end},
{'t', 'splitby', hasArg=true,
handler=function(optarg) parse_split_strategy(opts, optarg) end},
})

@ -35,6 +35,12 @@ function test.parse_gui_commandline()
name='blueprint', engrave=true,},
opts)
opts = {}
b.parse_gui_commandline(opts, {'--smooth'})
expect.table_eq({auto_phase=true, format='minimal', split_strategy='none',
name='blueprint', smooth=true,},
opts)
opts = {}
b.parse_gui_commandline(opts, {'--engrave'})
expect.table_eq({auto_phase=true, format='minimal', split_strategy='none',