예제 #1
0
 def setNormalTheme(boolean):
     if boolean:
         ColorTheme.SELECTED = ColorTheme.LIGHT
         QtGui.QApplication.setStyle(ColorTheme.originalStyle)
         QtGui.QApplication.setPalette(ColorTheme.originalPalette)
         Settings.setValue(Settings.COLORTHEME, '')
         QtGui.QApplication.instance().setStyleSheet('')
예제 #2
0
    def locateROMsDir(self):
        d = QtGui.QFileDialog.getExistingDirectory(self, "Open Directory",
                                                   os.path.expanduser("~"),
                                                   QtGui.QFileDialog.ShowDirsOnly
                                                   | QtGui.QFileDialog.DontResolveSymlinks)
        if d and os.path.isdir(d):
            Settings.setValue(Settings.ROMS_DIR, d)

        #on linux & MAC, symlink it to the ROMs folder to avoid configuring FBA
        if not IS_WINDOWS:
            fbaRomPath = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "ROMs")
            # remove it if it's a link or an empty dir
            if os.path.islink(fbaRomPath):
                os.remove(fbaRomPath)
            if os.path.isdir(fbaRomPath) and not os.listdir(fbaRomPath):
                os.rmdir(fbaRomPath)
            if not os.path.exists(fbaRomPath):
                os.symlink(d, fbaRomPath)

        # on windows, update fba's ini file with the new location
        if IS_WINDOWS:
            fbaIniFile = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "config", "ggpofba-ng.ini")
            if fbaIniFile and os.path.isfile(fbaIniFile):
                for line in fileinput.input(fbaIniFile, inplace=True, backup='.bak'):
                    new="szAppRomPaths[7] "+str(os.path.join(d,'')+"\\")
                    sys.stdout.write(re.sub("szAppRomPaths\[7\].*", new, line))
예제 #3
0
 def onAccepted(self):
     customEmoticons = self.uiEmoticonTextEdit.toPlainText()
     if customEmoticons:
         saved = "\n".join(filter(None, [line.strip()
                                         for line in customEmoticons.split("\n")
                                         if 0 < len(line) < 64]))
         Settings.setValue(Settings.CUSTOM_EMOTICONS, saved)
예제 #4
0
 def setStyleBuiltin(self, styleName):
     if styleName in QtGui.QStyleFactory.keys():
         ColorTheme.SELECTED = ColorTheme.LIGHT
         QtGui.QApplication.instance().setStyleSheet('')
         QtGui.QApplication.setStyle(QtGui.QStyleFactory.create(styleName))
         QtGui.QApplication.setPalette(QtGui.QApplication.style().standardPalette())
         Settings.setValue(Settings.COLORTHEME, styleName)
예제 #5
0
 def setNormalTheme(boolean):
     if boolean:
         ColorTheme.SELECTED = ColorTheme.LIGHT
         QtGui.QApplication.setStyle(ColorTheme.originalStyle)
         QtGui.QApplication.setPalette(ColorTheme.originalPalette)
         Settings.setValue(Settings.COLORTHEME, '')
         QtGui.QApplication.instance().setStyleSheet('')
예제 #6
0
    def AddRemoveFavorites(self):
        it = self.uiChannelsTree.currentItem().text(1)
        bold_font = QtGui.QFont()
        bold_font.setBold(True)
        not_bold_font = QtGui.QFont()
        not_bold_font.setBold(False)

        if not ("," + self.channels[it] + ","
                in self.favorites):  # Add favorite
            self.favorites = self.favorites + "," + self.channels[it] + ","
            self.uiChannelsTree.currentItem().setFont(1, bold_font)
        else:  # Remove favorite
            self.favorites = self.favorites.replace(
                "," + self.channels[it] + ",", ",")
            self.uiChannelsTree.currentItem().setFont(1, not_bold_font)
            if (not self.expectFirstChannelResponse) and Settings.value(
                    Settings.FILTER_FAVORITES
            ):  # Update list when removing from the filtered list
                self.expectFirstChannelResponse = True
                self.controller.sigChannelsLoaded.emit()
            self.uiChannelsTree.setCurrentItem(None)

        pattern1 = re.compile(",*,")  # trimming unwanted commas
        self.favorites = pattern1.sub(",", self.favorites)
        if self.favorites == ",":  # if it's only a comma after RegEx, then clear the favorites
            self.favorites = ""
        Settings.setValue(Settings.CHANNELS_FAVORITES, self.favorites)
