Beispiel #1
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.sr.main.clipChildren = True
     self.MakeUnMinimizable()
     self.HideHeader()
     descText = attributes.missingText
     self.faildToLoadInfo = attributes.faildToLoadInfo
     title = GetByLabel('UI/Common/Information')
     caption = EveCaptionLarge(text=title,
                               align=uiconst.CENTERLEFT,
                               parent=self.sr.topParent,
                               left=64,
                               width=270)
     self.SetTopparentHeight(max(56, caption.textheight + 16))
     self.SetWndIcon('res:/ui/Texture/WindowIcons/info.png')
     descLabel = EveLabelMedium(parent=self.sr.main,
                                text=descText,
                                align=uiconst.TOTOP,
                                padding=(11, 11, defaultPadding,
                                         defaultPadding))
     buttonGroup = ButtonGroup(parent=self.sr.main, unisize=1, idx=0)
     buyAllBtn = buttonGroup.AddButton(
         GetByLabel('UI/Market/MarketQuote/BuyAll'), self.BuyAll)
     closeBtn = buttonGroup.AddButton(GetByLabel('/Carbon/UI/Common/Close'),
                                      self.Close)
     if session.role & ROLE_GMH == ROLE_GMH:
         buttonGroup.AddButton('GM: Give all', self.GiveAllGM)
     self.typeScroll = Scroll(name='typeScroll',
                              parent=self.sr.main,
                              padding=(defaultPadding, 0, defaultPadding,
                                       0))
     self.LoadTypes(self.faildToLoadInfo)
Beispiel #2
0
 def _UpdateSubtitles(self):
     if self._subtitles is None or not self.showSubtitles:
         return
     currentTime = self.video.mediaTime or 0
     currentTime /= 1000000
     self.sr.subtitleCont.Flush()
     text = self._subtitles.GetSubtitle(currentTime)
     if text is not None:
         EveCaptionLarge(text=u'<center>%s' % text,
                         parent=self.sr.subtitleCont,
                         color=(0.75, 0.75, 0.75, 1),
                         align=uiconst.TOBOTTOM_NOPUSH,
                         bold=False,
                         state=uiconst.UI_DISABLED)
         l = EveCaptionLarge(text=u'<center>%s' % text,
                             parent=self.sr.subtitleCont,
                             color=(0, 0, 0, 1),
                             align=uiconst.TOBOTTOM,
                             bold=False,
                             state=uiconst.UI_DISABLED)
         l.renderObject.spriteEffect = trinity.TR2_SFX_GLOW
Beispiel #3
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.label = EveCaptionLarge(
         parent=self,
         align=uiconst.CENTER,
         text=localization.GetByLabel('UI/CharacterSelection/RedeemItems'))
     self.width = max(attributes.width,
                      self.label.width + 2 * DEFAULT_BUTTON_PADDING)
     self.sprite = Sprite(parent=self,
                          width=self.width,
                          height=attributes.height,
                          texturePath='res:\\UI\\Texture\\redeem_bar.png',
                          bgColor=attributes.bgColor,
                          state=uiconst.UI_DISABLED,
                          align=uiconst.CENTER)
Beispiel #4
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     padding = 30
     self.termHeaderLabel = EveCaptionLarge(name='termHeaderLabel',
                                            parent=self,
                                            align=uiconst.TOTOP,
                                            text='',
                                            padLeft=padding + 4,
                                            padTop=20)
     self.contentRightCont = Container(name='contentRightCont',
                                       parent=self,
                                       align=uiconst.TORIGHT,
                                       width=128,
                                       padRight=36)
     self.height = 300
     self.longTextEdit = EditPlainText(name='longTextEdit',
                                       parent=self,
                                       align=uiconst.TOTOP,
                                       readonly=True,
                                       setvalue='abc',
                                       padding=(padding, 0, padding, 0))
     self.longTextEdit.sr.maincontainer.padding = 0
     self.longTextEdit.DisableScrolling()
     self.longTextEdit.EnableAutoSize()
     self.longTextEdit.OnContentSizeChanged = self.OnContentChanged
     self.longTextEdit.HideBackground()
     self.longTextEdit.RemoveActiveFrame()
     self.termSpriteCont = Container(name='termSpriteCont',
                                     parent=self.contentRightCont,
                                     pos=(0, 0, 128, 128),
                                     align=uiconst.TOTOP)
     self.termSprite = Sprite(
         name='termSprite',
         parent=self.termSpriteCont,
         pos=(0, 0, 128, 128),
         texturePath=
         'res:/UI/Texture/Classes/ShipTree/groupIcons/frigate.png',
         align=uiconst.CENTER)
     self.loreTextLabel = EveLabelMedium(name='termNameLabel',
                                         text='',
                                         parent=self.contentRightCont,
                                         align=uiconst.TOTOP)
