def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.SetTopparentHeight(0)
     self.preSelectedItems = attributes.selectedItems
     self.outputPrice = 0
     self.outputItemsCount = 0
     mainCont = Container(name='mainCont', parent=self.sr.main, padding=const.defaultPadding)
     bottomCont = Container(name='bottomCont', parent=mainCont, align=uiconst.TOBOTTOM, height=36)
     reprocessingCont = Container(name='reprocessingCont', parent=mainCont, align=uiconst.TOALL)
     inputCont = Container(name='inputCont', parent=reprocessingCont, align=uiconst.TOLEFT_PROP, width=0.48)
     centerCont = Container(name='centerCont', parent=reprocessingCont, align=uiconst.TOLEFT_PROP, width=0.02)
     outputCont = Container(name='outputCont', parent=reprocessingCont, align=uiconst.TORIGHT_PROP, width=0.48)
     self.inputInfoCont = ReprocessInputContainer(name='inputInfo', parent=inputCont, dropFunc=self.AddItemByDrag, removeFunc=self.RemoveItem)
     self.outputInfoCont = ReprocessOutputContainer(name='outputInfo', parent=outputCont)
     self.loadingOverlay = Container(parent=self.inputInfoCont, idx=0)
     Fill(bgParent=self.loadingOverlay, color=(0.0, 0.0, 0.0, 0.3))
     LoadingWheel(name='loadingWheel', parent=self.loadingOverlay, align=uiconst.CENTER, width=80, height=80, state=uiconst.UI_DISABLED)
     self.loadingOverlay.opacity = 0.0
     self.controller = CreateReprocessingWindowController(self, self.inputInfoCont, self.outputInfoCont, sm.GetService('invCache'), sm.GetService('reprocessing'), GetActiveShip)
     self.inputInfoCont.captionLabel.text = GetByLabel('UI/Reprocessing/ReprocessingWindow/InputMaterials')
     self.outputInfoCont.captionLabel.text = GetByLabel('UI/Reprocessing/ReprocessingWindow/OutputResults')
     btnCont = Container(name='buttonCont', parent=bottomCont, align=uiconst.TOBOTTOM, height=36, idx=0, padding=(-4, 3, -4, -2))
     GradientThemeColored(bgParent=btnCont)
     self.reprocessButton = Button(parent=btnCont, label=GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessButton'), func=self.ReprocessItems, align=uiconst.CENTER, fixedheight=28)
     self.cancelButton = Button(parent=btnCont, label=GetByLabel('UI/Common/Buttons/Cancel'), func=self.Cancel, align=uiconst.CENTERRIGHT, left=8)
     self.DisableReprocessButton(disable=True)
     if self.preSelectedItems:
         start_tasklet(self.AddPreselectedItems, self.preSelectedItems)
Esempio n. 2
0
 def _on_video_state_change(self, videoPlayer, construction_parameters,
                            texture):
     logging.info('video state change. construction params=%s',
                  construction_parameters)
     try:
         if videoPlayer.state != resource.videoplayer.State.DONE:
             logging.warn('not done. construction params=%s',
                          construction_parameters)
             return
         name = construction_parameters.get('resource_name')
         if name is None:
             logging.warning(
                 'could not find resource in construction parameters %s',
                 construction_parameters)
             return
         logging.info('found dynamic resource name %s', name)
         billboard_resource = self.get_billboard_resource(name)
         if not billboard_resource:
             logging.warning(
                 "unable to locate billboard resource named '%s'" % name)
             return
         uthread2.start_tasklet(billboard_resource.play_next_in_playlist)
     except Exception:
         logger.exception('something is wrong. construction parameters %s',
                          construction_parameters)
Esempio n. 3
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.SetTopparentHeight(0)
     self.preSelectedItems = attributes.selectedItems
     self.outputPrice = 0
     self.outputItemsCount = 0
     mainCont = Container(name='mainCont', parent=self.sr.main, padding=const.defaultPadding)
     bottomCont = Container(name='bottomCont', parent=mainCont, align=uiconst.TOBOTTOM, height=36)
     reprocessingCont = Container(name='reprocessingCont', parent=mainCont, align=uiconst.TOALL)
     inputCont = Container(name='inputCont', parent=reprocessingCont, align=uiconst.TOLEFT_PROP, width=0.48)
     centerCont = Container(name='centerCont', parent=reprocessingCont, align=uiconst.TOLEFT_PROP, width=0.02)
     outputCont = Container(name='outputCont', parent=reprocessingCont, align=uiconst.TORIGHT_PROP, width=0.48)
     self.inputInfoCont = ReprocessInputContainer(name='inputInfo', parent=inputCont, dropFunc=self.AddItemByDrag, removeFunc=self.RemoveItem)
     self.outputInfoCont = ReprocessOutputContainer(name='outputInfo', parent=outputCont)
     self.loadingOverlay = Container(parent=self.inputInfoCont, idx=0)
     Fill(bgParent=self.loadingOverlay, color=(0.0, 0.0, 0.0, 0.3))
     LoadingWheel(name='loadingWheel', parent=self.loadingOverlay, align=uiconst.CENTER, width=80, height=80)
     self.loadingOverlay.opacity = 0.0
     self.controller = CreateReprocessingWindowController(self, self.inputInfoCont, self.outputInfoCont, sm.GetService('invCache'), sm.GetService('reprocessing'), GetActiveShip)
     self.inputInfoCont.captionLabel.text = GetByLabel('UI/Reprocessing/ReprocessingWindow/InputMaterials')
     self.outputInfoCont.captionLabel.text = GetByLabel('UI/Reprocessing/ReprocessingWindow/OutputResults')
     btnCont = Container(name='buttonCont', parent=bottomCont, align=uiconst.TOBOTTOM, height=36, idx=0, padding=(-4, 3, -4, -2))
     GradientUnderlay(bgParent=btnCont)
     self.reprocessButton = Button(parent=btnCont, label=GetByLabel('UI/Reprocessing/ReprocessingWindow/ReprocessButton'), func=self.ReprocessItems, align=uiconst.CENTER, fixedheight=28)
     self.cancelButton = Button(parent=btnCont, label=GetByLabel('UI/Common/Buttons/Cancel'), func=self.Cancel, align=uiconst.CENTERRIGHT, left=8)
     self.DisableReprocessButton(disable=True)
     if self.preSelectedItems:
         start_tasklet(self.AddPreselectedItems, self.preSelectedItems)
    def _DelayedDestroy(self):

        def _inner():
            _delay = 3000
            blue.synchro.SleepSim(_delay)
            self.Destroy()

        uthread2.start_tasklet(_inner)
Esempio n. 5
0
    def _on_error(self, player):
        try:
            player.validate()
        except RuntimeError as e:
            logging.exception('Video player error')
            for each in _error_handlers:
                each(player, e, self.constructor_params,
                     self.weak_texture.object)

            uthread2.start_tasklet(self.play_next)
Esempio n. 6
0
    def _on_state_change(self, player):
        if self.destroyed:
            return
        logging.debug('Video player state changed to %s',
                      videoplayer.State.GetNameFromValue(player.state))
        for each in _state_change_handlers:
            each(player, self.constructor_params, self.weak_texture.object)

        if player.state == videoplayer.State.DONE:
            uthread2.start_tasklet(self.play_next)
Esempio n. 7
0
def _main():
    sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
    import binbootstrapper
    binbootstrapper.update_binaries('.', *binbootstrapper.DLLS_GRAPHICS)
    from binbootstrapper.trinityapp import TrinityApp
    app = TrinityApp()
    import uthread2
    done = [False]
    uthread2.start_tasklet(crash, done)
    while not done[0]:
        app.run_frames(10)
Esempio n. 8
0
 def __call__(self, *args, **kwargs):
     dt = self.time_func() - self.time_since_step
     if dt > self.wait_seconds:
         self.time_since_step = 0.0
     if self.time_since_step == 0.0:
         self.f(*args, **kwargs)
         self.time_since_step = self.time_func()
         uthread.start_tasklet(self.trigger_next_call_if_exists)
         return
     self.next_call = self.f
     self.next_call_args = args
     self.next_call_kwargs = kwargs
Esempio n. 9
0
 def __call__(self, *args, **kwargs):
     dt = self.time_func() - self.time_since_step
     if dt > self.wait_seconds:
         self.time_since_step = 0.0
     if self.time_since_step == 0.0:
         self.f(*args, **kwargs)
         self.time_since_step = self.time_func()
         uthread.start_tasklet(self.trigger_next_call_if_exists)
         return
     self.next_call = self.f
     self.next_call_args = args
     self.next_call_kwargs = kwargs
Esempio n. 10
0
def _main():
    sys.path.append(
        os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
    import binbootstrapper
    binbootstrapper.update_binaries('.', *binbootstrapper.DLLS_GRAPHICS)
    from binbootstrapper.trinityapp import TrinityApp
    app = TrinityApp()
    import uthread2
    done = [False]
    uthread2.start_tasklet(crash, done)
    while not done[0]:
        app.run_frames(10)
Esempio n. 11
0
def spy(paths, delay = 0.5):
    if isinstance(paths, basestring):
        paths = [paths]
    waitables = win32api.Waitables()
    folderspy = FolderReloaderSpy(waitables, paths)
    tasklet = uthread.start_tasklet(_poll_spy, folderspy, delay)
    return (folderspy, tasklet)
Esempio n. 12
0
def spy(paths, delay = 0.5):
    if isinstance(paths, basestring):
        paths = [paths]
    waitables = win32api.Waitables()
    folderspy = FolderReloaderSpy(waitables, paths)
    tasklet = uthread.start_tasklet(_poll_spy, folderspy, delay)
    return (folderspy, tasklet)
Esempio n. 13
0
 def _show_expiration_timer(self):
     time_until_expiration = self._get_time_until_expiration()
     sleep_time = time_until_expiration - DAY
     if sleep_time > DAY:
         return
     if sleep_time > 0:
         self.expiration_timer_thread = uthread2.start_tasklet(self._show_expiration_timer_thread, sleep_time)
     else:
         self.Show()
 def _on_video_state_change(self, videoPlayer, construction_parameters, texture):
     logging.info('video state change. construction params=%s', construction_parameters)
     try:
         if videoPlayer.state != resource.videoplayer.State.DONE:
             logging.warn('not done. construction params=%s', construction_parameters)
             return
         name = construction_parameters.get('resource_name')
         if name is None:
             logging.warning('could not find resource in construction parameters %s', construction_parameters)
             return
         logging.info('found dynamic resource name %s', name)
         billboard_resource = self.get_billboard_resource(name)
         if not billboard_resource:
             logging.warning("unable to locate billboard resource named '%s'" % name)
             return
         uthread2.start_tasklet(billboard_resource.play_next_in_playlist)
     except Exception:
         logger.exception('something is wrong. construction parameters %s', construction_parameters)
Esempio n. 15
0
    def _create_low_quality_render_job(self):
        lq = blue.resMan.GetResource(self.low_quality_texture_path)

        def check():
            while True:
                if self.destroyed or not self.low_quality_texture_path or not _is_low_quality(
                ):
                    return
                if lq.isGood:
                    try:
                        self.weak_texture.object.CreateFromTexture(lq)
                    except:
                        pass

                    return
                blue.synchro.SleepWallclock(100)

        uthread2.start_tasklet(check)
Esempio n. 16
0
    def init(self,
             width,
             height,
             playlist,
             low_quality_texture_path=None,
             **kwargs):
        self.destroyed = False
        self.low_quality_texture_path = low_quality_texture_path
        self.generate_mips = kwargs.pop('generate_mips', False)
        self.constructor_params = kwargs
        self.playlist = playlist(**kwargs)

        def texture_destroyed():
            self._destroy()

        texture = trinity.TriTextureRes()
        self.weak_texture = blue.BluePythonWeakRef(texture)
        self.weak_texture.callback = texture_destroyed
        if not self.low_quality_texture_path or not _is_low_quality():
            uthread2.start_tasklet(self.play_next)
        else:
            self._create_low_quality_render_job()
        return texture
Esempio n. 17
0
    def __init__(self, url, language_id = None):
        if language_id is None:
            try:
                self._language_id = str(prefs.languageID)
            except (NameError, AttributeError):
                self._language_id = 'EN'

        else:
            self._language_id = language_id
        if self._language_id == 'ZH':
            self._language_id = 'CN'
        self._url = unicode(url)
        if self._url.lower().startswith(u'http'):
            self._base_url = u'/'.join(self._url.split(u'/')[0:-1])
            if not self._base_url.endswith(u'/'):
                self._base_url += u'/'
        else:
            self._base_url = unicode(os.path.dirname(self._url))
            if not self._base_url.endswith(os.path.sep):
                self._base_url += unicode(os.path.sep)
        self._data = None
        self._videos = {}
        uthread2.start_tasklet(self._load_index)
Esempio n. 18
0
    def init(self,
             video_local=None,
             video_remote=None,
             generate_mips=0,
             **kwargs):
        if not video_local and not video_remote:
            raise ValueError()
        self.generate_mips = bool(generate_mips)

        def texture_destroyed():
            self._destroy()

        texture = trinity.TriTextureRes()
        self.weak_texture = blue.BluePythonWeakRef(texture)
        self.weak_texture.callback = texture_destroyed
        self.constructor_params = dict(kwargs)
        self.constructor_params.update({
            'video_local': video_local,
            'video_remote': video_remote,
            'generate_mips': generate_mips
        })
        uthread2.start_tasklet(self._init, video_local, video_remote)
        return texture
Esempio n. 19
0
def ApplyBoosters(trinobjs, race):
    validobjs = filter(lambda o: hasattr(o, 'boosters'), trinobjs)
    if not validobjs:
        return

    def clearbooster(obj):
        obj.boosters = None

    if race is None:
        uthread2.map(clearbooster, validobjs)
        return
    booster_filepath = '%s/booster_%s.red' % (BOOSTER_RES_PATH, race)
    booster = trinity.Load(booster_filepath)
    if not booster:
        raise IOError("Could not load file '%s'" % booster_filepath)

    def loadit(obj):
        boost = trinity.Load(booster_filepath)
        obj.boosters = boost
        obj.boosters.alwaysOn = True
        obj.RebuildBoosterSet()

    uthread2.map(lambda o: uthread2.start_tasklet(loadit, o), validobjs)
Esempio n. 20
0
 def __init__(self,
              timer,
              persister,
              teamsInAuction,
              teams,
              iskMover,
              notifier,
              eventLogger,
              startExpirer=True):
     self.timer = timer
     self.persister = persister
     self.teamsInAuction = teamsInAuction
     self.teams = teams
     self.iskMover = iskMover
     self.notifier = notifier
     self.auctionExpirer = AuctionExpirer(self.ExpireAuction, timer)
     self.locks = defaultdict(Semaphore)
     if startExpirer:
         self.auctionExpirerThread = start_tasklet(self.auctionExpirer.Run)
     else:
         self.auctionExpirerThread = None
     self.bidsByTeamID = {}
     self.eventLogger = eventLogger
Esempio n. 21
0
def ApplyBoosters(trinobjs, race):
    validobjs = filter(lambda o: hasattr(o, 'boosters'), trinobjs)
    if not validobjs:
        return

    def clearbooster(obj):
        obj.boosters = None

    if race is None:
        uthread2.map(clearbooster, validobjs)
        return
    booster_filepath = '%s/booster_%s.red' % (BOOSTER_RES_PATH, race)
    booster = trinity.Load(booster_filepath)
    if not booster:
        raise IOError("Could not load file '%s'" % booster_filepath)

    def loadit(obj):
        boost = trinity.Load(booster_filepath)
        obj.boosters = boost
        obj.boosters.alwaysOn = True
        obj.RebuildBoosterSet()

    uthread2.map(lambda o: uthread2.start_tasklet(loadit, o), validobjs)
Esempio n. 22
0
 def start_update_thread(self):
     self.update_thread = uthread2.start_tasklet(
         self._update_remaining_time_tasklet)