Ejemplo n.º 1
0
 def updateRank(self, rank):
     logger.debug("updating rank interface")
     rankName = self.parent.get_rank(self.parent.faction, rank)
     self.nameLabel.setText("%s %s" % (rankName, self.parent.name))
     if rank > 0:
         self.planetaryDefensesButton.show()
         self.reinforcementButton.show()
Ejemplo n.º 2
0
 def updateRank(self, rank):
     logger.debug("updating rank interface")
     rankName = self.parent.get_rank(self.parent.faction, rank)
     self.nameLabel.setText("%s %s" %(rankName,self.parent.name))
     if rank > 0 :
         self.planetaryDefensesButton.show()
         self.reinforcementButton.show()
Ejemplo n.º 3
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW options instantiating.")
        BaseClass.__init__(self, *args, **kwargs)
        
        self.setupUi(self)
        self.parent = parent
        
         
        self.rotation = True
        self.AA = True

        self.mapTransparencySlider.setTracking(False)
        self.mapTransparencySlider.valueChanged.connect(self.Updatetransparency)
        
        self.starsSlider.setTracking(False)
        self.starsSlider.valueChanged.connect(self.updateStars)

        
        self.uefColor.pressed.connect(lambda : self.pickColor(0, self.uefColor))
        self.aeonColor.pressed.connect(lambda : self.pickColor(1, self.aeonColor))
        self.cybranColor.pressed.connect(lambda : self.pickColor(2, self.cybranColor))
        self.seraphimColor.pressed.connect(lambda : self.pickColor(3, self.seraphimColor))
        
        self.colorResetButton.pressed.connect(self.resetColors)
        
        self.rotationcheckBox.clicked.connect(self.updateRotation)
        self.AAcheckBox.clicked.connect(self.updateAA)
Ejemplo n.º 4
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW Info panel instantiating.")
        BaseClass.__init__(self, *args, **kwargs)
        
        self.setupUi(self)
        self.parent = parent
        self.galaxy = self.parent.galaxy

        #self.setup()
        self.attackListWidget.hide()
        
        self.planet = None
        
        
        self.myAttacks      = {}
        self.myDefenses     = {}
        self.onlinePlayers  = {}
        
        # if we are waiting for the player list...        
        self.waitingForPlayerList = False
        self.waitingForTeamMemberList = False
        self.teamwidget = TeamWidget(self.parent, {})
        
        self.completer= None
        
        # Updating stats
        self.parent.creditsUpdated.connect(self.updateCredit)
        self.parent.rankUpdated.connect(self.updateRank)
        self.parent.victoriesUpdated.connect(self.updateVictories)
        self.parent.dominationUpdated.connect(self.updateDomination)
        self.parent.playersListUpdated.connect(self.updatePlayerList)
        self.parent.teamUpdated.connect(self.updateTeam)
        self.parent.searchingUpdated.connect(self.updateSearch)
        
        self.parent.planetClicked.connect(self.planetClicked)
        self.parent.hovering.connect(self.setup)
        self.parent.attacksUpdated.connect(self.updateAttacks)
               
        self.attackButton.clicked.connect(self.attack)
        self.defenseButton.clicked.connect(self.defend)
        self.formTeamButton.clicked.connect(self.formTeam)
        
        self.rankUpButton.clicked.connect(self.rankup)
        self.awayBox.stateChanged.connect(self.away)
        
        self.attackListWidget.itemClicked.connect(self.attackClicked)
        self.defenseListWidget.itemClicked.connect(self.attackClicked)
        self.attackListWidget.itemDoubleClicked.connect(self.giveToattackProposal)

        self.planetaryDefensesButton.clicked.connect(self.buyPlanetaryDefensesItems)
        self.reinforcementButton.clicked.connect(self.buyReinforcementsItems)
        
        self.quitSquadButton.clicked.connect(self.quitSquad)

        self.defenseBox.hide()
        self.squadBox.hide()
        self.planetaryDefensesButton.hide()
        self.reinforcementButton.hide()
        self.dominationText.hide()
        self.searchProgress.hide()
