示例#1
0
 def initializePage(self):
     if self.parent.selectedFaction == 0:
         self.setTitle(
             "Welcome to the United Earth Federation Army !<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !"
         )
         self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                        util.pixmap("client/account_watermark_intro.png"))
     elif self.parent.selectedFaction == 1:
         self.setTitle(
             "You have embraced the Way.<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !"
         )
         self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                        util.pixmap("client/account_watermark_created.png"))
     elif self.parent.selectedFaction == 2:
         self.setTitle(
             "You have been integrated to the symbiont network.<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !"
         )
         self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                        util.pixmap("client/account_watermark_input.png"))
     elif self.parent.selectedFaction == 3:
         self.setTitle(
             "[Language Not Recognized]<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !"
         )
         self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                        util.pixmap("client/account_seraphim.png"))
示例#2
0
 def initializePage(self):
     if self.parent.selectedFaction == 0 :
         self.setTitle("Welcome to the United Earth Federation Army !<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !")
         self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_intro.png"))
     elif self.parent.selectedFaction == 1 :
         self.setTitle("You have embraced the Way.<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !")
         self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_created.png"))
     elif self.parent.selectedFaction == 2 :
         self.setTitle("You have been integrated to the symbiont network.<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !")
         self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_input.png"))
     elif self.parent.selectedFaction == 3 :
         self.setTitle("[Language Not Recognized]<br><br>You can still alter your choice.<br>Once you've clicked finished, there is no going back !")
         self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_seraphim.png"))
    def __init__(self, parent=None):
        super(AccountCreationPage, self).__init__(parent)

        self.parent = parent
        self.client = parent.client
        
        self.setTitle("Account Creation")
        self.setSubTitle("Please enter your desired login and password. Note that your password will not be stored on our server. Please specify a working email address in case you need to change it.")
        
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_input.png"))

        loginLabel = QtGui.QLabel("&User name :")
        self.loginLineEdit = QtGui.QLineEdit()
        rxLog = QtCore.QRegExp("[A-Z,a-z]{1}[A-Z,a-z,0-9,_,-]{0,15}")
        validLog = QtGui.QRegExpValidator(rxLog, self)
        self.loginLineEdit.setValidator(validLog)
        loginLabel.setBuddy(self.loginLineEdit)

        passwordLabel = QtGui.QLabel("&Password :"******"&Re-type Password :"******"E-mail :")
        self.EmailLineEdit = QtGui.QLineEdit()
        rxMail = QtCore.QRegExp("^[a-zA-Z0-9]{1}[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$")
        validMail = QtGui.QRegExpValidator(rxMail, self)
        self.EmailLineEdit.setValidator(validMail)


        self.registerField('login*', self.loginLineEdit)
        self.registerField('password*', self.passwordLineEdit)
        self.registerField('passwordCheck*', self.passwordCheckLineEdit)
        self.registerField('email*', self.EmailLineEdit)

        self.password1 = ''
        self.password2 = ''
        
        layout = QtGui.QGridLayout()
                
        layout.addWidget(loginLabel, 1, 0)
        layout.addWidget(self.loginLineEdit, 1, 1)
        
        layout.addWidget(passwordLabel, 2, 0)
        layout.addWidget(self.passwordLineEdit, 2, 1)
        
        layout.addWidget(passwordCheckLabel, 3, 0)
        layout.addWidget(self.passwordCheckLineEdit, 3, 1)
        
        layout.addWidget(EmailLabel, 4, 0)
        layout.addWidget(self.EmailLineEdit, 4, 1)

        self.setLayout(layout)
示例#4
0
    def __init__(self, parent, modDir, modinfo, *args, **kwargs):
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent
        self.client = self.parent.client
        self.modinfo = modinfo
        self.modDir = modDir
        
        self.setStyleSheet(self.parent.client.styleSheet())
        
        self.setWindowTitle("Uploading Mod")

        self.Name.setText(modinfo.name)
        self.Version.setText(str(modinfo.version))
        if modinfo.ui_only: self.isUILabel.setText("is UI Only")
        else: self.isUILabel.setText("not UI Only")
        self.UID.setText(modinfo.uid)
        self.Description.setPlainText(modinfo.description)
        if modinfo.icon != "":
            self.IconURI.setText(modvault.iconPathToFull(modinfo.icon))
            self.updateThumbnail()
        else:
            self.Thumbnail.setPixmap(util.pixmap("games/unknown_map.png"))
        self.UploadButton.pressed.connect(self.upload)
示例#5
0
    def __init__(self, parent=None):
        super(GameSettings, self).__init__(parent)

        self.parent = parent
        self.setTitle("Network Settings")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/settings_watermark.png"))
        
        self.label = QtGui.QLabel()
        self.label.setText('Forged Alliance needs an open UDP port to play. If you have trouble connecting to other players, try the UPnP option first. If that fails, you should try to open or forward the port on your router and firewall.<br/><br/>Visit the <a href="http://forums.faforever.com/forums/viewforum.php?f=3">Tech Support Forum</a> if you need help.<br/><br/>')
        self.label.setOpenExternalLinks(True)
        self.label.setWordWrap(True)

        self.labelport = QtGui.QLabel()
        self.labelport.setText("<b>UDP Port</b> (default 6112)")
        self.labelport.setWordWrap(True)
        
        self.gamePortSpin = QtGui.QSpinBox() 
        self.gamePortSpin.setMinimum(1024)
        self.gamePortSpin.setMaximum(65535) 
        self.gamePortSpin.setValue(6112)

        self.checkUPnP = QtGui.QCheckBox("use UPnP")
        self.checkUPnP.setToolTip("FAF can try to open and forward your game port automatically using UPnP.<br/><b>Caution: This doesn't work for all connections, but may help with some routers.</b>")

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.labelport)
        layout.addWidget(self.gamePortSpin)
        layout.addWidget(self.checkUPnP)
        self.setLayout(layout)
