diff --git a/charselect.py b/charselect.py index 5311302..b7d9918 100644 --- a/charselect.py +++ b/charselect.py @@ -98,9 +98,14 @@ class charselect(QtGui.QWidget): def populateCharacterDropdown(self): self.charDropdown.clear() self.charDropdown.addItem("") - for char in self.charlist: - self.charDropdown.addItem(char[0]) + model = self.charDropdown.model() self.populated = True + + # Disable characters not in filesystem + # for i, char in enumerate(self.charlist): + # self.charDropdown.addItem(char[0]) + # if not char[3]: + # model.item(i + 1).setEnabled(False) def setCharList(self, charlist): self.charlist = charlist @@ -115,6 +120,10 @@ class charselect(QtGui.QWidget): def prevPageButton(self): self.page -= 1 self.showCharPage() + + def showCharSelect(self, can_cancel = True): + self.show() + self.cancelbtn.setEnabled(can_cancel) def showCharPage(self): for ind in range(self.page * self.max_chars_on_page, self.max_chars_on_page * (self.page+1)): @@ -133,8 +142,6 @@ class charselect(QtGui.QWidget): self.prevpage.hide() char = self.charlist[ind][0].lower() - if not exists(AOpath+"characters/"+ char): - print char, "doesn't exist" if exists(AOpath+"characters/"+ char +"/char_icon.png"): # AO2 self.setBtnImage.emit(AOpath+"characters/"+ char +"/char_icon.png", i) elif exists(AOpath+"misc/demothings/"+ char +"_char_icon.png"): # AO 1.7.5/1.8 @@ -155,13 +162,14 @@ class charselect(QtGui.QWidget): self.buttons[ind].setPixmap(QtGui.QPixmap(filename)) def onCharClicked(self, ind): - if self.parent.charname.lower() == self.charlist[ind + self.page * self.max_chars_on_page][0].lower(): + char = self.charlist[ind + self.page * self.max_chars_on_page] + if self.parent.charname.lower() == char[0].lower(): self.onCancel() return self.selectChar(ind+(self.page*self.max_chars_on_page)) def onDropdownSelect(self, index): - if index == 0 or self.charDropdown.count() == 1: + if index < 1 or self.charDropdown.count() <= 1: return self.selectChar(index - 1) diff --git a/gameview.py b/gameview.py index a1b4fb7..70a6c31 100644 --- a/gameview.py +++ b/gameview.py @@ -1086,18 +1086,20 @@ class gui(QtGui.QWidget): self.prevemotepage.hide() self.nextemotepage = NextEmoteButton(self, 282 + 516, 253+190-28) self.nextemotepage.show() + self.realizationbtn = buttons.AOToggleButton(self, 265 + 164, 192 + 304, "realization") self.realizationbtn.clicked.connect(self.onRealizationButton) self.realizationbtn.setToolTip('Show the next message with a realization effect') self.realizationsnd = audio.loadhandle(False, AOpath + 'sounds/general/sfx-realization.wav', 0, 0, 0) - self.shakebtn = buttons.AOToggleButton(self, 265+42 + 164, 192 + 304, "screenshake") # AO 2.8 self.shakebtn.setToolTip('Show the next message with a shaking effect') self.customobject = buttons.CustomObjection(self, 250 + 516 - 30, 312 + 40) + self.takethatbtn = buttons.Objections(self, 170+ 516 - 20, 312 + 40, 3) self.objectbtn = buttons.Objections(self, 90+ 516 - 10, 312 + 40, 2) self.holditbtn = buttons.Objections(self, 10+ 516, 312 + 40, 1) self.objectsnd = 0 + self.defensebar = buttons.PenaltyBars(self, 1) self.prosecutionbar = buttons.PenaltyBars(self, 2) self.defensebar.minusClicked.connect(self.penaltyBarMinus) @@ -1494,9 +1496,14 @@ class gui(QtGui.QWidget): self.prevemotepage.hide() self.nextemotepage.hide() - total_emotes = ini.read_ini_int(AOpath+"characters/"+self.charname+"/char.ini", "emotions", "number", 1) + total_emotes = len(self.charemotes) + for button in self.emotebuttons: button.hide() + + if not total_emotes: + print "[client] The selected character appears to have no emotions defined" + return total_pages = total_emotes / self.max_emotes_on_page emotes_on_page = 0 @@ -1519,7 +1526,7 @@ class gui(QtGui.QWidget): else: image = QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(n_real_emote + 1) + '_off.png') - if not image.isNull() and image.width() > 40: + if not image.isNull() and not image.width() == 40: self.emotebuttons[n_emote].setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.FastTransformation)) else: self.emotebuttons[n_emote].setPixmap(image) @@ -1726,7 +1733,7 @@ class gui(QtGui.QWidget): def onClick_changeChar(self): #self.tcp.send('RD#%') - self.charselect.show() + self.charselect.showCharSelect() def changeFlipCheck(self, on): if on == 2: @@ -1861,7 +1868,7 @@ class gui(QtGui.QWidget): self.ooclogin.setText("Login") self.login = False self.privateinv = False - self.charselect.populated = False + self.charselect.onDisconnect() self.tcp.close() self.stopMusic() @@ -2980,7 +2987,7 @@ class gui(QtGui.QWidget): if coincidence > -1: self.charselect.selectChar(coincidence) else: - self.charselect.show() + self.charselect.showCharSelect(False) #putting it down here because some servers won't allow you to switch areas without picking a character first autojoinarea = get_option("General", "auto join area").decode('utf-8') @@ -3089,7 +3096,7 @@ class gui(QtGui.QWidget): self.tcpthread.OOC_Log.connect(self.ooclog.append) self.tcpthread.IC_Log.connect(self.icLog.append) self.tcpthread.charSlots.connect(partial(self.charselect.setCharList, self.charlist)) - self.tcpthread.showCharSelect.connect(self.charselect.show) + self.tcpthread.showCharSelect.connect(self.charselect.showCharSelect) self.tcpthread.allEvidence.connect(self.allEvidence) self.tcpthread.updatePlayerList.connect(self.updatePlayerList) self.tcpthread.rainbowColor.connect(self.text.setStyleSheet) diff --git a/mainmenu.py b/mainmenu.py index d2cec7f..605f084 100644 --- a/mainmenu.py +++ b/mainmenu.py @@ -556,7 +556,12 @@ class AOServerInfo(QtCore.QThread): continue del network[0] gotChars = True - charlist = [ [char.split('&')[0].decode('utf-8'), 0, "male"] for char in network ] + charlist = [ [char.split('&')[0].decode('utf-8'), 0, "male", True ] for char in network ] + + # Disable characters not found in filesystem + for char in charlist: + if not exists(AOpath+"characters/" + char[0].lower()): + char[3] = False self.setConnectProgress.emit('Requesting music list (%d)...' % maxmusic) self.tcp.send('RM#%')