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 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 __init__(self, parent=None): super(LoginDialog, self).__init__(parent) # ggpo.gui.loadUi(__file__, self) self.setupUi(self) self.uiNewVersionLink.clicked.connect( lambda: openURL('https://github.com/doctorguile/pyqtggpo/releases')) self.uiNewVersionLink.setVisible(False) versionLabel = 'v' + copyright.versionString() self.uiVersionLbl.setText(versionLabel) self.controller = None if Settings.value(Settings.SAVE_USERNAME_PASSWORD): self.uiSavePasswordChk.setChecked(True) if Settings.value(Settings.AUTOLOGIN): self.uiAutologinChk.setChecked(True) username = Settings.value(Settings.USERNAME) password = Settings.value(Settings.PASSWORD) serverAddress = Settings.value(Settings.SERVER_ADDRESS) or 'ggpo.net' if username: self.uiUsernameLine.setText(username) if password: self.uiPasswordLine.setText(base64.decodestring(password)) self.uiServerLine.setText(serverAddress) self.uiSavePasswordChk.toggled.connect(self.savePassword) self.uiUsernameLine.returnPressed.connect(self.login) self.uiPasswordLine.returnPressed.connect(self.login) self.uiServerLine.returnPressed.connect(self.login) self.uiLoginBtn.clicked.connect(self.login) self.uiRegisterLink.clicked.connect( lambda: openURL('http://ggpo.net/forums/ucp.php?mode=register'))
def setupMenuSettings(self): self.uiMuteChallengeSoundAct.toggled.connect(self.__class__.toggleSound) self.uiFontAct.triggered.connect(self.changeFont) self.setupMenuTheme() self.setupMenuSmoothing() self.uiCustomEmoticonsAct.triggered.connect(self.setCustomEmoticons) self.uiLocateGgpofbaAct.triggered.connect(self.locateGGPOFBA) if IS_WINDOWS: self.uiLocateWineAct.setVisible(False) else: self.uiLocateWineAct.triggered.connect(self.locateWine) self.uiLocateUnsupportedSavestatesDirAct.triggered.connect(self.locateUnsupportedSavestatesDirAct) self.uiLocateCustomChallengeSoundAct.triggered.connect(self.locateCustomChallengeSound) if GeoIP2Reader: self.uiLocateGeommdbAct.triggered.connect(self.locateGeoMMDB) else: self.uiLocateGeommdbAct.setVisible(False) self.uiNotifyPlayerStateChangeAct.toggled.connect(self.__class__.toggleNotifyPlayerStateChange) self.uiShowCountryFlagInChatAct.toggled.connect(self.__class__.toggleShowCountryFlagInChat) self.uiShowTimestampInChatAct.toggled.connect(self.__class__.toggleShowTimestampInChatAct) self.uiDisableAutoAnnounceAct.toggled.connect(self.__class__.toggleDisableAutoAnnounceUnsupported) if Settings.value(Settings.DEBUG_LOG): self.uiDebugLogAct.setChecked(True) if Settings.value(Settings.USER_LOG_CHAT): self.uiLogChatAct.setChecked(True) if Settings.value(Settings.USER_LOG_PLAYHISTORY): self.uiLogPlayHistoryAct.setChecked(True) self.uiDebugLogAct.triggered.connect(self.__class__.logdebugTriggered) self.uiLogChatAct.triggered.connect(self.__class__.loguserChatTriggered) self.uiLogPlayHistoryAct.triggered.connect(self.__class__.loguserPlayHistoryTriggered)
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 restoreStateAndGeometry(self): saved = Settings.value(Settings.SAVESTATES_DIALOG_GEOMETRY) if saved: self.restoreGeometry(saved) saved = Settings.value(Settings.SAVESTATES_DIALOG_TABLE_HEADER_STATE) if saved: self.uiSavestatesTblv.horizontalHeader().restoreState(saved)
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 __init__(self, *args, **kwargs): super(EmoticonDialog, self).__init__(*args, **kwargs) saved = Settings.value(Settings.EMOTICON_DIALOG_GEOMETRY) if saved: self.restoreGeometry(saved) self._value = '' flowLayout = FlowLayout(self) customEmoticons = Settings.value(Settings.CUSTOM_EMOTICONS) if customEmoticons: customEmoticons = filter(None, [ line.strip() for line in customEmoticons.split("\n") if 0 < len(line) < 64 ]) else: customEmoticons = [] for emoticon in customEmoticons + _emoticons.split("\n"): act = QtGui.QAction(emoticon, self) act.triggered.connect(self.onActionTriggered) btn = QtGui.QToolButton(self) btn.setDefaultAction(act) flowLayout.addWidget(btn) self.setLayout(flowLayout) self.setWindowTitle("Insert emoticon") self.accepted.connect(self.saveGeometrySettings) self.finished.connect(self.saveGeometrySettings) self.rejected.connect(self.saveGeometrySettings)
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 setupMenuSettings(self): self.uiMuteChallengeSoundAct.toggled.connect(self.__class__.toggleSound) self.uiMuteNotifySoundAct.toggled.connect(self.__class__.toggleNotifySound) self.uiFontAct.triggered.connect(self.changeFont) self.setupMenuTheme() self.setupMenuSmoothing() self.setupMenuChallengeSound() self.uiCustomEmoticonsAct.triggered.connect(self.setCustomEmoticons) #self.uiLocateGgpofbaAct.triggered.connect(self.locateGGPOFBA) self.uiLocateROMsAct.triggered.connect(self.locateROMsDir) #self.uiLocateUnsupportedSavestatesDirAct.triggered.connect(self.locateUnsupportedSavestatesDirAct) self.uiLocateCustomChallengeSoundAct.triggered.connect(self.locateCustomChallengeSound) #if GeoIP2Reader: # self.uiLocateGeommdbAct.triggered.connect(self.locateGeoMMDB) #else: # self.uiLocateGeommdbAct.setVisible(False) self.uiNotifyPlayerStateChangeAct.toggled.connect(self.__class__.toggleNotifyPlayerStateChange) self.uiShowCountryFlagInChatAct.toggled.connect(self.__class__.toggleShowCountryFlagInChat) self.uiShowTimestampInChatAct.toggled.connect(self.__class__.toggleShowTimestampInChatAct) #self.uiDisableAutoAnnounceAct.toggled.connect(self.__class__.toggleDisableAutoAnnounceUnsupported) self.uiDisableAutoColorNicks.toggled.connect(self.__class__.toggleDisableAutoColorNicks) self.uiHideGamesWithoutRomAct.toggled.connect(self.toggleHideGamesWithoutRomAct) self.uiFilterFavoriteLobbies.toggled.connect(self.toggleFilterFavoriteLobbies) if Settings.value(Settings.DEBUG_LOG): self.uiDebugLogAct.setChecked(True) if Settings.value(Settings.USER_LOG_CHAT): self.uiLogChatAct.setChecked(True) if Settings.value(Settings.USER_LOG_PLAYHISTORY): self.uiLogPlayHistoryAct.setChecked(True) self.uiDebugLogAct.triggered.connect(self.__class__.logdebugTriggered) self.uiLogChatAct.triggered.connect(self.__class__.loguserChatTriggered) self.uiLogPlayHistoryAct.triggered.connect(self.__class__.loguserPlayHistoryTriggered)
def __init__(self, QWidget_parent=None): super(GGPOWindow, self).__init__(QWidget_parent) self.setupUi(self) self.controller = None self.channels = {} self.expectFirstChannelResponse = True self.lastSplitterExpandedSizes = [] self.lastStateChangeMsg = '' self.uiChatInputEdit.returnPressed.connect(self.returnPressed) self.setupMenu() self.uiEmoticonTbtn.setDefaultAction(self.uiEmoticonAct) self.uiEmoticonTbtn.setText(':)') self.addSplitterHandleToggleButton() self.uiChatHistoryTxtB.anchorClicked.connect(self.onAnchorClicked) self.autoAnnounceUnsupportedTime = 0 self.refreshChannelsListTime = time.time() self.refreshListUsersTime = time.time() self.savestatesChecked = False if Settings.value(Settings.CHANNELS_FAVORITES) != None: # default value if it's not present in config file self.favorites = Settings.value(Settings.CHANNELS_FAVORITES) else: self.favorites = '' self.showfavorites=False if Settings.value(Settings.FILTER_FAVORITES): self.showfavorites = True self.hidemissing = False if Settings.value(Settings.HIDE_GAMES_WITHOUT_ROM): self.hidemissing = True self.uiChannelsTree.itemDoubleClicked.connect(self.AddRemoveFavorites) # call to double click handler
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 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 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 __init__(self, *args, **kwargs): super(EmoticonDialog, self).__init__(*args, **kwargs) saved = Settings.value(Settings.EMOTICON_DIALOG_GEOMETRY) if saved: self.restoreGeometry(saved) self._value = '' flowLayout = FlowLayout(self) customEmoticons = Settings.value(Settings.CUSTOM_EMOTICONS) if customEmoticons: customEmoticons = filter(None, [line.strip() for line in customEmoticons.split("\n") if 0 < len(line) < 64]) else: customEmoticons = [] for emoticon in customEmoticons + _emoticons.split("\n"): act = QtGui.QAction(emoticon, self) act.triggered.connect(self.onActionTriggered) btn = QtGui.QToolButton(self) btn.setDefaultAction(act) flowLayout.addWidget(btn) self.setLayout(flowLayout) self.setWindowTitle("Insert emoticon") self.accepted.connect(self.saveGeometrySettings) self.finished.connect(self.saveGeometrySettings) self.rejected.connect(self.saveGeometrySettings)
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 __init__(self, parent=None): super(LoginDialog, self).__init__(parent) # ggpo.gui.loadUi(__file__, self) if IS_WINDOWS: download_url = 'http://www.fightcade.com/download/windows' if IS_OSX: download_url = 'http://www.fightcade.com/download/osx' if IS_LINUX: download_url = 'http://www.fightcade.com/download/linux' self.setupUi(self) self.uiNewVersionLink.clicked.connect(lambda: openURL(download_url)) self.uiNewVersionLink.setVisible(False) self.uiRegisterLink.setVisible(False) versionLabel = 'v' + copyright.versionString() self.uiVersionLbl.setText(versionLabel) self.controller = None if Settings.value(Settings.SAVE_USERNAME_PASSWORD): self.uiSavePasswordChk.setChecked(True) username = Settings.value(Settings.USERNAME) password = Settings.value(Settings.PASSWORD) if username: self.uiUsernameLine.setText(username) if password: self.uiPasswordLine.setText(base64.decodestring(password)) if not username and not password: self.uiRegisterLink.setVisible(True) self.uiSavePasswordChk.toggled.connect(self.savePassword) self.uiUsernameLine.returnPressed.connect(self.login) self.uiPasswordLine.returnPressed.connect(self.login) self.uiLoginBtn.clicked.connect(self.login) self.uiRegisterLink.clicked.connect( lambda: openURL('http://www.fightcade.com/#register'))
def __init__(self, parent=None): super(LoginDialog, self).__init__(parent) # ggpo.gui.loadUi(__file__, self) if IS_WINDOWS: download_url='http://www.fightcade.com/download/windows' if IS_OSX: download_url='http://www.fightcade.com/download/osx' if IS_LINUX: download_url='http://www.fightcade.com/download/linux' self.setupUi(self) self.uiNewVersionLink.clicked.connect( lambda: openURL(download_url)) self.uiNewVersionLink.setVisible(False) self.uiRegisterLink.setVisible(False) versionLabel = 'v' + copyright.versionString() self.uiVersionLbl.setText(versionLabel) self.controller = None if Settings.value(Settings.SAVE_USERNAME_PASSWORD): self.uiSavePasswordChk.setChecked(True) username = Settings.value(Settings.USERNAME) password = Settings.value(Settings.PASSWORD) if username: self.uiUsernameLine.setText(username) if password: self.uiPasswordLine.setText(base64.decodestring(password)) if not username and not password: self.uiRegisterLink.setVisible(True) self.uiSavePasswordChk.toggled.connect(self.savePassword) self.uiUsernameLine.returnPressed.connect(self.login) self.uiPasswordLine.returnPressed.connect(self.login) self.uiLoginBtn.clicked.connect(self.login) self.uiRegisterLink.clicked.connect( lambda: openURL('http://www.fightcade.com/#register'))
def __init__(self, QWidget_parent=None): super(GGPOWindow, self).__init__(QWidget_parent) self.setupUi(self) self.controller = None self.channels = {} self.expectFirstChannelResponse = True self.lastSplitterExpandedSizes = [] self.lastStateChangeMsg = '' self.uiChatInputEdit.returnPressed.connect(self.returnPressed) self.setupMenu() self.uiEmoticonTbtn.setDefaultAction(self.uiEmoticonAct) self.uiEmoticonTbtn.setText(':)') self.addSplitterHandleToggleButton() self.uiChatHistoryTxtB.anchorClicked.connect(self.onAnchorClicked) self.autoAnnounceUnsupportedTime = 0 self.refreshChannelsListTime = time.time() self.refreshListUsersTime = time.time() self.savestatesChecked = False if Settings.value( Settings.CHANNELS_FAVORITES ) != None: # default value if it's not present in config file self.favorites = Settings.value(Settings.CHANNELS_FAVORITES) else: self.favorites = '' self.showfavorites = False if Settings.value(Settings.FILTER_FAVORITES): self.showfavorites = True self.hidemissing = False if Settings.value(Settings.HIDE_GAMES_WITHOUT_ROM): self.hidemissing = True self.uiChannelsTree.itemDoubleClicked.connect( self.AddRemoveFavorites) # call to double click handler
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 sendToggleAFK(self, afk): if afk: val = 1 state = True else: val = 0 state = False self.sendAndRemember(Protocol.TOGGLE_AFK, Protocol.packInt(val)) Settings.setBoolean(Settings.AWAY, state)
def wavfile(): filename = Settings.value(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION) if filename and os.path.isfile(filename): return filename fba = Settings.value(Settings.GGPOFBA_LOCATION) if fba: filename = os.path.join(os.path.dirname(fba), "assets", "challenger-comes.wav") if os.path.isfile(filename): return filename
def saveSetting(self, extID, key, val): """ Store an object in the application settings file. Args: extID: ID of the calling extension key: string key. Needs only to be unique within the extension val: picklable object """ Settings.setPythonValue("EXT%s%s" % (extID, key), val)
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 changeFont(self): font, ok = QtWidgets.QFontDialog.getFont() if ok: Settings.setPythonValue(Settings.CHAT_HISTORY_FONT, [ font.family(), font.pointSize(), font.weight(), font.italic() ]) self.uiChatHistoryTxtB.setFont(font)
def logdebugTriggered(value): if value: level = logging.INFO else: level = logging.ERROR Settings.setBoolean(Settings.DEBUG_LOG, value) for handler in logdebug().handlers: if isinstance(handler, logging.handlers.RotatingFileHandler): handler.setLevel(level) break
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 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 runFBA(self, quark): if not self.checkRom(): return if not self.fba: self.sigStatusMessage.emit( "Please configure Setting > Locate ggpofba.exe") return wine = '' args = [] fba = self.fba if IS_WINDOWS: if Settings.value(Settings.SERVER_ADDRESS) == 'ggpo.net': ngexe = os.path.join(os.path.dirname(fba), 'ggpofba-ng.exe') if os.path.exists(ngexe): fba = ngexe args = [fba, quark, '-w'] else: wine = findWine() if Settings.value(Settings.SERVER_ADDRESS) != 'ggpo.net': fba = fba.replace('.exe', '.py') if IS_LINUX: args = [ packagePathJoin('ggpo', 'scripts', 'ggpofba.sh'), fba, quark ] else: args = [fba, quark] else: if not wine: self.sigStatusMessage.emit( "Please configure Setting > Locate wine") return if IS_LINUX: args = [ packagePathJoin('ggpo', 'scripts', 'ggpofba.sh'), wine, fba, quark ] else: args = [wine, fba, quark] logdebug().info(" ".join(args)) try: # starting python from cmd.exe and redirect stderr and we got # python WindowsError(6, 'The handle is invalid') # apparently it's still not fixed if IS_WINDOWS: Popen(args) else: devnull = open(os.devnull, 'w') Popen(args, stdout=devnull, stderr=devnull) devnull.close() except OSError, ex: self.sigStatusMessage.emit("Error executing " + " ".join(args) + "\n" + repr(ex))
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 restoreStateAndGeometry(self): saved = Settings.value(Settings.WINDOW_GEOMETRY) if saved: self.restoreGeometry(saved) saved = Settings.value(Settings.WINDOW_STATE) if saved: self.restoreState(saved) saved = Settings.value(Settings.SPLITTER_STATE) if saved: self.uiSplitter.restoreState(saved) saved = Settings.value(Settings.TABLE_HEADER_STATE) if saved: self.uiPlayersTableV.horizontalHeader().restoreState(saved)
def restorePreference(self): theme = Settings.value(Settings.COLORTHEME) if theme: if theme == 'darkorange': self.uiDarkThemeAct.setChecked(True) elif theme == 'custom': fname = Settings.value(Settings.CUSTOM_THEME_FILENAME) self.setCustomQssfile(fname) else: cleanname = self.buildInStyleToActionName(theme) if hasattr(self, cleanname): getattr(self, cleanname).setChecked(True) smooth = Settings.value(Settings.SMOOTHING) if smooth: cleanname = self.buildInSmoothingToActionName(smooth) if hasattr(self, cleanname): getattr(self, cleanname).setChecked(True) if Settings.value(Settings.MUTE_CHALLENGE_SOUND): self.uiMuteChallengeSoundAct.setChecked(True) if Settings.value(Settings.NOTIFY_PLAYER_STATE_CHANGE): self.uiNotifyPlayerStateChangeAct.setChecked(True) if Settings.value(Settings.SHOW_COUNTRY_FLAG_IN_CHAT): self.uiShowCountryFlagInChatAct.setChecked(True) if Settings.value(Settings.SHOW_TIMESTAMP_IN_CHAT): self.uiShowTimestampInChatAct.setChecked(True) fontsetting = Settings.pythonValue(Settings.CHAT_HISTORY_FONT) if fontsetting: self.uiChatHistoryTxtB.setFont(QtGui.QFont(*fontsetting)) self.restoreStateAndGeometry()
def main(argv=None): app = None started = False # create the application if necessary if not QtGui.QApplication.instance(): app = QtGui.QApplication(argv) app.setQuitOnLastWindowClosed(True) app.setOrganizationName("FightCade") QtCore.QCoreApplication.setApplicationName("FightCade") ColorTheme.saveDefaultStyle() if not Settings.value(Settings.COLORTHEME) or Settings.value( Settings.COLORTHEME) == 'fightcade' or Settings.value( Settings.COLORTHEME) == 'ggpong': ColorTheme.setGNGTheme(True) controller = Controller() thread = QtCore.QThread() controller.moveToThread(thread) thread.started.connect(controller.selectLoop) thread.start() def loggedIn(): if started == False: window = GGPOWindow() window.setWindowIcon(QtGui.QIcon(':/assets/icon-128.png')) window.setController(controller) window.restorePreference() controller.sendListChannels() window.show() window.raise_() window.activateWindow() UDP = False port = 6009 while True: UDP = controller.connectUdp(port) port = port - 1 if (UDP == True or port < 6006): break logindialog = LoginDialog() logindialog.setController(controller) logindialog.accepted.connect(loggedIn) logindialog.rejected.connect(sys.exit) logindialog.exec_() logindialog.raise_() logindialog.activateWindow() started = True return app.exec_()
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 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 main(argv=None): app = None # create the application if necessary if not QtGui.QApplication.instance(): app = QtGui.QApplication(argv) app.setQuitOnLastWindowClosed(True) app.setOrganizationName("FightCade") QtCore.QCoreApplication.setApplicationName("FightCade") ColorTheme.saveDefaultStyle() if ( not Settings.value(Settings.COLORTHEME) or Settings.value(Settings.COLORTHEME) == "fightcade" or Settings.value(Settings.COLORTHEME) == "ggpong" ): ColorTheme.setGNGTheme(True) controller = Controller() thread = QtCore.QThread() controller.moveToThread(thread) thread.started.connect(controller.selectLoop) thread.start() def loggedIn(): UDP = False port = 6009 while True: UDP = controller.connectUdp(port) port = port - 1 if UDP == True or port < 6006: break window = GGPOWindow() window.setWindowIcon(QtGui.QIcon(":/assets/icon-128.png")) window.setController(controller) window.restorePreference() controller.sendListChannels() window.show() window.raise_() window.activateWindow() logindialog = LoginDialog() logindialog.setController(controller) logindialog.accepted.connect(loggedIn) logindialog.rejected.connect(sys.exit) logindialog.exec_() logindialog.raise_() logindialog.activateWindow() return app.exec_()
def loggerInit(): debuglog = logging.getLogger('GGPODebug') debuglog.setLevel(logging.INFO) fh = logging.handlers.RotatingFileHandler( os.path.join(expanduser("~"), 'fightcade-debug.log'), mode='a', maxBytes=500000, backupCount=10) if Settings.value(Settings.DEBUG_LOG): fh.setLevel(logging.INFO) else: fh.setLevel(logging.ERROR) ch = logging.StreamHandler() ch.setLevel(logging.ERROR) debuglog.addHandler(fh) debuglog.addHandler(ch) def handle_exception(exc_type, exc_value, exc_traceback): if issubclass(exc_type, KeyboardInterrupt): sys.__excepthook__(exc_type, exc_value, exc_traceback) return debuglog.error("<Uncaught exception>", exc_info=(exc_type, exc_value, exc_traceback)) sys.excepthook = handle_exception if __name__ == "__main__": raise RuntimeError("Test unhandled") userlog = logging.getLogger('GGPOUser') userlog.setLevel(logging.INFO) fh = logging.handlers.RotatingFileHandler( os.path.join(expanduser("~"), 'fightcade.log'), mode='a', maxBytes=500000, backupCount=10) fh.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(message)s', "%Y-%m-%d %H:%M") fh.setFormatter(formatter) userlog.addHandler(fh)
def __init__(self, *args, **kwargs): super(CustomEmoticonsDialog, self).__init__(*args, **kwargs) self.setupUi(self) customEmoticons = Settings.value(Settings.CUSTOM_EMOTICONS) if customEmoticons: self.uiEmoticonTextEdit.setPlainText(customEmoticons) self.accepted.connect(self.onAccepted)
def __init__(self): super(Controller, self).__init__() self.selectTimeout = 1 self.sequence = 0x1 self.tcpSock = None self.tcpConnected = False self.tcpData = '' self.tcpReadState = self.STATE_TCP_READ_LEN self.tcpResponseLen = 0 self.tcpCommandsWaitingForResponse = dict() self.udpSock = None self.udpConnected = False self.selectLoopRunning = True self.username = '' self.channel = 'lobby' self.rom = '' self.fba = None self.checkInstallation() self.unsupportedRom = '' self.checkUnsupportedRom() self.playingagainst = '' self.challengers = set() self.challenged = None self.channels = {} self.pinglist = {} self.players = {} self.available = {} self.playing = {} self.awayfromkb = {} self.ignored = Settings.pythonValue(Settings.IGNORED) or set() self.sigStatusMessage.connect(logdebug().info)