ya2 · news · projects · code · about

fullscreen and resolution option
[pmachines.git] / pmachines / pmachines.py
index e48af67bf35778589ff6077bfd43b9566beeaddc..d5f888601d9d05fa885df81d1aa48be6601a7edc 100755 (executable)
@@ -5,7 +5,8 @@ from sys import platform, argv
 from logging import info
 from os.path import exists
 from os import makedirs
-from panda3d.core import Filename, load_prc_file_data, AntialiasAttrib, Texture
+from panda3d.core import Filename, load_prc_file_data, AntialiasAttrib, \
+    Texture, WindowProperties, LVector2i
 from panda3d.bullet import BulletWorld, BulletDebugNode
 from direct.showbase.ShowBase import ShowBase
 from direct.fsm.FSM import FSM
@@ -109,7 +110,9 @@ class Pmachines:
         default_opt = {
             'settings': {
                 'volume': 1,
-                'language': 'en'},
+                'language': 'en',
+                'fullscreen': 1,
+                'resolution': ''},
             'development': {
                 'simplepbr': 1,
                 'verbose_log': 0,
@@ -121,6 +124,21 @@ class Pmachines:
             default_opt)
         if not opt_exists:
             self._options.store()
+        res = self._options['settings']['resolution']
+        if res:
+            res = LVector2i(*[int(_res) for _res in res.split('x')])
+        else:
+            d_i = base.pipe.get_display_information()
+            def _res(idx):
+                return d_i.get_display_mode_width(idx), \
+                    d_i.get_display_mode_height(idx)
+            resolutions = [
+                _res(idx) for idx in range(d_i.get_total_display_modes())]
+            res = sorted(resolutions)[-1]
+        props = WindowProperties()
+        props.set_size(res)
+        props.set_fullscreen(self._options['settings']['fullscreen'])
+        base.win.request_properties(props)
         gltf.patch_loader(base.loader)
         if self._options['development']['simplepbr']:
             pipeline = simplepbr.init(