From 85c01da1fd1f603faf27a69273ea16c1fedc8bad Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Mon, 29 Aug 2011 01:56:44 -0700 Subject: [PATCH] Disable random encounter options when bot is offline --- CHANGELOG.mkdn | 1 + TODO.mkdn | 1 - irc.py | 11 ++++++++++- menus.py | 10 +++++----- pesterchum.py | 7 ++++--- randomer.py | 7 +++++-- themes/pesterchum/style.js | 1 + 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 2c7b108..9428ee4 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -30,6 +30,7 @@ CHANGELOG * Explain why a chumhandle is invalid - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Netsplit notification in memos - Kiooeht [evacipatedBox] * Toast Notifications - Kiooeht [evacipatedBox] +* Disable randomEncounter options when it's offline - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Bug fixes * Don't delete random chum when blocking someone not on chumroll - Kiooeht [evacipatedBox] * Openning global userlist doesn't reset OP status of memo users - Kiooeht [evacipatedBox] diff --git a/TODO.mkdn b/TODO.mkdn index cadbda4..9d536b9 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -17,7 +17,6 @@ Features * When 'banned' make impossible to connect using timestamp banned under * Auto download/install updates via Windows installer * Turn memo notifications on/off from right-click menu on memos (Idea: lostGash) -* Gray out random encounter option when RE is offline Bugs ---- diff --git a/irc.py b/irc.py index f73b9de..cb9a38f 100644 --- a/irc.py +++ b/irc.py @@ -400,8 +400,10 @@ class PesterHandler(DefaultCommandHandler): helpers.nick(self.client, newnick) self.parent.nickCollision.emit(nick, newnick) def quit(self, nick, reason): - #print reason handle = nick[0:nick.find("!")] + logging.info("---> recv \"QUIT %s: %s\"" % (handle, reason)) + if handle == self.parent.mainwindow.randhandler.randNick: + self.parent.mainwindow.randhandler.setRunning(False) server = self.parent.mainwindow.config.server() baseserver = server[server.rfind(".", 0, server.rfind(".")):] if reason.count(baseserver) == 2: @@ -424,6 +426,8 @@ class PesterHandler(DefaultCommandHandler): logging.info("---> recv \"JOIN %s: %s\"" % (handle, channel)) self.parent.userPresentUpdate.emit(handle, channel, "join") if channel == "#pesterchum": + if handle == self.parent.mainwindow.randhandler.randNick: + self.parent.mainwindow.randhandler.setRunning(True) self.parent.moodUpdated.emit(handle, Mood("chummy")) def mode(self, op, channel, mode, *handles): if len(handles) <= 0: handles = [""] @@ -463,6 +467,10 @@ class PesterHandler(DefaultCommandHandler): self.parent.userPresentUpdate.emit("%s:%s" % (oldhandle, newnick), "", "nick") if newnick in self.mainwindow.chumList.chums: self.getMood(newchum) + if oldhandle == self.parent.mainwindow.randhandler.randNick: + self.parent.mainwindow.randhandler.setRunning(False) + elif newnick == self.parent.mainwindow.randhandler.randNick: + self.parent.mainwindow.randhandler.setRunning(True) def namreply(self, server, nick, op, channel, names): namelist = names.split(" ") logging.info("---> recv \"NAMES %s: %d names\"" % (channel, len(namelist))) @@ -478,6 +486,7 @@ class PesterHandler(DefaultCommandHandler): self.parent.namesReceived.emit(channel, pl) if channel == "#pesterchum" and not hasattr(self, "joined"): self.joined = True + self.parent.mainwindow.randhandler.setRunning(self.parent.mainwindow.randhandler.randNick in namelist) chums = self.mainwindow.chumList.chums lesschums = [] for c in chums: diff --git a/menus.py b/menus.py index f595ac0..8701211 100644 --- a/menus.py +++ b/menus.py @@ -1140,9 +1140,10 @@ class PesterOptions(QtGui.QDialog): self.mspaCheck = QtGui.QCheckBox("Check for MSPA Updates", self) self.mspaCheck.setChecked(self.config.checkMSPA()) - if parent.randhandler.running: - self.randomscheck = QtGui.QCheckBox("Receive Random Encounters") - self.randomscheck.setChecked(parent.userprofile.randoms) + self.randomscheck = QtGui.QCheckBox("Receive Random Encounters") + self.randomscheck.setChecked(parent.userprofile.randoms) + if not parent.randhandler.running: + self.randomscheck.setEnabled(False) avail_themes = self.config.availableThemes() self.themeBox = QtGui.QComboBox(self) @@ -1246,8 +1247,7 @@ class PesterOptions(QtGui.QDialog): if not ostools.isOSXBundle(): layout_chat.addWidget(self.animationscheck) layout_chat.addWidget(animateLabel) - if parent.randhandler.running: - layout_chat.addWidget(self.randomscheck) + layout_chat.addWidget(self.randomscheck) # Re-enable these when it's possible to disable User and Memo links #layout_chat.addWidget(hr) #layout_chat.addWidget(QtGui.QLabel("User and Memo Links")) diff --git a/pesterchum.py b/pesterchum.py index df0a56b..8853d5c 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -1663,8 +1663,9 @@ class PesterWindow(MovingWindow): filemenu.addAction(opts) filemenu.addAction(memoaction) filemenu.addAction(logv) - if self.randhandler.running: - filemenu.addAction(self.rand) + filemenu.addAction(self.rand) + if not self.randhandler.running: + self.rand.setEnabled(False) filemenu.addAction(userlistaction) filemenu.addAction(self.idleaction) filemenu.addAction(grps) @@ -2072,7 +2073,7 @@ class PesterWindow(MovingWindow): self.backgroundImage = QtGui.QPixmap(theme["main/background-image"]) self.backgroundMask = self.backgroundImage.mask() self.setMask(self.backgroundMask) - self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s }" % (theme["main/menu/style"], theme["main/menu/selected"])) + self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"])) newcloseicon = PesterIcon(theme["main/close/image"]) self.closeButton.setIcon(newcloseicon) self.closeButton.setIconSize(newcloseicon.realsize()) diff --git a/randomer.py b/randomer.py index 54c2c7f..ff9564e 100644 --- a/randomer.py +++ b/randomer.py @@ -6,8 +6,11 @@ class RandomHandler(QtCore.QObject): self.randNick = "randomEncounter" self.mainwindow = parent self.queue = [] - # Make True when Lex's new randomEncounter bot (C++) is online - self.running = True + self.running = False + + def setRunning(self, on): + self.running = on + self.mainwindow.rand.setEnabled(on) def getRandomer(self): self.queue.append("?") diff --git a/themes/pesterchum/style.js b/themes/pesterchum/style.js index a3139ae..14108df 100644 --- a/themes/pesterchum/style.js +++ b/themes/pesterchum/style.js @@ -13,6 +13,7 @@ "menu" : { "style": "font-family: 'Courier'; font: bold; font-size: 12px; color: black; background-color: #fdb302;border:2px solid #ffff00", "menuitem": "margin-right:10px;", "selected": "background-color: #ffff00", + "disabled": "color: grey", "loc": [10,0] }, "sounds": { "alertsound": "$path/alarm.wav",