from ya2.p3d.p3d import LibP3d
+class DirectOptionMenuTest(DirectOptionMenu):
+
+ def __init__(self, parent=None, **kw):
+ DirectOptionMenu.__init__(self, parent, **kw)
+ self.initialiseoptions(DirectOptionMenuTest)
+
+ def showPopupMenu(self, event=None):
+ super().showPopupMenu(event)
+ self._show_cb([self.component(cmp) for cmp in self.components()])
+
+
+
class Menu(DirectObject):
def __init__(self, fsm, lang_mgr, opt_file, music, pipeline, scenes,
'en': _('English'),
'it': _('Italian')
}[self._opt_file['settings']['language']]
- btn = DirectOptionMenu(
+
+ def lang_cb(comps):
+ self._pos_mgr.remove(['english', 'italian'])
+ for lng, btn in zip(['english', 'italian'], comps):
+ pos = LibP3d.wdg_pos(btn)
+ self._pos_mgr.register(lng, (pos[0] + 5, pos[1]))
+ btn = DirectOptionMenuTest(
text=_('Language'), items=items, initialitem=inititem,
pos=(0, 1, .8), command=self.on_language, **self._common_opt)
+ btn._show_cb = lang_cb
btn.popupMenu['frameColor'] = self._common_btn['frameColor']
btn.popupMenu['relief'] = self._common_btn['relief']
self._widgets += [btn]
pos_lang = LibP3d.wdg_pos(self._widgets[-1])
self._pos_mgr.register('languages', pos_lang)
- pos_eng = pos_lang[0] + 300, pos_lang[1] - 57
- pos_it = pos_lang[0] + 300, pos_lang[1] + 33
- self._pos_mgr.register('english', pos_eng)
- self._pos_mgr.register('italian', pos_it)
self._widgets += [OnscreenText(
_('Volume'), pos=(-.1, .55), font=self._common['text_font'],
scale=self._common['scale'], fg=self._common['text_fg'],
resolutions = ['x'.join(_res) for _res in resolutions]
if not res:
res = resolutions[-1]
- btn = DirectOptionMenu(
+
+ def res_cb(comps):
+ self._pos_mgr.remove(['res_1440x900', 'res_1360x768'])
+ for tgt_res in ['1440x900', '1360x768']:
+ for btn in comps:
+ if btn['text'] == tgt_res:
+ pos = LibP3d.wdg_pos(btn)
+ self._pos_mgr.register('res_' + tgt_res, (pos[0] + 5, pos[1]))
+ btn = DirectOptionMenuTest(
text=_('Resolution'), items=resolutions, initialitem=res,
pos=(0, 1, .05), command=self.on_resolution, **self._common_opt)
+ btn._show_cb = res_cb
btn.popupMenu['frameColor'] = self._common_btn['frameColor']
btn.popupMenu['relief'] = self._common_btn['relief']
self._widgets += [btn]
from setuptools.command.develop import develop
from multiprocessing import cpu_count
from direct.dist.commands import bdist_apps
-from ya2.build.build import _branch, files, _ver, files
+from ya2.build.build import _branch, files, _version
#from ya2.build.docs import bld_docs
from ya2.build.models import ModelsBuilder
from ya2.build.images import bld_images
package_data_dirs = {'simplepbr': [('simplepbr/shaders*', '', {})]}
setup(
name=appname,
- version=ver,
+ version=_version(),
cmdclass={
'develop': DevelopPyCmd,
# 'docs': DocsCmd,
from os.path import exists, basename, join
from glob import glob
from panda3d.core import Filename
-from ya2.build.build import exec_cmd, _branch, _ver
+from ya2.build.build import exec_cmd, _branch, _version
class FunctionalTests(TestCase):
for line in lines:
if line.strip().split()[0] == _branch():
commit = line.strip().split()[1][:7]
- __ver = _ver()
+ __ver = _version()
if _branch() == 'stable':
with open('/home/flavio/builders/pmachines_builder/pmachines/assets/version.txt') as fver:
__ver = fver.read().strip() + '-'
# TODO refactor: make class BuilderTools
-def exec_cmd(cmd):
+def exec_cmd(cmd, check=True):
'''Synchronously executes a command and returns its output.'''
# ret = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True).communicate()
# return ret[0].decode('utf-8').strip()
- proc = run(cmd, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=True)
+ proc = run(cmd, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=check)
return proc.stdout.strip() + proc.stderr.strip()