Пример #1
0
class NameAndDescBaseWnd(Window):
    default_name = 'nameAndDescBaseWnd'
    default_windowID = 'NameAndDescBaseWnd'
    default_width = 200
    default_height = 200
    default_topParentHeight = 0
    confirmLabelPath = ''
    nameLabelPath = ''
    descriptionLabelPath = ''

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.MakeUnResizeable()
        self.controller = attributes.controller
        self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0, line=True)
        self.btnGroup.AddButton(GetByLabel(self.confirmLabelPath),
                                self.OnConfirmClicked)
        self.btnGroup.AddButton(GetByLabel('UI/Commands/Cancel'), self.Cancel)
        self.groupNameField = SinglelineEdit(parent=self.sr.main,
                                             align=uiconst.TOTOP,
                                             label=GetByLabel(
                                                 self.nameLabelPath),
                                             padding=4,
                                             top=10,
                                             maxLength=30)
        EveLabelSmall(name='titleHeader',
                      parent=self.sr.main,
                      text=GetByLabel(self.descriptionLabelPath),
                      align=uiconst.TOTOP,
                      top=6,
                      padLeft=4)
        self.groupDescField = EditPlainText(parent=self.sr.main,
                                            padding=(4, 0, 4, 4),
                                            maxLength=200)
        self.PopulateFields()

    def PopulateFields(self):
        pass

    def OnConfirmClicked(self, *args):
        name = self.groupNameField.GetValue().strip()
        desc = self.groupDescField.GetValue().strip()
        if name:
            self.Confirm(name, desc)
            self.CloseByUser()
        else:
            uicore.Message('uiwarning03')

    def Confirm(self, name, desc):
        pass

    def Cancel(self, *args):
        self.CloseByUser()
Пример #2
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)
Пример #3
0
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)
Пример #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)]))