예제 #7
0
 def locateUnsupportedSavestatesDirAct(self):
     d = QtGui.QFileDialog.getExistingDirectory(self, "Open Directory",
                                                os.path.expanduser("~"),
                                                QtGui.QFileDialog.ShowDirsOnly
                                                | QtGui.QFileDialog.DontResolveSymlinks)
     if d and os.path.isdir(d):
         Settings.setValue(Settings.UNSUPPORTED_GAMESAVES_DIR, d)
예제 #8
0
 def closeEvent(self, evnt):
     Settings.setValue(Settings.WINDOW_GEOMETRY, self.saveGeometry())
     Settings.setValue(Settings.WINDOW_STATE, self.saveState())
     Settings.setValue(Settings.SPLITTER_STATE, self.uiSplitter.saveState())
     Settings.setValue(Settings.TABLE_HEADER_STATE, self.uiPlayersTableV.horizontalHeader().saveState())
     Settings.setValue(Settings.CHANNELS_HEADER_STATE, self.uiChannelsTree.header().saveState())
     super(GGPOWindow, self).closeEvent(evnt)
예제 #9
0
 def onAccepted(self):
     customEmoticons = self.uiEmoticonTextEdit.toPlainText()
     if customEmoticons:
         saved = "\n".join(filter(None, [line.strip()
                                         for line in customEmoticons.split("\n")
                                         if 0 < len(line) < 64]))
         Settings.setValue(Settings.CUSTOM_EMOTICONS, saved)
예제 #10
0
    def sendJoinChannelRequest(self, channel=None):
        if channel:
            self.channel = channel
            Settings.setValue(Settings.SELECTED_CHANNEL, channel)
            if channel in self.channels:
                if channel != 'lobby':
                    self.rom = self.channels[channel]['rom']
                else:
                    self.rom = ''
            else:
                logdebug().error("Invalid channel {}".format(channel))

        if (int(self.channelport) != int(self.channels[channel]['port'])):
            self.switchingServer = True
            self.channelport = int(self.channels[channel]['port'])
            Settings.setValue(Settings.PORT, self.channelport)
            self.tcpSock.close()
            self.sequence = 0x1
            self.connectTcp()
            self.sendWelcome()
            self.sendAuth(self.username, self.password)
            if Settings.value(Settings.AWAY):
                self.sendToggleAFK(1)
        self.sendAndRemember(Protocol.JOIN_CHANNEL,
                             Protocol.packTLV(self.channel))
예제 #11
0
 def closeEvent(self, evnt):
     Settings.setValue(Settings.WINDOW_GEOMETRY, self.saveGeometry())
     Settings.setValue(Settings.WINDOW_STATE, self.saveState())
     Settings.setValue(Settings.SPLITTER_STATE, self.uiSplitter.saveState())
     Settings.setValue(Settings.TABLE_HEADER_STATE,
                       self.uiPlayersTableV.horizontalHeader().saveState())
     Settings.setValue(Settings.CHANNELS_HEADER_STATE,
                       self.uiChannelsTree.header().saveState())
     super(GGPOWindow, self).closeEvent(evnt)
예제 #12
0
 def locateWine(self):
     if IS_WINDOWS:
         return
     defaultLocation = findWine()
     if not defaultLocation:
         defaultLocation = os.path.expanduser("~")
     fname = QtGui.QFileDialog.getOpenFileName(self, 'Locate wine', defaultLocation, "wine (wine)")
     if fname:
         Settings.setValue(Settings.WINE_LOCATION, fname)
