Skip to content

Commit 8b7fda8

Browse files
committed
got a ton of work done
1 parent a2f7fab commit 8b7fda8

File tree

6 files changed

+179
-91
lines changed

6 files changed

+179
-91
lines changed

.github/requirements.txt

30 Bytes
Binary file not shown.

core/database_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pylint: disable=W0718
88

9+
class __CloseDialogError(Exception): ...
910

1011
class StatusCodeNot200(Exception): ...
1112

core/settings.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
# pylint: disable=W0718
1212

13+
class __CloseDialogError(Exception): ...
14+
15+
16+
REGULAR_KEYS: tuple[str] = ("theme", "databases", "imageRatio", "imageWidth", "widthIsHeight", "checkUpdates", "autoUpdateLevel", "excludeRule", "zoomBoost", "smallFonts")
17+
1318

1419
class StrictModeError(Exception): ... # [<] teachers be like :| (this was such a stupid comment, gawdamn)
1520

@@ -32,7 +37,7 @@ def __init__(self, given_path: str, *_, handler: Any, initial_settings: dict[str
3237
"""
3338

3439
self._PATH = kw.get('overwrite', given_path)
35-
self._HANDLER = handler
40+
self.error_handler = handler
3641
self._SETTINGS: dict[str, int | bool | str | float | list[list[str, str, str]] | None] = initial_settings
3742
self._BE_STRICT = kw.get('strict', True)
3843

@@ -45,31 +50,31 @@ def load(self) -> None:
4550
self._SETTINGS = json.load(f)
4651

4752
except FileNotFoundError as e:
48-
self._HANDLER(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
53+
self.error_handler(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
4954
sys.exit()
5055

5156
except PermissionError as e:
52-
self._HANDLER(43, f"FATAL ERROR\nMissing permissions to read the settings file\n{e}")
57+
self.error_handler(43, f"FATAL ERROR\nMissing permissions to read the settings file\n{e}")
5358
sys.exit()
5459

5560
except UnicodeError as e:
56-
self._HANDLER(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters in the settings file\n{e}")
61+
self.error_handler(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters in the settings file\n{e}")
5762
sys.exit()
5863

5964
except json.JSONDecodeError as e:
60-
self._HANDLER(1, f"FATAL ERROR\nJSON file could not be parsed correctly.\n{e}")
65+
self.error_handler(1, f"FATAL ERROR\nJSON file could not be parsed correctly.\n{e}")
6166
sys.exit()
6267

6368
except Exception as e:
64-
self._HANDLER(3, f"FATAL ERROR\nUnknown error when attempting to parse the settings.\n{e}")
69+
self.error_handler(3, f"FATAL ERROR\nUnknown error when attempting to parse the settings.\n{e}")
6570
sys.exit()
6671

6772
it_happened = False # [i] variable that indicates whether an expected key is... gone... (this sounds stupid)
6873

69-
for ek in ("theme", "databases", "imageRatio", "imageWidth", "widthIsHeight", "checkUpdates", "autoUpdateLevel", "excludeRule", "zoomBoost", "seasonalEasterEggs"):
74+
for ek in REGULAR_KEYS:
7075
if ek not in self._SETTINGS:
7176
it_happened = True
72-
self._HANDLER(2, f"FATAL ERROR\nMissing a key in the settings file.\nMissing key:\n'{ek}'")
77+
self.error_handler(2, f"FATAL ERROR\nMissing a key in the settings file.\nMissing key:\n'{ek}'")
7378
continue
7479

7580
continue
@@ -104,23 +109,23 @@ def dump_settings(self, obj: dict, **kw) -> None:
104109
json.dump(obj, f, indent=kw.get("indent", 4))
105110

106111
except FileNotFoundError as e:
107-
self._HANDLER(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
112+
self.error_handler(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
108113
sys.exit()
109114

110115
except PermissionError as e:
111-
self._HANDLER(43, f"FATAL ERROR\nMissing permissions to write to the settings file\n{e}")
116+
self.error_handler(43, f"FATAL ERROR\nMissing permissions to write to the settings file\n{e}")
112117
sys.exit()
113118

114119
except UnicodeError as e:
115-
self._HANDLER(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters\n{e}")
120+
self.error_handler(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters\n{e}")
116121
sys.exit()
117122

118123
except json.JSONDecodeError as e:
119-
self._HANDLER(1, f"FATAL ERROR\nJSON file could not be parsed correctly\n{e}")
124+
self.error_handler(1, f"FATAL ERROR\nJSON file could not be parsed correctly\n{e}")
120125
sys.exit()
121126

122127
except Exception as e:
123-
self._HANDLER(3, f"FATAL ERROR\nUnknown error when attempting to write to the settings\n{e}")
128+
self.error_handler(3, f"FATAL ERROR\nUnknown error when attempting to write to the settings\n{e}")
124129
sys.exit()
125130

126131
@property
@@ -240,22 +245,21 @@ def autoupdate(self, value: bool):
240245
self._SETTINGS['autoUpdateLevel'] = value
241246

242247
@property
243-
def seasonal_easter_eggs(self) -> int:
244-
return self._SETTINGS['seasonalEasterEggs']
248+
def small_fonts(self) -> bool:
249+
return self._SETTINGS['smallFonts']
245250

246-
@seasonal_easter_eggs.setter
247-
def seasonal_easter_eggs(self, value: int):
251+
@small_fonts.setter
252+
def small_fonts(self, value: bool):
248253
"""
249-
# seasonal_easter_eggs
254+
# small_fonts
250255
251-
**Key name:** `seasonalEasterEggs`
256+
**Key name:** `smallFonts`
252257
253-
0. **Disabled**
254-
1. **Enabled** (Default)
255-
2. **Only the ones that do not interfere with gameplay**
258+
0. **Disabled**, which allows for the best UI experience
259+
1. **Enabled**, which allows for DoomMapGuesser to be played in smaller monitors
256260
"""
257261

258-
self._SETTINGS['seasonalEasterEgg'] = value
262+
self._SETTINGS['smallFonts'] = value
259263

260264
@property
261265
def exclude_rule_for_e3m1_e3m9(self, **kw) -> str | None:
@@ -307,7 +311,7 @@ def __setitem__(self, key: str, value: int | bool | float | str | list[str]):
307311
if not isinstance(value, (int, str, float, list, bool)):
308312
raise ValueError('can only assign int, str, list[str] or boolean using SettingsObject.__setitem__')
309313

310-
if key not in ("theme", "databases", "imageRatio", "imageWidth", "widthIsHeight", "checkUpdates", "seasonalEasterEggs", "excludeRule", "autoUpdateLevel", "zoomBoost"):
314+
if key not in REGULAR_KEYS:
311315
raise KeyError('strict mode in SettingsObject does not allow for assigning new keys')
312316

313317
self._SETTINGS[key] = value

0 commit comments

Comments
 (0)