From e89a44e858bcd1f71c0c4746e4669e41619d8a4b Mon Sep 17 00:00:00 2001 From: FlagCourier Date: Tue, 29 Oct 2024 14:11:13 -0500 Subject: [PATCH 1/3] Functionalization: Move script elements to encapsulating functions. Also: - Validate with ShellCheck (Mainly reduce globbing) - Remove unnecessary directory access jumps with `cd` - `mkdir` should be enough. - Replace Read Parsing with automatic file checking - Checks for presence of `project.godot` file to determine if it is in a project root. - Change exit code for to non-zero value if not in a project root. --- ...Script-setupGodotProjectDirectoryStructure | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/BashScript-setupGodotProjectDirectoryStructure b/BashScript-setupGodotProjectDirectoryStructure index d624904..17564e1 100755 --- a/BashScript-setupGodotProjectDirectoryStructure +++ b/BashScript-setupGodotProjectDirectoryStructure @@ -1,38 +1,52 @@ #!/bin/bash -echo -read -p "Are you sure you are in the root folder of the Godot project you want to create the structure for? (y/n): " userOk - -if [ $userOk != 'y' ] && [ $userOk != 'Y' ]; then +not_a_godot_project () { echo echo "Please move to the appropriate directory and run this script again." echo - exit 0 -fi - -#make addons directory -mkdir addons -echo "Addons directory created" - -# make assets directory and sub-directories -mkdir assets -cd assets -mkdir -p audio/sounds_effects audio/music art/sprites art/spritesheets art/textures art/tilesets -cd .. -echo "Assets directory and sub-directories created" - -# make scenes directory and sub-directories -mkdir scenes -cd scenes -mkdir characters components effects items levels weapons world_objects -cd characters -mkdir enemies bosses npcs -cd ../.. -echo "Scenes directory and sub-directories created" - -# make scripts directory and sub-directories -mkdir -p scripts/autoloads -echo "Scripts directory and sub-directories created" + exit 1 +} + +validate_project_dir () { + if [ ! -f project.godot ]; then + not_a_godot_project + fi +} + +create_addons_dirs () { + mkdir -p addons + echo "Addons directory created" +} + +create_assets_dirs () { + # Audio + mkdir -p assets/audio/sounds_effects assets/audio/music + # Art + mkdir -p assets/art/sprites assets/art/spritesheets assets/art/textures assets/art/tilesets + echo "Assets directory and sub-directories created" +} + +create_scenes_dirs () { + # Charactor Scenes + mkdir -p scenes/characters/enemies scenes/characters/bosses scenes/characters/npcs + # Other Scenes + mkdir -p scenes/components scenes/effects scenes/items scenes/levels scenes/weapons scenes/world_objects + echo "Scenes directory and sub-directories created" +} + +create_scripts_dirs () { + mkdir -p scripts/autoloads + echo "Scripts directory and sub-directories created" +} + +## Execution Chain +echo # Padding from previous terminal executions +validate_project_dir + +# Create Directories +create_addons_dirs +create_assets_dirs +create_scenes_dirs +create_scripts_dirs echo "Done creating Godot project directory structure." - From cd73c6ddc3c9b6c4aac66f64fb990ace08aa063f Mon Sep 17 00:00:00 2001 From: FlagCourier Date: Tue, 29 Oct 2024 14:56:09 -0500 Subject: [PATCH 2/3] Update Readme --- README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a88f731..569c984 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ ## Any software tools you make to add convenience to the development process -### BashScript-setupGodotProjectDirectoryStructure -Bash script (so should work on Linux and Mac, but now Windows) to setups a starting project directory structure. This is just a directory structure I made based on personal preferences, once we decide on a standard directory structure for the community we can update this to match that decision. Also gonna need a Windows user to make a version of the script that works in Windows. -

-Usage: After you make an empty Godot project, run this script in the project's root folder. +### Directory Tree Setup Scripts + +The following scripts can be used in an empty Godot project to create a basic directory structure. The scripts should be run from inside the base/root directory of the project. + +#### BashScript-setupGodotProjectDirectoryStructure + +Should work in any shell that can interpret Bash. For Linux, macOS; should work with Git for Windows' Bash shell as well. + +Current implementation does not prompt for user confirmation, and may be run headless or in an active terminal. + +#### BatchScript-setupGodotProjectDirectoryStructure + +*Initial Commit by [basile-laderchi](https://github.com/basile-laderchi).* + +Similar function as the Bash script, but intended for use in traditonal Windows NT environment. Execute with Windows' Command Prompt (`cmd.exe`). + +Current implementation asks for user confirmation. From c580bd9a81b2874325fd3abaac7bb962868ee26e Mon Sep 17 00:00:00 2001 From: FlagCourier Date: Tue, 29 Oct 2024 15:31:29 -0500 Subject: [PATCH 3/3] Collapse not_a_godot_project into validate_project_dir --- BashScript-setupGodotProjectDirectoryStructure | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/BashScript-setupGodotProjectDirectoryStructure b/BashScript-setupGodotProjectDirectoryStructure index 17564e1..3759ae8 100755 --- a/BashScript-setupGodotProjectDirectoryStructure +++ b/BashScript-setupGodotProjectDirectoryStructure @@ -1,15 +1,11 @@ #!/bin/bash -not_a_godot_project () { - echo - echo "Please move to the appropriate directory and run this script again." - echo - exit 1 -} - validate_project_dir () { if [ ! -f project.godot ]; then - not_a_godot_project + echo + echo "Please move to the appropriate directory and run this script again." + echo + exit 1 fi }