示例#6
0
    def __init__(self, parent=None):
        super(UpgradePageSC, self).__init__(parent)

        self.setTitle("Specify Supreme Commander folder")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("fa/updater/upgrade_watermark.png"))

        layout = QtGui.QVBoxLayout()
        
        self.label = QtGui.QLabel("You can use any version of Supreme Commander.<br/><br/>FAF won't modify your existing files.<br/><br/>Select folder:")        
        self.label.setWordWrap(True)
        layout.addWidget(self.label)

        self.comboBox = QtGui.QComboBox()       
        self.comboBox.setEditable(True)
        constructPathChoicesSC(self.comboBox)
        self.comboBox.currentIndexChanged.connect(self.comboChanged)
        self.comboBox.editTextChanged.connect(self.comboChanged)
        layout.addWidget(self.comboBox)
        self.setLayout(layout)

        self.browseButton = QtGui.QPushButton()
        self.browseButton.setText("Browse")       
        self.browseButton.clicked.connect(self.showChooser)
        layout.addWidget(self.browseButton )

        self.setLayout(layout)

        self.setCommitPage(True)
示例#7
0
    def __init__(self, parent=None):
        super(UpgradePage, self).__init__(parent)

        self.setTitle("Specify Forged Alliance folder")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("fa/updater/upgrade_watermark.png"))

        layout = QtGui.QVBoxLayout()
        
        self.label = QtGui.QLabel("FAF needs a version of Supreme Commander: Forged Alliance to launch games and replays. <br/><br/><b>Please choose the installation you wish to use.</b><br/><br/>The following versions are <u>equally</u> supported:<ul><li>3596(Retail version)</li><li>3599 (Retail patch)</li><li>3603beta (GPGnet beta patch)</li><li>1.6.6 (Steam Version)</li></ul>FAF doesn't modify your existing files.<br/><br/>Select folder:")        
        self.label.setWordWrap(True)
        layout.addWidget(self.label)

        self.comboBox = QtGui.QComboBox()       
        self.comboBox.setEditable(True)
        constructPathChoices(self.comboBox)
        self.comboBox.currentIndexChanged.connect(self.comboChanged)
        self.comboBox.editTextChanged.connect(self.comboChanged)
        layout.addWidget(self.comboBox)
        self.setLayout(layout)

        self.browseButton = QtGui.QPushButton()
        self.browseButton.setText("Browse")       
        self.browseButton.clicked.connect(self.showChooser)
        layout.addWidget(self.browseButton )

        self.setLayout(layout)

        self.setCommitPage(True)
示例#8
0
    def __init__(self, parent, modDir, modinfo, *args, **kwargs):
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent
        self.client = self.parent.client
        self.modinfo = modinfo
        self.modDir = modDir
        #self.oldname = self.modinfo["name"]

        self.setStyleSheet(self.parent.client.styleSheet())

        self.setWindowTitle("Uploading Mod")

        self.Name.setText(modinfo.name)
        self.Version.setText(str(modinfo.version))
        if modinfo.ui_only: self.isUILabel.setText("is UI Only")
        else: self.isUILabel.setText("not UI Only")
        #self.UIOnly.setChecked(modinfo["ui_only"])
        self.UID.setText(modinfo.uid)
        self.Description.setPlainText(modinfo.description)
        if modinfo.icon != "":
            self.IconURI.setText(modvault.iconPathToFull(modinfo.icon))
            self.updateThumbnail()
        else:
            self.Thumbnail.setPixmap(util.pixmap("games/unknown_map.png"))
        #self.IconURI.returnPressed.connect(self.updateThumbnail)
        self.UploadButton.pressed.connect(self.upload)
示例#9
0
 def updateThumbnail(self):
     iconfilename = modvault.iconPathToFull(self.modinfo.icon)
     if iconfilename == "":
         return False
     if os.path.splitext(iconfilename)[1].lower() == ".dds":
         old = iconfilename
         iconfilename = os.path.join(
             self.modDir,
             os.path.splitext(os.path.basename(iconfilename))[0] + ".png")
         succes = modvault.generateThumbnail(old, iconfilename)
         if not succes:
             logger.info("Could not write the png file for %s" % old)
             QtGui.QMessageBox.information(
                 self.client, "Invalid Icon File",
                 "Because FAF can't read DDS files, it tried to convert it to a png. This failed. Try something else"
             )
             return False
     try:
         self.Thumbnail.setPixmap(util.pixmap(iconfilename, False))
     except:
         QtGui.QMessageBox.information(
             self.client, "Invalid Icon File",
             "This was not a valid icon file. Please pick a png or jpeg")
         return False
     self.modinfo.thumbnail = modvault.fullPathToIcon(iconfilename)
     self.IconURI.setText(iconfilename)
     return True
