mirror of
https://github.com/Steffo99/flyingsnake.git
synced 2024-12-22 06:34:18 +00:00
None of the defaults, all the Nones
This commit is contained in:
parent
d4b8cd3c79
commit
62cea57c15
1 changed files with 11 additions and 17 deletions
|
@ -9,12 +9,10 @@ DEFAULT_COORDS = -1
|
||||||
|
|
||||||
|
|
||||||
def get_region_size(*, world, min_x, min_y, region_width, region_height):
|
def get_region_size(*, world, min_x, min_y, region_width, region_height):
|
||||||
if min_x == DEFAULT_COORDS or min_y == DEFAULT_COORDS:
|
min_x = max(0, min_x or 0)
|
||||||
return 0, 0, world.size.x, world.size.y
|
min_y = max(0, min_y or 0)
|
||||||
min_x = max(0, min_x)
|
max_x = min(world.size.x, (min_x or world.size.x) + region_width)
|
||||||
min_y = max(0, min_y)
|
max_y = min(world.size.y, (min_y or world.size.y) + region_height)
|
||||||
max_x = min(world.size.x, min_x + region_width)
|
|
||||||
max_y = min(world.size.y, min_y + region_height)
|
|
||||||
return min_x, min_y, max_x, max_y
|
return min_x, min_y, max_x, max_y
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,13 +34,13 @@ def get_region_size(*, world, min_x, min_y, region_width, region_height):
|
||||||
@c.option("--paint/--no-paint", "draw_paint",
|
@c.option("--paint/--no-paint", "draw_paint",
|
||||||
help="Draw painted blocks with the paint color overlayed on them.", default=True)
|
help="Draw painted blocks with the paint color overlayed on them.", default=True)
|
||||||
@c.option("-x", "--x_coord", "min_x",
|
@c.option("-x", "--x_coord", "min_x",
|
||||||
help="Min x coord for custom world rendering", default=DEFAULT_COORDS)
|
help="Min x coord for custom world rendering", default=None)
|
||||||
@c.option("-y", "--y_coord", "min_y",
|
@c.option("-y", "--y_coord", "min_y",
|
||||||
help="Min y coord for custom world rendering", default=DEFAULT_COORDS)
|
help="Min y coord for custom world rendering", default=None)
|
||||||
@c.option("-w", "--region_width", "region_width",
|
@c.option("-w", "--region_width", "region_width",
|
||||||
help="Width of region for custom world rendering", default=DEFAULT_REGION_VALUE)
|
help="Width of region for custom world rendering", default=None)
|
||||||
@c.option("-h", "--region_height", "region_height",
|
@c.option("-h", "--region_height", "region_height",
|
||||||
help="Height of region for custom world rendering", default=DEFAULT_REGION_VALUE)
|
help="Height of region for custom world rendering", default=None
|
||||||
def flyingsnake(input_file: str,
|
def flyingsnake(input_file: str,
|
||||||
output_file: str,
|
output_file: str,
|
||||||
colors_file: str,
|
colors_file: str,
|
||||||
|
@ -123,13 +121,9 @@ def flyingsnake(input_file: str,
|
||||||
|
|
||||||
c.echo("Parsing world...")
|
c.echo("Parsing world...")
|
||||||
world = li.World.create_from_file(input_file)
|
world = li.World.create_from_file(input_file)
|
||||||
if (min_x != DEFAULT_COORDS or min_y != DEFAULT_COORDS
|
min_x, min_y, max_x, max_y = get_region_size(world=world, min_x=min_x, min_y=min_y,
|
||||||
or region_height != DEFAULT_REGION_VALUE or region_width != DEFAULT_REGION_VALUE):
|
region_width=region_width, region_height=region_height)
|
||||||
min_x, min_y, max_x, max_y = get_region_size(world=world, min_x=min_x, min_y=min_y,
|
c.echo(f"Rendering world coordinates between ({min_x}, {min_y}) to ({max_x}, {max_y}")
|
||||||
region_width=region_width, region_height=region_height)
|
|
||||||
c.echo(f"Only rendering world coordinates ({min_x}, {min_y}) to ({max_x}, {max_y}")
|
|
||||||
else:
|
|
||||||
min_x, min_y, max_x, max_y = 0, 0, world.size.x, world.size.y
|
|
||||||
width = max_x - min_x
|
width = max_x - min_x
|
||||||
height = max_y - min_y
|
height = max_y - min_y
|
||||||
if draw_background:
|
if draw_background:
|
||||||
|
|
Loading…
Reference in a new issue