From 7774a9b2ab3d76d10525f628e7a2041a7a0f75bb Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 25 Jun 2021 17:48:09 -0700 Subject: [PATCH] Move the default save game directory. The top level DCS directory gets messy fast if we fill it with save games. --- changelog.md | 7 ++++--- game/persistency.py | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 5e4eadbc..06115f0d 100644 --- a/changelog.md +++ b/changelog.md @@ -23,16 +23,17 @@ Saves from 3.x are not compatible with 4.0. * **[Flight Planner]** Added ability to plan Tankers. * **[Modding]** Campaign format version is now 7.0 to account for DCS map changes that made scenery strike targets incompatible with existing campaigns. * **[Mods]** Added support for the Gripen mod. +* **[Mods]** Removes MB-339PAN support, as the mod is now deprecated and no longer works with DCS 2.7+. * **[Mission Generation]** Added support for "Neutral Dot" label options. +* **[New Game Wizard]** Mods are now selected via checkboxes in the new game wizard, not as separate factions. * **[UI]** Ctrl click and shift click now buy or sell 5 or 10 units respectively. * **[UI]** Multiple waypoints can now be deleted simultaneously if multiple waypoints are selected. * **[UI]** Carriers and LHAs now match the colour of airfields, and their destination icons are translucent. * **[UI]** Updated intel box text for first turn. * **[UI]** Base Capture Cheat is now usable at all bases and can also be used to transfer player-owned bases to OPFOR. * **[UI]** Pass Turn button is relabled as "Begin Campaign" on Turn 0. -* **[UI]** Added a ruler to the map. -* **[Units/Factions/Mods]** Removes MB-339PAN support, as the mod is now deprecated and no longer works with DCS 2.7+. -* **[New Game Wizard]** Mods are now selected via checkboxes in the new game wizard, not as separate factions. +* **[UI]** Added a ruler to the map. +* **[UI]** Liberation now saves games to `/Liberation/Saves` by default to declutter the main directory. ## Fixes diff --git a/game/persistency.py b/game/persistency.py index 8e15ece3..303b3cfb 100644 --- a/game/persistency.py +++ b/game/persistency.py @@ -5,13 +5,13 @@ import shutil from typing import Optional _dcs_saved_game_folder: Optional[str] = None -_file_abs_path = None def setup(user_folder: str): global _dcs_saved_game_folder - _dcs_saved_game_folder = user_folder - _file_abs_path = os.path.join(base_path(), "default.liberation") + _dcs_saved_game_folder = os.path.join(user_folder, "Liberation", "Saves") + if not os.path.exists(_dcs_saved_game_folder): + os.makedirs(_dcs_saved_game_folder) def base_path() -> str: @@ -21,15 +21,15 @@ def base_path() -> str: def _temporary_save_file() -> str: - return os.path.join(base_path(), "tmpsave.liberation") + return os.path.join(_dcs_saved_game_folder, "tmpsave.liberation") def _autosave_path() -> str: - return os.path.join(base_path(), "autosave.liberation") + return os.path.join(_dcs_saved_game_folder, "autosave.liberation") def mission_path_for(name: str) -> str: - return os.path.join(base_path(), "Missions", "{}".format(name)) + return os.path.join(base_path(), "Missions", name) def load_game(path):