Ejemplo n.º 5
0
    def __init__(self, client, *args, **kwargs):
        logger.debug("Lobby instantiating.")
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)

        self.client = client
        #self.client.galacticwarTab.setStyleSheet(util.readstylesheet("galacticwar/galacticwar.css"))

        self.COLOR_FACTIONS = {}
        self.mapTransparency = 10
        self.AA = True
        self.rotation = True
        self.stars = 25

        self.GWOptions = GWOptions(self)
        self.GWOptions.loadSettings()

        self.client.galacticwarTab.layout().addWidget(self)

        self.downloader = QNetworkAccessManager(self)
        self.downloader.finished.connect(self.finishRequest)

        self.shaderlist = []
        self.texturelist = {}
        self.shaders = {}

        self.infoPanel = None
        self.OGLdisplay = None

        self.galaxy = Galaxy(self)
        self.channel = None

        self.initDone = False

        self.uid = None
        self.faction = None
        self.name = None
        self.rank = None
        self.credits = 0
        self.victories = 0
        self.enslavedBy = None

        self.attacks = {}

        self.state = ClientState.NONE

        ## Network initialization

        self.socket = QtNetwork.QTcpSocket()
        self.socket.readyRead.connect(self.readFromServer)
        self.socket.disconnected.connect(self.disconnectedFromServer)
        self.socket.error.connect(self.socketError)
        self.blockSize = 0

        self.progress = QtGui.QProgressDialog()
        self.progress.setMinimum(0)
        self.progress.setMaximum(0)
Ejemplo n.º 6
0
    def __init__(self, client, *args, **kwargs):
        logger.debug("Lobby instantiating.")
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)

        self.client = client
        # self.client.galacticwarTab.setStyleSheet(util.readstylesheet("galacticwar/galacticwar.css"))

        self.COLOR_FACTIONS = {}
        self.mapTransparency = 10
        self.AA = True
        self.rotation = True
        self.stars = 25

        self.GWOptions = GWOptions(self)
        self.GWOptions.loadSettings()

        self.client.galacticwarTab.layout().addWidget(self)

        self.downloader = QNetworkAccessManager(self)
        self.downloader.finished.connect(self.finishRequest)

        self.shaderlist = []
        self.texturelist = {}
        self.shaders = {}

        self.infoPanel = None
        self.OGLdisplay = None

        self.galaxy = Galaxy(self)
        self.channel = None

        self.initDone = False

        self.uid = None
        self.faction = None
        self.name = None
        self.rank = None
        self.credits = 0
        self.victories = 0
        self.enslavedBy = None

        self.attacks = {}

        self.state = ClientState.NONE

        ## Network initialization

        self.socket = QtNetwork.QTcpSocket()
        self.socket.readyRead.connect(self.readFromServer)
        self.socket.disconnected.connect(self.disconnectedFromServer)
        self.socket.error.connect(self.socketError)
        self.blockSize = 0

        self.progress = QtGui.QProgressDialog()
        self.progress.setMinimum(0)
        self.progress.setMaximum(0)
Ejemplo n.º 7
0
    def writeToServer(self, action, *args, **kw):
        '''
        This method is the workhorse of the client, and is used to send messages, queries and commands to the server.
        '''
        logger.debug("Client: " + action)

        block = QtCore.QByteArray()
        out = QtCore.QDataStream(block, QtCore.QIODevice.ReadWrite)
        out.setVersion(QtCore.QDataStream.Qt_4_2)

        out.writeUInt32(0)
        out.writeQString(action)

        for arg in args:
            if type(arg) is IntType:
                out.writeInt(arg)
            elif isinstance(arg, basestring):
                out.writeQString(arg)
            elif type(arg) is FloatType:
                out.writeFloat(arg)
            elif type(arg) is ListType:
                out.writeQVariantList(arg)
            elif type(arg) is DictType:
                out.writeQString(json.dumps(arg))
            elif type(arg) is QtCore.QFile:
                arg.open(QtCore.QIODevice.ReadOnly)
                fileDatas = QtCore.QByteArray(arg.readAll())
                #seems that that logger doesn't work
                #logger.debug("file size ", int(fileDatas.size()))
                out.writeInt(fileDatas.size())
                out.writeRawData(fileDatas)

                # This may take a while. We display the progress bar so the user get a feedback
                self.sendFile = True
                self.progress.setLabelText("Sending file to server")
                self.progress.setCancelButton(None)
                self.progress.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                             | QtCore.Qt.WindowTitleHint)
                self.progress.setAutoClose(True)
                self.progress.setMinimum(0)
                self.progress.setMaximum(100)
                self.progress.setModal(1)
                self.progress.setWindowTitle("Uploading in progress")

                self.progress.show()
                arg.close()
            else:
                logger.warn("Uninterpreted Data Type: " + str(type(arg)) +
                            " sent as str: " + str(arg))
                out.writeQString(str(arg))

        out.device().seek(0)
        out.writeUInt32(block.size() - 4)
        self.bytesToSend = block.size() - 4

        self.socket.write(block)
