def showProdQueue(self, id):
        # construction queue
        prodQueue = self.player.prodQueues[id]
        items = []

        index = 0
        for task in prodQueue:
            if task.isShip:
                tech = self.player.shipDesigns[task.techID]
                icons = ((res.getShipImg(tech.combatClass, tech.isMilitary), ui.ALIGN_NONE),)
            else:
                tech = client.getFullTechInfo(task.techID)
                icons = ((res.getTechImg(task.techID), ui.ALIGN_NONE),)
            item = ui.Item(text = str(task.quantity), font = 'small', align = ui.ALIGN_NE, icons = icons, tooltipTitle = "", tooltip = tech.name, statustip = tech.name, index = index, const = tech.buildProd*task.quantity)
            if task.isShip:
                item.background = None
            else:
                item.background = (0x44, 0x44, 0x44)
            items.append(item)
            index += 1
        icons = ((res.getTechImg(1), ui.ALIGN_NONE),)
        item = ui.Item(_('New'), font = 'small-bold', align = ui.ALIGN_SW, icons = icons, index = None)
        items.append(item)
        self.vPQueues[id].items = items
        self.vPQueues[id].itemsChanged()
Beispiel #2
0
    def _showStructures(self, prodProd):
        items = []

        for techID in client.getPlayer().techs.keys():
            tech = client.getTechInfo(techID)
            if not tech.isStructure or tech.level not in self.showLevels or \
               (tech.isStructure and not self._filterStructure(tech)):
                continue

            if prodProd > 0:
                etc = math.ceil(float(tech.buildProd) / prodProd)
                if self.sourceID != self.planetID:
                    etc *= Rules.buildOnAnotherPlanetMod
                etc = res.formatTime(etc)
            else:
                etc = _("N/A")

            item = ui.Item(
                etc,
                techID=techID,
                tIsShip=0,
                name=tech.name,
                tl=tech.level,
                subtype=tech.subtype,
                icons=((res.getTechImg(techID), ui.ALIGN_N), ),
                font="small-bold",
                align=ui.ALIGN_S,
                tooltipTitle=_("Details"),
                tooltip="%s, %d %s, %s %d" %
                (tech.name, tech.buildProd, _("CP"), _("TL"), tech.level),
                statustip="%s, %d %s, %s %d" %
                (tech.name, tech.buildProd, _("CP"), _("TL"), tech.level))
            self.maxTechLevel = max(self.maxTechLevel, tech.level)
            items.append(item)
        return items
    def showProdQueue(self, id):
        # construction queue
        prodQueue = self.player.prodQueues[id]
        items = []

        index = 0
        for task in prodQueue:
            if task.isShip:
                tech = self.player.shipDesigns[task.techID]
                icons = ((res.getShipImg(tech.combatClass,
                                         tech.isMilitary), ui.ALIGN_NONE), )
            else:
                tech = client.getFullTechInfo(task.techID)
                icons = ((res.getTechImg(task.techID), ui.ALIGN_NONE), )
            item = ui.Item(text=str(task.quantity),
                           font='small',
                           align=ui.ALIGN_NE,
                           icons=icons,
                           tooltipTitle="",
                           tooltip=tech.name,
                           statustip=tech.name,
                           index=index,
                           const=tech.buildProd * task.quantity)
            if task.isShip:
                item.background = None
            else:
                item.background = (0x44, 0x44, 0x44)
            items.append(item)
            index += 1
        icons = ((res.getTechImg(1), ui.ALIGN_NONE), )
        item = ui.Item(_('New'),
                       font='small-bold',
                       align=ui.ALIGN_SW,
                       icons=icons,
                       index=None)
        items.append(item)
        self.vPQueues[id].items = items
        self.vPQueues[id].itemsChanged()
