make judge buttons and health bars skinnable
This commit is contained in:
parent
8d3272f90b
commit
6289b2a834
@ -2,7 +2,7 @@
|
||||
# window size is defined at the end of the file
|
||||
|
||||
# IC viewport
|
||||
_scale = 2
|
||||
_scale = 2.5
|
||||
self.viewport.setGeometry(0, 0, 256 * _scale, 192 * _scale)
|
||||
|
||||
# Textbox
|
||||
@ -110,10 +110,14 @@ self.cbSpacing.move(self.cbMockText.x(), self.cbMockText.y()+24)
|
||||
self.cbAutoCaps.move(self.cbSpacing.x(), self.cbSpacing.y()+24)
|
||||
|
||||
# Judge options
|
||||
self.btnDefenseBar.moveBar(self.gameTabs.x() + self.gameTabs.width() + 11, viewportBottom + 61)
|
||||
self.btnProsecutionBar.moveBar(self.btnDefenseBar.x(), viewportBottom + 75)
|
||||
self.btnDefenseBar.setGeometry(self.gameTabs.x() + self.gameTabs.width() + 11, viewportBottom + 61, 84, 14)
|
||||
self.btnProsecutionBar.setGeometry(self.btnDefenseBar.x(), viewportBottom + 75, 84, 14)
|
||||
self.btnRealization.move(self.btnDefenseBar.x(), viewportBottom + 89)
|
||||
self.btnShake.move(self.btnRealization.x() + self.btnRealization.width(), self.btnRealization.y())
|
||||
self.btnDefenseBar.btnMinus.move(self.btnDefenseBar.x() - (9/2), self.btnDefenseBar.y() + (14/2) - (9/2))
|
||||
self.btnDefenseBar.btnPlus.move(self.btnDefenseBar.x() + 84 - (9/2), self.btnDefenseBar.y() + (14/2) - (9/2))
|
||||
self.btnProsecutionBar.btnMinus.move(self.btnProsecutionBar.x() - (9/2), self.btnProsecutionBar.y() + (14/2) - (9/2))
|
||||
self.btnProsecutionBar.btnPlus.move(self.btnProsecutionBar.x() + 84 - (9/2), self.btnProsecutionBar.y() + (14/2) - (9/2))
|
||||
|
||||
self.btnWitnessTestimony.move(self.btnDefenseBar.x(), viewportBottom + 137)
|
||||
self.btnCrossExamination.move(self.btnWitnessTestimony.x(), self.btnWitnessTestimony.y() + self.btnWitnessTestimony.size().height())
|
||||
|
||||
128
buttons.py
128
buttons.py
@ -50,12 +50,24 @@ class CustomObjection(QtGui.QLabel):
|
||||
def __init__(self, parent):
|
||||
super(CustomObjection, self).__init__(parent)
|
||||
self.parent = parent
|
||||
self.resize(76, 28)
|
||||
self.notpressed_pix = QtGui.QPixmap(AO2XPpath + "themes/default/custom.png")
|
||||
self.pressed_pix = QtGui.QPixmap(AO2XPpath + "themes/default/custom_selected.png")
|
||||
self.setPixmap(self.notpressed_pix)
|
||||
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:
|
||||
@ -79,18 +91,30 @@ class WTCEbuttons(QtGui.QLabel):
|
||||
variant = 0
|
||||
def __init__(self, parent, type, variant=0):
|
||||
super(WTCEbuttons, self).__init__(parent)
|
||||
self.resize(85, 42)
|
||||
if type == 0:
|
||||
self.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/witnesstestimony.png"))
|
||||
elif type == 1:
|
||||
self.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/crossexamination.png"))
|
||||
elif type == 2:
|
||||
if variant == 0:
|
||||
self.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/notguilty.png"))
|
||||
elif variant == 1:
|
||||
self.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/guilty.png"))
|
||||
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)
|
||||
@ -154,7 +178,7 @@ class Objections(QtGui.QLabel):
|
||||
self.clicked.emit()
|
||||
|
||||
class PixmapButton(QtGui.QAbstractButton):
|
||||
def __init__(self, parent, pixmap):
|
||||
def __init__(self, parent, pixmap = None):
|
||||
super(PixmapButton, self).__init__(parent)
|
||||
self.pixmap = pixmap
|
||||
|
||||
@ -162,8 +186,11 @@ class PixmapButton(QtGui.QAbstractButton):
|
||||
painter = QtGui.QPainter(self)
|
||||
painter.drawPixmap(event.rect(), self.pixmap)
|
||||
|
||||
def sizeHint(self):
|
||||
return self.pixmap.size()
|
||||
# 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
|
||||
@ -192,29 +219,50 @@ class PenaltyBars(QtGui.QLabel):
|
||||
self.penaltybars = []
|
||||
self.type = type
|
||||
self.health = 10
|
||||
self.resize(84, 14)
|
||||
if type == 1: #defense bar.
|
||||
for i in range(11):
|
||||
self.penaltybars.append(QtGui.QPixmap(AO2XPpath + "themes/default/defensebar"+str(i)+".png"))
|
||||
side = "def"
|
||||
elif type == 2: #prosecution bar
|
||||
for i in range(11):
|
||||
self.penaltybars.append(QtGui.QPixmap(AO2XPpath + "themes/default/prosecutionbar"+str(i)+".png"))
|
||||
side = "pro"
|
||||
self.side = side
|
||||
self.minusbtn = PixmapButton(parent, QtGui.QPixmap(AO2XPpath + "themes/default/" + side + "minus.png"))
|
||||
self.plusbtn = PixmapButton(parent, QtGui.QPixmap(AO2XPpath + "themes/default/" + side + "plus.png"))
|
||||
self.minusbtn.clicked.connect(self.minusClick)
|
||||
self.plusbtn.clicked.connect(self.plusClick)
|
||||
self.setPixmap(self.penaltybars[10])
|
||||
self.minusbtn.show()
|
||||
self.plusbtn.show()
|
||||
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 moveBar(self, x, y):
|
||||
self.move(x, y)
|
||||
self.minusbtn.move(x-(9/2), y+(14/2)-(9/2))
|
||||
self.plusbtn.move(x+84-(9/2), y+(14/2)-(9/2))
|
||||
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)
|
||||
@ -223,8 +271,8 @@ class PenaltyBars(QtGui.QLabel):
|
||||
self.minusClicked.emit(self.type)
|
||||
|
||||
def setHealth(self, health):
|
||||
self.minusbtn.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/"+self.side+"minus.png"))
|
||||
self.plusbtn.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/"+self.side+"plus.png"))
|
||||
self.btnMinus.setPixmap(self.pixMinus)
|
||||
self.btnPlus.setPixmap(self.pixPlus)
|
||||
self.setPixmap(self.penaltybars[health])
|
||||
self.health = health
|
||||
|
||||
|
||||
55
gameview.py
55
gameview.py
@ -1717,7 +1717,7 @@ class GUI(QtGui.QWidget):
|
||||
|
||||
def loadTheme(self, switching=False):
|
||||
theme = getOption("General", "theme", "default")
|
||||
try:
|
||||
# try:
|
||||
stylesheet = ""
|
||||
self.emotePageGeometry = []
|
||||
self.gamewindow.setStyleSheet("")
|
||||
@ -1731,11 +1731,13 @@ class GUI(QtGui.QWidget):
|
||||
stack.setAutoFillBackground(False)
|
||||
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, True)
|
||||
|
||||
self.btnRealization.setPixmaps(theme)
|
||||
self.btnShake.setPixmaps(theme)
|
||||
self.btnObjection.setPixmaps(theme)
|
||||
self.btnTakeThat.setPixmaps(theme)
|
||||
self.btnHoldIt.setPixmaps(theme)
|
||||
for btn in [self.btnRealization, self.btnShake,
|
||||
self.btnCustomObjection, self.btnObjection,
|
||||
self.btnTakeThat, self.btnHoldIt, self.btnGuilty,
|
||||
self.btnNotGuilty, self.btnWitnessTestimony,
|
||||
self.btnCrossExamination, self.btnDefenseBar,
|
||||
self.btnProsecutionBar]:
|
||||
btn.setPixmaps(theme)
|
||||
|
||||
# Design
|
||||
courtroomDesign = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_design.ini'
|
||||
@ -1774,6 +1776,8 @@ class GUI(QtGui.QWidget):
|
||||
"message": self.text,
|
||||
"showname": self.name,
|
||||
"music_list": self.serverTabs,
|
||||
"defense_bar": self.btnDefenseBar,
|
||||
"prosecution_bar": self.btnProsecutionBar,
|
||||
}
|
||||
|
||||
move = {
|
||||
@ -1794,11 +1798,10 @@ class GUI(QtGui.QWidget):
|
||||
"guilty": self.btnGuilty,
|
||||
"witness_testimony": self.btnWitnessTestimony,
|
||||
"cross_examination": self.btnCrossExamination,
|
||||
}
|
||||
|
||||
bars = {
|
||||
"defense_bar": self.btnDefenseBar,
|
||||
"prosecution_bar": self.btnProsecutionBar
|
||||
"defense_plus": self.btnDefenseBar.btnPlus,
|
||||
"defense_minus": self.btnDefenseBar.btnMinus,
|
||||
"prosecution_plus": self.btnProsecutionBar.btnPlus,
|
||||
"prosecution_minus": self.btnProsecutionBar.btnMinus,
|
||||
}
|
||||
|
||||
for e in geometry.keys():
|
||||
@ -1809,10 +1812,6 @@ class GUI(QtGui.QWidget):
|
||||
if e in design:
|
||||
move[e].move(*[int(x) for x in design[e]][0:2])
|
||||
|
||||
for e in bars.keys():
|
||||
if e in design:
|
||||
bars[e].moveBar(*[int(x) for x in design[e]][0:2])
|
||||
|
||||
if "emotes" in design:
|
||||
self.emotePageGeometry = [int(x) for x in design["emotes"]]
|
||||
else:
|
||||
@ -1972,9 +1971,9 @@ class GUI(QtGui.QWidget):
|
||||
self.setEmotePage()
|
||||
self.gamewindow.setFixedSize(self.width, self.height)
|
||||
self.gamewindow.center()
|
||||
except Exception as e:
|
||||
QtGui.QMessageBox.critical(None, "Unable to load theme", "There was a problem loading the current theme \"%s\":\n\n%s." % (theme, e))
|
||||
os._exit(-2)
|
||||
# except Exception as e:
|
||||
# QtGui.QMessageBox.critical(None, "Unable to load theme", "There was a problem loading the current theme \"%s\":\n\n%s." % (theme, e))
|
||||
# os._exit(-2)
|
||||
|
||||
def resetPairOffsets(self):
|
||||
self.sliPairOffset.setValue(0)
|
||||
@ -2072,19 +2071,19 @@ class GUI(QtGui.QWidget):
|
||||
|
||||
def setJudgeButtons(self):
|
||||
if self.charSide == 'jud':
|
||||
self.btnDefenseBar.minusbtn.show()
|
||||
self.btnDefenseBar.plusbtn.show()
|
||||
self.btnProsecutionBar.minusbtn.show()
|
||||
self.btnProsecutionBar.plusbtn.show()
|
||||
self.btnDefenseBar.btnMinus.show()
|
||||
self.btnDefenseBar.btnPlus.show()
|
||||
self.btnProsecutionBar.btnMinus.show()
|
||||
self.btnProsecutionBar.btnPlus.show()
|
||||
self.btnWitnessTestimony.show()
|
||||
self.btnCrossExamination.show()
|
||||
self.btnNotGuilty.show()
|
||||
self.btnGuilty.show()
|
||||
else:
|
||||
self.btnDefenseBar.minusbtn.hide()
|
||||
self.btnDefenseBar.plusbtn.hide()
|
||||
self.btnProsecutionBar.minusbtn.hide()
|
||||
self.btnProsecutionBar.plusbtn.hide()
|
||||
self.btnDefenseBar.btnMinus.hide()
|
||||
self.btnDefenseBar.btnPlus.hide()
|
||||
self.btnProsecutionBar.btnMinus.hide()
|
||||
self.btnProsecutionBar.btnPlus.hide()
|
||||
self.btnWitnessTestimony.hide()
|
||||
self.btnCrossExamination.hide()
|
||||
self.btnNotGuilty.hide()
|
||||
@ -4520,8 +4519,8 @@ class GUI(QtGui.QWidget):
|
||||
self.cbFlip, self.cbPreanim, self.cbNoInterrupt,
|
||||
self.boxEffects, self.cbSlide, self.cbBench,
|
||||
self.cbAdditive, self.areaItems, self.shownameEdit,
|
||||
self.boxColors, self.btnDefenseBar.minusbtn, self.btnProsecutionBar.minusbtn,
|
||||
self.btnDefenseBar.plusbtn, self.btnProsecutionBar.plusbtn, self.btnWitnessTestimony,
|
||||
self.boxColors, self.btnDefenseBar.btnMinus, self.btnProsecutionBar.btnMinus,
|
||||
self.btnDefenseBar.btnPlus, self.btnProsecutionBar.btnPlus, self.btnWitnessTestimony,
|
||||
self.btnCrossExamination, self.btnNotGuilty, self.btnGuilty,
|
||||
self.btnRealization, self.btnShake,
|
||||
]:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user