예제 #13
0
 def sendJoinChannelRequest(self, channel=None):
     if channel:
         self.channel = channel
         Settings.setValue(Settings.SELECTED_CHANNEL, channel)
         if channel in self.channels:
             if channel != 'lobby':
                 self.rom = self.channels[channel]['rom']
         else:
             logdebug().error("Invalid channel {}".format(channel))
     self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
예제 #14
0
 def locateCustomChallengeSound(self):
     oldval = Settings.value(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION)
     if oldval and os.path.isdir(os.path.dirname(oldval)):
         dirname = os.path.dirname(oldval)
     else:
         dirname = os.path.expanduser("~")
     fname = QtGui.QFileDialog.getOpenFileName(self, 'Locate custom wave file', dirname,
                                               "wav file (*.wav)")
     if fname:
         Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname)
         ggpo.common.sound.play()
예제 #15
0
 def sendJoinChannelRequest(self, channel=None):
     if channel:
         self.channel = channel
         Settings.setValue(Settings.SELECTED_CHANNEL, channel)
         if channel in self.channels:
             if channel != 'lobby':
                 self.rom = self.channels[channel]['rom']
         else:
             logdebug().error("Invalid channel {}".format(channel))
     self.sendAndRemember(Protocol.JOIN_CHANNEL,
                          Protocol.packTLV(self.channel))
예제 #16
0
 def locateGeoMMDB(self):
     oldval = Settings.value(Settings.GEOIP2DB_LOCATION)
     if oldval and os.path.isdir(os.path.dirname(oldval)):
         dirname = os.path.dirname(oldval)
     else:
         dirname = os.path.expanduser("~")
     fname = QtGui.QFileDialog.getOpenFileName(self, 'Locate Geo mmdb file', dirname,
                                               "Geo mmdb (*.mmdb)")
     if fname:
         Settings.setValue(Settings.GEOIP2DB_LOCATION, fname)
         geolookupInit()
예제 #17
0
 def locateGGPOFBA(self):
     oldval = Settings.value(Settings.GGPOFBA_LOCATION)
     if oldval and os.path.isdir(os.path.dirname(oldval)):
         dirname = os.path.dirname(oldval)
     else:
         dirname = os.path.expanduser("~")
     fname = QtGui.QFileDialog.getOpenFileName(self, 'Locate ggpofba.exe', dirname,
                                               "ggpofba.exe (ggpofba.exe)")
     if fname:
         Settings.setValue(Settings.GGPOFBA_LOCATION, fname)
         self.controller.checkInstallation()
예제 #18
0
 def setCustomQssfile(self, fname):
     if fname and os.path.isfile(fname):
         # noinspection PyBroadException
         try:
             QtGui.QApplication.instance().setStyleSheet(open(fname).read())
             Settings.setValue(Settings.COLORTHEME, 'custom')
             Settings.setValue(Settings.CUSTOM_THEME_FILENAME, fname)
             ColorTheme.SELECTED = ColorTheme.SAFE
             return True
         except:
             pass
예제 #19
0
 def locateCustomChallengeSound(self):
     oldval = Settings.value(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION)
     if oldval and os.path.isdir(os.path.dirname(oldval)):
         dirname = os.path.dirname(oldval)
     else:
         dirname = os.path.expanduser("~")
     fname, filters = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Locate custom wave file', dirname, "wav file (*.wav)")
     if fname:
         Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname)
         ggpo.common.sound.play()
         for a in self.uiMenuChallengeSoundGroup.actions():
             if a.isChecked():
                 a.setChecked(False)
