ya2 · news · projects · code · about

fixed the width of the menu buttons
authorFlavio Calva <f.calva@gmail.com>
Mon, 24 Jan 2022 17:57:02 +0000 (18:57 +0100)
committerFlavio Calva <f.calva@gmail.com>
Mon, 24 Jan 2022 17:57:02 +0000 (18:57 +0100)
pmachines/menu.py
prj.org

index 953c063edadb30d0b774ed0af8727903bc9ea559..0fc6accf7f9fdb1136d52cce908e7d41d3cc59ae 100644 (file)
@@ -36,7 +36,7 @@ class Menu:
             'frameColor': (.4, .4, .4, .14),
             'rolloverSound': loader.load_sfx('assets/audio/sfx/rollover.ogg'),
             'clickSound': loader.load_sfx('assets/audio/sfx/click.ogg')}
-        self._common_btn = {'frameSize': (-3.8, 3.8, -.6, 1.2)} | self._common
+        self._common_btn = {'frameSize': (-4.8, 4.8, -.6, 1.2)} | self._common
         hlc = self._common_btn['frameColor']
         hlc = (hlc[0] + .2, hlc[1] + .2, hlc[2] + .2, hlc[3] + .2)
         self._common_opt = {
@@ -74,6 +74,7 @@ class Menu:
         self._widgets += [DirectButton(
             text=_('Exit'), pos=(0, 1, -.6), command=lambda: exit(),
             **self._common_btn)]
+        self._rearrange_width()
 
     def _set_options(self):
         self._widgets = []
@@ -173,6 +174,17 @@ class Menu:
         self.destroy()
         self._set_credits()
 
+    def _rearrange_width(self):
+        max_width = 0
+        for wdg in self._widgets:
+            t_n = wdg.component('text0')
+            u_l = t_n.textNode.get_upper_left_3d()
+            l_r = t_n.textNode.get_lower_right_3d()
+            max_width = max(l_r[0] - u_l[0], max_width)
+        for wdg in self._widgets:
+            m_w = max_width / 2 + .8
+            wdg['frameSize'] = -m_w, m_w, wdg['frameSize'][2], wdg['frameSize'][3]
+
     def on_language(self, arg):
         lang_code = {
             _('English'): 'en_EN',
diff --git a/prj.org b/prj.org
index f3a34691baae178780ff0e645fb4f4715aefa09a..83e4a6ded750d86d7eb0177f18dd1a221b6c039a 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,16 +1,23 @@
 * issues
 * todo
+** overlapping items
 ** implement the operations of the buttons
-** refactoring
+*** info
+*** restart
+*** undo
+*** redo
 ** implement other items
-** refactoring
+*** shelf
+*** domino
+*** basketball
+*** teeter_tooter
 ** create one level per item, then levels with more items
 *** e.g. item1, item2, item1+2, item3, item1+2+3, ...
 ** refactoring
-** android build
 ** build pipeline
 ** version 0.0.yymmdd
 ** do intro video with moviepy
+** android build
 ** magnet
 *  waiting
 ** itch.io's client works with wine: functional tests for windows-itch.io