Beispiel #5
0
 def _create_reward_header(self):
     self.reward_header_label_container = Container(
         name='reward_header_label_container',
         parent=self.reward_main_container,
         align=uiconst.TOTOP,
         width=self.width,
         height=REWARD_HEADER_LABEL_HEIGHT,
         opacity=ANIMATED_DEFAULT_OPACITY)
     EveCaptionLarge(name='reward_header_label',
                     parent=self.reward_header_label_container,
                     align=uiconst.CENTERTOP,
                     text=get_reward_unlocked_header(),
                     bold=True)
     self.reward_header_line = Sprite(
         name='reward_header_container_line',
         parent=self.reward_header_label_container,
         texturePath=SEASON_LINE_BREAK_GRADIENT,
         align=uiconst.BOTTOMLEFT,
         width=self.width,
         height=REWARD_ITEM_LABEL_LINE_HEIGHT,
         opacity=REWARD_ITEM_LABEL_LINE_OPACITY,
         useSizeFromTexture=False)
 def Layout(self):
     self.compactMode = False
     Frame(bgParent=self,
           texturePath='res:/UI/Texture/classes/Monetization/vignette.png',
           cornerSize=150)
     self.characters = Sprite(
         parent=self,
         align=uiconst.CENTER,
         state=uiconst.UI_DISABLED,
         left=self.CHARACTERS_LEFT,
         top=10,
         texturePath='res:/UI/Texture/classes/Monetization/characters.png',
         width=299,
         height=355)
     self.content = ContainerAutoSize(parent=self,
                                      align=uiconst.CENTER,
                                      left=self.CONTENT_LEFT,
                                      width=340)
     EveCaptionLarge(
         parent=self.content,
         align=uiconst.TOTOP,
         text=localization.GetByLabel(
             'UI/SkillQueue/MultiTrainingOverlay/MultiplePilotTraining'))
     EveLabelMedium(
         parent=self.content,
         align=uiconst.TOTOP,
         top=4,
         text=localization.GetByLabel(
             'UI/SkillQueue/MultiTrainingOverlay/MultiTrainingMessageTop'))
     itemCont = ContainerAutoSize(parent=self.content,
                                  align=uiconst.TOTOP,
                                  alignMode=uiconst.TOTOP,
                                  top=12)
     Frame(bgParent=itemCont,
           texturePath=
           'res:/UI/Texture/classes/Monetization/item_well_frame.png',
           cornerSize=2)
     itemIconCont = ContainerAutoSize(parent=itemCont,
                                      align=uiconst.TOLEFT,
                                      padding=(8, 8, 0, 8))
     Icon(parent=itemIconCont,
          align=uiconst.TOPLEFT,
          state=uiconst.UI_DISABLED,
          size=64,
          typeID=typeMultiTrainingToken)
     Sprite(parent=itemIconCont,
            align=uiconst.TOPLEFT,
            state=uiconst.UI_DISABLED,
            texturePath='res:/UI/Texture/classes/InvItem/bgNormal.png',
            width=64,
            height=64)
     EveLabelLargeBold(parent=itemCont,
                       align=uiconst.TOTOP,
                       padding=(8, 8, 24, 0),
                       text=evetypes.GetName(typeMultiTrainingToken))
     InfoIcon(parent=itemCont,
              align=uiconst.TOPRIGHT,
              top=8,
              left=8,
              typeID=typeMultiTrainingToken)
     self.estimatePriceLabel = EveLabelMedium(parent=itemCont,
                                              align=uiconst.TOTOP,
                                              padding=(8, 0, 8, 6),
                                              color=Color.GRAY5)
     buyButtonCont = FlowContainer(parent=itemCont,
                                   align=uiconst.TOTOP,
                                   padding=(8, 0, 8, 8),
                                   contentSpacing=(8, 0))
     MultiTrainingBuyButtonIsk(parent=buyButtonCont,
                               align=uiconst.NOALIGN,
                               typeID=typeMultiTrainingToken)
     MultiTrainingBuyButtonAur(parent=buyButtonCont,
                               align=uiconst.NOALIGN,
                               types=[typeMultiTrainingToken])
     EveLabelMedium(
         parent=self.content,
         align=uiconst.TOTOP,
         top=12,
         text=localization.GetByLabel(
             'UI/SkillQueue/MultiTrainingOverlay/MultiTrainingMessageBottom'
         ))
     dismissCont = FlowContainer(parent=self.content,
                                 align=uiconst.TOTOP,
                                 padding=(8, 24, 8, 0),
                                 contentAlignment=CONTENT_ALIGN_CENTER,
                                 contentSpacing=(8, 4))
     Button(parent=dismissCont,
            align=uiconst.NOALIGN,
            label=localization.GetByLabel(
                'UI/SkillQueue/MultiTrainingOverlay/Dismiss'),
            func=lambda *args: self.Dismiss())
     self.suppressCheckbox = Checkbox(
         parent=dismissCont,
         align=uiconst.NOALIGN,
         width=200,
         text=localization.GetByLabel('UI/Common/SuppressionShowMessage'),
         checked=self.suppressed,
         callback=self.OnSuppressChanged)
