Beispiel #1
0
class BioPanel(Container):
    default_name = 'BioPanel'

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.bioClient = None
        self.edit = EditPlainText(parent=self,
                                  maxLength=MAXBIOLENGTH,
                                  showattributepanel=1,
                                  padding=(0, const.defaultPadding, 0,
                                           const.defaultPadding))

    def LoadBioFromServer(self):
        self.bioServer = ''
        if not self.bioClient:
            bio = sm.RemoteSvc('charMgr').GetCharacterDescription(
                session.charid)
            if bio is not None:
                self.bioClient = bio
            else:
                self.bioClient = ''
        if self.bioClient:
            self.bioServer = self.bioClient

    def LoadPanel(self, *args):
        self.LoadBioFromServer()
        bio = self.bioServer or GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/BioEdit/HereYouCanTypeBio')
        self.edit.SetValue(bio)

    def AutoSaveBio(self):
        newbio = self.edit.GetValue()
        defaultBioString = GetByLabel(
            'UI/CharacterSheet/CharacterSheetWindow/BioEdit/HereYouCanTypeBio')
        newbio = newbio.replace(defaultBioString, '')
        if not len(StripTags(newbio)):
            newbio = ''
        self.bioClient = newbio
        if newbio.strip() != self.bioServer:
            uthread.new(self._AutoSaveBio, newbio)
            self.bioServer = newbio

    def _AutoSaveBio(self, newbio):
        sm.RemoteSvc('charMgr').SetCharacterDescription(newbio)

    def UnloadPanel(self):
        self.AutoSaveBio()

    def Close(self):
        if self.display:
            self.AutoSaveBio()
        Container.Close(self)
class PanelNotes(Container):
    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.infoType = attributes.infoType
        self.itemID = attributes.itemID
        self.initialized = False
        self.oldText = None
        self.edit = EditPlainText(parent=self,
                                  padding=const.defaultPadding,
                                  align=uiconst.TOALL,
                                  maxLength=5000,
                                  showattributepanel=True)

    def Close(self, *args):
        self.SaveNote()
        Container.Close(self)

    def Load(self):
        if self.initialized:
            return
        self.initialized = True
        text = ''
        if self.itemID:
            text = sm.RemoteSvc('charMgr').GetNote(self.itemID)
        self.edit.SetValue(text, scrolltotop=1)
        self.oldText = text

    def SaveNote(self, closing=0, *args):
        if not self.itemID:
            return
        if self.oldText is None:
            return
        text = self.edit.GetValue()
        if text is None:
            return
        toSave = None
        if len(uiutil.StripTags(text)):
            if self.oldText != text:
                toSave = text[:5000]
        elif self.oldText:
            toSave = ''
        if toSave is not None:
            uthread.new(sm.RemoteSvc('charMgr').SetNote, self.itemID, toSave)
Beispiel #3
0
class PodGuideContent(Container):
    MIN_RIGHT_SIDE_WIDTH = 100

    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)

    def LoadContent(self, termInfo):
        self.termHeaderLabel.text = GetByMessageID(termInfo.termTitleID)
        self.loreTextLabel.text = '<i>%s</i>' % GetByMessageID(
            termInfo.loreTextID)
        self.LoadAndWaitForIconSizeChange(termInfo.texturePath)
        self.longTextEdit.SetValue('<font size=14>%s</font>' %
                                   GetByMessageID(termInfo.longTextID))

    def OnContentChanged(self, width, height, *args):
        self.height = self.termHeaderLabel.padTop + self.termHeaderLabel.textheight + max(
            height, self.termSprite.height + self.loreTextLabel.textheight)

    def LoadAndWaitForIconSizeChange(self, texturePath):
        self.termSprite.LoadTexture(texturePath)
        if not texturePath:
            return
        import blue
        counter = 0
        while self.termSprite.renderObject.texturePrimary.atlasTexture.width == 0 and counter < 20:
            counter += 1
            blue.synchro.Yield()

        atlasTexture = self.termSprite.renderObject.texturePrimary.atlasTexture
        self.termSprite.width = atlasTexture.width
        self.termSprite.height = atlasTexture.height
        self.termSpriteCont.height = atlasTexture.height
        self.contentRightCont.width = max(self.MIN_RIGHT_SIDE_WIDTH,
                                          atlasTexture.width)
