ya2 · news · projects · code · about

refactoring rc stable
authorFlavio Calva <f.calva@gmail.com>
Tue, 30 Aug 2022 17:49:44 +0000 (18:49 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 30 Aug 2022 17:49:44 +0000 (18:49 +0100)
main.py
pmachines/app.py
prj.org
setup.py
ya2/p3d/gfx.py

diff --git a/main.py b/main.py
index b27b586a7ba862ee0306651d7a818bab338e1b59..59b5110576115894b3b2bf89bebff554dda799af 100644 (file)
--- a/main.py
+++ b/main.py
@@ -1,19 +1,26 @@
-'''This is the main file. This launches the application.'''
 import ya2.utils.log  # so logging's info/debug are logged
 from sys import argv
-from panda3d.core import load_prc_file_data
-if '--version' in argv:
-    load_prc_file_data('', 'window-type none')
+from ya2.p3d.gfx import P3dGfxMgr
+if '--version' in argv: P3dGfxMgr.no_window()
 from os.path import exists
 from traceback import print_exc
-from pmachines.app import PmachinesApp
+from pmachines.app import Pmachines
 from p3d_appimage import AppImageBuilder
 
+
+class Main:
+
+    def __init__(self):
+        self.__pmachines = Pmachines()
+
+    def run(self):
+        if self.__pmachines.is_update_run: AppImageBuilder('pmachines').update()
+        elif not self.__pmachines.is_version_run: self.__run_game()
+
+    def __run_game(self):
+        try: self.__pmachines.run()
+        except Exception: print_exc()
+
+
 if __name__ == '__main__' or exists('main.pyo'):
-    pmachines = PmachinesApp()
-    if pmachines.updating:
-        AppImageBuilder('pmachines').update()
-    elif not pmachines.version:
-        try: pmachines.base.run()
-        except Exception:
-            print_exc()
+    Main().run()
index a0ed4ed3466fb69dd71c2619e89de2daf8703625..97f8aee61ca847d17dce317ddc7bf70e43897875 100755 (executable)
@@ -68,7 +68,7 @@ class MainFsm(FSM):
             assert_buffers()
 
 
-class PmachinesApp:
+class Pmachines:
 
     scenes = [
         SceneDomino,
@@ -86,8 +86,8 @@ class PmachinesApp:
         self._configure(args)
         self.base = ShowBase()
         self._pipeline = None
-        self.updating = args.update
-        self.version = args.version
+        self.is_update_run = args.update
+        self.is_version_run = args.version
         self.log_mgr = LogMgr.init_cls()()
         self._pos_mgr = PositionMgr()
         self._prepare_window(args)
@@ -224,7 +224,7 @@ class PmachinesApp:
             res = LVector2i(*[int(_res) for _res in res.split('x')])
         else:
             resolutions = []
-            if not self.version:
+            if not self.is_version_run:
                 d_i = base.pipe.get_display_information()
                 def _res(idx):
                     return d_i.get_display_mode_width(idx), \
@@ -236,14 +236,14 @@ class PmachinesApp:
         props = WindowProperties()
         if args.functional_test or args.functional_ref:
             fullscreen = False
-        elif not self.version:
+        elif not self.is_version_run:
             props.set_size(res)
         props.set_fullscreen(fullscreen)
         props.set_icon_filename('assets/images/icon/pmachines.ico')
-        if not args.screenshot and not self.version:
+        if not args.screenshot and not self.is_version_run:
             base.win.request_properties(props)
         #gltf.patch_loader(base.loader)
-        if self._options['development']['simplepbr'] and not self.version:
+        if self._options['development']['simplepbr'] and not self.is_version_run:
             self._pipeline = simplepbr.init(
                 use_normal_maps=True,
                 use_emission_maps=False,
@@ -309,3 +309,6 @@ class PmachinesApp:
             fps_threshold = 55 if cpu_count() >= 4 else 25
             assert(any(fps > fps_threshold for fps in self.__fps_lst), 'low fps %s' % self.__fps_lst)
         return task.again
+
+    def run(self):
+        self.base.run()
diff --git a/prj.org b/prj.org
index 7dbc6011cdb089302966e5086637ca760654c7d9..165b81193df9b6943c41a4b4e3112f24225baf56 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,11 +1,10 @@
 #+STARTUP: indent
-#+TODO: BACKLOG READY CODE L10N UNITTEST BUILD BLOG | DONE
+#+TODO: BACKLOG READY RED GREEN REFACTOR LINT L10N BUILD BLOG | DONE
 #+CATEGORY: pmachines
 #+TAGS: bug(b) calendar(c) waiting(w)
 
-* CODE create builds and update website/itch.io
-* READY refactoring (recurring task)
-* BACKLOG rename pmachines/ to logics/ (business logics)
+* RED create builds (master, rc, stable) and update website/itch.io
+* READY rename pmachines/ to logics/ (business logics)
 * BACKLOG intro animation (from target item to start position)
 * BACKLOG buttons of the scenes enabled sequentially
 - [ ] each scene has a version
index 6133f04189f8c0ce105272241506af7ebe12e4b1..d4f80c773f73ed58e6e24d096cf77a07222d5324 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,7 @@ from ya2.build.lang import LanguageBuilder
 from p3d_appimage import AppImageBuilder
 #from p3d_flatpak import FlatpakBuilder
 import ya2.utils.log  # so logging's info/debug are logged
-from pmachines.app import PmachinesApp
+from pmachines.app import Pmachines
 
 
 appname = longname = 'pmachines'
@@ -77,7 +77,7 @@ class ImagesCmd(AbsCmd):
 
     def run(self):
         '''Builds the images.'''
-        bld_screenshots(PmachinesApp.scenes)
+        bld_screenshots(Pmachines.scenes)
         bld_images(
             files(['jpg', 'png'], ['models', 'gltf', 'bam'], ['_png.png']), int(AbsCmd.cores))
 
index d0871ba0d7c5b9ac3d00fd805ae2c576bb5e9953..c9ebccf10115407a253b504381f85e7184eb2aaf 100755 (executable)
@@ -2,7 +2,7 @@ import datetime
 from logging import info
 from os import getcwd
 from panda3d.core import AntialiasAttrib, PandaNode, LightRampAttrib, \
-    NodePath, Point2, Point3, Texture
+    NodePath, Point2, Point3, Texture, load_prc_file_data
 # from ya2.lib.p3d.p3d import LibP3d
 
 
@@ -95,6 +95,10 @@ class P3dGfxMgr:
                     texture.set_format(Texture.F_srgb)
         return model
 
+    @staticmethod
+    def no_window():
+        load_prc_file_data('', 'window-type none')
+
     @staticmethod
     def toggle_aa():
         aa_not_none = render.get_antialias() != AntialiasAttrib.MNone