create user-data.yaml if it doesn't exist (#67)

This commit is contained in:
Spencer Shepard
2024-04-01 19:42:42 -07:00
committed by GitHub
parent 2918e6255b
commit 96254c929a
5 changed files with 15 additions and 4 deletions

View File

@@ -519,6 +519,12 @@ class Window(QMainWindow, Ui_MainWindow):
self.user_ratings = prefs["ratings"]
except:
logger.error("Could not load prefs.yaml")
else:
logger.info("No user data file found. Creating a new one.")
prefs = {"player_slots": ["AH-64D_BLK_II", "UH-1H", "Mi-24P", "Ka-50_3", "Mi-8MT"]}
with open(directories.user_datafile_path, 'w') as pfile:
yaml.dump(prefs, pfile)
if not prefs:
prefs = {}