Beispiel #4
0
    def showTechs(self):
        # techs
        items = []
        select = None
        showMilitary = self.win.vMilitary.checked
        showBio = self.win.vBioProduction.checked
        showEn = self.win.vEnProduction.checked
        showCP = self.win.vCPProduction.checked
        showRP = self.win.vRPProduction.checked
        showMorale = self.win.vMorale.checked

        for techID in client.getPlayer().techs.keys():
            tech = client.getTechInfo(techID)

            if not ((tech.isMilitary and showMilitary) or \
               ((getattr(tech, "prodBio", 0) > 0 or getattr(tech, "prodEnv", 0) > 0) and showBio) or \
               (getattr(tech, "prodEn", 0) > 0 and showEn) or \
               (getattr(tech, "prodProd", 0) > 0 and showCP) or \
               (getattr(tech, "prodSci", 0) > 0 and showRP) or \
               (getattr(tech, "moraleTrgt", 0) > 0 and showMorale)):
                continue

            sourcePlanet = client.get(self.sourceID, noUpdate = 1)
            prodProd = getattr(sourcePlanet, "effProdProd", 0)

            if prodProd > 0:
                etc = math.ceil(float(tech.buildProd) / prodProd)
                if self.sourceID != self.planetID:
                    etc *= Rules.buildOnAnotherPlanetMod
                etc = res.formatTime(etc)
            else:
                etc = _("N/A")

            item = ui.Item(etc,
                techID = techID,
                tIsShip = 0,
                name = tech.name,
                tl = tech.level,
                subtype = tech.subtype,
                icons = ((res.getTechImg(techID), ui.ALIGN_N),),
                font = "small-bold",
                align = ui.ALIGN_S,
                tooltip = "%s, %d %s, %s %d" % (tech.name, tech.buildProd,_("CP"),_("TL"), tech.level),
                statustip = "%s, %d %s, %s %d" % (tech.name, tech.buildProd,_("CP"),_("TL"), tech.level),
            )
            if tech.level > self.maxTechLevel:
                self.maxTechLevel = tech.level
            # TODO FIX ME
            if tech.level in self.showLevels and \
                ((self.showStructures and tech.isStructure) or \
                (self.showOther and (tech.isProject))) or tech.level == 99:
                items.append(item)
                if techID == self.techID:
                    select = item

        # sort methods
        if self.sort == 'none': # sort by name
            items.sort(lambda a, b: cmp(a.name, b.name))
        elif self.sort == 'tl': # sort by TL, subsort by name
            items.sort(lambda a, b: cmp(a.name, b.name))
            items.sort(lambda a, b: cmp(a.tl, b.tl))
        elif self.sort == 'type': #sort by subtype, subsort by tl
            items.sort(lambda a, b: cmp(a.tl, b.tl))
            items.sort(lambda a, b: cmp(a.subtype, b.subtype))
        self.win.vTechs.items = items
        self.win.vTechs.itemsChanged()
        if select:
            self.win.vTechs.selectItem(select)

        # filter
        for i in xrange(1, 10):
            widget = getattr(self.win, 'vLevel%d' % i)
            if i in self.showLevels and i <= self.maxTechLevel:
                widget.visible = 1
                widget.pressed = 1
            elif i not in self.showLevels and i <= self.maxTechLevel:
                widget.visible = 1
                widget.pressed = 0
            else:
                widget.visible = 0

        # quantity
        self.win.vQuantity.text = str(self.quantity)
Beispiel #5
0
    def showTechs(self):
        # techs
        items = []
        select = None
        showMilitary = self.win.vMilitary.checked
        showBio = self.win.vBioProduction.checked
        showEn = self.win.vEnProduction.checked
        showCP = self.win.vCPProduction.checked
        showRP = self.win.vRPProduction.checked
        showMorale = self.win.vMorale.checked

        for techID in client.getPlayer().techs.keys():
            tech = client.getTechInfo(techID)

            if not ((tech.isMilitary and showMilitary) or \
               ((getattr(tech, "prodBio", 0) > 0 or getattr(tech, "prodEnv", 0) > 0) and showBio) or \
               (getattr(tech, "prodEn", 0) > 0 and showEn) or \
               (getattr(tech, "prodProd", 0) > 0 and showCP) or \
               (getattr(tech, "prodSci", 0) > 0 and showRP) or \
               (getattr(tech, "moraleTrgt", 0) > 0 and showMorale)):
                continue

            sourcePlanet = client.get(self.sourceID, noUpdate=1)
            prodProd = getattr(sourcePlanet, "effProdProd", 0)

            if prodProd > 0:
                etc = math.ceil(float(tech.buildProd) / prodProd)
                if self.sourceID != self.planetID:
                    etc *= Rules.buildOnAnotherPlanetMod
                etc = res.formatTime(etc)
            else:
                etc = _("N/A")

            item = ui.Item(
                etc,
                techID=techID,
                tIsShip=0,
                name=tech.name,
                tl=tech.level,
                subtype=tech.subtype,
                icons=((res.getTechImg(techID), ui.ALIGN_N), ),
                font="small-bold",
                align=ui.ALIGN_S,
                tooltipTitle=_("Details"),
                tooltip="%s, %d %s, %s %d" %
                (tech.name, tech.buildProd, _("CP"), _("TL"), tech.level),
                statustip="%s, %d %s, %s %d" %
                (tech.name, tech.buildProd, _("CP"), _("TL"), tech.level),
            )
            if tech.level > self.maxTechLevel:
                self.maxTechLevel = tech.level
            # TODO FIX ME
            if tech.level in self.showLevels and \
                ((self.showStructures and tech.isStructure) or \
                (self.showOther and (tech.isProject))) or tech.level == 99:
                items.append(item)
                if techID == self.techID:
                    select = item

        # sort methods
        if self.sort == 'none':  # sort by name
            items.sort(key=lambda a: a.name)
        elif self.sort == 'tl':  # sort by TL, subsort by name
            items.sort(key=lambda a: a.name)
            items.sort(key=lambda a: a.tl)
        elif self.sort == 'type':  #sort by subtype, subsort by tl
            items.sort(key=lambda a: a.tl)
            items.sort(key=lambda a: a.subtype)
        self.win.vTechs.items = items
        self.win.vTechs.itemsChanged()
        if select:
            self.win.vTechs.selectItem(select)

        # filter
        for i in xrange(1, 10):
            widget = getattr(self.win, 'vLevel%d' % i)
            if i in self.showLevels and i <= self.maxTechLevel:
                widget.visible = 1
                widget.pressed = 1
            elif i not in self.showLevels and i <= self.maxTechLevel:
                widget.visible = 1
                widget.pressed = 0
            else:
                widget.visible = 0

        # quantity
        self.win.vQuantity.text = str(self.quantity)