From 9dca836ed59db9eb7830d6177f863ab0d567e545 Mon Sep 17 00:00:00 2001 From: drwhut Date: Fri, 25 Nov 2022 17:37:52 +0000 Subject: [PATCH] Added a workaround for reading the main assets folder on macOS. FINALLY! You thought you could best me, Gatekeeper?? Of all of the people you chose to mess with, you messed with me! ME!! You have NO idea how much time I'm willing to spend on fixing something, and this felt SO GOOD TO FIX. For ages macOS players would have to extract the game in their Downloads folder so that the game could reach the default asset pack from within quarantine, but once I learnt that Godot has a function to return the executable path, and that .app bundles are just folders... that was the moment the wall crumbled. In case it was not immediately obvious... I. AM. SO. HAPPY. :D --- docs/general/download/compiling_from_source.rst | 5 +++++ docs/general/download/downloading_binaries.rst | 9 +++------ game/Scripts/AssetDB.gd | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/general/download/compiling_from_source.rst b/docs/general/download/compiling_from_source.rst index 18889de3..24b23a42 100644 --- a/docs/general/download/compiling_from_source.rst +++ b/docs/general/download/compiling_from_source.rst @@ -391,6 +391,11 @@ game through the editor to play it. Here's how you can export the project: 5. Copy the ``tabletop-club/assets/`` folder next to the exported binary, so the game has assets to import. + .. note:: + + On macOS, you'll need to put this folder inside the ``.app`` package, + specifically in ``Tabletop Club.app/Contents/Resources``. + Now, you should be able to launch the exported executable and play the game directly! diff --git a/docs/general/download/downloading_binaries.rst b/docs/general/download/downloading_binaries.rst index 47c6097c..6a96992c 100644 --- a/docs/general/download/downloading_binaries.rst +++ b/docs/general/download/downloading_binaries.rst @@ -101,13 +101,10 @@ Downloading for macOS ``TabletopClub_vX.X.X_OSX_Universal.zip``. 2. When it has downloaded, go to your downloads folder in Finder, and find - the compressed file. Double-click the file to extract the folder - it will be - called something like ``TabletopClub_vX.X.X_OSX_Universal``. + the compressed file. Double-click the file to extract the application. -3. Re-name the new folder to ``TabletopClub``. - -4. Go into the folder, and launch the game by right-clicking ``TabletopClub`` - and clicking :guilabel:`Open`. +3. Launch the game by right-clicking ``TabletopClub`` and clicking + :guilabel:`Open`. .. note:: diff --git a/game/Scripts/AssetDB.gd b/game/Scripts/AssetDB.gd index 31598b24..baf86399 100644 --- a/game/Scripts/AssetDB.gd +++ b/game/Scripts/AssetDB.gd @@ -36,6 +36,7 @@ enum { const ASSET_DIR_PREFIXES = [ ".", "..", + "{EXEC_DIR}/../Resources", # macOS workaround. "{DOWNLOADS}/TabletopClub", "{DOCUMENTS}/TabletopClub", "{DESKTOP}/TabletopClub" @@ -171,6 +172,7 @@ func get_asset_paths() -> Array: var out = [] for prefix in ASSET_DIR_PREFIXES: var path = prefix + "/assets" + path = path.replace("{EXEC_DIR}", OS.get_executable_path().get_base_dir()) path = path.replace("{DOWNLOADS}", OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS)) path = path.replace("{DOCUMENTS}", OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS)) path = path.replace("{DESKTOP}", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))