ya2 · news · projects · code · about

fixes for building
authorFlavio Calva <f.calva@gmail.com>
Sat, 14 Jan 2023 07:41:15 +0000 (09:41 +0200)
committerFlavio Calva <f.calva@gmail.com>
Sat, 14 Jan 2023 07:41:15 +0000 (09:41 +0200)
pmachines/application/persistent.py
pmachines/gui/menu.py
pmachines/scene/scene.py
ya2/build/lang.py
ya2/utils/gfx.py

index 81bbc91fb24fc27e7e31645265a3e761d8671767..eba2f3946e4e8da558421d734452b51d713a5afe 100644 (file)
@@ -9,8 +9,8 @@ class Persistent:
         self.__opt_file = opt_file
 
     def __fix_ini_parsing(self):
-        #if len(self.__scenes_done) == 1 and not self.__scenes_done[0]:
-        #    self.__scenes_done = []
+        if len(self.__scenes_done) == 1 and not self.__scenes_done[0]:
+            self.__scenes_done = []
         #print(self.__scenes_done)
         #self.__scenes_done = self.__scenes_done[0]
         if self.__scenes_done:
index 4fef839f33df48e058bba825a3ff4f0c724273d2..4bd88901ed09b52664fe33c89fa4ee14b7a7a48e 100644 (file)
@@ -11,7 +11,7 @@ from direct.gui.DirectGuiGlobals import FLAT
 from direct.gui.OnscreenText import OnscreenText
 from direct.showbase.DirectObject import DirectObject
 from ya2.utils.cursor import MouseCursor
-from ya2.utils.gfx import GfxTools, DirectGuiMixin
+from ya2.utils.gfx import GfxTools, DirectGuiMixin, pos_pixel
 
 
 class DirectOptionMenuTest(DirectOptionMenu):
@@ -90,7 +90,7 @@ class Menu(DirectObject):
         info('enforced resolution: ' + val)
 
     def _set_main(self):
-        self._pos_mgr = {}
+        for k in list(self._pos_mgr.keys()): del self._pos_mgr[k]
         self._widgets = []
         self._widgets += [DirectButton(
             text=_('Play'), pos=(0, 1, .6), command=self.on_play,
@@ -121,7 +121,7 @@ class Menu(DirectObject):
         self.accept('enforce_resolution', self.enforce_res)
 
     def _set_options(self):
-        self._pos_mgr = {}
+        for k in list(self._pos_mgr.keys()): del self._pos_mgr[k]
         self._widgets = []
         self._lang_funcs = [lambda: _('English'), lambda: _('Italian')]
         items = [fnc() for fnc in self._lang_funcs]
@@ -195,7 +195,7 @@ class Menu(DirectObject):
             for tgt_res in ['1440x900', '1360x768']:
                 for btn in comps:
                     if btn['text'] == tgt_res:
-                        pos = btn.pos_pixel()
+                        pos = pos_pixel(btn)
                         self._pos_mgr['res_' + tgt_res] = (pos[0] + 5, pos[1])
         btn = DirectOptionMenuTest(
             text=_('Resolution'), items=resolutions, initialitem=res,
@@ -233,7 +233,7 @@ class Menu(DirectObject):
         self.accept('enforce_resolution', self.enforce_res)
 
     def _set_credits(self):
-        self._pos_mgr = {}
+        for k in list(self._pos_mgr.keys()): del self._pos_mgr[k]
         self._widgets = []
         tp_scale = TextProperties()
         tp_scale.set_text_scale(.64)
@@ -259,7 +259,7 @@ class Menu(DirectObject):
         self.accept('enforce_resolution', self.enforce_res)
 
     def on_play(self):
-        self._pos_mgr = {}
+        for k in list(self._pos_mgr.keys()): del self._pos_mgr[k]
         self.destroy()
         self._cursor = MouseCursor(
             'assets/images/buttons/arrowUpLeft.dds', (.04, 1, .04), (.5, .5, .5, 1),
index 287f84f2f73bc7cdbfe5436b330522c04eac1210..0343d895eb61d1e83c500a7377f59c38010f59ff 100644 (file)
@@ -40,7 +40,7 @@ class Scene(DirectObject):
         self._dbg_items = dbg_items
         self._reload_cb = reload_cb
         self._pos_mgr = pos_mgr
-        self._pos_mgr = {}
+        for k in list(self._pos_mgr.keys()): del self._pos_mgr[k]
         self._scenes = scenes
         self._start_evt_time = None
         self._enforce_result = ''
index 7a67cc4b8fc0d16982a0717dcbc236cd715c0904..54fafdce1fc1e2f9d275272cb3827312c4c40c39 100644 (file)
@@ -36,14 +36,16 @@ class LanguageBuilder:
     def __add_from_json_to_pot(self):
         json_files = [name for name in listdir(self.__json_path)
                       if isfile(join(self.__json_path, name)) and
-                      name.endswith('.json')]
+                      name.endswith('.json') and
+                      name != 'index.json']
         json_strings = []
         for json_file in json_files:
             with open(f'{self.__json_path}{json_file}') as f:
                 json = loads(f.read())
             json_strings += [json['name']]
-            for instruction_line in json['instructions']:
-                json_strings += [instruction_line]
+            for instruction_line in json['instructions'].split('\n'):
+                if instruction_line:
+                    json_strings += [instruction_line]
         def process_json_escape(string):
             return bytes(string, 'utf-8').decode('unicode-escape')
         json_strings = [process_json_escape(s) for s in json_strings]
index cadcaa857a53ff90c098751d973d978c8f8b5f22..a25365af7e7de34cb246031c7f4552fcb4a3a527 100755 (executable)
@@ -94,6 +94,11 @@ class DirectGuiMixin():
         DirectGuiMixin.registered_tooltips = []
 
 
+def pos_pixel(widget):
+    pos = widget.get_pos(pixel2d)
+    return int(round(pos[0])), int(round(-pos[2]))
+
+
 class Point(Decorator):
 
     def screen_coord(self):