示例#10
0
    def __init__(self, parent=None):
        super(AccountCreationPage, self).__init__(parent)

        self.parent = parent
        self.client = parent.client

        self.setTitle("Account Creation")
        self.setSubTitle(
            "Please enter your desired login and password. Note that your password will not be stored on our server. Please specify a working email address in case you need to change it."
        )

        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/account_watermark_input.png"))

        loginLabel = QtGui.QLabel("&User name :")
        self.loginLineEdit = QtGui.QLineEdit()
        rxLog = QtCore.QRegExp("[A-Z,a-z]{1}[A-Z,a-z,0-9,_,-]{0,15}")
        validLog = QtGui.QRegExpValidator(rxLog, self)
        self.loginLineEdit.setValidator(validLog)
        loginLabel.setBuddy(self.loginLineEdit)

        passwordLabel = QtGui.QLabel("&Password :"******"&Re-type Password :"******"E-mail :")
        self.EmailLineEdit = QtGui.QLineEdit()
        rxMail = QtCore.QRegExp(
            "^[a-zA-Z0-9]{1}[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$")
        validMail = QtGui.QRegExpValidator(rxMail, self)
        self.EmailLineEdit.setValidator(validMail)

        self.registerField('login*', self.loginLineEdit)
        self.registerField('password*', self.passwordLineEdit)
        self.registerField('passwordCheck*', self.passwordCheckLineEdit)
        self.registerField('email*', self.EmailLineEdit)

        layout = QtGui.QGridLayout()

        layout.addWidget(loginLabel, 1, 0)
        layout.addWidget(self.loginLineEdit, 1, 1)

        layout.addWidget(passwordLabel, 2, 0)
        layout.addWidget(self.passwordLineEdit, 2, 1)

        layout.addWidget(passwordCheckLabel, 3, 0)
        layout.addWidget(self.passwordCheckLineEdit, 3, 1)

        layout.addWidget(EmailLabel, 4, 0)
        layout.addWidget(self.EmailLineEdit, 4, 1)

        self.setLayout(layout)
示例#11
0
    def __init__(self, parent=None):
        super(GameSettings, self).__init__(parent)

        self.parent = parent
        self.setTitle("Network Settings")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/settings_watermark.png"))

        self.label = QtGui.QLabel()
        self.label.setText(
            'Forged Alliance needs an open UDP port to play. If you have trouble connecting to other players, try the UPnP option first. If that fails, you should try to open or forward the port on your router and firewall.<br/><br/>Visit the <a href="http://forums.faforever.com/forums/viewforum.php?f=3">Tech Support Forum</a> if you need help.<br/><br/>'
        )
        self.label.setOpenExternalLinks(True)
        self.label.setWordWrap(True)

        self.labelport = QtGui.QLabel()
        self.labelport.setText("<b>UDP Port</b> (default 6112)")
        self.labelport.setWordWrap(True)

        self.gamePortSpin = QtGui.QSpinBox()
        self.gamePortSpin.setMinimum(1024)
        self.gamePortSpin.setMaximum(65535)
        self.gamePortSpin.setValue(6112)

        self.checkUPnP = QtGui.QCheckBox("use UPnP")
        self.checkUPnP.setToolTip(
            "FAF can try to open and forward your game port automatically using UPnP.<br/><b>Caution: This doesn't work for all connections, but may help with some routers.</b>"
        )

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.labelport)
        layout.addWidget(self.gamePortSpin)
        layout.addWidget(self.checkUPnP)
        self.setLayout(layout)
示例#12
0
    def __init__(self, client, *args, **kwargs):
        QtGui.QWizard.__init__(self, *args, **kwargs)
        self.client = client
        self.upgrade = UpgradePageSC()
        self.addPage(self.upgrade)

        self.setWizardStyle(QtGui.QWizard.ModernStyle)
        self.setWindowTitle("Supreme Commander Game Path")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("fa/updater/forged_alliance_watermark.png"))

        self.setOption(QtGui.QWizard.NoBackButtonOnStartPage, True)
示例#13
0
 def __init__(self, client, *args, **kwargs):
     QtGui.QWizard.__init__(self, *args, **kwargs)     
     self.client = client
     self.upgrade = UpgradePage()
     self.addPage(self.upgrade)
     
     self.setWizardStyle(QtGui.QWizard.ModernStyle)
     self.setWindowTitle("FAF Install Wizard")
     self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("fa/updater/upgrade_watermark.png"))
     
     self.setOption(QtGui.QWizard.NoBackButtonOnStartPage, True)
示例#14
0
    def __init__(self, *args, **kwargs):
        QtGui.QWizardPage.__init__(self, *args, **kwargs)

        self.setFinalPage(True)
        self.setTitle("Congratulations!")
        self.setSubTitle("Your Account has been created.")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_created.png"))

        self.label = QtGui.QLabel()
        self.label.setWordWrap(True)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        self.setLayout(layout)
示例#15
0
    def __init__(self, *args, **kwargs):
        QtGui.QWizardPage.__init__(self, *args, **kwargs)

        self.setFinalPage(True)
        self.setTitle("Congratulations!")
        self.setSubTitle("Your Account has been created.")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/account_watermark_created.png"))

        self.label = QtGui.QLabel()
        self.label.setWordWrap(True)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        self.setLayout(layout)
示例#16
0
    def __init__(self, parent=None):
        super(IntroPage, self).__init__(parent)

        self.setTitle("Welcome to FA Forever.")
        self.setSubTitle("In order to play, you first need to create an account.")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/account_watermark_intro.png"))

        label = QtGui.QLabel("This wizard will help you in the process of account creation.<br/><br/><b>At this time, we only allow one account per computer.</b>")
        
        label.setWordWrap(True)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(label)
        self.setLayout(layout)
示例#17
0
    def __init__(self, parent=None):
        super(IntroPage, self).__init__(parent)

        self.setTitle("Welcome to FA Forever.")
        self.setSubTitle(
            "In order to play, you first need to create an account.")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/account_watermark_intro.png"))

        label = QtGui.QLabel(
            "This wizard will help you in the process of account creation.<br/><br/><b>At this time, we only allow one account per computer.</b>"
        )

        label.setWordWrap(True)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(label)
        self.setLayout(layout)
示例#18
0
    def __init__(self, parent=None):
        super(MumbleSettings, self).__init__(parent)

        self.parent = parent
        self.setTitle("Voice Settings")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/settings_watermark.png"))
        
        self.label = QtGui.QLabel()
        self.label.setText('FAF supports the automatic setup of voice connections between you and your team mates. It will automatically move you into a channel with your team mates anytime you enter a game lobby or start a game. To enable, download and install <a href="http://mumble.sourceforge.net/">Mumble</a> and tick the checkbox below.')
        self.label.setOpenExternalLinks(True)
        self.label.setWordWrap(True)

        self.checkEnableMumble = QtGui.QCheckBox("Enable Mumble Connector")

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.checkEnableMumble)
        self.setLayout(layout)
示例#19
0
    def __init__(self, parent, mod, *args, **kwargs):
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent

        self.setStyleSheet(self.parent.client.styleSheet())

        self.setWindowTitle(mod.name)

        self.mod = mod

        self.Title.setText(mod.name)
        self.Description.setText(mod.description)
        modtext = ""
        if mod.isuimod: modtext = "UI mod\n"
        elif mod.isbigmod: modtext = "Big mod\n"
        elif mod.issmallmod: modtext = "Small mod\n"
        self.Info.setText(modtext + "By %s\nUploaded %s" %
                          (mod.author, str(mod.date)))
        if mod.thumbnail == None:
            self.Picture.setPixmap(util.pixmap("games/unknown_map.png"))
        else:
            self.Picture.setPixmap(mod.thumbnail.pixmap(100, 100))

        self.Comments.setItemDelegate(CommentItemDelegate(self))
        self.BugReports.setItemDelegate(CommentItemDelegate(self))

        if self.mod.uid in self.parent.uids:
            self.DownloadButton.setText("Remove Mod")
        self.DownloadButton.clicked.connect(self.download)
        self.likeButton.clicked.connect(self.like)
        self.LineComment.returnPressed.connect(self.addComment)
        self.LineBugReport.returnPressed.connect(self.addBugReport)

        for item in mod.comments:
            comment = CommentItem(self, item["uid"])
            comment.update(item)
            self.Comments.addItem(comment)
        for item in mod.bugreports:
            comment = CommentItem(self, item["uid"])
            comment.update(item)
            self.BugReports.addItem(comment)
示例#20
0
    def __init__(self, parent, mod, *args, **kwargs):
        BaseClass.__init__(self, *args, **kwargs)

        self.setupUi(self)
        self.parent = parent
        
        self.setStyleSheet(self.parent.client.styleSheet())
        
        self.setWindowTitle(mod.name)

        self.mod = mod
        
        self.Title.setText(mod.name)
        self.Description.setText(mod.description)
        modtext = ""
        if mod.isuimod: modtext = "UI mod\n"
        elif mod.isbigmod: modtext = "Big mod\n"
        elif mod.issmallmod: modtext = "Small mod\n"
        self.Info.setText(modtext + "By %s\nUploaded %s" % (mod.author,
                                    str(mod.date)))
        if mod.thumbnail == None:
            self.Picture.setPixmap(util.pixmap("games/unknown_map.png"))
        else:
            self.Picture.setPixmap(mod.thumbnail.pixmap(100,100))

        self.Comments.setItemDelegate(CommentItemDelegate(self))
        self.BugReports.setItemDelegate(CommentItemDelegate(self))

        if self.mod.uid in self.parent.uids:
            self.DownloadButton.setText("Remove Mod")
        self.DownloadButton.clicked.connect(self.download)
        self.likeButton.clicked.connect(self.like)
        self.LineComment.returnPressed.connect(self.addComment)
        self.LineBugReport.returnPressed.connect(self.addBugReport)

        for item in mod.comments:
            comment = CommentItem(self,item["uid"])
            comment.update(item)
            self.Comments.addItem(comment)
        for item in mod.bugreports:
            comment = CommentItem(self,item["uid"])
            comment.update(item)
            self.BugReports.addItem(comment)