예제 #20
0
    def login(self):
        if not self.uiLoginBtn.isEnabled():
            return
        username = self.uiUsernameLine.text().strip()
        password = self.uiPasswordLine.text()
        self.uiErrorLbl.clear()
        errmsg = ''
        if not username:
            errmsg += "Username required\n"
        if not password:
            errmsg += "Password required\n"
        if errmsg:
            self.uiErrorLbl.setText(errmsg)
            return

        if self.uiSavePasswordChk.isChecked():
            Settings.setValue(Settings.USERNAME, username)
            Settings.setValue(Settings.PASSWORD, base64.encodestring(password))
        else:
            Settings.setValue(Settings.USERNAME, '')
            Settings.setValue(Settings.PASSWORD, '')
            Settings.setBoolean(Settings.AUTOLOGIN, False)

        self.uiLoginBtn.setEnabled(False)

        if not self.controller.connectTcp():
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QtGui.QMessageBox.warning(self, 'Error', "Cannot connect to fightcade.com")
            self.uiLoginBtn.setEnabled(True)
            return -1

        self.controller.sendWelcome()
        self.controller.sendAuth(username, password)
예제 #21
0
    def login(self):
        if not self.uiLoginBtn.isEnabled():
            return
        username = self.uiUsernameLine.text().strip()
        password = self.uiPasswordLine.text()
        self.uiErrorLbl.clear()
        errmsg = ''
        if not username:
            errmsg += "Username required\n"
        if not password:
            errmsg += "Password required\n"
        if errmsg:
            self.uiErrorLbl.setText(errmsg)
            return

        if self.uiSavePasswordChk.isChecked():
            Settings.setValue(Settings.USERNAME, username)
            Settings.setValue(Settings.PASSWORD, base64.encodestring(password))
        else:
            Settings.setValue(Settings.USERNAME, '')
            Settings.setValue(Settings.PASSWORD, '')
            Settings.setBoolean(Settings.AUTOLOGIN, False)

        self.uiLoginBtn.setEnabled(False)

        if not self.controller.connectTcp():
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QtGui.QMessageBox.warning(self, 'Error',
                                      "Cannot connect to fightcade.com")
            self.uiLoginBtn.setEnabled(True)
            return -1

        self.controller.password = password
        self.controller.sendWelcome()
        self.controller.sendAuth(username, password)
예제 #22
0
    def locateROMsDir(self):
        d = QtGui.QFileDialog.getExistingDirectory(self, "Open Directory",
                                                   os.path.expanduser("~"),
                                                   QtGui.QFileDialog.ShowDirsOnly
                                                   | QtGui.QFileDialog.DontResolveSymlinks)
        if d and os.path.isdir(d):
            Settings.setValue(Settings.ROMS_DIR, d)

        # create FBA ini file and setup ROMs dir
        self.controller.createFbaIni()
        self.controller.setupROMsDir()

        # refresh the channels list
        self.expectFirstChannelResponse = True
        self.controller.sigChannelsLoaded.emit()
예제 #23
0
    def locateROMsDir(self):
        d = QtWidgets.QFileDialog.getExistingDirectory(
            self, "Open Directory", os.path.expanduser("~"),
            QtWidgets.QFileDialog.ShowDirsOnly
            | QtWidgets.QFileDialog.DontResolveSymlinks)
        if d and os.path.isdir(d):
            Settings.setValue(Settings.ROMS_DIR, d)

        # create FBA ini file and setup ROMs dir
        self.controller.createFbaIni()
        self.controller.setupROMsDir()

        # refresh the channels list
        self.expectFirstChannelResponse = True
        self.controller.sigChannelsLoaded.emit()
예제 #24
0
 def setDarkTheme(boolean):
     if boolean:
         qss = ''
         ColorTheme.SELECTED = ColorTheme.DARK
         Settings.setValue(Settings.COLORTHEME, 'darkorange')
         # noinspection PyBroadException
         try:
             qfile = QFile(':qss/darkorange.qss')
             if qfile.open(QIODevice.ReadOnly | QIODevice.Text):
                 qss = str(qfile.readAll())
                 qfile.close()
         except:
             qss = ''
             pass
         QtGui.QApplication.setStyle(ColorTheme.originalStyle)
         QtGui.QApplication.setPalette(ColorTheme.originalPalette)
         QtGui.QApplication.instance().setStyleSheet(qss)
예제 #25
0
 def setDarkTheme(boolean):
     if boolean:
         qss = ''
         ColorTheme.SELECTED = ColorTheme.DARK
         Settings.setValue(Settings.COLORTHEME, 'darkorange')
         # noinspection PyBroadException
         try:
             qfile = QFile(':qss/darkorange.qss')
             if qfile.open(QIODevice.ReadOnly | QIODevice.Text):
                 qss = str(qfile.readAll())
                 qfile.close()
         except:
             qss = ''
             pass
         QtGui.QApplication.setStyle(ColorTheme.originalStyle)
         QtGui.QApplication.setPalette(ColorTheme.originalPalette)
         QtGui.QApplication.instance().setStyleSheet(qss)
예제 #26
0
 def connectTcp(self):
     self.tcpConnected = False
     #noinspection PyBroadException
     try:
         if self.tcpSock:
             self.tcpSock.close()
         self.tcpSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.channelport = Settings.value(Settings.PORT)
         if self.channelport==None:
             self.channelport = 7000
             Settings.setValue(Settings.PORT, int(self.channelport))
         self.tcpSock.connect(('ggpo-ng.com', int(self.channelport),))
         self.tcpConnected = True
     except Exception:
         self.sigStatusMessage.emit("Cannot connect to FightCade server")
         self.sigServerDisconnected.emit()
     return self.tcpConnected
예제 #27
0
 def connectTcp(self):
     self.tcpConnected = False
     #noinspection PyBroadException
     try:
         if self.tcpSock:
             self.tcpSock.close()
         self.tcpSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.channelport = Settings.value(Settings.PORT)
         if self.channelport==None:
             self.channelport = 7000
             Settings.setValue(Settings.PORT, int(self.channelport))
         self.tcpSock.connect(('ggpo-ng.com', int(self.channelport),))
         self.tcpConnected = True
     except Exception:
         self.sigStatusMessage.emit("Cannot connect to FightCade server")
         self.sigServerDisconnected.emit()
     return self.tcpConnected
예제 #28
0
    def locateROMsDir(self):
        d = QtGui.QFileDialog.getExistingDirectory(
            self, "Open Directory", os.path.expanduser("~"),
            QtGui.QFileDialog.ShowDirsOnly
            | QtGui.QFileDialog.DontResolveSymlinks)
        if d and os.path.isdir(d):
            Settings.setValue(Settings.ROMS_DIR, d)

        #on linux & MAC, symlink it to the ROMs folder to avoid configuring FBA
        if not IS_WINDOWS:
            fbaRomPath = os.path.join(
                os.path.abspath(os.path.dirname(sys.argv[0])), "ROMs")
            # remove it if it's a link or an empty dir
            if os.path.islink(fbaRomPath):
                os.remove(fbaRomPath)
            if os.path.isdir(fbaRomPath) and not os.listdir(fbaRomPath):
                os.rmdir(fbaRomPath)
            if not os.path.exists(fbaRomPath):
                os.symlink(d, fbaRomPath)

        # on windows, update fba's ini file with the new location
        if IS_WINDOWS:
            # make sure FBA is not running, otherwise we can't modify the config file
            self.controller.killEmulator()
            fbaIniFile = os.path.join(
                os.path.abspath(os.path.dirname(sys.argv[0])), "config",
                "ggpofba-ng.ini")
            if fbaIniFile and os.path.isfile(fbaIniFile):
                for line in fileinput.input(fbaIniFile,
                                            inplace=True,
                                            backup='.bak'):
                    new = "szAppRomPaths[7] " + str(
                        os.path.join(d.upper(), '') + "\\")
                    sys.stdout.write(re.sub("szAppRomPaths\[7\].*", new, line))
                fileinput.close()

        # refresh the channels list
        self.controller.sigChannelsLoaded.emit()
