From: Flavio Calva Date: Sat, 14 Jan 2023 07:41:15 +0000 (+0200) Subject: fixes for building X-Git-Url: http://git.ya2.it/?p=pmachines.git;a=commitdiff_plain;h=88dde9250e49d9fc0520a48da67c2ec6f85c7b67 fixes for building --- diff --git a/pmachines/application/persistent.py b/pmachines/application/persistent.py index 81bbc91..eba2f39 100644 --- a/pmachines/application/persistent.py +++ b/pmachines/application/persistent.py @@ -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: diff --git a/pmachines/gui/menu.py b/pmachines/gui/menu.py index 4fef839..4bd8890 100644 --- a/pmachines/gui/menu.py +++ b/pmachines/gui/menu.py @@ -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), diff --git a/pmachines/scene/scene.py b/pmachines/scene/scene.py index 287f84f..0343d89 100644 --- a/pmachines/scene/scene.py +++ b/pmachines/scene/scene.py @@ -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 = '' diff --git a/ya2/build/lang.py b/ya2/build/lang.py index 7a67cc4..54fafdc 100644 --- a/ya2/build/lang.py +++ b/ya2/build/lang.py @@ -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] diff --git a/ya2/utils/gfx.py b/ya2/utils/gfx.py index cadcaa8..a25365a 100755 --- a/ya2/utils/gfx.py +++ b/ya2/utils/gfx.py @@ -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):