Exemplo n.º 1
0
 def __init__(self, app):
     self.app = app
     self.player = None
     self.vPQueues = None
     self.queueNo = 5
     self.activeQueue = 0
     self.activeIndex = None
     self.changeQtyDlg = ChangeQtyDlg(app)
     self.newGlobalTaskDlg = NewGlobalTaskDlg(self.app)
     self.constructionDlg = ConstructionDlg(app)
     self.techInfoDlg = TechInfoDlg(app)
     self.confirmDlg = ConfirmDlg(app)
     self.createUI()
Exemplo n.º 2
0
 def __init__(self, app):
     self.app = app
     self.player = None
     self.queueNo = 5
     self.activeQueue = 0
     self.activeIndex = None
     self.changeQtyDlg = ChangeQtyDlg(app)
     self.newGlobalTaskDlg = NewGlobalTaskDlg(self.app)
     self.constructionDlg = ConstructionDlg(app)
     self.techInfoDlg = TechInfoDlg(app)
     self.confirmDlg = ConfirmDlg(app)
     self.createUI()
Exemplo n.º 3
0
class GlobalQueuesDlg:

    def __init__(self, app):
        self.app = app
        self.player = None
        self.vPQueues = None
        self.queueNo = 5
        self.activeQueue = 0
        self.activeIndex = None
        self.changeQtyDlg = ChangeQtyDlg(app)
        self.newGlobalTaskDlg = NewGlobalTaskDlg(self.app)
        self.constructionDlg = ConstructionDlg(app)
        self.techInfoDlg = TechInfoDlg(app)
        self.confirmDlg = ConfirmDlg(app)
        self.createUI()

    def display(self):
        self.playerID = client.getPlayerID()
        self.show()
        self.win.show()
        # register for updates
        if self not in gdata.updateDlgs:
            gdata.updateDlgs.append(self)

    def hide(self):
        self.win.setStatus(_("Ready."))
        self.win.hide()
        if self.activeQueue is not None:
            # we don't want current selection to be visible next time we open the dialog
            self.vPQueues[self.activeQueue].selectItem(None)
            self.win.setTagAttr('data', 'visible', False)
        # unregister updates
        if self in gdata.updateDlgs:
            gdata.updateDlgs.remove(self)

    def update(self):
        self.show()
        if self.activeQueue is not None:
            if self.activeIndex is not None:
                # restore selection, as the items are recreated in show routine
                self.vPQueues[self.activeQueue].selectItem(self.vPQueues[self.activeQueue].items[self.activeIndex])
            else:
                self.vPQueues[self.activeQueue].selectItem(None)

    def show(self):
        self.player = client.getPlayer()
        self.vPQueues = [self.win.vPQueue0, self.win.vPQueue1, self.win.vPQueue2, self.win.vPQueue3, self.win.vPQueue4]
        #
        for queueNo in xrange(self.queueNo):
            self.showProdQueue(queueNo)

    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()

    def onQueueItemSelected(self, widget, action, data):
        if widget.orderNo != self.activeQueue:
            self.vPQueues[self.activeQueue].selectItem(None)
        self.activeQueue = widget.orderNo
        if not data:
            # unselected
            self.activeIndex = None
            self.win.setTagAttr('data', 'visible', False)
        elif data.index == None:
            # new task
            self.win.setTagAttr('data', 'visible', False)
            self.activeIndex = None
            self.newGlobalTaskDlg.display(self, self.activeQueue)
            self.vPQueues[self.activeQueue].selectItem(None)
        else:
            # info about task
            task = self.vPQueues[self.activeQueue].items[data.index]
            self.activeIndex = data.index
            self.win.setTagAttr('data', 'visible', True)
            self.win.vTaskName.text = task.tooltip
            self.win.vTaskQuantity.text = task.text
            self.win.vTaskConstPoints.text = task.const

    def onMoveTaskFirstLast(self, widget, action, data):
        if self.activeQueue == None or self.activeIndex == None:
            return

        if widget.data == -1:
            rel = -1 * self.activeIndex
            pos = 0
        else:
            rel = len(self.player.prodQueues[self.activeQueue]) - self.activeIndex - 1
            pos = len(self.player.prodQueues[self.activeQueue]) - 1

        try:
            self.win.setStatus(_('Executing MOVE TASK command...'))
            self.player.prodQueues[self.activeQueue] = client.cmdProxy.moveGlobalConstrItem(self.playerID, self.activeQueue, self.activeIndex, rel)
            self.win.setStatus(_('Command has been executed.'))
        except GameException, e:
            self.win.setStatus(e.args[0])
            return

        self.activeIndex = pos
        self.update()
