mini-arcade-core 0.9.4__py3-none-any.whl → 0.9.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mini_arcade_core/ui/menu.py +32 -6
- {mini_arcade_core-0.9.4.dist-info → mini_arcade_core-0.9.5.dist-info}/METADATA +1 -1
- {mini_arcade_core-0.9.4.dist-info → mini_arcade_core-0.9.5.dist-info}/RECORD +5 -5
- {mini_arcade_core-0.9.4.dist-info → mini_arcade_core-0.9.5.dist-info}/WHEEL +0 -0
- {mini_arcade_core-0.9.4.dist-info → mini_arcade_core-0.9.5.dist-info}/licenses/LICENSE +0 -0
mini_arcade_core/ui/menu.py
CHANGED
|
@@ -46,6 +46,7 @@ class MenuStyle:
|
|
|
46
46
|
line_height: int = 28
|
|
47
47
|
title_color: Color = (255, 255, 255)
|
|
48
48
|
title_spacing: int = 18
|
|
49
|
+
title_margin_bottom: int = 20
|
|
49
50
|
|
|
50
51
|
# Scene background (solid)
|
|
51
52
|
background_color: Color | None = None # e.g. BACKGROUND
|
|
@@ -75,6 +76,11 @@ class MenuStyle:
|
|
|
75
76
|
hint_color: Color = (200, 200, 200)
|
|
76
77
|
hint_margin_bottom: int = 50
|
|
77
78
|
|
|
79
|
+
# Font sizes (not used directly here, but for reference)
|
|
80
|
+
title_font_size = 44
|
|
81
|
+
hint_font_size = 14
|
|
82
|
+
item_font_size = 24
|
|
83
|
+
|
|
78
84
|
|
|
79
85
|
# pylint: enable=too-many-instance-attributes
|
|
80
86
|
|
|
@@ -165,13 +171,15 @@ class Menu:
|
|
|
165
171
|
title_h = 0
|
|
166
172
|
|
|
167
173
|
if self.title:
|
|
168
|
-
tw, th = surface.measure_text(
|
|
174
|
+
tw, th = surface.measure_text(
|
|
175
|
+
self.title, self.style.title_font_size
|
|
176
|
+
)
|
|
169
177
|
max_w = max(max_w, tw)
|
|
170
178
|
title_h = th
|
|
171
179
|
|
|
172
180
|
# Items
|
|
173
181
|
for it in self.items:
|
|
174
|
-
w, _ = surface.measure_text(it.label)
|
|
182
|
+
w, _ = surface.measure_text(it.label, self.style.item_font_size)
|
|
175
183
|
max_w = max(max_w, w)
|
|
176
184
|
|
|
177
185
|
items_h = len(self.items) * self.style.line_height
|
|
@@ -235,8 +243,13 @@ class Menu:
|
|
|
235
243
|
cursor_y,
|
|
236
244
|
self.title,
|
|
237
245
|
color=self.style.title_color,
|
|
246
|
+
font_size=self.style.title_font_size,
|
|
247
|
+
)
|
|
248
|
+
cursor_y += (
|
|
249
|
+
title_h
|
|
250
|
+
+ self.style.title_spacing
|
|
251
|
+
+ self.style.title_margin_bottom
|
|
238
252
|
)
|
|
239
|
-
cursor_y += title_h + self.style.title_spacing
|
|
240
253
|
|
|
241
254
|
if self.style.button_enabled:
|
|
242
255
|
self._draw_buttons(surface, x_center, cursor_y)
|
|
@@ -251,6 +264,7 @@ class Menu:
|
|
|
251
264
|
vh - self.style.hint_margin_bottom,
|
|
252
265
|
self.style.hint,
|
|
253
266
|
color=self.style.hint_color,
|
|
267
|
+
font_size=self.style.hint_font_size,
|
|
254
268
|
)
|
|
255
269
|
|
|
256
270
|
def _draw_text_items(self, surface: Backend, x_center: int, cursor_y: int):
|
|
@@ -266,6 +280,7 @@ class Menu:
|
|
|
266
280
|
cursor_y + i * self.style.line_height,
|
|
267
281
|
item.label,
|
|
268
282
|
color=color,
|
|
283
|
+
font_size=self.style.item_font_size,
|
|
269
284
|
)
|
|
270
285
|
|
|
271
286
|
# Justification: Local variables for layout calculations
|
|
@@ -350,10 +365,16 @@ class Menu:
|
|
|
350
365
|
|
|
351
366
|
content_h = items_h
|
|
352
367
|
if self.title:
|
|
353
|
-
content_h +=
|
|
368
|
+
content_h += (
|
|
369
|
+
title_h
|
|
370
|
+
+ self.style.title_spacing
|
|
371
|
+
+ self.style.title_margin_bottom
|
|
372
|
+
)
|
|
354
373
|
|
|
355
374
|
return max_w, content_h, title_h
|
|
356
375
|
|
|
376
|
+
# Justification: Many arguments for text drawing utility
|
|
377
|
+
# pylint: disable=too-many-arguments
|
|
357
378
|
@staticmethod
|
|
358
379
|
def _draw_text_center_x(
|
|
359
380
|
surface: Backend,
|
|
@@ -362,6 +383,11 @@ class Menu:
|
|
|
362
383
|
text: str,
|
|
363
384
|
*,
|
|
364
385
|
color: Color,
|
|
386
|
+
font_size: int | None = None,
|
|
365
387
|
):
|
|
366
|
-
w, _ = surface.measure_text(text)
|
|
367
|
-
surface.draw_text(
|
|
388
|
+
w, _ = surface.measure_text(text, font_size=font_size)
|
|
389
|
+
surface.draw_text(
|
|
390
|
+
x_center - (w // 2), y, text, color=color, font_size=font_size
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
# pylint: enable=too-many-arguments
|
|
@@ -14,8 +14,8 @@ mini_arcade_core/physics2d.py,sha256=qIq86qWVuvcnLIMEPH6xx7XQO4tQhfiMZY6FseuVOR8
|
|
|
14
14
|
mini_arcade_core/registry.py,sha256=go3wAu406ZhwocBxmfcgI0Tprg2LXnwcT65_MCMMDX4,3225
|
|
15
15
|
mini_arcade_core/scene.py,sha256=e0E81aHt6saYiGfA-1V2II1yWwcZfvqGTRAv8pZnQtY,3865
|
|
16
16
|
mini_arcade_core/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
mini_arcade_core/ui/menu.py,sha256=
|
|
18
|
-
mini_arcade_core-0.9.
|
|
19
|
-
mini_arcade_core-0.9.
|
|
20
|
-
mini_arcade_core-0.9.
|
|
21
|
-
mini_arcade_core-0.9.
|
|
17
|
+
mini_arcade_core/ui/menu.py,sha256=LiN1T8YCrigPB4Z6OxNlD0ErL5yAV5skpcAY_bgedKw,12144
|
|
18
|
+
mini_arcade_core-0.9.5.dist-info/METADATA,sha256=pne74vBWZlG2YYVJevZequ1T-MnTC_VZal9tRuYaKnM,8188
|
|
19
|
+
mini_arcade_core-0.9.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
20
|
+
mini_arcade_core-0.9.5.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
|
|
21
|
+
mini_arcade_core-0.9.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|