-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_module.py
More file actions
61 lines (53 loc) · 1.61 KB
/
Copy pathsettings_module.py
File metadata and controls
61 lines (53 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Settings Module for PyCraftHub
Handles user preferences, themes, and configuration
"""
import os
import json
SETTINGS_FILE = "data/settings.json"
DEFAULT_SETTINGS = {
"theme": "cyan", # cyan, green, blue, magenta, red
"server_directory": "servers",
"notifications_enabled": True,
"discord_webhook": "",
"auto_backup": False,
"backup_interval": "daily", # daily, weekly, manual
"playit_enabled": False,
"playit_secret": "",
"auto_update_check": True,
"show_splash": True,
"default_ram": "2G",
"default_difficulty": "normal"
}
def load_settings():
"""Load settings from file"""
if not os.path.exists(SETTINGS_FILE):
save_settings(DEFAULT_SETTINGS)
return DEFAULT_SETTINGS.copy()
try:
with open(SETTINGS_FILE, "r") as f:
settings = json.load(f)
# Merge with defaults in case new settings were added
for key, value in DEFAULT_SETTINGS.items():
if key not in settings:
settings[key] = value
return settings
except:
return DEFAULT_SETTINGS.copy()
def save_settings(settings):
"""Save settings to file"""
os.makedirs("data", exist_ok=True)
with open(SETTINGS_FILE, "w") as f:
json.dump(settings, f, indent=4)
def get_theme_color(theme_name):
"""Get Fore color based on theme name"""
from colorama import Fore
themes = {
"cyan": Fore.CYAN,
"green": Fore.GREEN,
"blue": Fore.BLUE,
"magenta": Fore.MAGENTA,
"red": Fore.RED,
"yellow": Fore.YELLOW
}
return themes.get(theme_name, Fore.CYAN)