11import os
22import json
33import logging
4-
54class ConfigManager :
65 base_dir = os .path .join (os .path .expanduser ('~' ), '.hackeros' , 'Hacker-Launcher' )
76 protons_dir = os .path .join (base_dir , 'Protons' )
@@ -10,22 +9,19 @@ class ConfigManager:
109 logs_dir = os .path .join (base_dir , 'Logs' )
1110 games_file = os .path .join (config_dir , 'games.json' )
1211 settings_file = os .path .join (config_dir , 'settings.json' )
13-
1412 def __init__ (self ):
1513 os .makedirs (self .config_dir , exist_ok = True )
1614 os .makedirs (self .prefixes_dir , exist_ok = True )
1715 os .makedirs (self .protons_dir , exist_ok = True )
1816 os .makedirs (self .logs_dir , exist_ok = True )
1917 self .setup_logging ()
20- self .settings = self .load_settings () # Store settings in instance variable
21-
18+ self .settings = self .load_settings () # Store settings in instance variable
2219 def setup_logging (self ):
2320 logging .basicConfig (
2421 filename = os .path .join (self .logs_dir , 'launcher.log' ),
25- level = logging .DEBUG , # Changed to DEBUG for more details
22+ level = logging .DEBUG , # Changed to DEBUG for more details
2623 format = '%(asctime)s [%(levelname)s] %(message)s'
2724 )
28-
2925 def load_games (self ):
3026 if os .path .exists (self .games_file ):
3127 try :
@@ -38,14 +34,12 @@ def load_games(self):
3834 return games
3935 except (json .JSONDecodeError , IOError , ValueError ) as e :
4036 logging .error (f"Error loading games.json: { e } " )
41- print (f"Error loading games.json: { e } " ) # Add console output
37+ print (f"Error loading games.json: { e } " ) # Add console output
4238 return []
4339 return []
44-
4540 def save_games (self , games ):
4641 with open (self .games_file , 'w' ) as f :
4742 json .dump (games , f , indent = 4 )
48-
4943 def load_settings (self ):
5044 default_settings = {
5145 'fullscreen' : True ,
@@ -65,9 +59,8 @@ def load_settings(self):
6559 default_settings .update (settings )
6660 except (json .JSONDecodeError , IOError , ValueError ) as e :
6761 logging .error (f"Error loading settings.json: { e } " )
68- print (f"Error loading settings.json: { e } " ) # Add console output
62+ print (f"Error loading settings.json: { e } " ) # Add console output
6963 return default_settings
70-
7164 def save_settings (self , settings ):
7265 with open (self .settings_file , 'w' ) as f :
7366 json .dump (settings , f , indent = 4 )
0 commit comments