Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from contextlib import contextmanager
- import sys
- import os
- sys.path.append(os.path.dirname(__file__))
- from bbot_template_pb2 import BBotUI, BBotUIControl
- class BBotUIWizard:
- def __init__(self, config):
- self._config = config
- self._ui = BBotUI()
- self._parent_path = ''
- @contextmanager
- def group(self, name):
- ctrl = BBotUIControl()
- ctrl.set_type(BBotUIControl.T_GROUP)
- ctrl.set_caption(name)
- ui = self._ui
- ui.add_controls(ctrl)
- self._ui = ctrl
- try:
- yield
- finally:
- self._ui = ui
- def textField(self, caption, defaultValue=None):
- ctrl = BBotUIControl()
- ctrl.set_type(BBotUIControl.T_STRING)
- ctrl.set_caption(caption)
- ctrl.set_str_value(defaultValue)
- self._ui.add_controls(ctrl)
- # TODO: return current value from config
- path = self._parent_path + '/' + caption
- return self._config.get(path, defaultValue) # 'Info/Build Mark'
- def comboBox(self, caption, options):
- pass
- def comboBoxMulti(self, caption, options):
- pass
- class Stage:
- def __init__(self, name):
- self._name = name
- self._params = {}
- self._stages = []
- self.__setitem__ = self._params.__setitem__
- class BBotStagesWizard:
- def __init__(self, config):
- self._config = config
- self._stages = []
- @contextmanager
- def stage(self, name):
- st = Stage(name)
- lst = self._stages
- lst.append(st)
- self._stages = st._stages
- try:
- yield st
- finally:
- self._stages = lst
- # ------------------------------------------------------------------------------------------
- def applyTemplate(projInfo, config):
- #
- # Emit UI
- #
- ui = BBotUIWizard(config)
- with ui.group('Info'):
- buildMark = ui.textField('Build Mark')
- if projInfo.workspace == 'HaloF2P':
- defaultLevel = 'startup_lobby'
- else:
- defaultLevel = 'ui'
- defaultLevel = ui.textField('Default Level', defaultLevel)
- scenes = ui.comboBoxMulti('Scenes List', projInfo.getSceneList()) # multiple selection
- with ui.group('Options'):
- lightmapQuality = ui.comboBox('LM Quality', ['High', 'Medium', 'Low'])
- #
- # Emit Stages
- #
- pr = BBotStagesWizard(config)
- with pr.stage('Perforce') as st:
- st['workspace'] = projInfo.workspace
- with pr.stage('Build'):
- for name in scenes:
- with pr.stage('BuildLevel') as st:
- st['workspace'] = projInfo.workspace
- st['level_name'] = name
- st['lm_quality'] = lightmapQuality
- with pr.stage('Packer') as st:
- st['levels'] = scenes
- st['default_level'] = defaultLevel
- st['build_mark'] = buildMark
- return ui, pr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement