362 lines
12 KiB
Python
362 lines
12 KiB
Python
from PyQt4 import QtCore, QtGui
|
|
import os
|
|
from constants import *
|
|
|
|
def testPath(*args):
|
|
for path in args:
|
|
if os.path.exists(path):
|
|
return path
|
|
return False
|
|
|
|
class AOToggleButton(QtGui.QLabel):
|
|
pressed = False
|
|
clicked = QtCore.pyqtSignal()
|
|
|
|
def __init__(self, parent, btnname):
|
|
super(AOToggleButton, self).__init__(parent)
|
|
self.notpressed_pix = None
|
|
self.pressed_pix = None
|
|
self.name = btnname
|
|
self.show()
|
|
|
|
def setPixmaps(self, theme):
|
|
self.pressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%s_pressed.png" % (theme, self.name),
|
|
AO2XPpath + "themes/default/%s_pressed.png" % self.name,
|
|
))
|
|
self.notpressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%s.png" % (theme, self.name),
|
|
AO2XPpath + "themes/default/%s.png" % self.name,
|
|
))
|
|
self.setPixmap(self.pressed_pix if self.pressed else self.notpressed_pix)
|
|
|
|
def move(self, x, y):
|
|
self.setGeometry(x, y, self.notpressed_pix.size().width(), self.notpressed_pix.size().height())
|
|
|
|
def setPressed(self, on):
|
|
self.pressed = on
|
|
self.setPixmap(self.pressed_pix if on else self.notpressed_pix)
|
|
|
|
def isPressed(self):
|
|
return self.pressed
|
|
|
|
def mousePressEvent(self, event):
|
|
self.setPressed(not self.isPressed())
|
|
self.clicked.emit()
|
|
|
|
class CustomObjection(QtGui.QLabel):
|
|
pressed = False
|
|
clicked = QtCore.pyqtSignal()
|
|
def __init__(self, parent):
|
|
super(CustomObjection, self).__init__(parent)
|
|
self.parent = parent
|
|
self.notpressed_pix = None
|
|
self.pressed_pix = None
|
|
self.show()
|
|
|
|
def setPixmaps(self, theme):
|
|
self.pressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/custom_selected.png" % theme,
|
|
AO2XPpath + "themes/default/custom_selected.png",
|
|
))
|
|
self.notpressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/custom.png" % theme,
|
|
AO2XPpath + "themes/default/custom.png",
|
|
))
|
|
self.setPixmap(self.pressed_pix if self.pressed else self.notpressed_pix)
|
|
|
|
def move(self, x, y):
|
|
self.setGeometry(x, y, self.notpressed_pix.size().width(), self.notpressed_pix.size().height())
|
|
|
|
def setPressed(self, on):
|
|
self.pressed = on
|
|
if on:
|
|
self.setPixmap(self.pressed_pix)
|
|
else:
|
|
self.setPixmap(self.notpressed_pix)
|
|
|
|
def isPressed(self):
|
|
return self.pressed
|
|
|
|
def mousePressEvent(self, event):
|
|
self.setPressed(not self.isPressed())
|
|
self.parent.btnObjection.setPressed(False)
|
|
self.parent.btnHoldIt.setPressed(False)
|
|
self.parent.btnTakeThat.setPressed(False)
|
|
self.clicked.emit()
|
|
|
|
class WTCEbuttons(QtGui.QLabel):
|
|
clicked = QtCore.pyqtSignal(int, int)
|
|
type = 0
|
|
variant = 0
|
|
def __init__(self, parent, type, variant=0):
|
|
super(WTCEbuttons, self).__init__(parent)
|
|
self.type = type
|
|
self.variant = variant
|
|
self.pix = None
|
|
|
|
def setPixmaps(self, theme):
|
|
name = ""
|
|
if self.type == 0:
|
|
name = "witnesstestimony"
|
|
elif self.type == 1:
|
|
name = "crossexamination"
|
|
elif self.type == 2:
|
|
if self.variant == 0:
|
|
name = "notguilty"
|
|
else:
|
|
name = "guilty"
|
|
|
|
self.pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%s.png" % (theme, name),
|
|
AO2XPpath + "themes/default/%s.png" % name,
|
|
))
|
|
self.setPixmap(self.pix)
|
|
|
|
def move(self, x, y):
|
|
self.setGeometry(x, y, self.pix.size().width(), self.pix.size().height())
|
|
|
|
def mousePressEvent(self, event):
|
|
self.clicked.emit(self.type, self.variant)
|
|
|
|
class Objections(QtGui.QLabel):
|
|
pressed = False
|
|
type = 0
|
|
clicked = QtCore.pyqtSignal()
|
|
def __init__(self, parent, type):
|
|
super(Objections, self).__init__(parent)
|
|
self.parent = parent
|
|
self.type = type
|
|
self.notpressed_pix = None
|
|
self.pressed_pix = None
|
|
self.show()
|
|
|
|
def setPixmaps(self, theme):
|
|
name = ""
|
|
if self.type == 1:
|
|
name = "holdit"
|
|
elif self.type == 2:
|
|
name = "objection"
|
|
elif self.type == 3:
|
|
name = "takethat"
|
|
|
|
self.pressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%s_selected.png" % (theme, name),
|
|
AO2XPpath + "themes/default/%s_selected.png" % name,
|
|
))
|
|
self.notpressed_pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%s.png" % (theme, name),
|
|
AO2XPpath + "themes/default/%s.png" % name,
|
|
))
|
|
self.setPixmap(self.pressed_pix if self.pressed else self.notpressed_pix)
|
|
|
|
def move(self, x, y):
|
|
self.setGeometry(x, y, self.notpressed_pix.size().width(), self.notpressed_pix.size().height())
|
|
|
|
def setPressed(self, on):
|
|
self.pressed = on
|
|
if on:
|
|
self.setPixmap(self.pressed_pix)
|
|
else:
|
|
self.setPixmap(self.notpressed_pix)
|
|
|
|
def isPressed(self):
|
|
return self.pressed
|
|
|
|
def mousePressEvent(self, event):
|
|
self.setPressed(not self.isPressed())
|
|
self.parent.btnCustomObjection.setPressed(False)
|
|
if self.type == 1:
|
|
self.parent.btnObjection.setPressed(False)
|
|
self.parent.btnTakeThat.setPressed(False)
|
|
elif self.type == 2:
|
|
self.parent.btnHoldIt.setPressed(False)
|
|
self.parent.btnTakeThat.setPressed(False)
|
|
elif self.type == 3:
|
|
self.parent.btnObjection.setPressed(False)
|
|
self.parent.btnHoldIt.setPressed(False)
|
|
self.clicked.emit()
|
|
|
|
class PixmapButton(QtGui.QAbstractButton):
|
|
def __init__(self, parent, pixmap = None):
|
|
super(PixmapButton, self).__init__(parent)
|
|
self.pixmap = pixmap
|
|
|
|
def paintEvent(self, event):
|
|
painter = QtGui.QPainter(self)
|
|
painter.drawPixmap(event.rect(), self.pixmap)
|
|
|
|
# def sizeHint(self):
|
|
# return self.pixmap.size() if self.pixmap else None
|
|
|
|
def move(self, x, y):
|
|
self.setGeometry(x, y, self.pixmap.size().width(), self.pixmap.size().height())
|
|
|
|
def setPixmap(self, pixmap):
|
|
self.pixmap = pixmap
|
|
|
|
class PixmapButton2(QtGui.QLabel):
|
|
clicked = QtCore.pyqtSignal()
|
|
rightClicked = QtCore.pyqtSignal()
|
|
|
|
def __init__(self, parent, pixmap):
|
|
super(PixmapButton2, self).__init__(parent)
|
|
self.setPixmap(pixmap)
|
|
self.show()
|
|
|
|
def mousePressEvent(self, ev):
|
|
if ev.buttons() == QtCore.Qt.LeftButton:
|
|
self.clicked.emit()
|
|
elif ev.buttons() == QtCore.Qt.RightButton:
|
|
self.rightClicked.emit()
|
|
|
|
class PenaltyBars(QtGui.QLabel):
|
|
minusClicked = QtCore.pyqtSignal(int)
|
|
plusClicked = QtCore.pyqtSignal(int)
|
|
def __init__(self, parent, type):
|
|
super(PenaltyBars, self).__init__(parent)
|
|
self.parent = parent
|
|
self.penaltybars = []
|
|
self.type = type
|
|
self.health = 10
|
|
self.side = "def" if self.type == 1 else "pro"
|
|
self.btnMinus = PixmapButton(parent)
|
|
self.btnPlus = PixmapButton(parent)
|
|
self.btnMinus.clicked.connect(self.minusClick)
|
|
self.btnPlus.clicked.connect(self.plusClick)
|
|
self.btnMinus.show()
|
|
self.btnPlus.show()
|
|
self.pixMinus = None
|
|
self.pixPlus = None
|
|
self.setScaledContents(True)
|
|
self.show()
|
|
|
|
def setPixmaps(self, theme):
|
|
del self.penaltybars[:]
|
|
self.penaltybars = []
|
|
if self.type == 1:
|
|
for i in range(11):
|
|
pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/defensebar%s.png" % (theme, i),
|
|
AO2XPpath + "themes/default/defensebar%s.png" % i
|
|
))
|
|
self.penaltybars.append(pix)
|
|
elif self.type == 2:
|
|
for i in range(11):
|
|
pix = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/prosecutionbar%s.png" % (theme, i),
|
|
AO2XPpath + "themes/default/prosecutionbar%s.png" % i
|
|
))
|
|
self.penaltybars.append(pix)
|
|
self.setPixmap(self.penaltybars[self.health])
|
|
|
|
self.pixMinus = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%sminus.png" % (theme, self.side),
|
|
AO2XPpath + "themes/default/%sminus.png" % self.side
|
|
))
|
|
self.pixPlus = QtGui.QPixmap(testPath(
|
|
AO2XPpath + "ao2xp_themes/%s/%splus.png" % (theme, self.side),
|
|
AO2XPpath + "themes/default/%splus.png" % self.side
|
|
))
|
|
self.btnMinus.setPixmap(self.pixMinus)
|
|
self.btnPlus.setPixmap(self.pixPlus)
|
|
|
|
# def setGeometry(self, x, y):
|
|
# super(PenaltyBars, self).setGeometry(x, y, self.penaltybars[0].size().width(), self.penaltybars[0].size().height())
|
|
|
|
def plusClick(self):
|
|
self.plusClicked.emit(self.type)
|
|
|
|
def minusClick(self):
|
|
self.minusClicked.emit(self.type)
|
|
|
|
def setHealth(self, health):
|
|
self.btnMinus.setPixmap(self.pixMinus)
|
|
self.btnPlus.setPixmap(self.pixPlus)
|
|
self.setPixmap(self.penaltybars[health])
|
|
self.health = health
|
|
|
|
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.ICChatFocus()
|
|
|
|
class EmoteButton(QtGui.QLabel):
|
|
clicked = QtCore.pyqtSignal()
|
|
|
|
def __init__(self, gamewindow, id):
|
|
super(EmoteButton, self).__init__(gamewindow)
|
|
self.gamewindow = gamewindow
|
|
self.resize(40, 40)
|
|
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)
|
|
if not button_img.width() == 40:
|
|
painter.drawPixmap(0, 0, button_img.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation))
|
|
else:
|
|
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):
|
|
super(BackEmoteButton, self).__init__(gamewindow)
|
|
self.gamewindow = gamewindow
|
|
self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_left.png'))
|
|
self.show()
|
|
|
|
def mousePressEvent(self, event):
|
|
self.gamewindow.currentEmotePage -= 1
|
|
self.gamewindow.setEmotePage()
|
|
|
|
class NextEmoteButton(QtGui.QLabel):
|
|
|
|
def __init__(self, gamewindow):
|
|
super(NextEmoteButton, self).__init__(gamewindow)
|
|
self.gamewindow = gamewindow
|
|
self.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/arrow_right.png'))
|
|
self.show()
|
|
|
|
def mousePressEvent(self, event):
|
|
self.gamewindow.currentEmotePage += 1
|
|
self.gamewindow.setEmotePage()
|