Beispiel #7
0
 def setup_layout(self):
     self.dialogue_container = uiprimitives.Container(
         name='dialogue_container', parent=self.parent, idx=0)
     self.left_main_container = uiprimitives.Container(
         name='left_main_container',
         parent=self,
         align=uiconst.TOLEFT_PROP,
         width=0.5,
         clipChildren=True,
         top=20)
     self.category_container = uiprimitives.Container(
         name='category_container',
         parent=self,
         align=uiconst.TOLEFT_PROP,
         width=0.5,
         padTop=45,
         clipChildren=True)
     self.task_label = EveCaptionLarge(
         parent=self.left_main_container,
         align=uiconst.CENTERTOP,
         text=localization.GetByLabel(
             'UI/ProjectDiscovery/Subcellular/Tutorial/TaskLabel'),
         color=(0.48, 0.48, 0.48, 1),
         top=35)
     self.explanation_icon = uiprimitives.Sprite(
         parent=self.left_main_container,
         align=uiconst.TOPRIGHT,
         width=54,
         height=54,
         top=35,
         left=15,
         texturePath='res:/UI/Texture/WindowIcons/attention.png',
         state=uiconst.UI_HIDDEN)
     self.training_task_image = TaskImage(
         label=const.Texts.TaskImageLabel,
         parent=self.left_main_container,
         align=uiconst.TOPLEFT_PROP,
         pos=(25, 80, 420, 445),
         starting_scale=self.starting_scale)
     self.result_window = ResultWindow(
         name='ResultWindow',
         parent=self.parent,
         align=uiconst.TOALL,
         opacity=0,
         isTrainingPhase=True,
         taskImage=self.training_task_image,
         starting_scale=self.starting_scale,
         bottom_container=self.bottom_container)
     self.rewards_view = RewardsView(parent=self.parent,
                                     opacity=0,
                                     playerState=self.playerState,
                                     bottom_container=self.bottom_container,
                                     idx=0,
                                     state=uiconst.UI_DISABLED)
     self.rewards_view.isTraining = True
     self.rewards_view.tutorial_completed = False
     self.processing_view = ProcessingView(parent=self.parent,
                                           opacity=0,
                                           state=uiconst.UI_DISABLED)
     self.training_category_selector = CategorySelector(
         categories=nested_categories_from_json(
             PROJECT_INFO['info']['classes']),
         parent=self.category_container,
         state=uiconst.UI_HIDDEN,
         starting_scale=self.starting_scale)
     self.main_button_container = uiprimitives.Container(
         name='main_button_container',
         parent=self.bottom_container,
         align=uiconst.CENTERBOTTOM,
         width=355,
         height=53,
         bgTexturePath=
         'res:/UI/Texture/classes/ProjectDiscovery/footerBG.png')
     self.submit_button_container = uiprimitives.Container(
         name='submitButtonContainer',
         parent=self.main_button_container,
         width=250,
         align=uiconst.CENTER,
         height=40,
         top=5)
     self.submit_button = uicontrols.Button(
         name='submitButton',
         parent=self.submit_button_container,
         align=uiconst.CENTER,
         label=localization.GetByLabel(
             'UI/ProjectDiscovery/SubmitButtonLabel'),
         fontsize=18,
         fixedwidth=170,
         fixedheight=30,
         func=lambda x: self.submit_training_solution())
     uiprimitives.Sprite(
         parent=self.submit_button_container,
         align=uiconst.CENTERLEFT,
         width=34,
         height=20,
         texturePath=
         'res:/UI/Texture/classes/ProjectDiscovery/submitArrow.png',
         opacity=0.7)
     uiprimitives.Sprite(
         parent=uiprimitives.Transform(parent=self.submit_button_container,
                                       align=uiconst.CENTERRIGHT,
                                       width=34,
                                       height=20,
                                       rotation=math.pi),
         align=uiconst.CENTERRIGHT,
         width=34,
         height=20,
         texturePath=
         'res:/UI/Texture/classes/ProjectDiscovery/submitArrow.png',
         opacity=0.7)
     self.task_id = uicontrols.Label(parent=self,
                                     align=uiconst.BOTTOMRIGHT,
                                     height=20,
                                     opacity=0.5,
                                     left=10)
     self.refresh_task_button = uicontrols.Button(
         name='refreshTaskButton',
         parent=self.category_container,
         align=uiconst.CENTER,
         func=lambda x: self.reset_task(),
         idx=0,
         label='Refresh Task',
         fixedwidth=120,
         fixedheight=30,
         state=uiconst.UI_HIDDEN)
