-'''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()
assert_buffers()
-class PmachinesApp:
+class Pmachines:
scenes = [
SceneDomino,
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)
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), \
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,
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()
#+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
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'
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))
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
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