DirectOptionMenu, DirectSlider, DirectCheckButton
from direct.gui.DirectGuiGlobals import FLAT
from direct.gui.OnscreenText import OnscreenText
+from direct.showbase.DirectObject import DirectObject
from lib.engine.gui.cursor import MouseCursor
from game.scene import Scene
from panda3d.bullet import BulletWorld
-class Menu:
+class Menu(DirectObject):
def __init__(self, fsm, lang_mgr, opt_file, music, pipeline, scenes, fun_test):
+ super().__init__()
self._fsm = fsm
self._lang_mgr = lang_mgr
self._opt_file = opt_file
self._pipeline = pipeline
self._scenes = scenes
self._fun_test = fun_test
+ self._enforced_res = ''
self._cursor = MouseCursor(
'assets/images/buttons/arrowUpLeft.dds', (.04, 1, .04), (.5, .5, .5, 1),
(.01, .01))
del self._common_slider['clickSound']
self._set_main()
+ def enforce_res(self, val):
+ self._enforced_res = val
+ info('enforced resolution: ' + val)
+
def _set_main(self):
self._widgets = []
self._widgets += [DirectButton(
text=_('Exit'), pos=(0, 1, -.6), command=lambda: exit(),
**self._common_btn)]
self._rearrange_width()
+ self.accept('enforce_resolution', self.enforce_res)
def _set_options(self):
self._widgets = []
self._widgets += [DirectButton(
text=_('Back'), pos=(0, 1, -.8), command=self.on_back,
**self._common_btn)]
+ self.accept('enforce_resolution', self.enforce_res)
def _set_credits(self):
self._widgets = []
self._widgets += [DirectButton(
text=_('Back'), pos=(0, 1, -.8), command=self.on_back,
**self._common_btn)]
+ self.accept('enforce_resolution', self.enforce_res)
def on_play(self):
self.destroy()
self._opt_file.store()
def on_resolution(self, arg):
+ info('on resolution: %s (%s)' % (arg, self._enforced_res))
+ arg = self._enforced_res or arg
+ info('set resolution: %s' % arg)
props = WindowProperties()
props.set_size(LVector2i(*[int(_res) for _res in arg.split('x')]))
base.win.request_properties(props)
def destroy(self):
[wdg.destroy() for wdg in self._widgets]
self._cursor.destroy()
+ self.ignore('enforce_resolution')
from os.path import exists
from os import makedirs
from glob import glob
-from logging import debug
+from logging import debug, info
from importlib import import_module
from inspect import isclass
from panda3d.core import AmbientLight, DirectionalLight, Point3, Texture, \
def enforce_res(self, val):
self._enforce_res = val
- debug('enforce res: ' + val)
+ info('enforce res: ' + val)
def destroy(self):
self.ignore('enforce_res')
taskMgr.doMethodLater(.01, self._callbacks[2], 'cb2')
elif msg[0] == 'set_idx':
taskMgr.doMethodLater(.01, self._callbacks[3], 'cb3', [msg[1]])
+ elif msg[0] == 'enforce_resolution':
+ taskMgr.doMethodLater(.01, self._callbacks[4], 'cb4', [msg[1]])
except EOFError:
running = False
def __init__(self, ref):
super().__init__()
- self._listener = ListenerThread([self._do_screenshot, self._do_enforce_res, self.__verify, self._set_idx])
+ self._listener = ListenerThread([self._do_screenshot, self._do_enforce_res, self.__verify, self._set_idx, self._do_enforce_resolution])
self._listener.start()
self.txt = OnscreenText('', fg=(1, 0, 0, 1), scale=.16)
#self._path = ''
info('enforce_res %s' % res)
messenger.send('enforce_res', [res])
+ def _do_enforce_resolution(self, res):
+ info('enforce resolution %s (callback)' % res)
+ messenger.send('enforce_resolution', [res])
+
#def _screenshot(self, time, name):
#self._fnames += [self._path + name + '.png']
#self._tasks += [(
if is_snap:
return str(Path(par_path).absolute())
#return getcwd()
- curr_path = dirname(__file__)
+ #curr_path = dirname(__file__)
+ curr_path = str(Path(__file__).parent.parent.parent.absolute())
info('current path: %s' % curr_path)
return curr_path
'enforce res: %s' % res)]
self._curr_time += time
+ def _enforce_resolution(self, time, res):
+ def cback():
+ self._conn.send(['enforce_resolution', res])
+ info('enforce_resolution %s (send)' % res)
+ self._tasks += [(
+ self._curr_time + time,
+ cback,
+ 'enforce resolution: %s' % res)]
+ self._curr_time += time
+
def _verify(self):
def __verify():
self._conn.send(['verify'])
# resolution
self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left'])
self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
+ self._enforce_resolution(FunctionalTest.evt_time, '1440x900')
self._event(FunctionalTest.evt_time, 'mouseclick', [(1000, 440), 'left'])
self._screenshot(FunctionalTest.screenshot_time, '1440x900')
self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left'])
self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
+ self._enforce_resolution(FunctionalTest.evt_time, '1360x768')
self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left'])
self._screenshot(FunctionalTest.screenshot_time, '1360x768')
# antialiasing