Beispiel #4
0
class AutoBotWindow(Window):
    """ An Insider window which makes it easy to debug UI containers """
    default_windowID = 'AutoBotWindow'
    default_width = 360
    default_height = 300
    default_topParentHeight = 0
    default_minSize = (default_width, default_height)
    default_caption = 'AutoBot Control Box'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.CreateLocationSelector()
        self.CreateSecurityFilter()
        self.CreateShipSelector()
        self.CreatePasses()
        self.CreateButtons()
        self.CreateLogDisplay()

    def CreateButtons(self):
        buttonCont = FlowContainer(name='SubCategoryButtons',
                                   parent=self.sr.main,
                                   centerContent=True,
                                   align=uiconst.TOBOTTOM,
                                   contentSpacing=(2, 1),
                                   state=uiconst.UI_PICKCHILDREN,
                                   padding=(0, 4, 0, 4))
        Button(parent=buttonCont,
               label='Roll out!!',
               func=self.StartBot,
               align=uiconst.NOALIGN,
               padding=2)
        Button(parent=buttonCont,
               label='Stop',
               func=self.StopBot,
               align=uiconst.NOALIGN,
               padding=2)
        Button(parent=buttonCont,
               label='Clear Log',
               func=self.ClearLogs,
               align=uiconst.NOALIGN,
               padding=2)

    def CreateLocationSelector(self):
        EveLabelSmall(
            parent=self.sr.main,
            text=
            '<color=orange>This is a tool for automating visits to solar systems and locations within them. There are several actions available while visiting each location.',
            align=uiconst.TOTOP,
            padding=4)
        EveLabelSmall(parent=self.sr.main,
                      text='Systems, Constellations or Regions',
                      align=uiconst.TOTOP,
                      padding=4)
        self.locationsEdit = EditPlainText(parent=self.sr.main,
                                           align=uiconst.TOTOP,
                                           height=50,
                                           padding=4)

    def CreateSecurityFilter(self):
        secCont = Container(parent=self.sr.main,
                            height=20,
                            padding=2,
                            align=uiconst.TOTOP)
        EveLabelSmall(parent=secCont,
                      text='Security Band:',
                      align=uiconst.TOLEFT,
                      padding=4)
        EveLabelSmall(parent=secCont,
                      text='Min Security',
                      align=uiconst.TOLEFT,
                      padding=4)
        self.minSecEdit = SinglelineEdit(parent=secCont,
                                         name='minSec',
                                         width=30,
                                         floats=(-1.0, 1.0, 1),
                                         align=uiconst.TOLEFT,
                                         padTop=-3,
                                         setvalue='-1.0')
        EveLabelSmall(parent=secCont,
                      text='Max Security',
                      align=uiconst.TOLEFT,
                      padding=4)
        self.maxSecEdit = SinglelineEdit(parent=secCont,
                                         name='maxSec',
                                         width=30,
                                         floats=(-1.0, 1.0, 1),
                                         align=uiconst.TOLEFT,
                                         padTop=-3,
                                         setvalue='1.0')

    def CreateShipSelector(self):
        cont = Container(parent=self.sr.main,
                         name='ship_options',
                         align=uiconst.TOTOP,
                         height=20)
        self.spawnShipCheckbox = Checkbox(parent=cont,
                                          align=uiconst.TOLEFT,
                                          text='Spawn new ship',
                                          checked=False,
                                          padLeft=8,
                                          callback=self.OnChangeSpawnShip,
                                          width=150)
        Container(parent=cont, width=16, align=uiconst.TOLEFT)
        EveLabelSmall(parent=cont, text='DNA', align=uiconst.TOLEFT, padding=4)
        self.dnaEdit = SinglelineEdit(parent=cont,
                                      setvalue='DNA:593:2528:20197',
                                      align=uiconst.TOLEFT,
                                      width=200)

    def CreatePasses(self):
        EveLabelSmall(parent=self.sr.main,
                      text='Actions for each system visited',
                      align=uiconst.TOTOP,
                      padding=4)
        self.CreateSystemPass(1)
        self.CreateSystemPass(2)

    def CreateSystemPass(self, passNumber):
        def GetLocationsMenu(menuParent):
            passConfig = GetPassConfig()[passNumber]
            menuParent.AddHeader(text='Locations to visit')
            for groupId in (const.groupAsteroidBelt, const.groupStargate,
                            const.groupStation):
                menuParent.AddCheckBox(
                    text=cfg.invgroups.Get(groupId).groupName,
                    checked=groupId in passConfig['locations'],
                    callback=(ToggleLocationGroupForPass, passNumber, groupId))

            menuParent.AddDivider()
            menuParent.AddHeader(text='Actions')
            menuParent.AddCheckBox(text='Nuke location',
                                   checked=passConfig['nuke'],
                                   callback=(ToggleNuke, passNumber))

        passConfig = {
            'locations': {const.groupAsteroidBelt},
            'nuke': False,
            'enabled': passNumber == 1,
            'minTime': 1
        }
        GetPassConfig()[passNumber] = passConfig
        menuCont = Container(name='pass%d' % passNumber,
                             parent=self.sr.main,
                             align=uiconst.TOTOP,
                             height=20,
                             padLeft=4)
        cont = Container(parent=menuCont, width=100, align=uiconst.TOLEFT)
        Checkbox(parent=cont,
                 text='Enable Pass %s' % passNumber,
                 align=uiconst.CENTERLEFT,
                 checked=passConfig['enabled'],
                 callback=lambda checkbox: SetPass(checkbox, passNumber),
                 width=200)
        cont = Container(parent=menuCont, width=100, align=uiconst.TOLEFT)
        EveLabelSmall(parent=cont,
                      text='Min time (sec)',
                      align=uiconst.CENTERRIGHT,
                      left=4)
        SinglelineEdit(
            parent=menuCont,
            ints=(1, 999),
            OnChange=lambda textValue: SetPassMinTime(textValue, passNumber),
            setvalue=passConfig['minTime'],
            align=uiconst.TOLEFT,
            width=50)
        UtilMenu(menuAlign=uiconst.TOPRIGHT,
                 parent=menuCont,
                 align=uiconst.TOLEFT,
                 GetUtilMenu=GetLocationsMenu,
                 label='Options',
                 texturePath='res:/UI/Texture/Icons/38_16_229.png',
                 closeTexturePath='res:/UI/Texture/Icons/38_16_230.png')

    def CreateLogDisplay(self):
        self.logEdit = EditPlainText(parent=self.sr.main,
                                     align=uiconst.TOALL,
                                     readonly=True,
                                     padTop=4)

    def OnChangeSpawnShip(self, checkbox):
        if checkbox.GetValue():
            self.dnaEdit.SetReadOnly(False)
            self.dnaEdit.opacity = 1.0
        else:
            self.dnaEdit.SetReadOnly(True)
            self.dnaEdit.opacity = 0.5

    def StartBot(self, *args):
        config = GetConfig()
        locations = SplitLocationsText(self.locationsEdit.GetValue())
        config['locations'] = locations
        config['minSecurity'] = self.minSecEdit.GetValue()
        config['maxSecurity'] = self.maxSecEdit.GetValue()
        if self.spawnShipCheckbox.GetValue():
            config['shipDna'] = self.dnaEdit.GetValue()
        else:
            config['shipDna'] = None
        sm.GetService('autobot').StartBot()
        self.logUpdated = AutoTimer(2000, self.UpdateLogText)

    def PauseBot(self, *args):
        sm.GetService('autobot').PauseBot()

    def StopBot(self, *args):
        sm.GetService('autobot').StopBot()
        self.logUpdated = None

    def ClearLogs(self, *args):
        sm.GetService('autobot').ClearLogs()

    def UpdateLogText(self):
        logLines = sm.GetService('autobot').logLines
        self.logEdit.SetValue('\n'.join([str(x) for x in reversed(logLines)]))