diff --git a/buttons.py b/buttons.py index eb92e80..c9ba2a1 100644 --- a/buttons.py +++ b/buttons.py @@ -199,3 +199,84 @@ class PenaltyBars(QtGui.QLabel): def getHealth(self): return self.health + +class PresentButton(QtGui.QLabel): + def __init__(self, gamegui, parent): + super(PresentButton, self).__init__(parent) + self.gamegui = gamegui + self.button_off = QtGui.QPixmap(AO2XPpath + 'themes/default/present_disabled.png') + self.button_on = QtGui.QPixmap(AO2XPpath + 'themes/default/present.png') + self.setPixmap(self.button_off) + self.show() + + def mousePressEvent(self, event): + self.gamegui.present = not self.gamegui.present + if self.gamegui.present: + self.setPixmap(self.button_on) + else: + self.setPixmap(self.button_off) + self.gamegui.icchat_focus() + +class EmoteButton(QtGui.QLabel): + clicked = QtCore.pyqtSignal() + + def __init__(self, gamewindow, x, y, id): + super(EmoteButton, self).__init__(gamewindow) + self.gamewindow = gamewindow + self.resize(40, 40) + self.move(x, y) + self.emoteid = id + self.path = '' + + def paintEvent(self, event): + if self.gamewindow.mychar == -1: + return + + painter = QtGui.QPainter(self) + painter.setRenderHint(QtGui.QPainter.TextAntialiasing, False) + painter.setPen(QtGui.QColor(255, 255, 255)) + font = QtGui.QFont("Tahoma", 8) + font.setStyle(QtGui.QFont.StyleNormal) + font.setWeight(QtGui.QFont.Normal) + painter.setFont(font) + + if self.pixmap(): + if self.pixmap().isNull(): + button_img = QtGui.QPixmap(self.path + '_off.png') + painter.setOpacity(0.5) + painter.drawPixmap(0, 0, button_img) + else: + painter.drawPixmap(0, 0, self.pixmap()) + else: + painter.fillRect(0, 0, 39, 39, QtGui.QColor(0, 0, 0)) + painter.drawText(1, 1, str(self.emoteid)) + + def mousePressEvent(self, event): + self.gamewindow.changeEmote(False, self.emoteid) + self.clicked.emit() + +class BackEmoteButton(QtGui.QLabel): + + def __init__(self, gamewindow, x, y): + super(BackEmoteButton, self).__init__(gamewindow) + self.gamewindow = gamewindow + self.move(x, y) + self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_left.png')) + self.show() + + def mousePressEvent(self, event): + self.gamewindow.current_emote_page -= 1 + self.gamewindow.set_emote_page() + +class NextEmoteButton(QtGui.QLabel): + + def __init__(self, gamewindow, x, y): + super(NextEmoteButton, self).__init__(gamewindow) + self.gamewindow = gamewindow + self.move(x, y) + self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_right.png')) + self.show() + + def mousePressEvent(self, event): + self.gamewindow.current_emote_page += 1 + self.gamewindow.set_emote_page() diff --git a/gameview.py b/gameview.py index 89064a8..2daf01a 100644 --- a/gameview.py +++ b/gameview.py @@ -1029,7 +1029,7 @@ class gui(QtGui.QWidget): self.evidenceswitchglobal.setToolTip('Switch to the global inventory') self.evidenceswitchglobal.clicked.connect(self.onSwitchInventory) - self.evidencepresent = PresentButton(self, self.gametab_evidence) + self.evidencepresent = buttons.PresentButton(self, self.gametab_evidence) self.privatedropdown.hide() self.evidencemoveglobal.hide() @@ -1216,7 +1216,7 @@ class gui(QtGui.QWidget): for i in range(self.max_emotes_on_page): x_pos = (40 + spacing) * x_mod_count y_pos = (40 + spacing) * y_mod_count - button = EmoteButton(self, left + x_pos, top + y_pos, i) + button = buttons.EmoteButton(self, left + x_pos, top + y_pos, i) button.clicked.connect(self.icchat_focus) self.emotebuttons.append(button) x_mod_count += 1 @@ -1226,9 +1226,9 @@ class gui(QtGui.QWidget): self.emotebuttons[i].show() self.current_emote_page = 0 - self.prevemotepage = BackEmoteButton(self, 520, 253+190-28) + self.prevemotepage = buttons.BackEmoteButton(self, 520, 253+190-28) self.prevemotepage.hide() - self.nextemotepage = NextEmoteButton(self, 282 + 516, 253+190-28) + self.nextemotepage = buttons.NextEmoteButton(self, 282 + 516, 253+190-28) self.nextemotepage.show() self.realizationbtn = buttons.AOToggleButton(self, 265 + 164, 192 + 304, "realization") @@ -2068,6 +2068,7 @@ class gui(QtGui.QWidget): self.playerList.clear() self.playerKick.setDisabled(True) self.playerBan.setDisabled(True) + self.demo_recorder = None self.ooclogin.setText("Lo&gin") self.login = False self.privateinv = False @@ -3753,23 +3754,6 @@ class TCP_Thread(QtCore.QThread): def stop(self): self.stop_now = True - -class PresentButton(QtGui.QLabel): - def __init__(self, gamegui, parent): - super(PresentButton, self).__init__(parent) - self.gamegui = gamegui - self.button_off = QtGui.QPixmap(AO2XPpath + 'themes/default/present_disabled.png') - self.button_on = QtGui.QPixmap(AO2XPpath + 'themes/default/present.png') - self.setPixmap(self.button_off) - self.show() - - def mousePressEvent(self, event): - self.gamegui.present = not self.gamegui.present - if self.gamegui.present: - self.setPixmap(self.button_on) - else: - self.setPixmap(self.button_off) - self.gamegui.icchat_focus() class EditEvidenceDialog(QtGui.QDialog): def __init__(self, gamegui): @@ -3910,67 +3894,3 @@ class EditEvidenceDialog(QtGui.QDialog): def setTitle(self): self.setWindowTitle('Add evidence' if not self.gamegui.privateinv else "Add evidence to private inventory") - -class EmoteButton(QtGui.QLabel): - clicked = QtCore.pyqtSignal() - - def __init__(self, gamewindow, x, y, id): - super(EmoteButton, self).__init__(gamewindow) - self.gamewindow = gamewindow - self.resize(40, 40) - self.move(x, y) - self.emoteid = id - self.path = '' - - def paintEvent(self, event): - if self.gamewindow.mychar == -1: - return - - painter = QtGui.QPainter(self) - painter.setRenderHint(QtGui.QPainter.TextAntialiasing, False) - painter.setPen(QtGui.QColor(255, 255, 255)) - font = QtGui.QFont("Tahoma", 8) - font.setStyle(QtGui.QFont.StyleNormal) - font.setWeight(QtGui.QFont.Normal) - painter.setFont(font) - - if self.pixmap(): - if self.pixmap().isNull(): - button_img = QtGui.QPixmap(self.path + '_off.png') - painter.setOpacity(0.5) - painter.drawPixmap(0, 0, button_img) - else: - painter.drawPixmap(0, 0, self.pixmap()) - else: - painter.fillRect(0, 0, 39, 39, QtGui.QColor(0, 0, 0)) - painter.drawText(1, 1, str(self.emoteid)) - - def mousePressEvent(self, event): - self.gamewindow.changeEmote(False, self.emoteid) - self.clicked.emit() - -class BackEmoteButton(QtGui.QLabel): - - def __init__(self, gamewindow, x, y): - super(BackEmoteButton, self).__init__(gamewindow) - self.gamewindow = gamewindow - self.move(x, y) - self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_left.png')) - self.show() - - def mousePressEvent(self, event): - self.gamewindow.current_emote_page -= 1 - self.gamewindow.set_emote_page() - -class NextEmoteButton(QtGui.QLabel): - - def __init__(self, gamewindow, x, y): - super(NextEmoteButton, self).__init__(gamewindow) - self.gamewindow = gamewindow - self.move(x, y) - self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_right.png')) - self.show() - - def mousePressEvent(self, event): - self.gamewindow.current_emote_page += 1 - self.gamewindow.set_emote_page()