示例#21
0
    def __init__(self, parent=None):
        super(MumbleSettings, self).__init__(parent)

        self.parent = parent
        self.setTitle("Voice Settings")
        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/settings_watermark.png"))

        self.label = QtGui.QLabel()
        self.label.setText(
            'FAF supports the automatic setup of voice connections between you and your team mates. It will automatically move you into a channel with your team mates anytime you enter a game lobby or start a game. To enable, download and install <a href="http://mumble.sourceforge.net/">Mumble</a> and tick the checkbox below.'
        )
        self.label.setOpenExternalLinks(True)
        self.label.setWordWrap(True)

        self.checkEnableMumble = QtGui.QCheckBox("Enable Mumble Connector")

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.checkEnableMumble)
        self.setLayout(layout)
示例#22
0
 def updateThumbnail(self):
     iconfilename = modvault.iconPathToFull(self.modinfo.icon)
     if iconfilename == "":
         return False
     if os.path.splitext(iconfilename)[1].lower() == ".dds":
         old = iconfilename
         iconfilename = os.path.join(self.modDir, os.path.splitext(os.path.basename(iconfilename))[0] + ".png")
         succes = modvault.generateThumbnail(old,iconfilename)
         if not succes:
             QtGui.QMessageBox.information(self.client,"Invalid Icon File",
                     "Because FAF can't read DDS files, it tried to convert it to a png. This failed. Try something else")
             return False
     try:
         self.Thumbnail.setPixmap(util.pixmap(iconfilename,False))
     except:
         QtGui.QMessageBox.information(self.client,"Invalid Icon File",
                     "This was not a valid icon file. Please pick a png or jpeg")
         return False
     self.modinfo.thumbnail = modvault.fullPathToIcon(iconfilename)
     self.IconURI.setText(iconfilename)
     return True
示例#23
0
    def __init__(self, parent=None, *args, **kwargs):
        QtGui.QWizardPage.__init__(self, *args, **kwargs)

        self.parent = parent
        self.client = parent.client

        self.setButtonText(QtGui.QWizard.CancelButton, "Quit")
        self.setButtonText(QtGui.QWizard.FinishButton, "Login")

        self.setTitle("ACU ready for combat.")
        self.setSubTitle("Log yourself in, commander.")

        self.setPixmap(QtGui.QWizard.WatermarkPixmap,
                       util.pixmap("client/login_watermark.png"))

        loginLabel = QtGui.QLabel("&User name :")
        self.loginLineEdit = QtGui.QLineEdit()
        loginLabel.setBuddy(self.loginLineEdit)
        self.loginLineEdit.setText(self.client.login)

        passwordLabel = QtGui.QLabel("&Password :"******"!!!password!!!")

        self.passwordLineEdit.selectionChanged.connect(
            self.passwordLineEdit.clear)

        self.rememberCheckBox = QtGui.QCheckBox("&Remember me")
        self.rememberCheckBox.setChecked(self.client.remember)

        self.rememberCheckBox.clicked.connect(self.rememberCheck)

        self.createAccountBtn = QtGui.QPushButton("Create new Account")
        self.renameAccountBtn = QtGui.QPushButton("Rename your account")
        self.linkAccountBtn = QtGui.QPushButton("Link your account to Steam")
        self.forgotPasswordBtn = QtGui.QPushButton("Forgot Login or Password")
        self.reportBugBtn = QtGui.QPushButton("Report a Bug")

        self.createAccountBtn.released.connect(self.createAccount)
        self.renameAccountBtn.released.connect(self.renameAccount)
        self.linkAccountBtn.released.connect(self.linkAccount)
        self.forgotPasswordBtn.released.connect(self.forgotPassword)
        self.reportBugBtn.released.connect(self.reportBug)

        self.registerField('login', self.loginLineEdit)
        self.registerField('password', self.passwordLineEdit)
        self.registerField('remember', self.rememberCheckBox)

        layout = QtGui.QGridLayout()

        layout.addWidget(loginLabel, 1, 0)
        layout.addWidget(self.loginLineEdit, 1, 1)

        layout.addWidget(passwordLabel, 2, 0)
        layout.addWidget(self.passwordLineEdit, 2, 1)

        layout.addWidget(self.rememberCheckBox, 3, 0, 1, 3)
        layout.addWidget(self.createAccountBtn, 5, 0, 1, 3)
        layout.addWidget(self.renameAccountBtn, 6, 0, 1, 3)
        layout.addWidget(self.linkAccountBtn, 7, 0, 1, 3)
        layout.addWidget(self.forgotPasswordBtn, 8, 0, 1, 3)

        layout.addWidget(self.reportBugBtn, 10, 0, 1, 3)

        self.setLayout(layout)
示例#24
0
文件: maps.py 项目: norraxx/client
def __exportPreviewFromMap(mapname, positions=None):
    '''
    This method auto-upgrades the maps to have small and large preview images
    '''
    if mapname == "" or mapname == None:
        return
    smallExists = False
    largeExists = False
    ddsExists = False
    previews = {"cache": None, "tozip": list()}

    if os.path.isdir(mapname):
        mapdir = mapname
    elif os.path.isdir(os.path.join(getUserMapsFolder(), mapname)):
        mapdir = os.path.join(getUserMapsFolder(), mapname)
    elif os.path.isdir(os.path.join(getBaseMapsFolder(), mapname)):
        mapdir = os.path.join(getBaseMapsFolder(), mapname)
    else:
        logger.debug("Can't find mapname in file system: " + mapname)
        return previews

    mapname = os.path.basename(mapdir).lower()
    mapfilename = os.path.join(mapdir, mapname.split(".")[0] + ".scmap")

    mode = os.stat(mapdir)[0]
    if not (mode and stat.S_IWRITE):
        logger.debug("Map directory is not writable: " + mapdir)
        logger.debug("Writing into cache instead.")
        mapdir = os.path.join(util.CACHE_DIR, mapname)
        if not os.path.isdir(mapdir):
            os.mkdir(mapdir)

    previewsmallname = os.path.join(mapdir, mapname + ".small.png")
    previewlargename = os.path.join(mapdir, mapname + ".large.png")
    previewddsname = os.path.join(mapdir, mapname + ".dds")
    cachepngname = os.path.join(util.CACHE_DIR, mapname + ".png")

    logger.debug("Generating preview from user maps for: " + mapname)
    logger.debug("Using directory: " + mapdir)

    #Unknown / Unavailable mapname?
    if not os.path.isfile(mapfilename):
        logger.warning("Unable to find the .scmap for: " + mapname +
                       ", was looking here: " + mapfilename)
        return previews

    #Small preview already exists?
    if os.path.isfile(previewsmallname):
        logger.debug(mapname + " already has small preview")
        previews["tozip"].append(previewsmallname)
        smallExists = True
        #save it in cache folder
        shutil.copyfile(previewsmallname, cachepngname)
        #checking if file was copied correctly, just in case
        if os.path.isfile(cachepngname):
            previews["cache"] = cachepngname
        else:
            logger.debug("Couldn't copy preview into cache folder")
            return previews

    #Large preview already exists?
    if os.path.isfile(previewlargename):
        logger.debug(mapname + " already has large preview")
        previews["tozip"].append(previewlargename)
        largeExists = True

    #Preview DDS already exists?
    if os.path.isfile(previewddsname):
        logger.debug(mapname + " already has DDS extracted")
        previews["tozip"].append(previewddsname)
        ddsExists = True

    if not ddsExists:
        logger.debug("Extracting preview DDS from .scmap for: " + mapname)
        mapfile = open(mapfilename, "rb")
        """
        magic = struct.unpack('i', mapfile.read(4))[0]       
        version_major = struct.unpack('i', mapfile.read(4))[0]       
        unk_edfe = struct.unpack('i', mapfile.read(4))[0]
        unk_efbe = struct.unpack('i', mapfile.read(4))[0]
        width = struct.unpack('f', mapfile.read(4))[0]
        height = struct.unpack('f', mapfile.read(4))[0]
        unk_32 = struct.unpack('i', mapfile.read(4))[0]
        unk_16 = struct.unpack('h', mapfile.read(2))[0]
        """
        mapfile.seek(
            30
        )  #Shortcut. Maybe want to clean out some of the magic numbers some day
        size = struct.unpack('i', mapfile.read(4))[0]
        data = mapfile.read(size)
        #version_minor = struct.unpack('i', mapfile.read(4))[0]
        mapfile.close()
        #logger.debug("SCMAP version %i.%i" % (version_major, version_minor))

        try:
            with open(previewddsname, "wb") as previewfile:
                previewfile.write(data)

                #checking if file was created correctly, just in case
                if os.path.isfile(previewddsname):
                    previews["tozip"].append(previewddsname)
                else:
                    logger.debug("Failed to make DDS for: " + mapname)
                    return previews
        except IOError:
            pass

    if not smallExists:
        logger.debug("Making small preview from DDS for: " + mapname)
        genPrevFromDDS(previewddsname, previewsmallname, small=True)
        if os.path.isfile(previewsmallname):
            previews["tozip"].append(previewsmallname)
        else:
            logger.debug("Failed to make small preview for: " + mapname)
            return previews

        shutil.copyfile(previewsmallname, cachepngname)
        #checking if file was copied correctly, just in case
        if os.path.isfile(cachepngname):
            previews["cache"] = cachepngname
        else:
            logger.debug("Failed to write in cache folder")
            return previews

    if not largeExists:
        logger.debug("Making large preview from DDS for: " + mapname)
        if not isinstance(positions, dict):
            logger.debug(
                "Icon positions were not passed or they were wrong for: " +
                mapname)
            return previews
        genPrevFromDDS(previewddsname, previewlargename, small=False)
        mapimage = util.pixmap(previewlargename)
        armyicon = util.pixmap("vault/map_icons/army.png").scaled(8, 9, 1, 1)
        massicon = util.pixmap("vault/map_icons/mass.png").scaled(8, 8, 1, 1)
        hydroicon = util.pixmap("vault/map_icons/hydro.png").scaled(
            10, 10, 1, 1)

        painter = QtGui.QPainter()

        painter.begin(mapimage)
        #icons should be drawn in certain order: first layer is hydros, second - mass, and army on top. made so that previews not look messed up.
        if positions.has_key("hydro"):
            for pos in positions["hydro"]:
                target = QtCore.QRectF(positions["hydro"][pos][0] - 5,
                                       positions["hydro"][pos][1] - 5, 10, 10)
                source = QtCore.QRectF(0.0, 0.0, 10.0, 10.0)
                painter.drawPixmap(target, hydroicon, source)
        if positions.has_key("mass"):
            for pos in positions["mass"]:
                target = QtCore.QRectF(positions["mass"][pos][0] - 4,
                                       positions["mass"][pos][1] - 4, 8, 8)
                source = QtCore.QRectF(0.0, 0.0, 8.0, 8.0)
                painter.drawPixmap(target, massicon, source)
        if positions.has_key("army"):
            for pos in positions["army"]:
                target = QtCore.QRectF(positions["army"][pos][0] - 4,
                                       positions["army"][pos][1] - 4, 8, 9)
                source = QtCore.QRectF(0.0, 0.0, 8.0, 9.0)
                painter.drawPixmap(target, armyicon, source)
        painter.end()

        mapimage.save(previewlargename)
        #checking if file was created correctly, just in case
        if os.path.isfile(previewlargename):
            previews["tozip"].append(previewlargename)
        else:
            logger.debug("Failed to make large preview for: " + mapname)

    return previews
