-from panda3d.core import Texture, TextNode
+from panda3d.core import Texture, TextNode, WindowProperties, LVector2i
from direct.gui.DirectGui import DirectButton, DirectCheckButton, \
- DirectOptionMenu, DirectSlider
+ DirectOptionMenu, DirectSlider, DirectCheckButton
from direct.gui.DirectGuiGlobals import FLAT
from direct.gui.OnscreenText import OnscreenText
'rolloverSound': loader.load_sfx('assets/audio/sfx/rollover.ogg'),
'clickSound': loader.load_sfx('assets/audio/sfx/click.ogg')}
self._common_btn = {'frameSize': (-3.8, 3.8, -.6, 1.2)} | self._common
+ hlc = self._common_btn['frameColor']
+ hlc = (hlc[0] + .2, hlc[1] + .2, hlc[2] + .2, hlc[3] + .2)
+ self._common_opt = {
+ 'item_frameColor': self._common_btn['frameColor'],
+ 'popupMarker_frameColor': self._common_btn['frameColor'],
+ 'item_relief': self._common_btn['relief'],
+ 'item_text_font': self._common_btn['text_font'],
+ 'item_text_fg': self._common_btn['text_fg'],
+ 'textMayChange': 1,
+ 'highlightColor': hlc,
+ 'text_align': TextNode.A_center,
+ } | self._common_btn
+ f_s = self._common_opt['frameSize']
+ self._common_opt['frameSize'] = f_s[0], f_s[1] - .56, f_s[2], f_s[3]
self._common_slider = self._common | {
'range': (0, 1),
'thumb_frameColor': (.4, .4, .4, .4),
'en': _('English'),
'it': _('Italian')
}[self._opt_file['settings']['language']]
- hlc = self._common_btn['frameColor']
- hlc = (hlc[0] + .2, hlc[1] + .2, hlc[2] + .2, hlc[3] + .2)
btn = DirectOptionMenu(
text=_('Language'), items=items, initialitem=inititem,
- pos=(0, 1, .6), command=self.on_language,
- item_frameColor=self._common_btn['frameColor'],
- popupMarker_frameColor=self._common_btn['frameColor'],
- item_relief=self._common_btn['relief'],
- item_text_font=self._common_btn['text_font'],
- item_text_fg=self._common_btn['text_fg'],
- textMayChange=1, highlightColor=hlc,
- **self._common_btn)
+ pos=(0, 1, .6), command=self.on_language, **self._common_opt)
btn.popupMenu['frameColor'] = self._common_btn['frameColor']
btn.popupMenu['relief'] = self._common_btn['relief']
self._widgets += [btn]
command=self.on_volume,
**self._common_slider)]
self._slider = self._widgets[-1]
+ self._widgets += [DirectCheckButton(
+ text=_('Fullscreen'), pos=(0, 1, 0), command=self.on_fullscreen,
+ indicator_frameColor=self._common_opt['highlightColor'],
+ indicator_relief=self._common_btn['relief'],
+ indicatorValue=self._opt_file['settings']['fullscreen'],
+ **self._common_btn)]
+ res = self._opt_file['settings']['resolution']
+ 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())]
+ resolutions = list(set(resolutions))
+ resolutions = sorted(resolutions)
+ resolutions = [(str(_res[0]), str(_res[1])) for _res in resolutions]
+ resolutions = ['x'.join(_res) for _res in resolutions]
+ if not res:
+ res = resolutions[-1]
+ btn = DirectOptionMenu(
+ text=_('Resolution'), items=resolutions, initialitem=res,
+ pos=(0, 1, -.3), command=self.on_resolution, **self._common_opt)
+ btn.popupMenu['frameColor'] = self._common_btn['frameColor']
+ btn.popupMenu['relief'] = self._common_btn['relief']
+ self._widgets += [btn]
self._widgets += [DirectButton(
text=_('Back'), pos=(0, 1, -.6), command=self.on_back,
**self._common_btn)]
self._opt_file['settings']['volume'] = self._slider['value']
self._music.set_volume(self._slider['value'])
+ def on_fullscreen(self, arg):
+ props = WindowProperties()
+ props.set_fullscreen(arg)
+ base.win.request_properties(props)
+ self._opt_file['settings']['fullscreen'] = int(arg)
+ self._opt_file.store()
+
+ def on_resolution(self, arg):
+ props = WindowProperties()
+ props.set_size(LVector2i(*[int(_res) for _res in arg.split('x')]))
+ base.win.request_properties(props)
+ self._opt_file['settings']['resolution'] = arg
+ self._opt_file.store()
+
def on_back(self):
self._opt_file.store()
self.destroy()
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
default_opt = {
'settings': {
'volume': 1,
- 'language': 'en'},
+ 'language': 'en',
+ 'fullscreen': 1,
+ 'resolution': ''},
'development': {
'simplepbr': 1,
'verbose_log': 0,
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(