|
10 | 10 |
|
11 | 11 | # pylint: disable=W0718 |
12 | 12 |
|
13 | | -class __CloseDialogError(Exception): ... |
| 13 | + |
14 | 14 |
|
15 | 15 |
|
16 | 16 | REGULAR_KEYS: tuple[str] = ("theme", "databases", "imageRatio", "imageWidth", "widthIsHeight", "checkUpdates", "excludeRule", "zoomBoost", "smallFonts") |
17 | 17 |
|
18 | 18 |
|
19 | 19 | class StrictModeError(Exception): ... # [<] teachers be like :| (this was such a stupid comment, gawdamn) |
20 | | - |
21 | | - |
22 | | -class __SettingsObjectCopy: |
23 | | - def __init__(self, master: Any) -> None: |
24 | | - """ |
25 | | - # __SettingsObjectCopy |
26 | | - |
27 | | - Serves as a copy of SettingsObject that doesn't allow for as much features. |
28 | | -
|
29 | | - :param master: SettingsObject class |
30 | | - """ |
31 | | - |
32 | | - self._SETTINGS: dict[str, int | bool | str | float | list[list[str, str, str]] | None] = master._SETTINGS |
33 | | - self.error_handler = master.error_handler |
34 | | - self._MASTER = master |
35 | | - |
36 | | - def load(self) -> None: |
37 | | - """""" |
38 | | - |
39 | | - self._MASTER.load() |
40 | | - |
41 | | - self._SETTINGS = self._MASTER._SETTINGS.copy() |
42 | | - |
43 | | - def save_settings(self, **kw) -> None: |
44 | | - """ |
45 | | - ## save_settings |
46 | | - Automatically save the settings using the default inner settings of the class. |
47 | | -
|
48 | | - :param indent: how many spaces as indentation *(int, defaults to 4)* |
49 | | - """ |
50 | | - |
51 | | - self._MASTER._SETTINGS = self._SETTINGS |
52 | | - self._MASTER.save_settings(**kw) |
53 | | - del self |
54 | | - |
55 | | - @property |
56 | | - def databases(self) -> list[list[str, str, str]]: |
57 | | - return self._SETTINGS['databases'] |
58 | | - |
59 | | - @databases.setter |
60 | | - def databases(self, value: list[list[str, str, str]]): |
61 | | - value.pop(0) |
62 | | - self._SETTINGS['databases'] = value |
63 | | - |
64 | | - @databases.deleter |
65 | | - def databases(self): |
66 | | - self._SETTINGS['databases'].clear() |
67 | | - |
68 | | - @property |
69 | | - def theme(self) -> str: |
70 | | - match self._SETTINGS['theme']: |
71 | | - case 1: |
72 | | - return "light" |
73 | | - |
74 | | - case 2: |
75 | | - return "dark" |
76 | | - |
77 | | - case _: |
78 | | - return "auto" |
79 | | - |
80 | | - @theme.setter |
81 | | - def theme(self, value: str | int): |
82 | | - if isinstance(value, int): |
83 | | - self._SETTINGS['theme'] = value |
84 | | - return |
85 | | - |
86 | | - match value: |
87 | | - case 'light': |
88 | | - value = 1 |
89 | | - |
90 | | - case 'dark': |
91 | | - value = 2 |
92 | | - |
93 | | - case _: |
94 | | - value = 0 |
95 | | - |
96 | | - self._SETTINGS['theme'] = value |
97 | | - |
98 | | - @property |
99 | | - def image_ratio(self) -> bool: |
100 | | - return self._SETTINGS['imageRatio'] |
101 | | - |
102 | | - @image_ratio.setter |
103 | | - def image_ratio(self, value: str): |
104 | | - match value: |
105 | | - case '16:9' | '1:1': |
106 | | - print('Good image ratio.') |
107 | | - |
108 | | - case _: |
109 | | - value = 'detect' |
110 | | - |
111 | | - self._SETTINGS['imageRatio'] = value |
112 | | - |
113 | | - @property |
114 | | - def image_width(self) -> int: |
115 | | - return self._SETTINGS['imageWidth'] |
116 | | - |
117 | | - @image_width.setter |
118 | | - def image_width(self, value: int): |
119 | | - self._SETTINGS['imageWidth'] = value |
120 | | - |
121 | | - @property |
122 | | - def use_width_as_height(self) -> bool: |
123 | | - return self._SETTINGS['widthIsHeight'] |
124 | | - |
125 | | - @use_width_as_height.setter |
126 | | - def use_width_as_height(self, value: bool): |
127 | | - self._SETTINGS['widthIsHeight'] = value |
128 | | - |
129 | | - @property |
130 | | - def zoom_boost(self) -> float: |
131 | | - return self._SETTINGS['zoomBoost'] |
132 | | - |
133 | | - @zoom_boost.setter |
134 | | - def zoom_boost(self, value: float): |
135 | | - self._SETTINGS['zoomBoost'] = value |
136 | | - |
137 | | - @property |
138 | | - def check_for_updates_on_startup(self) -> bool: |
139 | | - return self._SETTINGS['checkUpdates'] |
140 | | - |
141 | | - @check_for_updates_on_startup.setter |
142 | | - def check_for_updates_on_startup(self, value: bool): |
143 | | - self._SETTINGS['checkUpdates'] = value |
144 | | - |
145 | | - ''' |
146 | | - @property |
147 | | - def autoupdate(self) -> bool: |
148 | | - """ |
149 | | - # Levels of Auto Updating |
150 | | - |
151 | | - **Key name:** `autoUpdateLevel` |
152 | | -
|
153 | | - 0. **Always ask** (Default) |
154 | | - 1. **Always update** |
155 | | - 2. **Update if the latest is a major** |
156 | | - 3. **Never update** |
157 | | - |
158 | | - Auto Updating only works if **Check for Updates on Startup** (key name is `checkUpdates`) is enabled (set to `True`). |
159 | | - |
160 | | - Both Auto Updates and Check for Updates require a stable Internet connection. |
161 | | - """ |
162 | | - |
163 | | - return self._SETTINGS['autoUpdateLevel'] |
164 | | - |
165 | | - @autoupdate.setter |
166 | | - def autoupdate(self, value: bool): |
167 | | - if value < 0 or value > 3: |
168 | | - value = 0 # [i] set to default |
169 | | - |
170 | | - self._SETTINGS['autoUpdateLevel'] = value |
171 | | - ''' |
172 | | - |
173 | | - @property |
174 | | - def small_fonts(self) -> bool: |
175 | | - return self._SETTINGS['smallFonts'] |
176 | | - |
177 | | - @small_fonts.setter |
178 | | - def small_fonts(self, value: bool): |
179 | | - """ |
180 | | - # small_fonts |
181 | | - |
182 | | - **Key name:** `smallFonts` |
183 | | -
|
184 | | - 0. **Disabled**, which allows for the best UI experience |
185 | | - 1. **Enabled**, which allows for DoomMapGuesser to be played in smaller monitors |
186 | | - """ |
187 | | - |
188 | | - self._SETTINGS['smallFonts'] = value |
189 | | - |
190 | | - @property |
191 | | - def exclude_rule_for_e3m1_e3m9(self, **kw) -> str | None: |
192 | | - """ |
193 | | - # exclude_rule_for_e3m1_e3m9 |
194 | | - |
195 | | - Whether to use **Hell Keep** or **Warrens** or both, even! |
196 | | - |
197 | | - :param obj: the object to save - if not specified, will save itself |
198 | | - :param object: same as above but this one does not take priority |
199 | | - |
200 | | - Returns: |
201 | | - str: either 'warrens', 'hellkeep' or 'both' depending on what the user chose *(None if set to show none)* |
202 | | - """ |
203 | | - |
204 | | - __obj = kw.get('obj', None) |
205 | | - |
206 | | - if __obj is None: |
207 | | - __obj = kw.get('object', None) |
208 | | - |
209 | | - a: str | None = self._SETTINGS['excludeRule'] |
210 | | - |
211 | | - if a not in ('warrens', 'hell_keep', 'both'): |
212 | | - self._SETTINGS['excludeRule'] = None |
213 | | - |
214 | | - if __obj is None: |
215 | | - self.save_settings() |
216 | | - |
217 | | - else: |
218 | | - self.dump_settings(__obj) |
219 | | - |
220 | | - return self._SETTINGS['excludeRule'] |
221 | | - |
222 | | - @exclude_rule_for_e3m1_e3m9.setter |
223 | | - def exclude_rule_for_e3m1_e3m9(self, value: str | None): |
224 | | - if value not in ('warrens', 'hell_keep', 'both'): |
225 | | - value = None |
226 | | - |
227 | | - self._SETTINGS['excludeRule'] = value |
| 20 | +class __CloseDialogError(Exception): ... |
228 | 21 |
|
229 | 22 |
|
230 | 23 | class SettingsObject: |
@@ -311,7 +104,7 @@ def image_ratio(self) -> bool: |
311 | 104 | @image_ratio.setter |
312 | 105 | def image_ratio(self, value: str): |
313 | 106 | match value: |
314 | | - case '16:9' | '1:1': |
| 107 | + case '16:9' | '1:1' | '16:9 (Landscape)' | '1:1 (Square)': |
315 | 108 | print('Good image ratio.') |
316 | 109 |
|
317 | 110 | case _: |
@@ -593,7 +386,7 @@ def image_ratio(self) -> bool: |
593 | 386 | @image_ratio.setter |
594 | 387 | def image_ratio(self, value: str): |
595 | 388 | match value: |
596 | | - case '16:9' | '1:1': |
| 389 | + case '16:9' | '1:1' | '16:9 (Landscape)' | '1:1 (Square)': |
597 | 390 | print('Good image ratio.') |
598 | 391 |
|
599 | 392 | case _: |
|
0 commit comments