예제 #29
0
    def AddRemoveFavorites(self):
        it = self.uiChannelsTree.currentItem().text(1)
        bold_font = QtGui.QFont()
        bold_font.setBold(True)
        not_bold_font = QtGui.QFont()
        not_bold_font.setBold(False)

        if not("," + self.channels[it] + "," in self.favorites): # Add favorite
            self.favorites = self.favorites + "," + self.channels[it] + ","
            self.uiChannelsTree.currentItem().setFont(1, bold_font)
        else: # Remove favorite
            self.favorites = self.favorites.replace("," + self.channels[it] + ",",",")
            self.uiChannelsTree.currentItem().setFont(1, not_bold_font)
            if (not self.expectFirstChannelResponse) and Settings.value(Settings.FILTER_FAVORITES): # Update list when removing from the filtered list
                self.expectFirstChannelResponse=True
                self.controller.sigChannelsLoaded.emit()
            self.uiChannelsTree.setCurrentItem(None)

        pattern1 = re.compile(",*,") # trimming unwanted commas
        self.favorites = pattern1.sub(",", self.favorites)
        if self.favorites == ",": # if it's only a comma after RegEx, then clear the favorites
            self.favorites = ""
        Settings.setValue(Settings.CHANNELS_FAVORITES, self.favorites)
예제 #30
0
    def sendJoinChannelRequest(self, channel=None):
        if channel:
            self.channel = channel
            Settings.setValue(Settings.SELECTED_CHANNEL, channel)
            if channel in self.channels:
                if channel != 'lobby':
                    self.rom = self.channels[channel]['rom']
                else:
                    self.rom = ''
            else:
                logdebug().error("Invalid channel {}".format(channel))

        if (int(self.channelport)!=int(self.channels[channel]['port'])):
            self.switchingServer=True
            self.channelport = int(self.channels[channel]['port'])
            Settings.setValue(Settings.PORT, self.channelport)
            self.tcpSock.close()
            self.sequence = 0x1
            self.connectTcp()
            self.sendWelcome()
            self.sendAuth(self.username, self.password)
            if Settings.value(Settings.AWAY):
                self.sendToggleAFK(1)
        self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
예제 #31
0
 def saveGeometrySettings(self):
     Settings.setValue(Settings.SAVESTATES_DIALOG_GEOMETRY, self.saveGeometry())
     Settings.setValue(Settings.SAVESTATES_DIALOG_TABLE_HEADER_STATE,
                       self.uiSavestatesTblv.horizontalHeader().saveState())
예제 #32
0
 def SetChallengeSound(fname):
     Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname)
     ggpo.common.sound.play()
예제 #33
0
 def SetChallengeSound(fname):
     Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname)
     ggpo.common.sound.play()
예제 #34
0
 def onSmoothingToggled(boolean):
     if boolean:
         result = re.search(r'[0-9]+', self.sender().text())
         if result:
             Settings.setValue(Settings.SMOOTHING, result.group(0))
예제 #35
0
 def saveGeometrySettings(self):
     Settings.setValue(Settings.SAVESTATES_DIALOG_GEOMETRY,
                       self.saveGeometry())
     Settings.setValue(Settings.SAVESTATES_DIALOG_TABLE_HEADER_STATE,
                       self.uiSavestatesTblv.horizontalHeader().saveState())
예제 #36
0
 def saveGeometrySettings(self):
     Settings.setValue(Settings.EMOTICON_DIALOG_GEOMETRY,
                       self.saveGeometry())
예제 #37
0
 def saveGeometrySettings(self):
     Settings.setValue(Settings.EMOTICON_DIALOG_GEOMETRY, self.saveGeometry())