make judge buttons and health bars skinnable

This commit is contained in:
cidoku 2025-10-11 20:44:57 -03:00
parent 8d3272f90b
commit 6289b2a834
3 changed files with 348 additions and 297 deletions

View File

@ -2,7 +2,7 @@
# window size is defined at the end of the file # window size is defined at the end of the file
# IC viewport # IC viewport
_scale = 2 _scale = 2.5
self.viewport.setGeometry(0, 0, 256 * _scale, 192 * _scale) self.viewport.setGeometry(0, 0, 256 * _scale, 192 * _scale)
# Textbox # 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) self.cbAutoCaps.move(self.cbSpacing.x(), self.cbSpacing.y()+24)
# Judge options # Judge options
self.btnDefenseBar.moveBar(self.gameTabs.x() + self.gameTabs.width() + 11, viewportBottom + 61) self.btnDefenseBar.setGeometry(self.gameTabs.x() + self.gameTabs.width() + 11, viewportBottom + 61, 84, 14)
self.btnProsecutionBar.moveBar(self.btnDefenseBar.x(), viewportBottom + 75) self.btnProsecutionBar.setGeometry(self.btnDefenseBar.x(), viewportBottom + 75, 84, 14)
self.btnRealization.move(self.btnDefenseBar.x(), viewportBottom + 89) self.btnRealization.move(self.btnDefenseBar.x(), viewportBottom + 89)
self.btnShake.move(self.btnRealization.x() + self.btnRealization.width(), self.btnRealization.y()) 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.btnWitnessTestimony.move(self.btnDefenseBar.x(), viewportBottom + 137)
self.btnCrossExamination.move(self.btnWitnessTestimony.x(), self.btnWitnessTestimony.y() + self.btnWitnessTestimony.size().height()) self.btnCrossExamination.move(self.btnWitnessTestimony.x(), self.btnWitnessTestimony.y() + self.btnWitnessTestimony.size().height())

View File

@ -50,11 +50,23 @@ class CustomObjection(QtGui.QLabel):
def __init__(self, parent): def __init__(self, parent):
super(CustomObjection, self).__init__(parent) super(CustomObjection, self).__init__(parent)
self.parent = parent self.parent = parent
self.resize(76, 28) self.notpressed_pix = None
self.notpressed_pix = QtGui.QPixmap(AO2XPpath + "themes/default/custom.png") self.pressed_pix = None
self.pressed_pix = QtGui.QPixmap(AO2XPpath + "themes/default/custom_selected.png")
self.setPixmap(self.notpressed_pix)
self.show() 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): def setPressed(self, on):
self.pressed = on self.pressed = on
@ -79,18 +91,30 @@ class WTCEbuttons(QtGui.QLabel):
variant = 0 variant = 0
def __init__(self, parent, type, variant=0): def __init__(self, parent, type, variant=0):
super(WTCEbuttons, self).__init__(parent) 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.type = type
self.variant = variant 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): def mousePressEvent(self, event):
self.clicked.emit(self.type, self.variant) self.clicked.emit(self.type, self.variant)
@ -154,7 +178,7 @@ class Objections(QtGui.QLabel):
self.clicked.emit() self.clicked.emit()
class PixmapButton(QtGui.QAbstractButton): class PixmapButton(QtGui.QAbstractButton):
def __init__(self, parent, pixmap): def __init__(self, parent, pixmap = None):
super(PixmapButton, self).__init__(parent) super(PixmapButton, self).__init__(parent)
self.pixmap = pixmap self.pixmap = pixmap
@ -162,8 +186,11 @@ class PixmapButton(QtGui.QAbstractButton):
painter = QtGui.QPainter(self) painter = QtGui.QPainter(self)
painter.drawPixmap(event.rect(), self.pixmap) painter.drawPixmap(event.rect(), self.pixmap)
def sizeHint(self): # def sizeHint(self):
return self.pixmap.size() # 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): def setPixmap(self, pixmap):
self.pixmap = pixmap self.pixmap = pixmap
@ -192,29 +219,50 @@ class PenaltyBars(QtGui.QLabel):
self.penaltybars = [] self.penaltybars = []
self.type = type self.type = type
self.health = 10 self.health = 10
self.resize(84, 14) self.side = "def" if self.type == 1 else "pro"
if type == 1: #defense bar. self.btnMinus = PixmapButton(parent)
for i in range(11): self.btnPlus = PixmapButton(parent)
self.penaltybars.append(QtGui.QPixmap(AO2XPpath + "themes/default/defensebar"+str(i)+".png")) self.btnMinus.clicked.connect(self.minusClick)
side = "def" self.btnPlus.clicked.connect(self.plusClick)
elif type == 2: #prosecution bar self.btnMinus.show()
for i in range(11): self.btnPlus.show()
self.penaltybars.append(QtGui.QPixmap(AO2XPpath + "themes/default/prosecutionbar"+str(i)+".png")) self.pixMinus = None
side = "pro" self.pixPlus = None
self.side = side self.setScaledContents(True)
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.show() 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 moveBar(self, x, y): # def setGeometry(self, x, y):
self.move(x, y) # super(PenaltyBars, self).setGeometry(x, y, self.penaltybars[0].size().width(), self.penaltybars[0].size().height())
self.minusbtn.move(x-(9/2), y+(14/2)-(9/2))
self.plusbtn.move(x+84-(9/2), y+(14/2)-(9/2))
def plusClick(self): def plusClick(self):
self.plusClicked.emit(self.type) self.plusClicked.emit(self.type)
@ -223,8 +271,8 @@ class PenaltyBars(QtGui.QLabel):
self.minusClicked.emit(self.type) self.minusClicked.emit(self.type)
def setHealth(self, health): def setHealth(self, health):
self.minusbtn.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/"+self.side+"minus.png")) self.btnMinus.setPixmap(self.pixMinus)
self.plusbtn.setPixmap(QtGui.QPixmap(AO2XPpath + "themes/default/"+self.side+"plus.png")) self.btnPlus.setPixmap(self.pixPlus)
self.setPixmap(self.penaltybars[health]) self.setPixmap(self.penaltybars[health])
self.health = health self.health = health