Ejemplo n.º 8
0
    def writeToServer(self, action, *args, **kw):
        '''
        This method is the workhorse of the client, and is used to send messages, queries and commands to the server.
        '''
        logger.debug("Client: " + action)
        
        block = QtCore.QByteArray()
        out = QtCore.QDataStream(block, QtCore.QIODevice.ReadWrite)
        out.setVersion(QtCore.QDataStream.Qt_4_2)

        out.writeUInt32(0)
        out.writeQString(action)
   
        
        for arg in args :
            if type(arg) is IntType:
                out.writeInt(arg)
            elif isinstance(arg, basestring):
                out.writeQString(arg)
            elif type(arg) is FloatType:
                out.writeFloat(arg)
            elif type(arg) is ListType:
                out.writeQVariantList(arg)
            elif type(arg) is DictType:
                out.writeQString(json.dumps(arg))                                
            elif type(arg) is QtCore.QFile :       
                arg.open(QtCore.QIODevice.ReadOnly)
                fileDatas = QtCore.QByteArray(arg.readAll())
                #seems that that logger doesn't work
                #logger.debug("file size ", int(fileDatas.size()))
                out.writeInt(fileDatas.size())
                out.writeRawData(fileDatas)

                # This may take a while. We display the progress bar so the user get a feedback
                self.sendFile = True
                self.progress.setLabelText("Sending file to server")
                self.progress.setCancelButton(None)
                self.progress.setWindowFlags(QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowTitleHint)
                self.progress.setAutoClose(True)
                self.progress.setMinimum(0)
                self.progress.setMaximum(100)
                self.progress.setModal(1)
                self.progress.setWindowTitle("Uploading in progress")
 
                self.progress.show()
                arg.close()
            else:
                logger.warn("Uninterpreted Data Type: " + str(type(arg)) + " sent as str: " + str(arg))
                out.writeQString(str(arg))

        out.device().seek(0)        
        out.writeUInt32(block.size() - 4)
        self.bytesToSend = block.size() - 4
    
        self.socket.write(block)
Ejemplo n.º 9
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW Temporary item instantiating.")
        BaseClass.__init__(self, *args, **kwargs)
        
        self.setupUi(self)
        self.parent = parent

        self.planetaryDefenseListWidget.setItemDelegate(PlanetaryReinforcementDelegate(self))
        self.parent.planetaryDefenseUpdated.connect(self.processReinforcementInfo)
        self.parent.creditsUpdated.connect(self.updateCreditsCheck)
        
        #self.reinforcementListWidget.itemDoubleClicked.connect(self.buyItem)
        self.planetaryDefenseListWidget.mouseMoveEvent = self.mouseMove
        self.planetaryReinforcements = {}
Ejemplo n.º 10
0
 def handle_player_info(self, message):
     ''' Update Player stats '''
     
     self.uid        = int(message["uid"])
     self.faction    = message["faction"]
     self.name       = message["name"]        
     self.rank       = message["rank"]
     self.credits    = message["credits"]
     self.victories  = message["victories"]        
     
     logger.debug("Received player info : victories %i, credits %i" % (self.victories, self.credits))
    
     self.rankUpdated.emit(self.rank)
     self.creditsUpdated.emit(self.credits)
     self.victoriesUpdated.emit(self.victories)
Ejemplo n.º 11
0
    def handle_player_info(self, message):
        ''' Update Player stats '''

        self.uid = int(message["uid"])
        self.faction = message["faction"]
        self.name = message["name"]
        self.rank = message["rank"]
        self.credits = message["credits"]
        self.victories = message["victories"]

        logger.debug("Received player info : victories %i, credits %i" %
                     (self.victories, self.credits))

        self.rankUpdated.emit(self.rank)
        self.creditsUpdated.emit(self.credits)
        self.victoriesUpdated.emit(self.victories)