示例#25
0
文件: maps.py 项目: Arkonen8/client
def __exportPreviewFromMap(mapname, positions=None):
    '''
    This method auto-upgrades the maps to have small and large preview images
    '''
    if mapname == "" or mapname == None:
        return
    smallExists = False
    largeExists = False
    ddsExists = False
    previews = {"cache":None, "tozip":list()}
    
    if os.path.isdir(mapname):
        mapdir = mapname
    elif os.path.isdir(os.path.join(getUserMapsFolder(), mapname)):
        mapdir = os.path.join(getUserMapsFolder(), mapname)
    elif os.path.isdir(os.path.join(getBaseMapsFolder(), mapname)):
        mapdir = os.path.join(getBaseMapsFolder(), mapname)
    else:
        logger.debug("Can't find mapname in file system: " + mapname)
        return previews
        
    mapname = os.path.basename(mapdir).lower()
    mapfilename = os.path.join(mapdir, mapname.split(".")[0]+".scmap")
    
    mode = os.stat(mapdir)[0]
    if not (mode and stat.S_IWRITE):
        logger.debug("Map directory is not writable: " + mapdir)
        logger.debug("Writing into cache instead.")
        mapdir = os.path.join(util.CACHE_DIR, mapname)
        if not os.path.isdir(mapdir):
            os.mkdir(mapdir)
    
    previewsmallname = os.path.join(mapdir, mapname + ".small.png")
    previewlargename = os.path.join(mapdir, mapname + ".large.png")
    previewddsname = os.path.join(mapdir, mapname + ".dds")
    cachepngname = os.path.join(util.CACHE_DIR, mapname + ".png")
        
    logger.debug("Generating preview from user maps for: " + mapname)
    logger.debug("Using directory: " + mapdir)
    
    #Unknown / Unavailable mapname? 
    if not os.path.isfile(mapfilename):
        logger.warning("Unable to find the .scmap for: " + mapname + ", was looking here: " + mapfilename)
        return previews

    #Small preview already exists?
    if os.path.isfile(previewsmallname):
        logger.debug(mapname + " already has small preview")
        previews["tozip"].append(previewsmallname)
        smallExists = True
        #save it in cache folder
        shutil.copyfile(previewsmallname, cachepngname)
        #checking if file was copied correctly, just in case
        if os.path.isfile(cachepngname):
            previews["cache"] = cachepngname
        else:
            logger.debug("Couldn't copy preview into cache folder")
            return previews
        
    #Large preview already exists?
    if os.path.isfile(previewlargename):
        logger.debug(mapname + " already has large preview")
        previews["tozip"].append(previewlargename)
        largeExists = True

    #Preview DDS already exists?
    if os.path.isfile(previewddsname):
        logger.debug(mapname + " already has DDS extracted")
        previews["tozip"].append(previewddsname)
        ddsExists = True
    
    if not ddsExists:
        logger.debug("Extracting preview DDS from .scmap for: " + mapname)
        mapfile = open(mapfilename, "rb")
        """
        magic = struct.unpack('i', mapfile.read(4))[0]       
        version_major = struct.unpack('i', mapfile.read(4))[0]       
        unk_edfe = struct.unpack('i', mapfile.read(4))[0]
        unk_efbe = struct.unpack('i', mapfile.read(4))[0]
        width = struct.unpack('f', mapfile.read(4))[0]
        height = struct.unpack('f', mapfile.read(4))[0]
        unk_32 = struct.unpack('i', mapfile.read(4))[0]
        unk_16 = struct.unpack('h', mapfile.read(2))[0]
        """
        mapfile.seek(30)    #Shortcut. Maybe want to clean out some of the magic numbers some day
        size = struct.unpack('i', mapfile.read(4))[0]
        data = mapfile.read(size)
        #version_minor = struct.unpack('i', mapfile.read(4))[0]   
        mapfile.close()
        #logger.debug("SCMAP version %i.%i" % (version_major, version_minor))

        try:
            with open(previewddsname, "wb") as previewfile:
                previewfile.write(data)

                #checking if file was created correctly, just in case
                if os.path.isfile(previewddsname):
                    previews["tozip"].append(previewddsname)
                else:
                    logger.debug("Failed to make DDS for: " + mapname)
                    return previews
        except IOError:
            pass
    
    if not smallExists:
        logger.debug("Making small preview from DDS for: " + mapname)
        genPrevFromDDS(previewddsname,previewsmallname,small=True)
        if os.path.isfile(previewsmallname):
            previews["tozip"].append(previewsmallname)
        else:
            logger.debug("Failed to make small preview for: " + mapname)
            return previews
        
        shutil.copyfile(previewsmallname, cachepngname)
        #checking if file was copied correctly, just in case
        if os.path.isfile(cachepngname):
            previews["cache"] = cachepngname
        else:
            logger.debug("Failed to write in cache folder")
            return previews
    
    if not largeExists:
        logger.debug("Making large preview from DDS for: " + mapname)
        if not isinstance(positions, dict):
            logger.debug("Icon positions were not passed or they were wrong for: " + mapname)
            return previews
        genPrevFromDDS(previewddsname, previewlargename, small=False)
        mapimage = util.pixmap(previewlargename)
        armyicon = util.pixmap("vault/map_icons/army.png").scaled(8, 9, 1, 1)
        massicon = util.pixmap("vault/map_icons/mass.png").scaled(8, 8, 1, 1)
        hydroicon = util.pixmap("vault/map_icons/hydro.png").scaled(10, 10, 1, 1)
        
        
        painter = QtGui.QPainter()
        
        painter.begin(mapimage)
        #icons should be drawn in certain order: first layer is hydros, second - mass, and army on top. made so that previews not look messed up.
        if positions.has_key("hydro"):
            for pos in positions["hydro"]:
                target = QtCore.QRectF(positions["hydro"][pos][0]-5, positions["hydro"][pos][1]-5, 10, 10)
                source = QtCore.QRectF(0.0, 0.0, 10.0, 10.0)
                painter.drawPixmap(target, hydroicon, source)
        if positions.has_key("mass"):
            for pos in positions["mass"]:
                target = QtCore.QRectF(positions["mass"][pos][0]-4, positions["mass"][pos][1]-4, 8, 8)
                source = QtCore.QRectF(0.0, 0.0, 8.0, 8.0)
                painter.drawPixmap(target, massicon, source)
        if positions.has_key("army"):
            for pos in positions["army"]:
                target = QtCore.QRectF(positions["army"][pos][0]-4, positions["army"][pos][1]-4, 8, 9)
                source = QtCore.QRectF(0.0, 0.0, 8.0, 9.0)
                painter.drawPixmap(target, armyicon, source)
        painter.end()
        
        mapimage.save(previewlargename)
        #checking if file was created correctly, just in case
        if os.path.isfile(previewlargename):
            previews["tozip"].append(previewlargename)
        else:
            logger.debug("Failed to make large preview for: " + mapname)

    return previews