Beispiel #8
0
class Tutorial(uiprimitives.Container):
    MAX_CATEGORIES = PROJECT_INFO['resultSchema']['maxItems'] - 1

    def ApplyAttributes(self, attributes):
        super(Tutorial, self).ApplyAttributes(attributes)
        self.service = sm.RemoteSvc('ProjectDiscovery')
        self.selection = []
        self.isGreeting = False
        self.isSubmitting = False
        self.project_id = self.service.get_project_id()
        self.playerState = attributes.get('playerState')
        self.starting_scale = attributes.get('starting_scale')
        self.bottom_container = self.parent.parent.FindChild(
            'bottom_container')
        self.loading = False
        self.task_number = None
        self.finishedTaskCount = 0
        self.setup_layout()

    def setup_layout(self):
        self.dialogue_container = uiprimitives.Container(
            name='dialogue_container', parent=self.parent, idx=0)
        self.left_main_container = uiprimitives.Container(
            name='left_main_container',
            parent=self,
            align=uiconst.TOLEFT_PROP,
            width=0.5,
            clipChildren=True,
            top=20)
        self.category_container = uiprimitives.Container(
            name='category_container',
            parent=self,
            align=uiconst.TOLEFT_PROP,
            width=0.5,
            padTop=45,
            clipChildren=True)
        self.task_label = EveCaptionLarge(
            parent=self.left_main_container,
            align=uiconst.CENTERTOP,
            text=localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/TaskLabel'),
            color=(0.48, 0.48, 0.48, 1),
            top=35)
        self.explanation_icon = uiprimitives.Sprite(
            parent=self.left_main_container,
            align=uiconst.TOPRIGHT,
            width=54,
            height=54,
            top=35,
            left=15,
            texturePath='res:/UI/Texture/WindowIcons/attention.png',
            state=uiconst.UI_HIDDEN)
        self.training_task_image = TaskImage(
            label=const.Texts.TaskImageLabel,
            parent=self.left_main_container,
            align=uiconst.TOPLEFT_PROP,
            pos=(25, 80, 420, 445),
            starting_scale=self.starting_scale)
        self.result_window = ResultWindow(
            name='ResultWindow',
            parent=self.parent,
            align=uiconst.TOALL,
            opacity=0,
            isTrainingPhase=True,
            taskImage=self.training_task_image,
            starting_scale=self.starting_scale,
            bottom_container=self.bottom_container)
        self.rewards_view = RewardsView(parent=self.parent,
                                        opacity=0,
                                        playerState=self.playerState,
                                        bottom_container=self.bottom_container,
                                        idx=0,
                                        state=uiconst.UI_DISABLED)
        self.rewards_view.isTraining = True
        self.rewards_view.tutorial_completed = False
        self.processing_view = ProcessingView(parent=self.parent,
                                              opacity=0,
                                              state=uiconst.UI_DISABLED)
        self.training_category_selector = CategorySelector(
            categories=nested_categories_from_json(
                PROJECT_INFO['info']['classes']),
            parent=self.category_container,
            state=uiconst.UI_HIDDEN,
            starting_scale=self.starting_scale)
        self.main_button_container = uiprimitives.Container(
            name='main_button_container',
            parent=self.bottom_container,
            align=uiconst.CENTERBOTTOM,
            width=355,
            height=53,
            bgTexturePath=
            'res:/UI/Texture/classes/ProjectDiscovery/footerBG.png')
        self.submit_button_container = uiprimitives.Container(
            name='submitButtonContainer',
            parent=self.main_button_container,
            width=250,
            align=uiconst.CENTER,
            height=40,
            top=5)
        self.submit_button = uicontrols.Button(
            name='submitButton',
            parent=self.submit_button_container,
            align=uiconst.CENTER,
            label=localization.GetByLabel(
                'UI/ProjectDiscovery/SubmitButtonLabel'),
            fontsize=18,
            fixedwidth=170,
            fixedheight=30,
            func=lambda x: self.submit_training_solution())
        uiprimitives.Sprite(
            parent=self.submit_button_container,
            align=uiconst.CENTERLEFT,
            width=34,
            height=20,
            texturePath=
            'res:/UI/Texture/classes/ProjectDiscovery/submitArrow.png',
            opacity=0.7)
        uiprimitives.Sprite(
            parent=uiprimitives.Transform(parent=self.submit_button_container,
                                          align=uiconst.CENTERRIGHT,
                                          width=34,
                                          height=20,
                                          rotation=math.pi),
            align=uiconst.CENTERRIGHT,
            width=34,
            height=20,
            texturePath=
            'res:/UI/Texture/classes/ProjectDiscovery/submitArrow.png',
            opacity=0.7)
        self.task_id = uicontrols.Label(parent=self,
                                        align=uiconst.BOTTOMRIGHT,
                                        height=20,
                                        opacity=0.5,
                                        left=10)
        self.refresh_task_button = uicontrols.Button(
            name='refreshTaskButton',
            parent=self.category_container,
            align=uiconst.CENTER,
            func=lambda x: self.reset_task(),
            idx=0,
            label='Refresh Task',
            fixedwidth=120,
            fixedheight=30,
            state=uiconst.UI_HIDDEN)

    def get_total_task_count(self):
        count = 0
        for level in self.levelList:
            count += level['tasksToFinishLevel']

        return count

    def get_finished_task_count(self):
        count = 1
        for x in range(0, self.level):
            count += self.levelList[x]['tasksToFinishLevel']

        return count

    @on_event(const.Events.QuitTutorialTooltips)
    def enable_everything_after_tutorial(self):
        self.enable_ui()

    def get_tutorial_tooltip_steps(self):
        return [{
            'owner':
            self.training_task_image.images_container,
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/SampleImageHeader'),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/SampleImageText')
        }, {
            'owner':
            self.training_category_selector,
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/CategorySelectionHeader'
            ),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/CategorySelectionText'
            )
        }, {
            'owner':
            self.training_category_selector.super_categories[0],
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/NucleusHeader'),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/NucleusText')
        }, {
            'owner':
            self.training_category_selector.super_categories[1],
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/CytoplasmHeader'),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/CytoplasmText')
        }, {
            'owner':
            self.training_category_selector.super_categories[2],
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/PeripheryHeader'),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/PeripheryText')
        }, {
            'owner':
            self.training_category_selector.super_categories[3],
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/MiscellaneousHeader'
            ),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/MiscellaneousText')
        }, {
            'owner':
            self.training_category_selector.super_categories[4],
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/NotIdentifiableHeader'
            ),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/NotIdentifiableText')
        }, {
            'owner':
            self.training_task_image.colorFilterContainer,
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/ChannelFilterHeader'
            ),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/ChannelFilterText')
        }, {
            'owner':
            self.main_button_container,
            'header':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/SubmitButtonHeader'),
            'text':
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/SubmitButtonText')
        }]

    @on_event(const.Events.ProjectDiscoveryStarted)
    def skip_tutorial(self, show_dialogue):
        self.service.skip_tutorial()

    def start(self):
        self.show_greeting_dialogue()
        if self.playerState.finishedTutorial:
            self.playerState = self.service.reset_tutorial()
        self.level = self.playerState.tutorialLevel
        self.levelList = copy.deepcopy(
            const.get_training_task_list(self.project_id))
        self.levelDict = copy.deepcopy(self.levelList[self.level])
        self.new_training_task()
        self.finishedTaskCount = self.get_finished_task_count()
        self.set_task_label()

    def show_greeting_dialogue(self):
        self.disable_ui()
        Dialogue(
            name='greetingDialogue',
            parent=self.dialogue_container,
            align=uiconst.CENTER,
            width=450,
            height=340,
            messageText=localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/GreetingText'),
            messageHeaderText=localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/GreetingHeader'),
            label=localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/GreetingLabel'),
            buttonLabel=localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/GreetingButton'),
            toHide=self,
            isTutorial=True)

    def close(self):
        self.dialogue_container.Close()
        self.main_button_container.Close()
        self.result_window.Close()
        self.processing_view.Close()
        self.training_task_image.Flush()
        self.training_task_image.Close()
        self.training_category_selector.Close()
        self.rewards_view.Close()
        self.Close()

    def reset_task(self):
        if not self.loading:
            self.loading = True
            self.refresh_task_button.SetState(uiconst.UI_HIDDEN)
            self.training_task_image.reset_image()
            self.training_category_selector.cascade_categories_out()
            self.training_category_selector.reset_categories()
            self.new_training_task()
            self.loading = False

    def new_training_task(self):
        self.training_task_image.reset_image()
        self.selection = []
        self.hide_explanation_icon()
        if not self.levelDict:
            logger.error(
                'tutorial.py::new_training_task:: no training tasks found')
            return
        self.choose_random_task()
        self.explanation = self.levelDict[self.task_number]
        try:
            self.task = self.service.new_training_task(self.task_number)
        except (NoConnectionToAPIError, MissingKeyError):
            self.disable_ui()
            self.training_category_selector.cascade_categories_out()
            self.category_container.SetState(uiconst.UI_NORMAL)
            self.training_category_selector.SetState(uiconst.UI_DISABLED)
            self.show_error_message_and_button()
            return

        self.task_id.SetText(self.task['taskId'])
        self.delete_task_number()
        self.set_categories_to_solution()
        self.set_task_label()
        sm.ScatterEvent(const.Events.NewTask, self.task)
        self.training_category_selector.cascade_categories_in()
        self.training_category_selector.SetState(uiconst.UI_NORMAL)
        self.enable_ui()

    def show_error_message_and_button(self):
        self.training_task_image.hide_loading_wheel()
        self.training_task_image.show_error_message()
        self.refresh_task_button.SetState(uiconst.UI_NORMAL)

    def set_task_label(self):
        self.task_label.SetText(
            localization.GetByLabel(
                'UI/ProjectDiscovery/Subcellular/Tutorial/TaskLabel') + ' ' +
            str(self.finishedTaskCount) + '/' +
            str(self.get_total_task_count()))

    def set_categories_to_solution(self):
        relevant_categories = list(self.task['solution'])
        for super_cat in self.training_category_selector.super_categories:
            for sub in super_cat.sub_categories:
                if sub.id in self.task['solution']:
                    relevant_categories.extend(sub.excludes)

        for super_cat in self.training_category_selector.super_categories:
            for sub in super_cat.sub_categories:
                if sub.id in self.task['solution']:
                    temp_list = list(super_cat.sub_categories)
                    if sub in temp_list:
                        temp_list.remove(sub)
                    max_cats = 2
                    if len(temp_list) < max_cats:
                        max_cats = len(temp_list)
                    for n in range(0, max_cats):
                        item = random.choice(temp_list)
                        relevant_categories.append(item.id)
                        if item in temp_list:
                            temp_list.remove(item)

                    break

        for super_cat in self.training_category_selector.super_categories:
            for sub in super_cat.sub_categories:
                if sub.id not in relevant_categories:
                    sub.set_unavailable()
                    sub.set_unclickable()
                else:
                    sub.set_clickable()
                    sub.set_available()

    def delete_task_number(self):
        if self.task_number:
            del self.levelDict[self.task_number]
            self.task_number = None

    def choose_random_task(self):
        if not self.task_number:
            self.task_number = random.choice(self.levelDict.keys()[1:])

    def hide_explanation_icon(self):
        self.explanation_icon.SetAlpha(0)
        self.explanation_icon.SetState(uiconst.UI_HIDDEN)

    def open_error_dialogue(self):
        self.disable_ui()
        self.dialogue = Dialogue(
            name='ErrorDialogue',
            parent=self.dialogue_container,
            align=uiconst.CENTER,
            width=450,
            height=215,
            messageText=localization.GetByLabel(
                'UI/ProjectDiscovery/NoCategorySelectedErrorMessage'),
            messageHeaderText=localization.GetByLabel(
                'UI/ProjectDiscovery/NoCategorySelectedHeader'),
            label=localization.GetByLabel(
                'UI/ProjectDiscovery/NotificationHeader'),
            buttonLabel=localization.GetByLabel(
                'UI/ProjectDiscovery/ErrorButton'),
            toHide=self)

    def open_too_many_categories_selected_dialogue(self):
        self.disable_ui()
        self.dialogue = Dialogue(
            name='ErrorDialogue',
            parent=self.dialogue_container,
            align=uiconst.CENTER,
            width=450,
            height=215,
            messageText=localization.GetByLabel(
                'UI/ProjectDiscovery/TooManyCategoriesMessage'),
            messageHeaderText=localization.GetByLabel(
                'UI/ProjectDiscovery/TooManyCategoriesHeader'),
            label=localization.GetByLabel(
                'UI/ProjectDiscovery/NotificationHeader'),
            buttonLabel=localization.GetByLabel(
                'UI/ProjectDiscovery/ErrorButton'),
            toHide=self)

    def disable_ui(self):
        self.left_main_container.state = uiconst.UI_DISABLED
        self.category_container.state = uiconst.UI_DISABLED
        self.main_button_container.state = uiconst.UI_DISABLED
        self.training_category_selector.state = uiconst.UI_DISABLED

    @on_event(const.Events.EnableUI)
    def enable_ui(self):
        self.training_task_image.state = uiconst.UI_NORMAL
        self.left_main_container.state = uiconst.UI_NORMAL
        self.category_container.state = uiconst.UI_NORMAL
        self.main_button_container.state = uiconst.UI_NORMAL
        self.training_category_selector.state = uiconst.UI_NORMAL

    def submit_training_solution(self):
        if self.isSubmitting:
            return
        if not self.selection:
            self.open_error_dialogue()
            return
        self.isSubmitting = True
        self.finishedTaskCount += 1
        sm.GetService('audio').SendUIEvent(const.Sounds.MainImageLoopStop)
        classification = list(
            set([cat['id'] for cat in self.selection if not cat['excluded']]))
        self.result = {
            'playerSelection': classification,
            'task': {
                'solution': self.task['solution']
            }
        }
        SetTooltipHeaderAndDescription(targetObject=self.explanation_icon,
                                       headerText='',
                                       descriptionText=self.explanation)
        self.result_window.assign_result(self.result)
        self.training_category_selector.cascade_categories_out()
        self.training_category_selector.state = uiconst.UI_DISABLED
        animations.FadeOut(self.main_button_container)
        animations.FadeOut(self.training_task_image.colorFilterContainer)
        animations.FadeOut(self.task_label)
        animations.FadeOut(self.refresh_task_button)
        self.training_task_image.start_transmission_animation()
        self.left_main_container.state = uiconst.UI_DISABLED
        self.category_container.state = uiconst.UI_DISABLED
        self.main_button_container.state = uiconst.UI_DISABLED

    @on_event(const.Events.TransmissionFinished)
    def on_transmission_finished(self):
        self.left_main_container.state = uiconst.UI_NORMAL
        self.result_window.open()
        self.result_window.show_result()
        animations.FadeIn(self.training_task_image.colorFilterContainer)
        self.show_and_blink_explanation_icon()

    def show_and_blink_explanation_icon(self):
        self.explanation_icon.SetAlpha(0)
        self.explanation_icon.SetState(uiconst.UI_NORMAL)
        animations.FadeIn(self.explanation_icon,
                          duration=1,
                          loops=5,
                          curveType=uiconst.ANIM_OVERSHOT5)

    def is_tutorial_finished(self):
        self.playerState = self.service.get_player_state()
        return self.playerState.tutorialLevel >= self.get_number_of_levels()

    def get_number_of_levels(self):
        return len(self.levelList)

    @on_event(const.Events.ContinueFromTrainingResult)
    def on_training_result_closed(self):
        self.isSubmitting = False
        self.increment_level_if_needed()
        uthread.new(self.new_training_task)
        animations.FadeIn(self, duration=1)
        animations.FadeIn(self.main_button_container)
        animations.FadeIn(self.training_task_image.colorFilterContainer)
        animations.FadeIn(self.task_label, timeOffset=1)
        animations.FadeIn(self.refresh_task_button)
        self.training_task_image.state = uiconst.UI_NORMAL
        self.left_main_container.state = uiconst.UI_NORMAL
        self.category_container.state = uiconst.UI_NORMAL
        self.main_button_container.state = uiconst.UI_NORMAL

    def end_tutorial(self):
        if self.service.give_tutorial_rewards():
            result = {
                'XP_Reward': self.service.get_tutorial_xp_reward(),
                'LP_Reward': 0,
                'ISK_Reward': 0,
                'AK_Reward': 0,
                'playerState': self.service.get_player_state(),
                'player': {
                    'score': 0.5
                },
                'isTraining': True
            }
            self.rewards_view.tutorial_completed = True
            sm.ScatterEvent(const.Events.CloseResult, result)
            self.processing_view.start()
            settings.char.ui.Set('loadStatisticsAfterSubmission', True)
        else:
            sm.ScatterEvent(const.Events.ProjectDiscoveryStarted, True)
        self.Close()

    def increment_level_if_needed(self):
        self.levelDict['tasksToFinishLevel'] -= 1
        if self.levelDict['tasksToFinishLevel'] <= 0:
            self.playerState = self.service.increase_tutorial_level()
            if self.is_tutorial_finished():
                self.end_tutorial()
            else:
                self.level = self.playerState.tutorialLevel
                self.levelDict = copy.deepcopy(self.levelList[self.level])

    def _update_excluded(self, excluder):
        excluded = set()
        for cat in self.selection:
            excluded.update(cat.get('excludes', []))

        sm.ScatterEvent(const.Events.ExcludeCategories, excluder, excluded)

    @on_event(const.Events.CategoryChanged)
    def on_category_changed(self, hexagon):
        if hexagon.category['selected']:
            if len(self.selection) > self.MAX_CATEGORIES:
                hexagon.set_unselected()
                self.open_too_many_categories_selected_dialogue()
                return
            self.selection.append(hexagon.category)
        elif hexagon.category in self.selection:
            self.selection.remove(hexagon.category)
        self._update_excluded(hexagon.category['id'])
Beispiel #9
0
    def Init(self):
        scrollEntries = []

        def AddItem(icon, header, text, url=None, isSmall=False):
            if url:
                header = '<url=localsvc:service=contracts&%s>%s</url>' % (
                    url, header.rstrip('\n'))
            else:
                header = header.rstrip('\n')
            text = text.rstrip('\n')
            data = {
                'header': header,
                'text': text,
                'icon': icon,
                'isSmall': isSmall
            }
            entry = listentry.Get('ContractStartPageEntry', data)
            scrollEntries.append(entry)

        if not getattr(self, 'startPageScroll', None):
            header = EveCaptionLarge(
                text=GetByLabel('UI/Contracts/ContractEntry/MyStartPage'),
                parent=self,
                left=const.defaultPadding * 2,
                top=const.defaultPadding)
            self.startPageScroll = Scroll(
                parent=self,
                align=uiconst.TOALL,
                padding=(const.defaultPadding,
                         header.textheight + const.defaultPadding * 2,
                         const.defaultPadding, const.defaultPadding))
            self.startPageScroll.HideBackground()
            self.startPageScroll.RemoveActiveFrame()
            Frame(parent=self.startPageScroll, color=(1.0, 1.0, 1.0, 0.2))
            self.inited = 1
            sm.RegisterNotify(self)
        mpi = sm.GetService('contracts').CollectMyPageInfo()
        n = mpi.numContractsLeft
        ntot = mpi.numContractsTotal
        np = mpi.numContractsLeftInCorp
        nforcorp = mpi.numContractsLeftForCorp
        desc = GetByLabel('UI/Contracts/ContractsService/YouCanCreateNew',
                          numContracts=ntot)
        if not util.IsNPC(eve.session.corpid):
            desc += '<br>' + GetByLabel(
                'UI/Contracts/ContractsService/YouCanCreateForCorp',
                numContracts=np)
        if session.corprole & const.corpRoleContractManager == const.corpRoleContractManager:
            desc += '<br>' + GetByLabel(
                'UI/Contracts/ContractsService/YouCanCreateOnBehalfOfCorp',
                numContracts=nforcorp)
        createLabel = GetByLabel('UI/Contracts/ContractsService/YouCanCreate',
                                 numContracts=n)
        AddItem('res:/ui/Texture/WindowIcons/contracts.png', createLabel, desc,
                'method=OpenCreateContract')
        ignoreList = set(settings.user.ui.Get('contracts_ignorelist', []))
        numAssignedToMeAuctionItemExchange = 0
        numAssignedToMeCourier = 0
        numAssignedToMyCorpAuctionItemExchange = 0
        numAssignedToMyCorpCourier = 0
        if mpi.outstandingContracts is None:
            eve.Message('ConNotReady')
            mpi.outstandingContracts = []
        else:
            for contract in mpi.outstandingContracts:
                if contract[0] in ignoreList or contract[1] in ignoreList:
                    continue
                if contract[2] == session.charid:
                    if contract[3] == const.conTypeCourier:
                        numAssignedToMeCourier += 1
                    else:
                        numAssignedToMeAuctionItemExchange += 1
                elif contract[3] == const.conTypeCourier:
                    numAssignedToMyCorpCourier += 1
                else:
                    numAssignedToMyCorpAuctionItemExchange += 1

        if mpi.numRequiresAttention > 0:
            attentionReqLabel = GetByLabel(
                'UI/Contracts/ContractsService/RequireAttention',
                numContracts=mpi.numRequiresAttention)
            attentionReqDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/RequiresAttentionDesc')
            AddItem('res:/ui/Texture/WindowIcons/warning.png',
                    attentionReqLabel, attentionReqDescLabel,
                    'method=OpenJournal&status=0&forCorp=0')
        if mpi.numRequiresAttentionCorp > 0:
            attentionReqCorpLabel = GetByLabel(
                'UI/Contracts/ContractsService/RequireAttentionCorp',
                numContracts=mpi.numRequiresAttentionCorp)
            attentionReqCorpDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/RequireAttentionCorpDesc')
            AddItem('res:/ui/Texture/WindowIcons/warning.png',
                    attentionReqCorpLabel, attentionReqCorpDescLabel,
                    'method=OpenJournal&forCorp=1')
        if numAssignedToMeAuctionItemExchange > 0 or numAssignedToMeCourier > 0:
            assignedLabel = GetByLabel(
                'UI/Contracts/ContractsService/AssignedPersonal',
                numContracts=numAssignedToMeAuctionItemExchange +
                numAssignedToMeCourier)
            subText = ''
            subTextList = []
            if numAssignedToMeAuctionItemExchange > 0:
                auctionLabel = GetByLabel(
                    'UI/Contracts/ContractsService/AuctionItemExchange',
                    numContracts=numAssignedToMeAuctionItemExchange)
                method = self._GetContractMethodText(
                    CONTYPE_AUCTIONANDITEMECHANGE, isCorp=0)
                subText += self._GetContractLink(auctionLabel, method)
            if numAssignedToMeCourier > 0:
                assignedCourierLabel = GetByLabel(
                    'UI/Contracts/ContractsService/AssignedCourier',
                    numContracts=numAssignedToMeCourier)
                method = self._GetContractMethodText(const.conTypeCourier,
                                                     isCorp=0)
                subText += self._GetContractLink(assignedCourierLabel,
                                                 method,
                                                 numSpaces=2)
            AddItem('res:/ui/Texture/WindowIcons/info.png', assignedLabel,
                    subText)
        if numAssignedToMyCorpAuctionItemExchange > 0 or numAssignedToMyCorpCourier > 0:
            numContracts = numAssignedToMyCorpAuctionItemExchange + numAssignedToMyCorpCourier
            corpAssignedLabel = GetByLabel(
                'UI/Contracts/ContractsService/AssignedCorp',
                numContracts=numContracts)
            subText = ''
            if numAssignedToMyCorpAuctionItemExchange > 0:
                corpExchangeLabel = GetByLabel(
                    'UI/Contracts/ContractsService/AssignedCorpAuctionItemExchange',
                    numContracts=numAssignedToMyCorpAuctionItemExchange)
                method = self._GetContractMethodText(
                    CONTYPE_AUCTIONANDITEMECHANGE, isCorp=1)
                subText += self._GetContractLink(corpExchangeLabel, method)
            if numAssignedToMyCorpCourier > 0:
                corpCourierLabel = GetByLabel(
                    'UI/Contracts/ContractsService/AssignedCorpCourier',
                    numContracts=numAssignedToMyCorpCourier)
                method = self._GetContractMethodText(const.conTypeCourier,
                                                     isCorp=1)
                subText += self._GetContractLink(corpCourierLabel, method)
            AddItem('res:/ui/Texture/WindowIcons/info.png', corpAssignedLabel,
                    subText)
        if mpi.numBiddingOn > 0:
            activeLabel = GetByLabel('UI/Contracts/ContractsService/BiddingOn',
                                     numAuctions=mpi.numBiddingOn)
            activeDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/BiddingOnDesc')
            AddItem('64_16', activeLabel, activeDescLabel,
                    'method=OpenJournal&status=3&forCorp=0')
        if mpi.numInProgress > 0:
            progressLabel = GetByLabel(
                'UI/Contracts/ContractsService/InProgress',
                numContracts=mpi.numInProgress)
            progressDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/InProgressDesc')
            AddItem('res:/ui/Texture/WindowIcons/info.png', progressLabel,
                    progressDescLabel, 'method=OpenJournal&status=2&forCorp=0')
        if mpi.numBiddingOnCorp > 0:
            biddingOnLabel = GetByLabel(
                'UI/Contracts/ContractsService/BiddingOnCorp',
                numAuctions=mpi.numBiddingOnCorp)
            biddingOnDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/BiddingOnCorpDesc')
            AddItem('64_16', biddingOnLabel, biddingOnDescLabel,
                    'method=OpenJournal&status=3&forCorp=1')
        if mpi.numInProgressCorp > 0:
            inProgressCorpLabel = GetByLabel(
                'UI/Contracts/ContractsService/InProgressCorp',
                numContracts=mpi.numInProgressCorp)
            inProgressCorpDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/InProgressCorpDesc')
            AddItem('res:/ui/Texture/WindowIcons/info.png',
                    inProgressCorpLabel, inProgressCorpDescLabel,
                    'method=OpenJournal&status=2&forCorp=1')
        ignoreList = settings.user.ui.Get('contracts_ignorelist', [])
        l = len(ignoreList)
        if l > 0:
            ignoreLabel = GetByLabel('UI/Contracts/ContractsService/Ignoring',
                                     numIssuers=l)
            ignoreDescLabel = GetByLabel(
                'UI/Contracts/ContractsService/IngoringDesc',
                numIssuers=MAX_IGNORED)
            AddItem('ui_38_16_208',
                    ignoreLabel,
                    ignoreDescLabel,
                    'method=OpenIgnoreList',
                    isSmall=True)
        mess = sm.GetService('contracts').GetMessages()
        for i in mess:
            AddItem('ui_38_16_208', '', i, isSmall=True)

        self.startPageScroll.LoadContent(contentList=scrollEntries)