diff --git a/.gitignore b/.gitignore index 030061a..379896d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ -build/ -maps/ +# Build directory +/build/ + +# Built binary and maps +/maps/ +/ttrts + +# user files *.user *.sublime* *.idea + diff --git a/source/scripts/gen_usage.sh b/source/scripts/gen_usage.sh new file mode 100755 index 0000000..a183af7 --- /dev/null +++ b/source/scripts/gen_usage.sh @@ -0,0 +1,9 @@ +#! /bin/bash +# Used to generate usage text from markdown +cat README.md \ + | sed 's/^#* //g' \ + | sed 's/\t/\\t/g' \ + | sed ':a;N;$!ba;s/\n/\\n\n/g' \ + | sed 's/^/\"/' \ + | sed 's/$/\"/' \ + > $1 diff --git a/source/ttrts/CMakeLists.txt b/source/ttrts/CMakeLists.txt index 08af9fb..2a49815 100644 --- a/source/ttrts/CMakeLists.txt +++ b/source/ttrts/CMakeLists.txt @@ -3,6 +3,7 @@ project( ttrts ) include_directories( + ${CMAKE_CURRENT_BINARY_DIR} ../maths ../game ) @@ -13,6 +14,16 @@ set( SOURCES ) # Add the executable -add_executable( ttrts ${SOURCES} ) +add_executable( ${PROJECT_NAME} ${SOURCES} ) -target_link_libraries( ttrts game ) \ No newline at end of file +target_link_libraries( ${PROJECT_NAME} game ) + +# Installation target +install( TARGETS ${PROJECT_NAME} DESTINATION bin ) + +# Run the gen_usage script to generate our usage header +add_custom_target( + gen_ttrts_usage + cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_SOURCE_DIR}/scripts/gen_usage.sh "${CMAKE_CURRENT_BINARY_DIR}/usage.h" +) +add_dependencies(${PROJECT_NAME} gen_ttrts_usage) diff --git a/source/ttrts/README.md b/source/ttrts/README.md index f00384b..2579dc5 100644 --- a/source/ttrts/README.md +++ b/source/ttrts/README.md @@ -2,7 +2,7 @@ ttrts - Tiny Terminal RTS ## SYNOPSYS - ttrts [OPTIONS...] MAPFILE + ttrts MAPFILE ## DESCRIPTION ttrts is a tiny terminal based RTS where that uses text @@ -50,8 +50,6 @@ ... ### Orders - F - Move unit forward one space - L/R - Rotate unit left or right - A - Attack row in front of unit - -`$ cat README.md | sed 's/^#* //g' | sed 's/\t/\\t/g' | sed ':a;N;$!ba;s/\n/\\n\n/g' | sed 's/^/"/' | sed 's/$/"/' | sed '$ d' > usage.h # To convert this file to c++` \ No newline at end of file + F - move unit [F]orward one space + L/R - rotate unit [L]eft or [R]ight + A - [A]ttack in straight line in front of unit \ No newline at end of file diff --git a/source/ttrts/usage.h b/source/ttrts/usage.h deleted file mode 100644 index 3a94c8d..0000000 --- a/source/ttrts/usage.h +++ /dev/null @@ -1,56 +0,0 @@ -"NAME\n" -"\tttrts - Tiny Terminal RTS\n" -"\n" -"SYNOPSYS\n" -"\tttrts [OPTIONS...] MAPFILE\n" -"\n" -"DESCRIPTION\n" -"\tttrts is a tiny terminal based RTS where that uses text\n" -"\tfiles as order lists to control it's units.\n" -"\n" -"\tThis means that any user, program or cat that can read\n" -"\tand write to text files can play the game.\n" -"\n" -"USAGE\n" -"\tWhen invoked, ttrts will set up a full game and output a\n" -"\tsingle file representing the current gamestate into a \n" -"\tlocal directory called `ttrts_{GAME_NAME}`.\n" -"\n" -"\tThis file can be read in and interpretted by human, robot\n" -"\tor cat. ttrts will wait for orders files to be placed in \n" -"\tit's current working directory.\n" -"\n" -"\tOnce orders have been set for each player taking part \n" -"\tttrts will calculate the new game state and output a new \n" -"\tgamestate file for the next turn.\n" -"\n" -"\tThis process repeats until a winner is chosen!\n" -"\n" -"OPTIONS\n" -"\tMAPFILE - File to read in the initial game state from\n" -"\n" -"-------------------------------------------------------------------------------\n" -"\n" -"GAMESTATE FILE FORMAT\n" -"Name\n" -"\tTurn_{TURN_NUMBER}.txt\n" -"Contents\n" -"\t===== {GAME_NAME} =====\n" -"\tSIZE:[{X},{Y}]\n" -"\tTURN:{TURN_NUMBER}\n" -"\t~~~~\n" -"\tUNIT:{ID} tm:{TEAM} vs:{VIS} dr:{DIR(NESW)} ps:[{X},{Y}]\n" -"\t...\n" -"\n" -"ORDER FILE FORMAT\n" -"Name\n" -"\tTurn_{TURN_NUMBER}_Team_{TEAM_NUMBER}.txt\n" -"Contents\n" -"\tORDER:{ORDER_CHAR} id:{UNIT_ID}\n" -"\t...\n" -"\n" -"Orders\n" -"\tF - Move unit forward one space\n" -"\tL/R - Rotate unit left or right\n" -"\tA - Attack row in front of unit\n" -"\t\n"