From 050fc6c5ef765fab03e5b7269722249100b01834 Mon Sep 17 00:00:00 2001 From: Ben-Ryder Date: Mon, 30 Aug 2021 15:22:35 +0100 Subject: [PATCH] Fixing #3 and #8 in a more thorough way by checking if the save game dir exists. --- paths.py | 16 ++++++++-------- project/menus/loadgame.py | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/paths.py b/paths.py index 7e1f153..912072d 100644 --- a/paths.py +++ b/paths.py @@ -5,17 +5,17 @@ dataPath = os.getcwd() + os.sep + "data" + os.sep assetPath = os.getcwd() + os.sep + "assets" + os.sep -gamePath = dataPath + os.sep + "saved" + os.sep -mapPath = dataPath + os.sep + "maps" + os.sep +gamePath = dataPath + "saved" + os.sep +mapPath = dataPath + "maps" + os.sep -fontPath = assetPath + os.sep + "fonts" + os.sep +fontPath = assetPath + "fonts" + os.sep imagePath = assetPath + "images" + os.sep -tilePath = imagePath + os.sep + "tiles" + os.sep -unitPath = imagePath + os.sep + "units" + os.sep +tilePath = imagePath + "tiles" + os.sep +unitPath = imagePath + "units" + os.sep -uiPath = imagePath + os.sep + "UI" + os.sep # general, throughout sections. -uiMenuPath = imagePath + os.sep + "menu" + os.sep -uiGamePath = imagePath + os.sep + "game" + os.sep +uiPath = imagePath + "UI" + os.sep # general, throughout sections. +uiMenuPath = imagePath + "menu" + os.sep +uiGamePath = imagePath + "game" + os.sep diff --git a/project/menus/loadgame.py b/project/menus/loadgame.py index 0a2c8f1..7b6b2d5 100644 --- a/project/menus/loadgame.py +++ b/project/menus/loadgame.py @@ -124,6 +124,9 @@ def __init__(self, control, origin): self.origin = origin self.max_amount = 6 # split into lists of amount (pages of so many games) + # Create game save directory if it doesn't exist. + os.makedirs(paths.gamePath, exist_ok=True) + # Load Game Names From Directory self.games = sorted([file for file in os.listdir(paths.gamePath)]) try: