Skip to content

Commit

Permalink
WIP: preview structures
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 13, 2025
1 parent d9f3ab1 commit bd88fa2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/scene/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ import Swarm.Game.World.Render (FailureMode (..), OuputFormat (..), RenderComput

data CLI
= RenderMap FilePath RenderOpts
| RenderStructures FilePath RenderOpts


mapRenderOpts :: Parser FilePath
mapRenderOpts = strArgument (metavar "SCENARIO")

cliParser :: Parser CLI
cliParser =
RenderMap <$> strArgument (metavar "SCENARIO") <*> subOpts
subparser
( mconcat
[ command "scene" (info (RenderMap <$> mapRenderOpts <*> subOpts <**> helper) (progDesc "Run the Swarm game (default)"))
, command "structures" (info (RenderStructures <$> mapRenderOpts <*> subOpts <**> helper ) (progDesc "Format a file"))
]
)
<|> RenderMap <$> mapRenderOpts <*> subOpts
where
sizeOpts =
AreaDimensions
Expand Down
18 changes: 18 additions & 0 deletions scripts/gen/img/preview-structures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -xe

cd $(git rev-parse --show-toplevel)

SCENARIO_PATH=${1?"Usage: $0 SCENARIO_PATH"}

IMG_WIDTH=200
IMG_HEIGHT=150

IMG_OUTPUT_PATH=output.png
RENDER_IMG_COMMAND="cabal run swarm-scene -- $SCENARIO_PATH --fail-blank --dest $IMG_OUTPUT_PATH --png --width $IMG_WIDTH --height $IMG_HEIGHT"

cabal build -j -O0 swarm:swarm-scene

$RENDER_IMG_COMMAND
code --reuse-window $SCENARIO_PATH && code --reuse-window $IMG_OUTPUT_PATH

while inotifywait -e close_write $SCENARIO_PATH; do $RENDER_IMG_COMMAND; done

0 comments on commit bd88fa2

Please sign in to comment.