Ejemplo n.º 12
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW Temporary item instantiating.")
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent

        self.reinforcementListWidget.setItemDelegate(
            ReinforcementDelegate(self))

        unitGroupsLayout = {}
        self.unitsGroup = {}

        unitGroupsLayout[0] = self.ownedGroup.layout()
        unitGroupsLayout[1] = self.group1.layout()
        unitGroupsLayout[2] = self.group2.layout()
        unitGroupsLayout[3] = self.group3.layout()
        unitGroupsLayout[4] = self.group4.layout()
        unitGroupsLayout[5] = self.group5.layout()

        for i in range(0, 6):
            self.unitsGroup[i] = groupListWidget(self, i)
            unitGroupsLayout[i].addWidget(self.unitsGroup[i])

        #self.group1ListWidget.setItemDelegate(ReinforcementGroupDelegate(self))

        self.parent.ReinforcementUpdated.connect(self.processReinforcementInfo)
        self.parent.ReinforcementsGroupDeleted.connect(self.removeGroup)
        self.parent.ReinforcementsGroupUpdated.connect(
            self.processReinforcementGroup)
        self.parent.playersListUpdated.connect(self.updatePlayerList)
        self.parent.creditsUpdated.connect(self.updateCreditsCheck)

        self.reinforcementListWidget.itemPressed.connect(self.itemPressed)

        self.reinforcements = {}

        self.poolOfUnits = {}

        #self.confirmGroupButton.clicked.connect(self.confirmGroup)
        self.buyBtn.clicked.connect(self.buyAll)
        self.offerBtn.clicked.connect(self.offer)

        self.currentMoneyCost = 0

        self.waitingForPlayerList = False
Ejemplo n.º 13
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW Temporary item instantiating.")
        BaseClass.__init__(self, *args, **kwargs)
        
        self.setupUi(self)
        self.parent = parent

        self.reinforcementListWidget.setItemDelegate(ReinforcementDelegate(self))
        
        unitGroupsLayout = {}
        self.unitsGroup = {}

        unitGroupsLayout[0] = self.ownedGroup.layout()
        unitGroupsLayout[1] = self.group1.layout() 
        unitGroupsLayout[2] = self.group2.layout()
        unitGroupsLayout[3] = self.group3.layout()
        unitGroupsLayout[4] = self.group4.layout()
        unitGroupsLayout[5] = self.group5.layout()
        
        for i in range(0,6):
            self.unitsGroup[i] = groupListWidget(self, i)
            unitGroupsLayout[i].addWidget(self.unitsGroup[i])
        
        #self.group1ListWidget.setItemDelegate(ReinforcementGroupDelegate(self))
        
        self.parent.ReinforcementUpdated.connect(self.processReinforcementInfo)
        self.parent.ReinforcementsGroupDeleted.connect(self.removeGroup)
        self.parent.ReinforcementsGroupUpdated.connect(self.processReinforcementGroup)
        self.parent.playersListUpdated.connect(self.updatePlayerList)
        self.parent.creditsUpdated.connect(self.updateCreditsCheck)

        self.reinforcementListWidget.itemPressed.connect(self.itemPressed)

        self.reinforcements = {}
        
        self.poolOfUnits = {}
        
        #self.confirmGroupButton.clicked.connect(self.confirmGroup)
        self.buyBtn.clicked.connect(self.buyAll)
        self.offerBtn.clicked.connect(self.offer)
                
        self.currentMoneyCost = 0

        self.waitingForPlayerList = False
Ejemplo n.º 14
0
    def doConnect(self):
        logger.debug("Connecting to server")
        if self.client.state == ClientState.ACCEPTED:

            self.progress.setCancelButtonText("Cancel")
            self.progress.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                         | QtCore.Qt.WindowTitleHint)
            self.progress.setAutoClose(False)
            self.progress.setAutoReset(False)
            self.progress.setModal(1)
            self.progress.setWindowTitle("Galactic War Network...")
            self.progress.setLabelText("Gating in ...")
            self.progress.show()

            #            self.login = self.client.login.strip()
            #            logger.info("Attempting to gate as: " + str(self.client.login))
            self.state = ClientState.NONE

            # Begin connecting.
            self.socket.connectToHost(LOBBY_HOST, LOBBY_PORT)

            while (self.socket.state() !=
                   QtNetwork.QAbstractSocket.ConnectedState
                   ) and self.progress.isVisible():
                QtGui.QApplication.processEvents()

    #        #Perform Version Check first
            if not self.socket.state(
            ) == QtNetwork.QAbstractSocket.ConnectedState:

                self.progress.close()  # in case it was still showing...
                # We either cancelled or had a TCP error, meaning the connection failed..
                if self.progress.wasCanceled():
                    logger.warn("doConnect() aborted by user.")
                else:
                    logger.error("doConnect() failed with clientstate " +
                                 str(self.state) + ", socket errorstring: " +
                                 self.socket.errorString())
                return False
            else:

                return True