Exemplo n.º 4
0
class GlobalQueuesDlg:
    def __init__(self, app):
        self.app = app
        self.player = None
        self.vPQueues = None
        self.queueNo = 5
        self.activeQueue = 0
        self.activeIndex = None
        self.changeQtyDlg = ChangeQtyDlg(app)
        self.newGlobalTaskDlg = NewGlobalTaskDlg(self.app)
        self.constructionDlg = ConstructionDlg(app)
        self.techInfoDlg = TechInfoDlg(app)
        self.confirmDlg = ConfirmDlg(app)
        self.createUI()

    def display(self):
        self.playerID = client.getPlayerID()
        self.show()
        self.win.show()
        # register for updates
        if self not in gdata.updateDlgs:
            gdata.updateDlgs.append(self)

    def hide(self):
        self.win.setStatus(_("Ready."))
        self.win.hide()
        if self.activeQueue is not None:
            # we don't want current selection to be visible next time we open the dialog
            self.vPQueues[self.activeQueue].selectItem(None)
            self.win.setTagAttr('data', 'visible', False)
        # unregister updates
        if self in gdata.updateDlgs:
            gdata.updateDlgs.remove(self)

    def update(self):
        self.show()
        if self.activeQueue is not None:
            if self.activeIndex is not None:
                # restore selection, as the items are recreated in show routine
                self.vPQueues[self.activeQueue].selectItem(
                    self.vPQueues[self.activeQueue].items[self.activeIndex])
            else:
                self.vPQueues[self.activeQueue].selectItem(None)

    def show(self):
        self.player = client.getPlayer()
        self.vPQueues = [
            self.win.vPQueue0, self.win.vPQueue1, self.win.vPQueue2,
            self.win.vPQueue3, self.win.vPQueue4
        ]
        #
        for queueNo in xrange(self.queueNo):
            self.showProdQueue(queueNo)

    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()

    def onQueueItemSelected(self, widget, action, data):
        if widget.orderNo != self.activeQueue:
            self.vPQueues[self.activeQueue].selectItem(None)
        self.activeQueue = widget.orderNo
        if not data:
            # unselected
            self.activeIndex = None
            self.win.setTagAttr('data', 'visible', False)
        elif data.index == None:
            # new task
            self.win.setTagAttr('data', 'visible', False)
            self.activeIndex = None
            self.newGlobalTaskDlg.display(self, self.activeQueue)
            self.vPQueues[self.activeQueue].selectItem(None)
        else:
            # info about task
            task = self.vPQueues[self.activeQueue].items[data.index]
            self.activeIndex = data.index
            self.win.setTagAttr('data', 'visible', True)
            self.win.vTaskName.text = task.tooltip
            self.win.vTaskQuantity.text = task.text
            self.win.vTaskConstPoints.text = task.const

    def onMoveTaskFirstLast(self, widget, action, data):
        if self.activeQueue == None or self.activeIndex == None:
            return

        if widget.data == -1:
            rel = -1 * self.activeIndex
            pos = 0
        else:
            rel = len(self.player.prodQueues[
                self.activeQueue]) - self.activeIndex - 1
            pos = len(self.player.prodQueues[self.activeQueue]) - 1

        try:
            self.win.setStatus(_('Executing MOVE TASK command...'))
            self.player.prodQueues[
                self.activeQueue] = client.cmdProxy.moveGlobalConstrItem(
                    self.playerID, self.activeQueue, self.activeIndex, rel)
            self.win.setStatus(_('Command has been executed.'))
        except GameException, e:
            self.win.setStatus(e.args[0])
            return

        self.activeIndex = pos
        self.update()