示例#26
0
    def __init__(self, parent=None, *args, **kwargs):
        QtGui.QWizardPage.__init__(self, *args, **kwargs)

        self.parent= parent
        self.client = parent.client
        
        self.setButtonText(QtGui.QWizard.CancelButton, "Quit")
        self.setButtonText(QtGui.QWizard.FinishButton, "Login")        
        
        self.setTitle("ACU ready for combat.")
        self.setSubTitle("Log yourself in, commander.")
        
        self.setPixmap(QtGui.QWizard.WatermarkPixmap, util.pixmap("client/login_watermark.png"))

        loginLabel = QtGui.QLabel("&User name :")
        self.loginLineEdit = QtGui.QLineEdit()
        loginLabel.setBuddy(self.loginLineEdit)
        self.loginLineEdit.setText(self.client.login)

        passwordLabel = QtGui.QLabel("&Password :"******"!!!password!!!")

        self.passwordLineEdit.selectionChanged.connect(self.passwordLineEdit.clear)               


        self.rememberCheckBox = QtGui.QCheckBox("&Remember me")
        self.rememberCheckBox.setChecked(self.client.remember)
        

        self.rememberCheckBox.clicked.connect(self.rememberCheck)

        self.createAccountBtn = QtGui.QPushButton("Create new Account")
        self.renameAccountBtn = QtGui.QPushButton("Rename your account")
        self.linkAccountBtn = QtGui.QPushButton("Link your account to Steam")
        self.forgotPasswordBtn = QtGui.QPushButton("Forgot Login or Password")
        self.reportBugBtn = QtGui.QPushButton("Report a Bug")

        self.createAccountBtn.released.connect(self.createAccount)
        self.renameAccountBtn.released.connect(self.renameAccount)
        self.linkAccountBtn.released.connect(self.linkAccount)
        self.forgotPasswordBtn.released.connect(self.forgotPassword)
        self.reportBugBtn.released.connect(self.reportBug)

        self.registerField('login', self.loginLineEdit)
        self.registerField('password', self.passwordLineEdit)
        self.registerField('remember', self.rememberCheckBox)


        layout = QtGui.QGridLayout()

        layout.addWidget(loginLabel, 1, 0)
        layout.addWidget(self.loginLineEdit, 1, 1)
        
        layout.addWidget(passwordLabel, 2, 0)
        layout.addWidget(self.passwordLineEdit, 2, 1)

        layout.addWidget(self.rememberCheckBox, 3, 0, 1, 3)
        layout.addWidget(self.createAccountBtn, 5, 0, 1, 3)
        layout.addWidget(self.renameAccountBtn, 6, 0, 1, 3)
        layout.addWidget(self.linkAccountBtn, 7, 0, 1, 3)
        layout.addWidget(self.forgotPasswordBtn, 8, 0, 1, 3)

        layout.addWidget(self.reportBugBtn, 10, 0, 1, 3)

        self.setLayout(layout)