ya2 · news · projects · code · about

credits
authorFlavio Calva <f.calva@gmail.com>
Fri, 21 Jan 2022 18:32:03 +0000 (19:32 +0100)
committerFlavio Calva <f.calva@gmail.com>
Fri, 21 Jan 2022 18:32:03 +0000 (19:32 +0100)
pmachines/menu.py
prj.org

index 4fb8e371a093f81636a0955da78318bab384d014..f4c4ff2924e67cc2945060f966f0f9bffefa4fc9 100644 (file)
@@ -1,5 +1,9 @@
 from logging import info
-from panda3d.core import Texture, TextNode, WindowProperties, LVector2i
+from sys import platform, exit
+from os import environ, system
+from webbrowser import open_new_tab
+from panda3d.core import Texture, TextNode, WindowProperties, LVector2i, \
+    TextProperties, TextPropertiesManager
 from direct.gui.DirectGui import DirectButton, DirectCheckButton, \
     DirectOptionMenu, DirectSlider, DirectCheckButton
 from direct.gui.DirectGuiGlobals import FLAT
@@ -58,16 +62,13 @@ class Menu:
             text=_('Play'), pos=(0, 1, .6), command=self.on_play,
             **self._common_btn)]
         self._widgets += [DirectButton(
-            text=_('Options'), pos=(0, 1, .3), command=self.on_options,
+            text=_('Options'), pos=(0, 1, .2), command=self.on_options,
             **self._common_btn)]
         self._widgets += [DirectButton(
-            text=_('Support us'), pos=(0, 1, 0), command=self.on_play,
+            text=_('Credits'), pos=(0, 1, -.2), command=self.on_credits,
             **self._common_btn)]
         self._widgets += [DirectButton(
-            text=_('Credits'), pos=(0, 1, -.3), command=self.on_play,
-            **self._common_btn)]
-        self._widgets += [DirectButton(
-            text=_('Exit'), pos=(0, 1, -.6), command=self.on_play,
+            text=_('Exit'), pos=(0, 1, -.6), command=lambda: exit(),
             **self._common_btn)]
 
     def _set_options(self):
@@ -135,6 +136,28 @@ class Menu:
             text=_('Back'), pos=(0, 1, -.8), command=self.on_back,
             **self._common_btn)]
 
+    def _set_credits(self):
+        self._widgets = []
+        tp_scale = TextProperties()
+        tp_scale.set_text_scale(.64)
+        TextPropertiesManager.getGlobalPtr().setProperties('scale', tp_scale)
+        self._widgets += [OnscreenText(
+            _('Code and gfx\n  \1scale\1Flavio Calva\2\n\n\nMusic\n  \1scale\1Stefan Grossmann\2'),
+            pos=(-.9, .55), font=self._common['text_font'],
+            scale=self._common['scale'], fg=self._common['text_fg'],
+            align=TextNode.A_left)]
+        self._widgets += [DirectButton(
+            text=_('Website'), pos=(-.6, 1, .29), command=self.on_website,
+            **self._common_btn | {'scale': .08})]
+        self._widgets += [OnscreenText(
+            _('Supporters\n  \1scale\1rdb\2\n  \1scale\1Luisa Tenuta\2\n  \1scale\1Damiana Ercolani\2'),
+            pos=(.1, .55), font=self._common['text_font'],
+            scale=self._common['scale'], fg=self._common['text_fg'],
+            align=TextNode.A_left)]
+        self._widgets += [DirectButton(
+            text=_('Back'), pos=(0, 1, -.8), command=self.on_back,
+            **self._common_btn)]
+
     def on_play(self):
         self._fsm.demand('Scene')
 
@@ -142,6 +165,10 @@ class Menu:
         self.destroy()
         self._set_options()
 
+    def on_credits(self):
+        self.destroy()
+        self._set_credits()
+
     def on_language(self, arg):
         lang_code = {
             _('English'): 'en_EN',
@@ -181,6 +208,13 @@ class Menu:
         self._opt_file['settings']['shadows'] = int(arg)
         self._opt_file.store()
 
+    def on_website(self):
+        if platform.startswith('linux'):
+            environ['LD_LIBRARY_PATH'] = ''
+            system('xdg-open https://www.ya2.it')
+        else:
+            open_new_tab('https://www.ya2.it')
+
     def on_back(self):
         self._opt_file.store()
         self.destroy()
diff --git a/prj.org b/prj.org
index 72f52d4063c6e28dc8b64baa269d60baf1439b7b..4c8c28fc2b61684a522270197412ed43c39043b0 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,8 +1,6 @@
 * issues
 * todo
-** main menu
-*** menu: credits (developers (our website) and supporters in the same page)
-*** menu: exit
+** srgb textures
 ** options: autostart, auto_close_instructions, show_buffers
 ** remove shadows of side-panel items (light.node().set_camera_mask(BitMask32(0x01)))
 ** glitch when dragging with shadows