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('')
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))
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)
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)
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('')
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)
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)
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)
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)
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))
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)
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)
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))
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()
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))
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()
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()
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
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)
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)
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)
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()
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()
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)
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)
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
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
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()
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)
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))
def saveGeometrySettings(self): Settings.setValue(Settings.SAVESTATES_DIALOG_GEOMETRY, self.saveGeometry()) Settings.setValue(Settings.SAVESTATES_DIALOG_TABLE_HEADER_STATE, self.uiSavestatesTblv.horizontalHeader().saveState())
def SetChallengeSound(fname): Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname) ggpo.common.sound.play()
def SetChallengeSound(fname): Settings.setValue(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION, fname) ggpo.common.sound.play()
def onSmoothingToggled(boolean): if boolean: result = re.search(r'[0-9]+', self.sender().text()) if result: Settings.setValue(Settings.SMOOTHING, result.group(0))
def saveGeometrySettings(self): Settings.setValue(Settings.SAVESTATES_DIALOG_GEOMETRY, self.saveGeometry()) Settings.setValue(Settings.SAVESTATES_DIALOG_TABLE_HEADER_STATE, self.uiSavestatesTblv.horizontalHeader().saveState())
def saveGeometrySettings(self): Settings.setValue(Settings.EMOTICON_DIALOG_GEOMETRY, self.saveGeometry())
def saveGeometrySettings(self): Settings.setValue(Settings.EMOTICON_DIALOG_GEOMETRY, self.saveGeometry())