View File

@ -1717,264 +1717,263 @@ class GUI(QtGui.QWidget):
def loadTheme(self, switching=False): def loadTheme(self, switching=False):
theme = getOption("General", "theme", "default") theme = getOption("General", "theme", "default")
try: # try:
stylesheet = "" stylesheet = ""
self.emotePageGeometry = [] self.emotePageGeometry = []
self.gamewindow.setStyleSheet("") self.gamewindow.setStyleSheet("")
self.chatbox.resetGeometry() self.chatbox.resetGeometry()
self.btnReloadTheme.setVisible(False) self.btnReloadTheme.setVisible(False)
self.cbBench.setVisible(True) self.cbBench.setVisible(True)
self.cbSlide.setVisible(True) self.cbSlide.setVisible(True)
for w in [self.gameTabs, self.serverTabs]:
stack = w.findChild(QtGui.QStackedWidget)
if stack:
stack.setAutoFillBackground(False)
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, True)
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'
if exists(courtroomDesign):
design = {}
with open(courtroomDesign) as f:
for keys in f.read().split("\n"):
if not keys or "=" not in keys or keys[0] == ";": continue
key, value = keys.split("=")
design[key.strip()] = value.replace(" ", "").split(',')
geometry = {
"viewport": self.viewport,
"ic_chatlog": self.gameTabs,
"server_chatlog": self.OOCLog,
"ooc_chat_name": self.OOCNameInput,
"ooc_chat_message": self.OOCInput,
"music_label": self.lblMusicVolume,
"sfx_label": self.lblSoundVolume,
"blip_label": self.lblBlipsVolume,
"music_slider": self.sliMusicVolume,
"sfx_slider": self.sliSoundVolume,
"blip_slider": self.sliBlipsVolume,
"emote_dropdown": self.boxEmotes,
"effects_dropdown": self.boxEffects,
"pos_dropdown": self.boxPositions,
"text_color": self.boxColors,
"change_character": self.btnChangeChar,
"call_mod": self.btnCallMod,
"reload_theme": self.btnReloadTheme,
"ic_chat_name": self.shownameEdit,
"settings": self.btnSettings,
"ao2_chatbox": self.chatbox,
"ao2_ic_chat_message": self.ICChatInput,
"message": self.text,
"showname": self.name,
"music_list": self.serverTabs,
"defense_bar": self.btnDefenseBar,
"prosecution_bar": self.btnProsecutionBar,
}
move = {
"pre": self.cbPreanim,
"flip": self.cbFlip,
"additive": self.cbAdditive,
"slide_enable": self.cbSlide,
"pre_no_interrupt": self.cbNoInterrupt,
"hold_it": self.btnHoldIt,
"objection": self.btnObjection,
"take_that": self.btnTakeThat,
"custom_objection": self.btnCustomObjection,
"emote_left": self.btnPrevEmotePage,
"emote_right": self.btnNextEmotePage,
"realization": self.btnRealization,
"screenshake": self.btnShake,
"not_guilty": self.btnNotGuilty,
"guilty": self.btnGuilty,
"witness_testimony": self.btnWitnessTestimony,
"cross_examination": self.btnCrossExamination,
"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():
if e in design:
geometry[e].setGeometry(*[int(x) for x in design[e]])
for e in move.keys():
if e in design:
move[e].move(*[int(x) for x in design[e]][0:2])
if "emotes" in design:
self.emotePageGeometry = [int(x) for x in design["emotes"]]
else:
self.emotePageGeometry = [0, 0, 0, 0]
if "emote_button_spacing" in design:
self.emotePageGeometry += [int(x) for x in design["emote_button_spacing"]]
else:
self.emotePageGeometry += [1, 1]
if "found_song_color" in design:
self.foundSongItemColor = QtGui.QColor(*[int(x) for x in design["found_song_color"]])
self.cbSlide.setVisible("slide_enable" in design)
self.cbBench.setVisible("ao2xp_desk" in design)
self.btnReloadTheme.setVisible(True)
# TODO: Load script common to all themes
QtGui.QApplication.setStyle('plastique')
for w in [self.gameTabs, self.serverTabs]: for w in [self.gameTabs, self.serverTabs]:
stack = w.findChild(QtGui.QStackedWidget) stack = w.findChild(QtGui.QStackedWidget)
if stack: if stack:
stack.setAutoFillBackground(False) stack.setAutoFillBackground(False)
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, True)
else:
self.btnRealization.setPixmaps(theme) QtGui.QApplication.setStyle(self.defaultStyle)
self.btnShake.setPixmaps(theme) for w in [self.gameTabs, self.serverTabs]:
self.btnObjection.setPixmaps(theme) stack = w.findChild(QtGui.QStackedWidget)
self.btnTakeThat.setPixmaps(theme) if stack:
self.btnHoldIt.setPixmaps(theme) stack.setAutoFillBackground(True)
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
# Design
courtroomDesign = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_design.ini'
if exists(courtroomDesign):
design = {}
with open(courtroomDesign) as f:
for keys in f.read().split("\n"):
if not keys or "=" not in keys or keys[0] == ";": continue
key, value = keys.split("=") with open(AO2XPpath + "ao2xp_themes/" + theme + "/theme.py") as t:
design[key.strip()] = value.replace(" ", "").split(',') exec t
if switching:
geometry = { # This is to reset the colors on the music list. Not necessary on startup
"viewport": self.viewport, self.onMusicSearch("")
"ic_chatlog": self.gameTabs,
"server_chatlog": self.OOCLog,
"ooc_chat_name": self.OOCNameInput,
"ooc_chat_message": self.OOCInput,
"music_label": self.lblMusicVolume,
"sfx_label": self.lblSoundVolume,
"blip_label": self.lblBlipsVolume,
"music_slider": self.sliMusicVolume,
"sfx_slider": self.sliSoundVolume,
"blip_slider": self.sliBlipsVolume,
"emote_dropdown": self.boxEmotes,
"effects_dropdown": self.boxEffects,
"pos_dropdown": self.boxPositions,
"text_color": self.boxColors,
"change_character": self.btnChangeChar,
"call_mod": self.btnCallMod,
"reload_theme": self.btnReloadTheme,
"ic_chat_name": self.shownameEdit,
"settings": self.btnSettings,
"ao2_chatbox": self.chatbox,
"ao2_ic_chat_message": self.ICChatInput,
"message": self.text,
"showname": self.name,
"music_list": self.serverTabs,
}
move = {
"pre": self.cbPreanim,
"flip": self.cbFlip,
"additive": self.cbAdditive,
"slide_enable": self.cbSlide,
"pre_no_interrupt": self.cbNoInterrupt,
"hold_it": self.btnHoldIt,
"objection": self.btnObjection,
"take_that": self.btnTakeThat,
"custom_objection": self.btnCustomObjection,
"emote_left": self.btnPrevEmotePage,
"emote_right": self.btnNextEmotePage,
"realization": self.btnRealization,
"screenshake": self.btnShake,
"not_guilty": self.btnNotGuilty,
"guilty": self.btnGuilty,
"witness_testimony": self.btnWitnessTestimony,
"cross_examination": self.btnCrossExamination,
}
bars = {
"defense_bar": self.btnDefenseBar,
"prosecution_bar": self.btnProsecutionBar
}
for e in geometry.keys():
if e in design:
geometry[e].setGeometry(*[int(x) for x in design[e]])
for e in move.keys(): self.viewportScale = self.viewport.height() / float(192)
if e in design:
move[e].move(*[int(x) for x in design[e]][0:2]) self.court.resize(self.viewport.size())
self.bench.resize(self.viewport.size())
for e in bars.keys(): self.effectView.resize()
if e in design: self.objectionView.resize()
bars[e].moveBar(*[int(x) for x in design[e]][0:2]) self.zoom.resize()
self.wtceView.resize()
if "emotes" in design: self.char.resize()
self.emotePageGeometry = [int(x) for x in design["emotes"]] self.sideChar.resize()
else: self.slideWitness.resize()
self.emotePageGeometry = [0, 0, 0, 0] self.slideSpeaker.resize()
if "emote_button_spacing" in design:
self.emotePageGeometry += [int(x) for x in design["emote_button_spacing"]]
else:
self.emotePageGeometry += [1, 1]
if "found_song_color" in design:
self.foundSongItemColor = QtGui.QColor(*[int(x) for x in design["found_song_color"]])
self.cbSlide.setVisible("slide_enable" in design)
self.cbBench.setVisible("ao2xp_desk" in design)
self.btnReloadTheme.setVisible(True)
# TODO: Load script common to all themes
QtGui.QApplication.setStyle('plastique')
for w in [self.gameTabs, self.serverTabs]:
stack = w.findChild(QtGui.QStackedWidget)
if stack:
stack.setAutoFillBackground(False)
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, True)
else:
QtGui.QApplication.setStyle(self.defaultStyle)
for w in [self.gameTabs, self.serverTabs]:
stack = w.findChild(QtGui.QStackedWidget)
if stack:
stack.setAutoFillBackground(True)
stack.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
with open(AO2XPpath + "ao2xp_themes/" + theme + "/theme.py") as t:
exec t
if switching:
# This is to reset the colors on the music list. Not necessary on startup
self.onMusicSearch("")
self.viewportScale = self.viewport.height() / float(192)
self.court.resize(self.viewport.size()) self.ao2text.setGeometry(self.text.geometry())
self.bench.resize(self.viewport.size()) self.ao2text.setStyleSheet(self.text.styleSheet())
self.effectView.resize() self.sliDemoSeekbar.setGeometry(self.ICChatInput.geometry())
self.objectionView.resize()
self.zoom.resize() # Theme chatbox
self.wtceView.resize() chatboxPixmap = QtGui.QPixmap(testPath(
self.char.resize() AO2XPpath + "ao2xp_themes/%s/chat.png" % theme,
self.sideChar.resize() AO2XPpath + 'themes/default/chatmed.png'
self.slideWitness.resize() ))
self.slideSpeaker.resize() if not self.chatbox.geometrySet:
self.chatboxWidth = self.viewport.width()
self.chatboxHeight = chatboxPixmap.size().height() * self.viewportScale
self.chatbox.resize(self.chatboxWidth, self.chatboxHeight)
self.chatbox.move(0, self.viewport.height() - self.chatboxHeight)
else:
self.chatboxWidth = self.chatbox.width()
self.chatboxHeight = self.chatbox.height()
self.chatbox.setPixmap(chatboxPixmap.scaled(self.chatboxWidth, self.chatboxHeight, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
# Theme background
courtroomBackground = AO2XPpath + "ao2xp_themes/" + theme + '/courtroombackground.png'
if exists(courtroomBackground):
stylesheet += "QTabWidget {background-color: transparent;} QMainWindow { background-image: url(./" + courtroomBackground + ");}"
courtroomBackground = QtGui.QPixmap(courtroomBackground)
self.width = courtroomBackground.size().width()
self.height = courtroomBackground.size().height()
# Stylesheet
courtroomStylesheets = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_stylesheets.css'
if exists(courtroomStylesheets):
with open(courtroomStylesheets) as f:
stylesheet += f.read()
self.ao2text.setGeometry(self.text.geometry()) self.gamewindow.setStyleSheet(stylesheet)
self.ao2text.setStyleSheet(self.text.styleSheet())
self.sliDemoSeekbar.setGeometry(self.ICChatInput.geometry()) self.presentedEvidence.setGeometry(self.viewport.x() + 16, self.viewport.y() + 16, 70 * self.viewportScale, 70 * self.viewportScale)
# Theme chatbox # Theme fonts
chatboxPixmap = QtGui.QPixmap(testPath( courtroomFonts = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_fonts.ini'
AO2XPpath + "ao2xp_themes/%s/chat.png" % theme, if exists(courtroomFonts):
AO2XPpath + 'themes/default/chatmed.png' fonts = {}
)) with open(courtroomDesign) as f:
if not self.chatbox.geometrySet: for keys in f.read().split("\n"):
self.chatboxWidth = self.viewport.width() if not keys or "=" not in keys or keys[0] == ";": continue
self.chatboxHeight = chatboxPixmap.size().height() * self.viewportScale
self.chatbox.resize(self.chatboxWidth, self.chatboxHeight)
self.chatbox.move(0, self.viewport.height() - self.chatboxHeight)
else:
self.chatboxWidth = self.chatbox.width()
self.chatboxHeight = self.chatbox.height()
self.chatbox.setPixmap(chatboxPixmap.scaled(self.chatboxWidth, self.chatboxHeight, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
# Theme background
courtroomBackground = AO2XPpath + "ao2xp_themes/" + theme + '/courtroombackground.png'
if exists(courtroomBackground):
stylesheet += "QTabWidget {background-color: transparent;} QMainWindow { background-image: url(./" + courtroomBackground + ");}"
courtroomBackground = QtGui.QPixmap(courtroomBackground)
self.width = courtroomBackground.size().width()
self.height = courtroomBackground.size().height()
# Stylesheet
courtroomStylesheets = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_stylesheets.css'
if exists(courtroomStylesheets):
with open(courtroomStylesheets) as f:
stylesheet += f.read()
self.gamewindow.setStyleSheet(stylesheet)
self.presentedEvidence.setGeometry(self.viewport.x() + 16, self.viewport.y() + 16, 70 * self.viewportScale, 70 * self.viewportScale)
# Theme fonts
courtroomFonts = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_fonts.ini'
if exists(courtroomFonts):
fonts = {}
with open(courtroomDesign) as f:
for keys in f.read().split("\n"):
if not keys or "=" not in keys or keys[0] == ";": continue
key, value = keys.split("=") key, value = keys.split("=")
fonts[key.strip()] = value.replace(" ", "").split(',') fonts[key.strip()] = value.replace(" ", "").split(',')
fontDb = None
nameFont = None
textFont = None
fontDb = QtGui.QFontDatabase()
fontDb.addApplicationFont(AO2XPpath + 'font/Igiari.ttf')
fontDb.addApplicationFont(AO2XPpath + 'font/Ace_Name_Regular.ttf')
nameFont = QtGui.QFont("Ace Name")
textFont = QtGui.QFont("Igiari")
nameFont.setPointSize(self.nameFontPointSize)
textFont.setPointSize(self.textFontPointSize)
self.text.setFont(textFont)
self.ao2text.setFont(textFont)
self.name.setFont(nameFont)
for label in self.onscreenTimerLabels:
label.resize(self.viewport.width(), label.sizeHint().height())
label.setFont(nameFont)
fontDb = None # Load emote buttons
nameFont = None # TODO: Buggy on theme switch / reload
textFont = None xMod_count = yMod_count = 0
fontDb = QtGui.QFontDatabase() left, top, width, height, hSpacing, vSpacing = self.emotePageGeometry
fontDb.addApplicationFont(AO2XPpath + 'font/Igiari.ttf') columns = (width - 40) / (hSpacing + 40) + 1
fontDb.addApplicationFont(AO2XPpath + 'font/Ace_Name_Regular.ttf') rows = (height - 40) / (vSpacing + 40) + 1
nameFont = QtGui.QFont("Ace Name") self.maxEmotesOnPage = columns * rows
textFont = QtGui.QFont("Igiari")
nameFont.setPointSize(self.nameFontPointSize) if len(self.emoteButtons) > 0:
textFont.setPointSize(self.textFontPointSize) for button in self.emoteButtons:
self.text.setFont(textFont) button.setParent(None)
self.ao2text.setFont(textFont) button.deleteLater()
self.name.setFont(nameFont) button = None
self.emoteButtons = []
for i in range(self.maxEmotesOnPage):
xPos = (40 + hSpacing) * xMod_count
yPos = (40 + vSpacing) * yMod_count
xMod_count += 1
if xMod_count == columns:
xMod_count = 0
yMod_count += 1
for label in self.onscreenTimerLabels: button = buttons.EmoteButton(self, i)
label.resize(self.viewport.width(), label.sizeHint().height()) button.move(left + xPos, top + yPos)
label.setFont(nameFont) button.clicked.connect(self.ICChatFocus)
button.show()
# Load emote buttons button.lower()
# TODO: Buggy on theme switch / reload self.emoteButtons.append(button)
xMod_count = yMod_count = 0
left, top, width, height, hSpacing, vSpacing = self.emotePageGeometry
columns = (width - 40) / (hSpacing + 40) + 1
rows = (height - 40) / (vSpacing + 40) + 1
self.maxEmotesOnPage = columns * rows
if len(self.emoteButtons) > 0: self.btnPrevEmotePage.raise_()
for button in self.emoteButtons: self.btnNextEmotePage.raise_()
button.setParent(None)
button.deleteLater()
button = None
self.emoteButtons = [] if switching:
self.setBackground()
for i in range(self.maxEmotesOnPage): self.setScene()
xPos = (40 + hSpacing) * xMod_count self.boxEmotes.setCurrentIndex(0)
yPos = (40 + vSpacing) * yMod_count self.setEmotePage()
xMod_count += 1 self.gamewindow.setFixedSize(self.width, self.height)
if xMod_count == columns: self.gamewindow.center()
xMod_count = 0 # except Exception as e:
yMod_count += 1 # 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)
button = buttons.EmoteButton(self, i)
button.move(left + xPos, top + yPos)
button.clicked.connect(self.ICChatFocus)
button.show()
button.lower()
self.emoteButtons.append(button)
self.btnPrevEmotePage.raise_()
self.btnNextEmotePage.raise_()
if switching:
self.setBackground()
self.setScene()
self.boxEmotes.setCurrentIndex(0)
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)
def resetPairOffsets(self): def resetPairOffsets(self):
self.sliPairOffset.setValue(0) self.sliPairOffset.setValue(0)
@ -2072,19 +2071,19 @@ class GUI(QtGui.QWidget):
def setJudgeButtons(self): def setJudgeButtons(self):
if self.charSide == 'jud': if self.charSide == 'jud':
self.btnDefenseBar.minusbtn.show() self.btnDefenseBar.btnMinus.show()
self.btnDefenseBar.plusbtn.show() self.btnDefenseBar.btnPlus.show()
self.btnProsecutionBar.minusbtn.show() self.btnProsecutionBar.btnMinus.show()
self.btnProsecutionBar.plusbtn.show() self.btnProsecutionBar.btnPlus.show()
self.btnWitnessTestimony.show() self.btnWitnessTestimony.show()
self.btnCrossExamination.show() self.btnCrossExamination.show()
self.btnNotGuilty.show() self.btnNotGuilty.show()
self.btnGuilty.show() self.btnGuilty.show()
else: else:
self.btnDefenseBar.minusbtn.hide() self.btnDefenseBar.btnMinus.hide()
self.btnDefenseBar.plusbtn.hide() self.btnDefenseBar.btnPlus.hide()
self.btnProsecutionBar.minusbtn.hide() self.btnProsecutionBar.btnMinus.hide()
self.btnProsecutionBar.plusbtn.hide() self.btnProsecutionBar.btnPlus.hide()
self.btnWitnessTestimony.hide() self.btnWitnessTestimony.hide()
self.btnCrossExamination.hide() self.btnCrossExamination.hide()
self.btnNotGuilty.hide() self.btnNotGuilty.hide()
@ -4520,8 +4519,8 @@ class GUI(QtGui.QWidget):
self.cbFlip, self.cbPreanim, self.cbNoInterrupt, self.cbFlip, self.cbPreanim, self.cbNoInterrupt,
self.boxEffects, self.cbSlide, self.cbBench, self.boxEffects, self.cbSlide, self.cbBench,
self.cbAdditive, self.areaItems, self.shownameEdit, self.cbAdditive, self.areaItems, self.shownameEdit,
self.boxColors, self.btnDefenseBar.minusbtn, self.btnProsecutionBar.minusbtn, self.boxColors, self.btnDefenseBar.btnMinus, self.btnProsecutionBar.btnMinus,
self.btnDefenseBar.plusbtn, self.btnProsecutionBar.plusbtn, self.btnWitnessTestimony, self.btnDefenseBar.btnPlus, self.btnProsecutionBar.btnPlus, self.btnWitnessTestimony,
self.btnCrossExamination, self.btnNotGuilty, self.btnGuilty, self.btnCrossExamination, self.btnNotGuilty, self.btnGuilty,
self.btnRealization, self.btnShake, self.btnRealization, self.btnShake,
]: ]: