From fed30db7c8c27bd25283d7dbad7ed9c0d991845e Mon Sep 17 00:00:00 2001 From: cidoku Date: Mon, 6 Oct 2025 20:18:12 -0300 Subject: [PATCH] make objection, realization, shake and judge buttons' positions definable by theme --- AO2XPbase/ao2xp_themes/default/theme.py | 137 ++++++++++++++---------- buttons.py | 19 ++-- gameview.py | 28 ++--- 3 files changed, 104 insertions(+), 80 deletions(-) diff --git a/AO2XPbase/ao2xp_themes/default/theme.py b/AO2XPbase/ao2xp_themes/default/theme.py index 53dd685..c082c5f 100644 --- a/AO2XPbase/ao2xp_themes/default/theme.py +++ b/AO2XPbase/ao2xp_themes/default/theme.py @@ -1,58 +1,47 @@ self.gamewindow.setStyleSheet("") -self.width = 820 -self.height = 730 +# Because it depends on the positions and sizes of other widgets, the main +# window size is defined at the end of the file -#self.viewport_w = 256*2 -#self.viewport_h = 192*2 +# IC viewport +_scale = 2.5 +self.viewport.move(0, 0) +self.viewport.resize(256 * _scale, 192 * _scale) -self.ao2text.setGeometry(16, 32, self.viewport_w - 32, 112) -self.ao2text.setStyleSheet("background-color: rgba(0, 0, 0, 0); color: white;") -self.text.setGeometry(16, 32, self.viewport_w - 32, 112) -self.text.setStyleSheet("background-color: rgba(0, 0, 0, 0); color: white;") - -self.name.setStyleSheet('color: white') -self.name.move(16, -1) +# Textbox +self.name.move(8 * _scale, -15 + 7 * _scale) self.name.resize(248, 32) +self.name.setStyleSheet('color: white') +self.text.setGeometry(8 * _scale, 16 * _scale, self.viewport.width() - 32, 112) +self.text.setStyleSheet("background-color: rgba(0, 0, 0, 0); color: white;") +self.nameFontPointSize = 6 * _scale +self.textFontPointSize = 12 * _scale -self.icchatinput.setGeometry(0, self.viewport_h, self.viewport_w, 23) -self.emotedropdown.setGeometry(164 - 28, 344 + 66 + 4, 72, 20) -self.colordropdown.setGeometry(self.emotedropdown.x(), 376 + 64, 72, 20) +# IC input and demo slider +viewportRight = max(self.viewport.x() + self.viewport.width(), 512) +viewportBottom = self.viewport.y() + self.viewport.height() +self.icchatinput.setGeometry(self.viewport.x(), viewportBottom, self.viewport.width(), 23) +self.demoslider.setGeometry(self.icchatinput.x(), self.icchatinput.y(), self.viewport.width(), 23) +viewportBottom += self.icchatinput.height() # 407 + +# IC options +self.emotedropdown.setGeometry(164 - 28, viewportBottom + 7, 72, 20) +self.colordropdown.setGeometry(self.emotedropdown.x(), viewportBottom + 33, 72, 20) self.posdropdown.setGeometry(self.emotedropdown.x() + self.emotedropdown.size().width() + 4, self.emotedropdown.y(), 72, 20) - -self.demoslider.setGeometry(self.icchatinput.x(), self.icchatinput.y(), self.viewport_w, 23) - self.flipbutton.move(self.posdropdown.x() + self.posdropdown.width() + 4, self.colordropdown.y() - 5) self.sfxbutton.move(self.flipbutton.x(), self.flipbutton.y() + 14) self.nointerruptbtn.move(self.flipbutton.x() + 140, self.flipbutton.y()) self.additivebtn.move(self.nointerruptbtn.x(), self.sfxbutton.y()) -self.deskbtn.move(self.flipbutton.x()+70, self.flipbutton.y()) +self.deskbtn.move(self.flipbutton.x() + 70, self.flipbutton.y()) self.slidebutton.move(self.deskbtn.x(), self.sfxbutton.y()) - self.effectdropdown.setGeometry(self.posdropdown.x(), self.colordropdown.y(), 72, 20) -self.callmodbtn.setGeometry(10, 376 + 62, 60, 23) -self.settingsbtn.setGeometry(self.callmodbtn.x()+self.callmodbtn.size().width(), 376 + 62, self.callmodbtn.width(), 23) -self.changechar.setGeometry(10, 344 + 66 + 4, self.callmodbtn.size().width() + self.settingsbtn.size().width(), 23) - +self.callmodbtn.setGeometry(10, viewportBottom + 31, 60, 23) +self.settingsbtn.setGeometry(self.callmodbtn.x()+self.callmodbtn.size().width(), viewportBottom + 31, self.callmodbtn.width(), 23) +self.changechar.setGeometry(10, viewportBottom + 7, self.callmodbtn.size().width() + self.settingsbtn.size().width(), 23) self.shownameedit.setGeometry(self.posdropdown.x() + self.posdropdown.width() + 4, self.posdropdown.y(), 168 + 56, 20) -self.ooclog.setGeometry(814 - 288, 0, 288, 248) -self.oocnameinput.resize(self.oocnameinput.sizeHint().width() - 32, self.oocnameinput.sizeHint().height()) -self.oocnameinput.move(814 - 288, 248) -self.oocinput.resize(self.ooclog.width() - self.oocnameinput.width(), self.oocinput.sizeHint().height()) -self.oocinput.move(814 - 288 + self.oocnameinput.size().width(), 248) -self.ooclogin.resize(48, 20) -self.ooclogin.move(814 - (self.ooclogin.size().width()), self.oocinput.y() + self.ooclogin.size().height()) - -self.musicareatabs.setGeometry(814 - 288, 468, 288, 258) -self.musicitems.setGeometry(8, 8, 268, 184) -self.musicsearch.setGeometry(8, self.musicitems.size().height() + 16, 268, self.musicsearch.sizeHint().height()) -self.found_songitem_color = "#80ff80" - -self.backgrounditems.setGeometry(8, 8, 268, 184) -self.backgroundsearch.setGeometry(8, self.musicitems.size().height() + 16, 268 - self.backgroundrefresh.sizeHint().width() - 20, self.musicsearch.sizeHint().height()) -self.backgroundrefresh.resize(self.backgroundrefresh.sizeHint()) -self.backgroundrefresh.move(268 - self.backgroundrefresh.sizeHint().width(), self.backgrounditems.size().height() + 16) +self.gametabs.move(8, viewportBottom + 61) +self.gametabs.resize(714 - 304, 256) self.iclog.setGeometry(8, 8, 714 - 304 - 22, 212) @@ -94,13 +83,6 @@ self.remove_queue.resize(self.remove_queue.sizeHint()) self.remove_queue.move(8, self.msgqueue_list.size().height() + 16) self.clear_queue.move(self.remove_queue.x() + self.remove_queue.size().width(), self.remove_queue.y()) -self.player_pair.resize(self.player_pair.sizeHint()) -self.player_kick.resize(self.player_kick.sizeHint()) -self.player_ban.resize(self.player_ban.sizeHint()) -self.player_pair.move(8, self.player_list.size().height() + 16) -self.player_kick.move(8 + self.player_pair.x() + self.player_pair.size().width(), self.player_list.size().height() + 16) -self.player_ban.move(8 + self.player_kick.x() + self.player_kick.size().width(), self.player_list.size().height() + 16) - self.notmutedlabel.move(8, 8) self.unmutedlist.setGeometry(8, 24, 160, 192) self.mutedlist.setGeometry(238, 24, 160, 192) @@ -108,7 +90,7 @@ self.mutedlabel.move(238 + self.mutedlist.size().width() - self.mutedlist.size() self.mutebtn.setGeometry((714 - 304) / 2 - 26, 64, 48, 32) self.unmutebtn.setGeometry((714 - 304) / 2 - 26, 128, 48, 32) -self.iniswaplist.setGeometry(8, 8, 192, self.iniswaplist.sizeHint().height()) +self.iniSwapList.setGeometry(8, 8, 192, self.iniSwapList.sizeHint().height()) self.iniswapconfirm.resize(self.iniswapconfirm.sizeHint()) self.iniswapconfirm.move(714 - 304 - 22 - self.iniswapconfirm.size().width(), 8) self.iniswapreset.resize(self.iniswapconfirm.size()) @@ -119,19 +101,59 @@ self.iniswaprefresh.resize(self.iniswaprefresh.sizeHint()) self.paircheckbox.setGeometry(16, 16, 128, 24) self.pairdropdown.setGeometry(112, 20, 192, 18) -self.pairoffset.setGeometry(114, 48, 192, 24) -self.pairoffset_l.move(self.pairoffset.x() - 88, self.pairoffset.y()+4) -self.ypairoffset.setGeometry(114, 72, 24, 112) +self.pairOffset.setGeometry(114, 48, 192, 24) +self.pairoffset_l.move(self.pairOffset.x() - 88, self.pairOffset.y()+4) +self.yPairOffset.setGeometry(114, 72, 24, 112) self.ypairoffset_l.move(self.pairoffset_l.x(), self.pairoffset_l.y()+64) -self.pairoffsetreset.move(self.pairoffset.x() + self.pairoffset.size().width() + 8, self.ypairoffset_l.y()) +self.pairoffsetreset.move(self.pairOffset.x() + self.pairOffset.size().width() + 8, self.ypairoffset_l.y()) self.pair_order_l.move(self.pairoffset_l.x(), self.pairoffset_l.y()+144) -self.pair_order.setGeometry(self.pairoffset.x(), self.pair_order_l.y()-4, 80, self.pairoffsetreset.sizeHint().height()) +self.pair_order.setGeometry(self.pairOffset.x(), self.pair_order_l.y()-4, 80, self.pairoffsetreset.sizeHint().height()) self.spacebartext.move(self.mocktext.x(), self.mocktext.y()+24) self.autocaps.move(self.spacebartext.x(), self.spacebartext.y()+24) -self.gametabs.move(8, 468) -self.gametabs.resize(714 - 304, 256) +# Misc IC buttons +self.defensebar.moveBar(429, viewportBottom + 61) +self.prosecutionbar.moveBar(429, viewportBottom + 75) +self.realizationbtn.move(429, viewportBottom + 89) +self.shakebtn.move(471, self.realizationbtn.y()) + +self.wtcebtn_1.move(429, viewportBottom + 137) +self.wtcebtn_2.move(self.wtcebtn_1.x(), self.wtcebtn_1.y() + self.wtcebtn_1.size().height()) +self.notguiltybtn.move(self.wtcebtn_1.x(), self.wtcebtn_2.y() + self.wtcebtn_2.size().height()) +self.guiltybtn.move(self.wtcebtn_1.x(), self.notguiltybtn.y() + self.notguiltybtn.size().height()) + +self.holditbtn.move(viewportRight + 14, 352) +self.objectbtn.move(self.holditbtn.x() + 70, self.holditbtn.y()) +self.takethatbtn.move(self.objectbtn.x() + 70, self.holditbtn.y()) +self.customobject.move(self.takethatbtn.x() + 70, self.holditbtn.y()) + +# OOC chat +self.ooclog.setGeometry(viewportRight + 14, 0, 288, 248) +self.oocnameinput.resize(self.oocnameinput.sizeHint().width() - 32, self.oocnameinput.sizeHint().height()) +self.oocnameinput.move(viewportRight + 14, 248) +self.oocinput.resize(self.ooclog.width() - self.oocnameinput.width(), self.oocinput.sizeHint().height()) +self.oocinput.move(viewportRight + 14 + self.oocnameinput.size().width(), 248) +self.ooclogin.resize(48, 20) +self.ooclogin.move(viewportRight + 14 + self.ooclog.size().width() - (self.ooclogin.size().width()), self.oocinput.y() + self.ooclogin.size().height()) + +# Server tabs +self.musicareatabs.setGeometry(viewportRight + 14, 468, 288, 258) +self.musicitems.setGeometry(8, 8, 268, 184) +self.musicsearch.setGeometry(8, self.musicitems.size().height() + 16, 268, self.musicsearch.sizeHint().height()) +self.found_songitem_color = "#80ff80" + +self.backgrounditems.setGeometry(8, 8, 268, 184) +self.backgroundsearch.setGeometry(8, self.musicitems.size().height() + 16, 268 - self.backgroundrefresh.sizeHint().width() - 20, self.musicsearch.sizeHint().height()) +self.backgroundrefresh.resize(self.backgroundrefresh.sizeHint()) +self.backgroundrefresh.move(268 - self.backgroundrefresh.sizeHint().width(), self.backgrounditems.size().height() + 16) + +self.player_pair.resize(self.player_pair.sizeHint()) +self.player_kick.resize(self.player_kick.sizeHint()) +self.player_ban.resize(self.player_ban.sizeHint()) +self.player_pair.move(8, self.player_list.size().height() + 16) +self.player_kick.move(8 + self.player_pair.x() + self.player_pair.size().width(), self.player_list.size().height() + 16) +self.player_ban.move(8 + self.player_kick.x() + self.player_kick.size().width(), self.player_list.size().height() + 16) self.musicslider.setGeometry(self.oocnameinput.x(), self.oocnameinput.y()+24, 192, 16) self.soundslider.setGeometry(self.oocnameinput.x(), self.oocnameinput.y()+48, 192, 16) @@ -143,5 +165,6 @@ self.sliderlabel3.move(self.blipslider.x() + self.blipslider.size().width()+8, s self.pinglabel.setGeometry(self.sliderlabel3.x() + 32, self.sliderlabel3.y(), 96, 14) -self.defensebar.moveBar(265 + 164, 164 + 304) -self.prosecutionbar.moveBar(265 + 164, 178 + 304) \ No newline at end of file +# Main window +self.width = self.ooclog.x() + self.ooclog.width() + 4 +self.height = max(730, self.gametabs.y() + self.gametabs.height() + 6) \ No newline at end of file diff --git a/buttons.py b/buttons.py index 71be818..2322784 100644 --- a/buttons.py +++ b/buttons.py @@ -6,15 +6,16 @@ class AOToggleButton(QtGui.QLabel): pressed = False clicked = QtCore.pyqtSignal() - def __init__(self, parent, x, y, btnname): + def __init__(self, parent, btnname): super(AOToggleButton, self).__init__(parent) - self.parent = parent self.notpressed_pix = QtGui.QPixmap(AO2XPpath+"themes/default/%s.png" % btnname) self.pressed_pix = QtGui.QPixmap(AO2XPpath+"themes/default/%s_pressed.png" % btnname) self.setPixmap(self.notpressed_pix) - self.setGeometry(x, y, self.notpressed_pix.size().width(), self.notpressed_pix.size().height()) self.show() + 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) @@ -29,10 +30,10 @@ class AOToggleButton(QtGui.QLabel): class CustomObjection(QtGui.QLabel): pressed = False clicked = QtCore.pyqtSignal() - def __init__(self, parent, x, y): + def __init__(self, parent): super(CustomObjection, self).__init__(parent) self.parent = parent - self.setGeometry(x, y, 76, 28) + 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) @@ -59,9 +60,9 @@ class WTCEbuttons(QtGui.QLabel): clicked = QtCore.pyqtSignal(int, int) type = 0 variant = 0 - def __init__(self, parent, x, y, type, variant=0): + def __init__(self, parent, type, variant=0): super(WTCEbuttons, self).__init__(parent) - self.setGeometry(x, y, 85, 42) + self.resize(85, 42) if type == 0: self.setPixmap(QtGui.QPixmap(AO2XPpath+"themes/default/witnesstestimony.png")) elif type == 1: @@ -81,11 +82,11 @@ class Objections(QtGui.QLabel): pressed = False type = 0 clicked = QtCore.pyqtSignal() - def __init__(self, parent, x, y, type): + def __init__(self, parent, type): super(Objections, self).__init__(parent) self.parent = parent self.type = type - self.setGeometry(x, y, 76, 28) + self.resize(76, 28) if type == 1: self.notpressed_pix = QtGui.QPixmap(AO2XPpath+"themes/default/holdit.png") self.pressed_pix = QtGui.QPixmap(AO2XPpath+"themes/default/holdit_selected.png") diff --git a/gameview.py b/gameview.py index 2710876..a42a32c 100644 --- a/gameview.py +++ b/gameview.py @@ -1507,21 +1507,21 @@ class GUI(QtGui.QWidget): self.nextemotepage = buttons.NextEmoteButton(self, 282 + 516, 253+190-28) self.nextemotepage.show() - self.realizationbtn = buttons.AOToggleButton(self, 265 + 164, 192 + 304, "realization") + self.realizationbtn = buttons.AOToggleButton(self, "realization") self.realizationbtn.clicked.connect(self.on_realization_button) 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 = buttons.AOToggleButton(self, "screenshake") # AO 2.8 self.shakebtn.clicked.connect(self.on_shake_button) 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.takethatbtn.clicked.connect(self.icchat_focus) - self.objectbtn.clicked.connect(self.icchat_focus) + self.customobject = buttons.CustomObjection(self) + self.takethatbtn = buttons.Objections(self, 3) + self.objectbtn = buttons.Objections(self, 2) + self.holditbtn = buttons.Objections(self, 1) self.holditbtn.clicked.connect(self.icchat_focus) + self.objectbtn.clicked.connect(self.icchat_focus) + self.takethatbtn.clicked.connect(self.icchat_focus) self.customobject.clicked.connect(self.icchat_focus) self.objectsnd = 0 @@ -1532,10 +1532,10 @@ class GUI(QtGui.QWidget): self.prosecutionbar.minusClicked.connect(self.penaltyBarMinus) self.prosecutionbar.plusClicked.connect(self.penaltyBarPlus) - self.wtcebtn_1 = buttons.WTCEbuttons(self, 429, 544, 0) - self.wtcebtn_2 = buttons.WTCEbuttons(self, self.wtcebtn_1.x(), self.wtcebtn_1.y() + self.wtcebtn_1.size().height(), 1) - self.notguiltybtn = buttons.WTCEbuttons(self, self.wtcebtn_1.x(), self.wtcebtn_2.y() + self.wtcebtn_2.size().height(), 2, 0) - self.guiltybtn = buttons.WTCEbuttons(self, self.wtcebtn_1.x(), self.notguiltybtn.y() + self.notguiltybtn.size().height(), 2, 1) + self.wtcebtn_1 = buttons.WTCEbuttons(self, 0) + self.wtcebtn_2 = buttons.WTCEbuttons(self, 1) + self.notguiltybtn = buttons.WTCEbuttons(self, 2, 0) + self.guiltybtn = buttons.WTCEbuttons(self, 2, 1) self.wtcebtn_1.clicked.connect(self.WTCEbuttonPressed) self.wtcebtn_2.clicked.connect(self.WTCEbuttonPressed) @@ -1615,8 +1615,8 @@ class GUI(QtGui.QWidget): self.slideKind = 0 # 0 = def-pro, 1 = def-wit, 2 = pro-wit self.slideDirection = 0 # 0 = left to right, 1 = right to left - if self.slideEnabled: - self.slidebutton.setChecked(True) + # if self.slideEnabled: + # self.slidebutton.setChecked(True) # slideMap[old_pos][new_pos] = [kind, direction] self.slideMap = {