Ejemplo n.º 15
0
    def doConnect(self):
        logger.debug("Connecting to server")
        if self.client.state == ClientState.ACCEPTED:

            self.progress.setCancelButtonText("Cancel")
            self.progress.setWindowFlags(QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowTitleHint)
            self.progress.setAutoClose(False)
            self.progress.setAutoReset(False)
            self.progress.setModal(1)
            self.progress.setWindowTitle("Galactic War Network...")
            self.progress.setLabelText("Gating in ...")
            self.progress.show()

            #            self.login = self.client.login.strip()
            #            logger.info("Attempting to gate as: " + str(self.client.login))
            self.state = ClientState.NONE

            # Begin connecting.
            self.socket.connectToHost(LOBBY_HOST, LOBBY_PORT)

            while (self.socket.state() != QtNetwork.QAbstractSocket.ConnectedState) and self.progress.isVisible():
                QtGui.QApplication.processEvents()

            #        #Perform Version Check first
            if not self.socket.state() == QtNetwork.QAbstractSocket.ConnectedState:

                self.progress.close()  # in case it was still showing...
                # We either cancelled or had a TCP error, meaning the connection failed..
                if self.progress.wasCanceled():
                    logger.warn("doConnect() aborted by user.")
                else:
                    logger.error(
                        "doConnect() failed with clientstate "
                        + str(self.state)
                        + ", socket errorstring: "
                        + self.socket.errorString()
                    )
                return False
            else:

                return True
Ejemplo n.º 16
0
    def __init__(self, parent, *args, **kwargs):
        logger.debug("GW Info panel instantiating.")
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent
        self.galaxy = self.parent.galaxy

        #self.setup()
        self.attackListWidget.hide()

        self.planet = None

        self.myAttacks = {}
        self.myDefenses = {}
        self.onlinePlayers = {}

        # if we are waiting for the player list...
        self.waitingForPlayerList = False
        self.waitingForTeamMemberList = False
        self.teamwidget = TeamWidget(self.parent, {})

        self.completer = None

        # Updating stats
        self.parent.creditsUpdated.connect(self.updateCredit)
        self.parent.rankUpdated.connect(self.updateRank)
        self.parent.victoriesUpdated.connect(self.updateVictories)
        self.parent.dominationUpdated.connect(self.updateDomination)
        self.parent.playersListUpdated.connect(self.updatePlayerList)
        self.parent.teamUpdated.connect(self.updateTeam)
        self.parent.searchingUpdated.connect(self.updateSearch)

        self.parent.planetClicked.connect(self.planetClicked)
        self.parent.hovering.connect(self.setup)
        self.parent.attacksUpdated.connect(self.updateAttacks)

        self.attackButton.clicked.connect(self.attack)
        self.defenseButton.clicked.connect(self.defend)
        self.formTeamButton.clicked.connect(self.formTeam)

        self.rankUpButton.clicked.connect(self.rankup)
        self.awayBox.stateChanged.connect(self.away)

        self.attackListWidget.itemClicked.connect(self.attackClicked)
        self.defenseListWidget.itemClicked.connect(self.attackClicked)
        self.attackListWidget.itemDoubleClicked.connect(
            self.giveToattackProposal)

        self.planetaryDefensesButton.clicked.connect(
            self.buyPlanetaryDefensesItems)
        self.reinforcementButton.clicked.connect(self.buyReinforcementsItems)

        self.quitSquadButton.clicked.connect(self.quitSquad)

        self.defenseBox.hide()
        self.squadBox.hide()
        self.planetaryDefensesButton.hide()
        self.reinforcementButton.hide()
        self.dominationText.hide()
        self.searchProgress.hide()
Ejemplo n.º 17
0
 def updateCredit(self, credits):
     logger.debug("updating credit interface")
     self.creditsLabel.setText("%i / %i" % (credits, (1000+ 1000*self.parent.rank)))
Ejemplo n.º 18
0
 def updateVictories(self, victories):
     logger.debug("updating victories interface")
     self.victoriesLabel.setText("%i" % victories)
Ejemplo n.º 19
0
 def updateVictories(self, victories):
     logger.debug("updating victories interface")
     self.victoriesLabel.setText("%i" % victories)
Ejemplo n.º 20
0
 def updateCredit(self, credits):
     logger.debug("updating credit interface")
     self.creditsLabel.setText("%i / %i" %
                               (credits, (1000 + 1000 * self.parent.rank)))