refactoring + improving the visuals of the joining process

This commit is contained in:
cidoku 2026-02-07 19:20:00 -03:00
parent 967809a404
commit 968ea04abe
8 changed files with 305 additions and 317 deletions

View File

@ -53,13 +53,14 @@ class charselect(QtGui.QWidget):
self.btns = [] self.btns = []
self.chartaken = [] self.chartaken = []
self.max_chars_on_page = 0
self.prevpage = PixmapButton(self, QtGui.QPixmap(AO2XPpath + "themes/default/arrow_left.png")) self.prevpage = PixmapButton(self, QtGui.QPixmap(AO2XPpath + "themes/default/arrow_left.png"))
self.nextpage = PixmapButton(self, QtGui.QPixmap(AO2XPpath + "themes/default/arrow_right.png")) self.nextpage = PixmapButton(self, QtGui.QPixmap(AO2XPpath + "themes/default/arrow_right.png"))
self.setButtons() self.setButtons()
self.setBtnImage.connect(self.setButtonImage) self.setBtnImage.connect(self.setButtonImage)
self.hide()
def setButtons(self): def setButtons(self):
#directly stolen from ao2 source code and default theme because i was stuck (i'm so sorry) #directly stolen from ao2 source code and default theme because i was stuck (i'm so sorry)
@ -120,10 +121,10 @@ class charselect(QtGui.QWidget):
char = charList[ind][0].lower() char = charList[ind][0].lower()
charid = charList[ind][2] if filtered else ind charid = charList[ind][2] if filtered else ind
if exists(AOpath + "characters/"+ char +"/char_icon.png"): # AO2 if exists(BASE_PATH + "characters/"+ char +"/char_icon.png"): # AO2
self.setBtnImage.emit(AOpath + "characters/"+ char +"/char_icon.png", i, charid) self.setBtnImage.emit(BASE_PATH + "characters/"+ char +"/char_icon.png", i, charid)
elif exists(AOpath + "misc/demothings/"+ char +"_char_icon.png"): # AO 1.7.5/1.8 elif exists(BASE_PATH + "misc/demothings/"+ char +"_char_icon.png"): # AO 1.7.5/1.8
self.setBtnImage.emit(AOpath + "misc/demothings/"+ char +"_char_icon.png", i, charid) self.setBtnImage.emit(BASE_PATH + "misc/demothings/"+ char +"_char_icon.png", i, charid)
else: else:
self.setBtnImage.emit("placeholder.png", i, charid) self.setBtnImage.emit("placeholder.png", i, charid)
@ -144,7 +145,7 @@ class charselect(QtGui.QWidget):
self.showCharPage(charList) self.showCharPage(charList)
def quitToLobby(self): def quitToLobby(self):
self.parent.gamewindow.returnToMenu() self.parent.mainWindow.returnToMenu()
def setCharList(self, charList): def setCharList(self, charList):
self.charList = charList self.charList = charList
@ -183,14 +184,20 @@ class charselect(QtGui.QWidget):
self.showCharPage() self.showCharPage()
def selectChar(self, charIndex): def selectChar(self, charIndex):
self.hide()
self.parent.tcp.send("CC#0#"+str(charIndex)+"##%") self.parent.tcp.send("CC#0#"+str(charIndex)+"##%")
if not self.parent.gotPV:
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
self.parent.setDisabled(True)
self.parent.mainWindow.setFixedSize(self.parent.width, self.parent.height)
self.parent.mainWindow.center()
def onCancel(self): def onCancel(self):
self.hide() self.hide()
self.parent.gamewindow.setFixedSize(self.parent.width, self.parent.height) self.parent.mainWindow.setFixedSize(self.parent.width, self.parent.height)
self.parent.gamewindow.center() self.parent.mainWindow.center()
def show(self): def show(self):
super(charselect, self).show() super(charselect, self).show()
self.parent.gamewindow.setFixedSize(714, 668) self.parent.mainWindow.setFixedSize(714, 668)
self.parent.gamewindow.center() self.parent.mainWindow.center()

View File

@ -1,5 +1,7 @@
GAME_VERSION = "2.9.4" GAME_VERSION = "2.9.5"
AOpath = "base/" YEAR = "2026"
BASE_PATH = "base/"
AO2XPpath = "AO2XPbase/" AO2XPpath = "AO2XPbase/"
DESK_MOD = 1 DESK_MOD = 1

View File

@ -172,7 +172,7 @@ class DemoPicker(QtGui.QDialog):
def __init__(self, parent): def __init__(self, parent):
super(DemoPicker, self).__init__() super(DemoPicker, self).__init__()
self.setModal(True) self.setModal(True)
self.gamewindow = parent self.mainWindow = parent
self.parent = parent self.parent = parent
self.setWindowTitle("Select a demo file...") self.setWindowTitle("Select a demo file...")
@ -204,8 +204,8 @@ class DemoPicker(QtGui.QDialog):
if not fname: if not fname:
return return
self.gamewindow.gamewidget.startDemo(fname) self.mainWindow.gameWidget.startDemo(fname)
self.gamewindow.stackwidget.setCurrentWidget(self.gamewindow.gamewidget) self.mainWindow.widgetStack.setCurrentWidget(self.mainWindow.gameWidget)
self.hide() self.hide()
def get_demo_treeview(): def get_demo_treeview():

View File

@ -25,7 +25,7 @@ def delay(msec):
def getCharIni(char, section, value, default=""): def getCharIni(char, section, value, default=""):
tempini = ConfigParser() tempini = ConfigParser()
return ini.read_ini(AOpath + 'characters/' + char.lower() + '/char.ini', section, value, default) return ini.read_ini(BASE_PATH + 'characters/' + char.lower() + '/char.ini', section, value, default)
def getOption(section, value, default=""): def getOption(section, value, default=""):
tempini = ConfigParser() tempini = ConfigParser()
@ -320,13 +320,13 @@ class AOCharMovie(QtGui.QLabel):
pEmote = pEmote.lower() pEmote = pEmote.lower()
apngPath = testPath( apngPath = testPath(
AOpath + "characters/" + pChar + "/" + emotePrefix + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".apng",
AOpath + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".apng",
AOpath + "characters/" + pChar + "/" + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/" + pEmote + ".apng",
AOpath + "characters/" + pChar + "/(a)" + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".apng",
AOpath + "characters/" + pChar + "/(b)" + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".apng",
AOpath + "characters/" + pChar + "/(a)/" + pEmote + ".apng", BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".apng",
AOpath + "characters/" + pChar + "/(b)/" + pEmote + ".apng" BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".apng"
) )
placeholderPath = AO2XPpath + "themes/default/oldplaceholder.gif" placeholderPath = AO2XPpath + "themes/default/oldplaceholder.gif"
@ -337,13 +337,13 @@ class AOCharMovie(QtGui.QLabel):
self.usePillow = 1 self.usePillow = 1
else: else:
pngPath = testPath( pngPath = testPath(
AOpath + "characters/" + pChar + "/" + emotePrefix + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".png",
AOpath + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".png",
AOpath + "characters/" + pChar + "/" + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/" + pEmote + ".png",
AOpath + "characters/" + pChar + "/(a)" + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".png",
AOpath + "characters/" + pChar + "/(b)" + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".png",
AOpath + "characters/" + pChar + "/(a)/" + pEmote + ".png", BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".png",
AOpath + "characters/" + pChar + "/(b)/" + pEmote + ".png" BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".png"
) )
if pngPath: if pngPath:
@ -351,13 +351,13 @@ class AOCharMovie(QtGui.QLabel):
self.usePillow = 0 self.usePillow = 0
else: else:
webpPath = testPath( webpPath = testPath(
AOpath + "characters/" + pChar + "/" + emotePrefix + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".webp",
AOpath + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".webp",
AOpath + "characters/" + pChar + "/" + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/" + pEmote + ".webp",
AOpath + "characters/" + pChar + "/(a)" + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".webp",
AOpath + "characters/" + pChar + "/(b)" + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".webp",
AOpath + "characters/" + pChar + "/(a)/" + pEmote + ".webp", BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".webp",
AOpath + "characters/" + pChar + "/(b)/" + pEmote + ".webp" BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".webp"
) )
if webpPath: if webpPath:
@ -365,13 +365,13 @@ class AOCharMovie(QtGui.QLabel):
self.usePillow = 2 self.usePillow = 2
else: else:
gifPath = testPath( gifPath = testPath(
AOpath + "characters/" + pChar + "/" + emotePrefix + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".gif",
AOpath + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".gif",
AOpath + "characters/" + pChar + "/" + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/" + pEmote + ".gif",
AOpath + "characters/" + pChar + "/(a)" + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".gif",
AOpath + "characters/" + pChar + "/(b)" + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".gif",
AOpath + "characters/" + pChar + "/(a)/" + pEmote + ".gif", BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".gif",
AOpath + "characters/" + pChar + "/(b)/" + pEmote + ".gif" BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".gif"
) )
if gifPath: if gifPath:
@ -440,9 +440,9 @@ class AOCharMovie(QtGui.QLabel):
def playPre(self, pChar, pEmote, duration, scaling = SCALING_AUTO): def playPre(self, pChar, pEmote, duration, scaling = SCALING_AUTO):
pChar = pChar.lower() pChar = pChar.lower()
gifPath = AOpath + "characters/" + pChar + "/" + pEmote + ".gif" gifPath = BASE_PATH + "characters/" + pChar + "/" + pEmote + ".gif"
apngPath = AOpath + "characters/" + pChar + "/" + pEmote + ".apng" apngPath = BASE_PATH + "characters/" + pChar + "/" + pEmote + ".apng"
webpPath = AOpath + "characters/" + pChar + "/" + pEmote + ".webp" webpPath = BASE_PATH + "characters/" + pChar + "/" + pEmote + ".webp"
fullDuration = duration * self.timeMod fullDuration = duration * self.timeMod
realDuration = 0 realDuration = 0
@ -489,7 +489,7 @@ class AOCharMovie(QtGui.QLabel):
def playTalking(self, pChar, pEmote, scaling = SCALING_AUTO): def playTalking(self, pChar, pEmote, scaling = SCALING_AUTO):
pChar = pChar.lower() pChar = pChar.lower()
gifPath = AOpath + 'characters/' + pChar + '/(b)' + pEmote + '.gif' gifPath = BASE_PATH + 'characters/' + pChar + '/(b)' + pEmote + '.gif'
self.mMovie.stop() self.mMovie.stop()
self.clear() self.clear()
@ -503,7 +503,7 @@ class AOCharMovie(QtGui.QLabel):
def playIdle(self, pChar, pEmote, scaling = SCALING_AUTO): def playIdle(self, pChar, pEmote, scaling = SCALING_AUTO):
pChar = pChar.lower() pChar = pChar.lower()
gifPath = AOpath + 'characters/' + pChar + '/(a)' + pEmote + '.gif' gifPath = BASE_PATH + 'characters/' + pChar + '/(a)' + pEmote + '.gif'
self.mMovie.stop() self.mMovie.stop()
self.clear() self.clear()
@ -625,8 +625,8 @@ class AOMovie(QtGui.QLabel):
if not exists(gifPath): if not exists(gifPath):
pathlist = [ pathlist = [
getImageSuffix(AO2XPpath + "themes/default/" + pImage + "_bubble"), getImageSuffix(AO2XPpath + "themes/default/" + pImage + "_bubble"),
getImageSuffix(AOpath + "characters/" + pChar + "/" + pImage), getImageSuffix(BASE_PATH + "characters/" + pChar + "/" + pImage),
getImageSuffix(AOpath + "misc/default/" + pImage), getImageSuffix(BASE_PATH + "misc/default/" + pImage),
getImageSuffix(AO2XPpath + "themes/default/" + pImage) getImageSuffix(AO2XPpath + "themes/default/" + pImage)
] ]
@ -792,7 +792,7 @@ class EditEvidenceDialog(QtGui.QDialog):
self.evidesc.setAcceptRichText(False) self.evidesc.setAcceptRichText(False)
self.evipicture = QtGui.QLabel(self) self.evipicture = QtGui.QLabel(self)
self.filename = 'empty.png' self.filename = 'empty.png'
evipic = QtGui.QPixmap(AOpath + 'evidence/empty.png') evipic = QtGui.QPixmap(BASE_PATH + 'evidence/empty.png')
self.evipicture.setPixmap(evipic) self.evipicture.setPixmap(evipic)
self.evipicture.move(434, 8) self.evipicture.move(434, 8)
self.evipicture.show() self.evipicture.show()
@ -814,7 +814,7 @@ class EditEvidenceDialog(QtGui.QDialog):
self.browse.clicked.connect(self.onBrowseClicked) self.browse.clicked.connect(self.onBrowseClicked)
self.browse.move(self.choosepic.x() + self.choosepic.width() + 8, self.choosepic.y()) self.browse.move(self.choosepic.x() + self.choosepic.width() + 8, self.choosepic.y())
files = os.listdir(AOpath + 'evidence') files = os.listdir(BASE_PATH + 'evidence')
fileslength = len(files) fileslength = len(files)
i = 0 i = 0
while i < fileslength: while i < fileslength:
@ -837,8 +837,8 @@ class EditEvidenceDialog(QtGui.QDialog):
def choosePicChange(self, ind): def choosePicChange(self, ind):
self.filename = self.filenames[ind] self.filename = self.filenames[ind]
if exists(AOpath + 'evidence/' + self.filename): if exists(BASE_PATH + 'evidence/' + self.filename):
self.evipicture.setPixmap(QtGui.QPixmap(AOpath + 'evidence/' + self.filename)) self.evipicture.setPixmap(QtGui.QPixmap(BASE_PATH + 'evidence/' + self.filename))
else: else:
self.evipicture.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png')) self.evipicture.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png'))
@ -866,7 +866,7 @@ class EditEvidenceDialog(QtGui.QDialog):
self.eviname.setText('') self.eviname.setText('')
self.evidesc.setText('') self.evidesc.setText('')
evipic = QtGui.QPixmap(AOpath + 'evidence/empty.png') evipic = QtGui.QPixmap(BASE_PATH + 'evidence/empty.png')
self.evipicture.setPixmap(evipic) self.evipicture.setPixmap(evipic)
self.filename = 'empty.png' self.filename = 'empty.png'
self.editing = False self.editing = False
@ -877,7 +877,7 @@ class EditEvidenceDialog(QtGui.QDialog):
def onCancelClicked(self): def onCancelClicked(self):
self.eviname.setText('') self.eviname.setText('')
self.evidesc.setText('') self.evidesc.setText('')
evipic = QtGui.QPixmap(AOpath + 'evidence/empty.png') evipic = QtGui.QPixmap(BASE_PATH + 'evidence/empty.png')
self.evipicture.setPixmap(evipic) self.evipicture.setPixmap(evipic)
self.filename = 'empty.png' self.filename = 'empty.png'
self.editing = False self.editing = False
@ -886,7 +886,7 @@ class EditEvidenceDialog(QtGui.QDialog):
self.hide() self.hide()
def onBrowseClicked(self): def onBrowseClicked(self):
path = str(QtGui.QFileDialog.getOpenFileName(self, "Select an image", AOpath + 'evidence', "Images (*.png)")) path = str(QtGui.QFileDialog.getOpenFileName(self, "Select an image", BASE_PATH + 'evidence', "Images (*.png)"))
if path: if path:
if not "/evidence/" in path.lower(): if not "/evidence/" in path.lower():
QtGui.QMessageBox.warning(self, 'Wrong directory', 'Please select a file from the "evidence" directory.') QtGui.QMessageBox.warning(self, 'Wrong directory', 'Please select a file from the "evidence" directory.')
@ -895,7 +895,7 @@ class EditEvidenceDialog(QtGui.QDialog):
file = basename(path) file = basename(path)
if file.lower().endswith('.png'): if file.lower().endswith('.png'):
ind = os.listdir(AOpath + 'evidence').index(file) ind = os.listdir(BASE_PATH + 'evidence').index(file)
self.choosepic.setCurrentIndex(ind) self.choosepic.setCurrentIndex(ind)
else: else:
QtGui.QMessageBox.warning(self, 'Not a valid file', 'Please select a PNG image.') QtGui.QMessageBox.warning(self, 'Not a valid file', 'Please select a PNG image.')
@ -1026,7 +1026,7 @@ class Chatbox(QtGui.QLabel):
self.geometrySet = False self.geometrySet = False
class GUI(QtGui.QWidget): class GUI(QtGui.QWidget):
gamewindow = None mainWindow = None
# In theory 3 sounds may play at the same time: character, evidence sweep, # In theory 3 sounds may play at the same time: character, evidence sweep,
# effect # effect
soundChannels = 3 soundChannels = 3
@ -1078,7 +1078,7 @@ class GUI(QtGui.QWidget):
def __init__(self, parent=None): def __init__(self, parent=None):
super(GUI, self).__init__(parent) super(GUI, self).__init__(parent)
self.gamewindow = parent self.mainWindow = parent
self.gotPing.connect(self.setPing) self.gotPing.connect(self.setPing)
@ -1244,7 +1244,7 @@ class GUI(QtGui.QWidget):
self.evidenceDescription = QtGui.QTextEdit(self.tabEvidence) self.evidenceDescription = QtGui.QTextEdit(self.tabEvidence)
self.evidenceDescription.setReadOnly(True) self.evidenceDescription.setReadOnly(True)
self.evidenceImage = QtGui.QLabel(self.tabEvidence) self.evidenceImage = QtGui.QLabel(self.tabEvidence)
self.evidenceImage.setPixmap(QtGui.QPixmap(AOpath + 'evidence/empty.png')) self.evidenceImage.setPixmap(QtGui.QPixmap(BASE_PATH + 'evidence/empty.png'))
self.evidenceImage.show() self.evidenceImage.show()
self.btnEvidenceAdd = QtGui.QPushButton(QtGui.QIcon(AO2XPpath + "icons/" + "add.png"), "", self.tabEvidence) self.btnEvidenceAdd = QtGui.QPushButton(QtGui.QIcon(AO2XPpath + "icons/" + "add.png"), "", self.tabEvidence)
self.btnEvidenceAdd.setToolTip('Add new evidence') self.btnEvidenceAdd.setToolTip('Add new evidence')
@ -1507,7 +1507,7 @@ class GUI(QtGui.QWidget):
self.btnReloadTheme.setObjectName("ui_reload_theme") self.btnReloadTheme.setObjectName("ui_reload_theme")
self.btnSettings = QtGui.QPushButton("&Settings", self) self.btnSettings = QtGui.QPushButton("&Settings", self)
self.btnSettings.clicked.connect(self.gamewindow.showSettings) self.btnSettings.clicked.connect(self.mainWindow.showSettings)
self.btnSettings.setObjectName("ui_settings") self.btnSettings.setObjectName("ui_settings")
self.boxEmotes = QtGui.QComboBox(self) self.boxEmotes = QtGui.QComboBox(self)
@ -1601,8 +1601,8 @@ class GUI(QtGui.QWidget):
self.btnShake.setToolTip('Show the next message with a shaking effect') self.btnShake.setToolTip('Show the next message with a shaking effect')
self.btnShake.setObjectName("ui_screenshake") self.btnShake.setObjectName("ui_screenshake")
self.sndRealization = audio.loadHandle(False, AOpath + 'sounds/general/sfx-realization.wav', 0, 0, 0) self.sndRealization = audio.loadHandle(False, BASE_PATH + 'sounds/general/sfx-realization.wav', 0, 0, 0)
#self.sndShake = audio.loadHandle(False, AOpath + 'sounds/general/sfx-damage.wav', 0, 0, 0) #self.sndShake = audio.loadHandle(False, BASE_PATH + 'sounds/general/sfx-damage.wav', 0, 0, 0)
# Objections # Objections
self.btnCustomObjection = buttons.CustomObjection(self) self.btnCustomObjection = buttons.CustomObjection(self)
@ -1766,6 +1766,7 @@ class GUI(QtGui.QWidget):
self.XPDownloadThread = None self.XPDownloadThread = None
self.tcp = None self.tcp = None
self.demoPlayer = None self.demoPlayer = None
self.gotPV = False
# TTS fun # TTS fun
self.speaker = None self.speaker = None
@ -1786,7 +1787,7 @@ class GUI(QtGui.QWidget):
stylesheet = "" stylesheet = ""
self.emotePageGeometry = [] self.emotePageGeometry = []
self.viewportScale = 0 self.viewportScale = 0
self.gamewindow.setStyleSheet("") self.mainWindow.setStyleSheet("")
self.chatbox.resetGeometry() self.chatbox.resetGeometry()
self.btnReloadTheme.setVisible(False) self.btnReloadTheme.setVisible(False)
self.cbBench.setVisible(True) self.cbBench.setVisible(True)
@ -1897,6 +1898,10 @@ class GUI(QtGui.QWidget):
else: else:
move[e].move(-500, -500) move[e].move(-500, -500)
if "courtroom" in design:
self.width = int(design["courtroom"][2])
self.height = int(design["courtroom"][3])
if "emotes" in design: if "emotes" in design:
self.emotePageGeometry = [int(x) for x in design["emotes"]] self.emotePageGeometry = [int(x) for x in design["emotes"]]
else: else:
@ -1910,14 +1915,12 @@ class GUI(QtGui.QWidget):
if "found_song_color" in design: if "found_song_color" in design:
self.foundSongItemColor = QtGui.QColor(*[int(x) for x in design["found_song_color"]]) self.foundSongItemColor = QtGui.QColor(*[int(x) for x in design["found_song_color"]])
self.cbSlide.setVisible("slide_enable" in design) self.cbSlide.setVisible("slide_enable" in design)
self.cbBench.setVisible("ao2xp_desk" in design) self.cbBench.setVisible("ao2xp_desk" in design)
self.OOCLogin.setVisible("ao2xp_login" in design) self.OOCLogin.setVisible("ao2xp_login" in design)
self.btnReloadTheme.setVisible(True) self.btnReloadTheme.setVisible(True)
QtGui.QApplication.setStyle('plastique') QtGui.QApplication.setStyle('plastique') # This avoids issues with widget colors
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:
@ -1987,8 +1990,8 @@ class GUI(QtGui.QWidget):
if exists(courtroomBackground): if exists(courtroomBackground):
stylesheet += "QTabWidget {background-color: transparent;} QMainWindow { background-image: url(./" + courtroomBackground + ");}" stylesheet += "QTabWidget {background-color: transparent;} QMainWindow { background-image: url(./" + courtroomBackground + ");}"
courtroomBackground = QtGui.QPixmap(courtroomBackground) courtroomBackground = QtGui.QPixmap(courtroomBackground)
self.width = courtroomBackground.size().width() # self.width = courtroomBackground.size().width()
self.height = courtroomBackground.size().height() # self.height = courtroomBackground.size().height()
# Stylesheet # Stylesheet
courtroomStylesheets = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_stylesheets.css' courtroomStylesheets = AO2XPpath + "ao2xp_themes/" + theme + '/courtroom_stylesheets.css'
@ -1996,7 +1999,7 @@ class GUI(QtGui.QWidget):
with open(courtroomStylesheets) as f: with open(courtroomStylesheets) as f:
stylesheet += f.read() stylesheet += f.read()
self.gamewindow.setStyleSheet(stylesheet) self.mainWindow.setStyleSheet(stylesheet)
self.presentedEvidence.setGeometry(self.viewport.x() + 16, self.viewport.y() + 16, 70 * self.viewportScale, 70 * self.viewportScale) self.presentedEvidence.setGeometry(self.viewport.x() + 16, self.viewport.y() + 16, 70 * self.viewportScale, 70 * self.viewportScale)
@ -2113,8 +2116,8 @@ class GUI(QtGui.QWidget):
self.setScene() self.setScene()
self.boxEmotes.setCurrentIndex(0) self.boxEmotes.setCurrentIndex(0)
self.setEmotePage() self.setEmotePage()
self.gamewindow.setFixedSize(self.width, self.height) self.mainWindow.setFixedSize(self.width, self.height)
self.gamewindow.center() self.mainWindow.center()
# except Exception as e: # 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)) # 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) # os._exit(-2)
@ -2346,7 +2349,7 @@ class GUI(QtGui.QWidget):
if QtCore.QString(fname).contains(text, QtCore.Qt.CaseInsensitive): if QtCore.QString(fname).contains(text, QtCore.Qt.CaseInsensitive):
songitem = QtGui.QListWidgetItem() songitem = QtGui.QListWidgetItem()
songitem.setText(song) songitem.setText(song)
if not self.privateMusicSelected and exists(unicode(AOpath + 'sounds/music/' + decodeAOString(fname).lower())): if not self.privateMusicSelected and exists(unicode(BASE_PATH + 'sounds/music/' + decodeAOString(fname).lower())):
songitem.setBackgroundColor(QtGui.QColor(self.foundSongItemColor)) songitem.setBackgroundColor(QtGui.QColor(self.foundSongItemColor))
self.musicItems.addItem(songitem) self.musicItems.addItem(songitem)
else: else:
@ -2438,7 +2441,7 @@ class GUI(QtGui.QWidget):
self.backgroundItems.clear() self.backgroundItems.clear()
self.backgroundSearch.clear() self.backgroundSearch.clear()
self.backgrounds = [] self.backgrounds = []
for folder in os.listdir(unicode(AOpath + 'background')): for folder in os.listdir(unicode(BASE_PATH + 'background')):
self.backgrounds.append(folder) self.backgrounds.append(folder)
self.backgroundItems.addItem(folder) self.backgroundItems.addItem(folder)
@ -2454,8 +2457,8 @@ class GUI(QtGui.QWidget):
self.backgroundItems.addItem(bg) self.backgroundItems.addItem(bg)
def setEvidenceImage(self, guiobj, image, scale=False): def setEvidenceImage(self, guiobj, image, scale=False):
if exists(AOpath + 'evidence/' + image): if exists(BASE_PATH + 'evidence/' + image):
img = QtGui.QPixmap(AOpath + "evidence/%s" % image) img = QtGui.QPixmap(BASE_PATH + "evidence/%s" % image)
if not img.isNull() and scale: if not img.isNull() and scale:
guiobj.setPixmap(img.scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) guiobj.setPixmap(img.scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
else: else:
@ -2470,7 +2473,7 @@ class GUI(QtGui.QWidget):
if ini.read_ini_bool("AO2XP.ini", "General", "download evidence", True): if ini.read_ini_bool("AO2XP.ini", "General", "download evidence", True):
url = "base/evidence/"+image.lower() url = "base/evidence/"+image.lower()
url = url.replace("evidence/../", "") url = url.replace("evidence/../", "")
path = AOpath + "evidence/"+image path = BASE_PATH + "evidence/"+image
path = path.replace("evidence/../", "") path = path.replace("evidence/../", "")
thread.start_new_thread(downloadThread, (url, path)) thread.start_new_thread(downloadThread, (url, path))
@ -2570,8 +2573,9 @@ class GUI(QtGui.QWidget):
self.ICChatFocus() self.ICChatFocus()
def onPVPacket(self, charName=""): def onPVPacket(self, charName=""):
self.gamewindow.setFixedSize(self.width, self.height) QtGui.QApplication.restoreOverrideCursor()
self.gamewindow.center() self.setDisabled(False)
self.gotPV = True
if not self.swapping and charName: if not self.swapping and charName:
self.loadCharacter(charName) self.loadCharacter(charName)
@ -2598,27 +2602,27 @@ class GUI(QtGui.QWidget):
elif isinstance(charName, QtCore.QString): elif isinstance(charName, QtCore.QString):
charName = unicode(charName.toLower()) charName = unicode(charName.toLower())
#self.charName = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "options", "name", charName.decode('utf-8').lower() #self.charName = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "options", "name", charName.decode('utf-8').lower()
self.charName = charName # Just use the folder name self.charName = charName # Just use the folder name
self.charShowname = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "options", "showname") self.charShowname = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "options", "showname")
if not self.charShowname == "": if not self.charShowname == "":
self.charShowname = self.charShowname.decode('utf-8') self.charShowname = self.charShowname.decode('utf-8')
self.charSide = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "options", "side", "def") self.charSide = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "options", "side", "def")
self.boxPositions.setCurrentIndex(self.boxPositions.findText(self.charSide)) self.boxPositions.setCurrentIndex(self.boxPositions.findText(self.charSide))
self.setJudgeButtons() self.setJudgeButtons()
for emoteind in range(1, ini.read_ini_int(AOpath + "characters/"+self.charName+"/char.ini", "emotions", "number") + 1): for emoteind in range(1, ini.read_ini_int(BASE_PATH + "characters/"+self.charName+"/char.ini", "emotions", "number") + 1):
if emoteind == 1: if emoteind == 1:
suffix = 'on' suffix = 'on'
else: else:
suffix = 'off' suffix = 'off'
emote = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "emotions", str(emoteind), 'normal#(a)normal#normal#0#') emote = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "emotions", str(emoteind), 'normal#(a)normal#normal#0#')
sound = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "soundn", str(emoteind), '1') sound = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "soundn", str(emoteind), '1')
soundt = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "soundt", str(emoteind), '0') soundt = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "soundt", str(emoteind), '0')
soundl = ini.read_ini(AOpath + 'characters/' + charName + '/char.ini', "soundl", str(emoteind), '0') # AO 2.8 soundl = ini.read_ini(BASE_PATH + 'characters/' + charName + '/char.ini', "soundl", str(emoteind), '0') # AO 2.8
emoteList = emote.split('#') emoteList = emote.split('#')
deskmod = emoteList.pop(len(emoteList) - 1) deskmod = emoteList.pop(len(emoteList) - 1)
@ -2668,9 +2672,9 @@ class GUI(QtGui.QWidget):
for nEmote in range(emotesOnPage): for nEmote in range(emotesOnPage):
nRealEmote = nEmote + self.currentEmotePage * self.maxEmotesOnPage nRealEmote = nEmote + self.currentEmotePage * self.maxEmotesOnPage
if nRealEmote == self.selectedEmote: if nRealEmote == self.selectedEmote:
image = QtGui.QPixmap(AOpath + 'characters/' + self.charName + '/emotions/button' + str(nRealEmote + 1) + '_on.png') image = QtGui.QPixmap(BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(nRealEmote + 1) + '_on.png')
else: else:
image = QtGui.QPixmap(AOpath + 'characters/' + self.charName + '/emotions/button' + str(nRealEmote + 1) + '_off.png') image = QtGui.QPixmap(BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(nRealEmote + 1) + '_off.png')
if not image.isNull() and not image.width() == 40: if not image.isNull() and not image.width() == 40:
self.emoteButtons[nEmote].setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)) self.emoteButtons[nEmote].setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation))
@ -2686,8 +2690,8 @@ class GUI(QtGui.QWidget):
def loadSwapCharacters(self): def loadSwapCharacters(self):
self.charsFolder = [] self.charsFolder = []
self.iniSwapList.clear() self.iniSwapList.clear()
for folder in os.listdir(unicode(AOpath + 'characters')): for folder in os.listdir(unicode(BASE_PATH + 'characters')):
if exists(AOpath + 'characters/' + folder + '/char.ini'): if exists(BASE_PATH + 'characters/' + folder + '/char.ini'):
self.charsFolder.append(folder) self.charsFolder.append(folder)
self.iniSwapList.addItem(folder) self.iniSwapList.addItem(folder)
@ -2901,7 +2905,7 @@ class GUI(QtGui.QWidget):
self.inboxTimer.stop() self.inboxTimer.stop()
self.chatTickTimer.stop() self.chatTickTimer.stop()
self.disconnectCommon() self.disconnectCommon()
self.gamewindow.returnToMenu() self.mainWindow.returnToMenu()
else: else:
self.charSelect.showCharSelect() self.charSelect.showCharSelect()
@ -3007,10 +3011,10 @@ class GUI(QtGui.QWidget):
self.selectedEmote = ind self.selectedEmote = ind
for button in self.emoteButtons: for button in self.emoteButtons:
if button.emoteid == ind: if button.emoteid == ind:
button.path = AOpath + 'characters/' + self.charName + '/emotions/button' + str(button.emoteid + self.currentEmotePage * self.maxEmotesOnPage + 1) button.path = BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(button.emoteid + self.currentEmotePage * self.maxEmotesOnPage + 1)
image = QtGui.QPixmap(button.path + '_on.png') image = QtGui.QPixmap(button.path + '_on.png')
else: else:
image = QtGui.QPixmap(AOpath + 'characters/' + self.charName + '/emotions/button' + str(button.emoteid + self.currentEmotePage * self.maxEmotesOnPage + 1) + '_off.png') image = QtGui.QPixmap(BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(button.emoteid + self.currentEmotePage * self.maxEmotesOnPage + 1) + '_off.png')
if not image.isNull() and not image.width() == 40: if not image.isNull() and not image.width() == 40:
button.setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)) button.setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation))
@ -3032,7 +3036,7 @@ class GUI(QtGui.QWidget):
reply = QtGui.QMessageBox.warning(self, *args, **kwargs) reply = QtGui.QMessageBox.warning(self, *args, **kwargs)
if self.willDisconnect: if self.willDisconnect:
self.disconnectCommon() self.disconnectCommon()
self.gamewindow.returnToMenu() self.mainWindow.returnToMenu()
def exitCommon(self): def exitCommon(self):
self.disconnectCommon() self.disconnectCommon()
@ -3041,6 +3045,8 @@ class GUI(QtGui.QWidget):
self.speaker.wait() self.speaker.wait()
def disconnectCommon(self): def disconnectCommon(self):
self.gotPV = False
self.charName = ""
self.onSwitchInventory(True) self.onSwitchInventory(True)
self.selectedPlayer = -1 self.selectedPlayer = -1
self.playerItems.clear() self.playerItems.clear()
@ -3256,7 +3262,7 @@ class GUI(QtGui.QWidget):
for fEmote in emotes_to_check: for fEmote in emotes_to_check:
packet += fEmote packet += fEmote
if ini.read_ini_bool("AO2XP.ini", "General", "network frame effects", True): if ini.read_ini_bool("AO2XP.ini", "General", "network frame effects", True):
sfx_frames = "|".join(ini.read_ini_tags(AOpath + "characters/"+self.charName+"/char.ini", fEmote + f_effect)) sfx_frames = "|".join(ini.read_ini_tags(BASE_PATH + "characters/"+self.charName+"/char.ini", fEmote + f_effect))
if sfx_frames: if sfx_frames:
packet += "|" + sfx_frames packet += "|" + sfx_frames
packet += "^" packet += "^"
@ -3268,7 +3274,7 @@ class GUI(QtGui.QWidget):
if "effects" in self.features: if "effects" in self.features:
fx = self.boxEffects.currentText() if self.boxEffects.currentIndex() > 0 else "" fx = self.boxEffects.currentText() if self.boxEffects.currentIndex() > 0 else ""
fxSound = ini.get_effect_sound(fx, self.charName) fxSound = ini.get_effect_sound(fx, self.charName)
p_effect = ini.read_ini(AOpath + "characters/"+self.charName+"/char.ini", "options", "effects") p_effect = ini.read_ini(BASE_PATH + "characters/"+self.charName+"/char.ini", "options", "effects")
msg += str(fx + "|" + p_effect + "|" + fxSound + "#").encode('utf-8') msg += str(fx + "|" + p_effect + "|" + fxSound + "#").encode('utf-8')
self.boxEffects.setCurrentIndex(0) self.boxEffects.setCurrentIndex(0)
@ -3276,9 +3282,9 @@ class GUI(QtGui.QWidget):
# AO 2.10.2+ # AO 2.10.2+
if "custom_blips" in self.features: if "custom_blips" in self.features:
blip = ini.read_ini(AOpath + "characters/"+self.charName+"/char.ini", "options", "blips") blip = ini.read_ini(BASE_PATH + "characters/"+self.charName+"/char.ini", "options", "blips")
if not blip: if not blip:
blip = ini.read_ini(AOpath + "characters/"+self.charName+"/char.ini", "options", "gender") blip = ini.read_ini(BASE_PATH + "characters/"+self.charName+"/char.ini", "options", "gender")
if blip: if blip:
msg += str(blip) + "#" msg += str(blip) + "#"
@ -3301,7 +3307,7 @@ class GUI(QtGui.QWidget):
else: else:
self.background = bg self.background = bg
if not exists(AOpath + 'background/' + bg): if not exists(BASE_PATH + 'background/' + bg):
bg = 'default' bg = 'default'
for bgfile in [["sideDef", "defenseempty"], for bgfile in [["sideDef", "defenseempty"],
@ -3321,7 +3327,7 @@ class GUI(QtGui.QWidget):
["sideSea", "seancestand"], ["sideSea", "seancestand"],
["benchSea", "seancedesk"]]: ["benchSea", "seancedesk"]]:
bgimg = QtGui.QImage(AOpath + 'background/' + bg + '/' + bgfile[1] + '.png') bgimg = QtGui.QImage(BASE_PATH + 'background/' + bg + '/' + bgfile[1] + '.png')
if not bgimg.isNull(): if not bgimg.isNull():
if bgimg.size().width() != self.viewport.width() or bgimg.size().height() != self.viewport.height(): if bgimg.size().width() != self.viewport.width() or bgimg.size().height() != self.viewport.height():
if "bench" in bgfile[0]: if "bench" in bgfile[0]:
@ -3334,7 +3340,7 @@ class GUI(QtGui.QWidget):
else: else:
setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg)) setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg))
court = AOpath + 'background/' + bg + '/court.png' court = BASE_PATH + 'background/' + bg + '/court.png'
self.slideAvailable = exists(court) self.slideAvailable = exists(court)
if self.slideAvailable: if self.slideAvailable:
@ -3344,7 +3350,7 @@ class GUI(QtGui.QWidget):
self.slideBg.resize(slide_width, self.viewport.height()) self.slideBg.resize(slide_width, self.viewport.height())
self.slideBg.setPixmap(slide.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) self.slideBg.setPixmap(slide.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
courtOverlay = AOpath + 'background/' + bg + '/courtOverlay.png' courtOverlay = BASE_PATH + 'background/' + bg + '/courtOverlay.png'
if exists(courtOverlay): if exists(courtOverlay):
slideOverlay = QtGui.QPixmap(courtOverlay) slideOverlay = QtGui.QPixmap(courtOverlay)
self.slideOverlay.resize(slide_width, self.viewport.height()) self.slideOverlay.resize(slide_width, self.viewport.height())
@ -3376,7 +3382,7 @@ class GUI(QtGui.QWidget):
self.slideDirection = value[1] self.slideDirection = value[1]
# TODO: play only first frame of preanim, figure out zooms # TODO: play only first frame of preanim, figure out zooms
scaling = getScaling(ini.read_ini(AOpath + 'characters/' + self.mChatMessage[CHARNAME].lower() + '/char.ini', "options", "scaling").lower()) scaling = getScaling(ini.read_ini(BASE_PATH + 'characters/' + self.mChatMessage[CHARNAME].lower() + '/char.ini', "options", "scaling").lower())
if self.mChatMessage[FLIP] == "1": if self.mChatMessage[FLIP] == "1":
self.slideSpeaker.setFlipped(True) self.slideSpeaker.setFlipped(True)
else: else:
@ -3878,7 +3884,7 @@ class GUI(QtGui.QWidget):
self.objectionView.raise_() self.objectionView.raise_()
self.whiteFlashLabel.raise_() self.whiteFlashLabel.raise_()
self.scaling[1] = getScaling(ini.read_ini(AOpath + 'characters/' + self.mChatMessage[OTHER_NAME].lower() + '/char.ini', "options", "scaling").lower()) self.scaling[1] = getScaling(ini.read_ini(BASE_PATH + 'characters/' + self.mChatMessage[OTHER_NAME].lower() + '/char.ini', "options", "scaling").lower())
self.sideChar.setFlipped(self.mChatMessage[OTHER_FLIP] == "1") self.sideChar.setFlipped(self.mChatMessage[OTHER_FLIP] == "1")
if not self.animIsEmpty: if not self.animIsEmpty:
@ -3888,7 +3894,7 @@ class GUI(QtGui.QWidget):
self.sideChar.hide() self.sideChar.hide()
self.sideChar.move(0, 0) self.sideChar.move(0, 0)
self.scaling[0] = getScaling(ini.read_ini(AOpath + 'characters/' + self.mChatMessage[CHARNAME].lower() + '/char.ini', "options", "scaling").lower()) self.scaling[0] = getScaling(ini.read_ini(BASE_PATH + 'characters/' + self.mChatMessage[CHARNAME].lower() + '/char.ini', "options", "scaling").lower())
if self.slideEnabled and self.slideAvailable: if self.slideEnabled and self.slideAvailable:
if side == "wit": if side == "wit":
@ -3919,8 +3925,8 @@ class GUI(QtGui.QWidget):
fChar = self.mChatMessage[CHARNAME].lower() fChar = self.mChatMessage[CHARNAME].lower()
fPreanim = self.mChatMessage[PREANIM].strip() fPreanim = self.mChatMessage[PREANIM].strip()
ao2Duration = ini.read_ini_int(AOpath + "characters/" + fChar + "/char.ini", "time", fPreanim, -1) ao2Duration = ini.read_ini_int(BASE_PATH + "characters/" + fChar + "/char.ini", "time", fPreanim, -1)
textDelay = ini.read_ini_int(AOpath + "characters/" + fChar + "/char.ini", "textdelay", fPreanim, -1) textDelay = ini.read_ini_int(BASE_PATH + "characters/" + fChar + "/char.ini", "textdelay", fPreanim, -1)
sfxDelay = int(self.mChatMessage[SFX_DELAY]) * 60 sfxDelay = int(self.mChatMessage[SFX_DELAY]) * 60
if sfxDelay > 0: if sfxDelay > 0:
@ -3930,9 +3936,9 @@ class GUI(QtGui.QWidget):
preanimDuration = ao2Duration preanimDuration = ao2Duration
animToFind = AOpath + "characters/" + fChar + "/" + fPreanim + ".gif" animToFind = BASE_PATH + "characters/" + fChar + "/" + fPreanim + ".gif"
apngToFind = AOpath + "characters/" + fChar + "/" + fPreanim + ".apng" apngToFind = BASE_PATH + "characters/" + fChar + "/" + fPreanim + ".apng"
webpToFind = AOpath + "characters/" + fChar + "/" + fPreanim + ".webp" webpToFind = BASE_PATH + "characters/" + fChar + "/" + fPreanim + ".webp"
if (not animToFind and not apngToFind and not webpToFind) or preanimDuration < 0: if (not animToFind and not apngToFind and not webpToFind) or preanimDuration < 0:
if nonInterrupting: if nonInterrupting:
@ -4089,10 +4095,10 @@ class GUI(QtGui.QWidget):
self.blip = "male" self.blip = "male"
path = testPath( path = testPath(
AOpath + "sounds/blips/"+ self.blip +".wav", BASE_PATH + "sounds/blips/"+ self.blip +".wav",
AOpath + "sounds/blips/"+ self.blip +".opus", BASE_PATH + "sounds/blips/"+ self.blip +".opus",
AOpath + "sounds/general/sfx-blip"+ self.blip +".wav", BASE_PATH + "sounds/general/sfx-blip"+ self.blip +".wav",
AOpath + "sounds/general/sfx-blip"+ self.blip +".opus" BASE_PATH + "sounds/general/sfx-blip"+ self.blip +".opus"
) )
if path: if path:
@ -4326,20 +4332,20 @@ class GUI(QtGui.QWidget):
objecting = ["holdit", "objection", "takethat", "custom"][objection - 1] objecting = ["holdit", "objection", "takethat", "custom"][objection - 1]
if objecting: if objecting:
if exists(AOpath + 'characters/' + charName + '/' + objecting + '.wav'): if exists(BASE_PATH + 'characters/' + charName + '/' + objecting + '.wav'):
self.sndObjection = audio.loadHandle(False, AOpath + 'characters/' + charName + '/' + objecting + '.wav', 0, 0, 0) self.sndObjection = audio.loadHandle(False, BASE_PATH + 'characters/' + charName + '/' + objecting + '.wav', 0, 0, 0)
elif exists(AOpath + 'characters/' + charName + '/' + objecting + '.opus'): elif exists(BASE_PATH + 'characters/' + charName + '/' + objecting + '.opus'):
self.sndObjection = audio.loadHandle(False, AOpath + 'characters/' + charName + '/' + objecting + '.opus', 0, 0, 0) self.sndObjection = audio.loadHandle(False, BASE_PATH + 'characters/' + charName + '/' + objecting + '.opus', 0, 0, 0)
else: else:
self.sndObjection = None self.sndObjection = None
if ini.read_ini_bool("AO2XP.ini", "General", "download sounds", True): if ini.read_ini_bool("AO2XP.ini", "General", "download sounds", True):
thread.start_new_thread(downloadThread, ("base/characters/"+charName+"/"+objecting+".wav", AOpath + "characters/"+charName+"/"+objecting.lower() + ".wav")) thread.start_new_thread(downloadThread, ("base/characters/"+charName+"/"+objecting+".wav", BASE_PATH + "characters/"+charName+"/"+objecting.lower() + ".wav"))
thread.start_new_thread(downloadThread, ("base/characters/"+charName+"/"+objecting+".opus", AOpath + "characters/"+charName+"/"+objecting.lower() + ".wav")) thread.start_new_thread(downloadThread, ("base/characters/"+charName+"/"+objecting+".opus", BASE_PATH + "characters/"+charName+"/"+objecting.lower() + ".wav"))
if exists(AOpath + 'sounds/general/sfx-objection.opus'): if exists(BASE_PATH + 'sounds/general/sfx-objection.opus'):
self.sndObjection = audio.loadHandle(False, AOpath + 'sounds/general/sfx-objection.opus', 0, 0, 0) self.sndObjection = audio.loadHandle(False, BASE_PATH + 'sounds/general/sfx-objection.opus', 0, 0, 0)
else: else:
self.sndObjection = audio.loadHandle(False, AOpath + 'sounds/general/sfx-objection.wav', 0, 0, 0) self.sndObjection = audio.loadHandle(False, BASE_PATH + 'sounds/general/sfx-objection.wav', 0, 0, 0)
audio.setHandleAttr(self.sndObjection, BASS_ATTRIB_VOL, self.sliSoundVolume.value() / 100.0) audio.setHandleAttr(self.sndObjection, BASS_ATTRIB_VOL, self.sliSoundVolume.value() / 100.0)
audio.playHandle(self.sndObjection, True) audio.playHandle(self.sndObjection, True)
@ -4369,9 +4375,9 @@ class GUI(QtGui.QWidget):
audio.freeHandle(self.sound[self.soundChannel]) audio.freeHandle(self.sound[self.soundChannel])
path = testPath( path = testPath(
AOpath + 'sounds/general/' + sfx, BASE_PATH + 'sounds/general/' + sfx,
AOpath + 'sounds/general/' + sfx + '.wav', BASE_PATH + 'sounds/general/' + sfx + '.wav',
AOpath + 'sounds/general/' + sfx + '.opus' BASE_PATH + 'sounds/general/' + sfx + '.opus'
) )
if path: if path:
@ -4394,16 +4400,16 @@ class GUI(QtGui.QWidget):
playLocal = False playLocal = False
if exists(AOpath + 'sounds/music/' + musl): if exists(BASE_PATH + 'sounds/music/' + musl):
playLocal = True playLocal = True
elif self.pickedMusicItem: elif self.pickedMusicItem:
_musl = _musicList[self.musicItems.currentItem().text()] _musl = _musicList[self.musicItems.currentItem().text()]
if exists(AOpath + 'sounds/music/' + _musl): if exists(BASE_PATH + 'sounds/music/' + _musl):
musl = _musl musl = _musl
playLocal = True playLocal = True
elif musl.startswith("http"): elif musl.startswith("http"):
_musl = urllib.unquote(basename(mus)) _musl = urllib.unquote(basename(mus))
if exists(AOpath + 'sounds/music/' + _musl): if exists(BASE_PATH + 'sounds/music/' + _musl):
musl = _musl musl = _musl
playLocal = True playLocal = True
@ -4415,7 +4421,7 @@ class GUI(QtGui.QWidget):
musl = musl.encode('mbcs') musl = musl.encode('mbcs')
else: else:
musl = musl.encode('utf-8') musl = musl.encode('utf-8')
self.music = audio.loadHandle(False, AOpath + 'sounds/music/' + musl, 0, 0, BASS_SAMPLE_LOOP) self.music = audio.loadHandle(False, BASE_PATH + 'sounds/music/' + musl, 0, 0, BASS_SAMPLE_LOOP)
if self.music: if self.music:
audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0) audio.setHandleAttr(self.music, BASS_ATTRIB_VOL, self.sliMusicVolume.value() / 100.0)
audio.playHandle(self.music, True) audio.playHandle(self.music, True)
@ -4501,7 +4507,7 @@ class GUI(QtGui.QWidget):
for song, fname in _musicList.items(): for song, fname in _musicList.items():
songitem = QtGui.QListWidgetItem() songitem = QtGui.QListWidgetItem()
songitem.setText(song) songitem.setText(song)
if not self.privateMusicSelected and exists(unicode(AOpath + 'sounds/music/' + decodeAOString(fname).lower())): if not self.privateMusicSelected and exists(unicode(BASE_PATH + 'sounds/music/' + decodeAOString(fname).lower())):
songitem.setBackgroundColor(QtGui.QColor(self.foundSongItemColor)) songitem.setBackgroundColor(QtGui.QColor(self.foundSongItemColor))
self.musicItems.addItem(songitem) self.musicItems.addItem(songitem)
@ -4547,7 +4553,7 @@ class GUI(QtGui.QWidget):
_data = self.charList[int(data)][0] if data.isdigit() else decodeAOString(data) _data = self.charList[int(data)][0] if data.isdigit() else decodeAOString(data)
else: else:
_dataInt, ok = data.toInt() _dataInt, ok = data.toInt()
_data = self.charList[int(_dataInt)][0] if ok else data _data = self.charList[int(_dataInt)][0] if ok else decodeAOString(data)
self.playerList[pid][utype] = _data self.playerList[pid][utype] = _data
item = self.playerItems.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith) item = self.playerItems.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
@ -4658,7 +4664,6 @@ class GUI(QtGui.QWidget):
global bucket global bucket
bucket = webAO_bucket bucket = webAO_bucket
self.charSelect.setCharList(charList)
autopick = getOption("General", "auto pick").decode('utf-8').lower() autopick = getOption("General", "auto pick").decode('utf-8').lower()
coincidence = -1 coincidence = -1
for i, char in enumerate(self.charList): for i, char in enumerate(self.charList):
@ -4667,8 +4672,10 @@ class GUI(QtGui.QWidget):
break break
if coincidence > -1: if coincidence > -1:
self.setDisabled(True)
self.charSelect.selectChar(coincidence) self.charSelect.selectChar(coincidence)
else: else:
self.charSelect.setCharList(charList)
self.charSelect.showCharSelect(False) self.charSelect.showCharSelect(False)
# Putting it down here because some servers won't allow you to switch areas without picking a character first # Putting it down here because some servers won't allow you to switch areas without picking a character first
@ -4712,7 +4719,7 @@ class GUI(QtGui.QWidget):
self.healthbars.emit(hp[0], hp[1]) self.healthbars.emit(hp[0], hp[1])
for char in self.charList: for char in self.charList:
if not exists(AOpath + 'characters/' + char[0].lower() + '/char.ini'): if not exists(BASE_PATH + 'characters/' + char[0].lower() + '/char.ini'):
continue continue
char[2] = getCharIni(char[0], "Options", "gender").lower() char[2] = getCharIni(char[0], "Options", "gender").lower()
if not char[2]: if not char[2]:
@ -4733,6 +4740,9 @@ class GUI(QtGui.QWidget):
for evi in evidence: for evi in evidence:
self.boxEvidence.addItem(evi[0].strip()) self.boxEvidence.addItem(evi[0].strip())
if tcp.isWS and tcp.isSecure:
self.OOCLog.append("<b>--- Using a secure connection ---</b>")
logstart = '<b>--- Log started on ' + time.ctime() + ' ---</b>' logstart = '<b>--- Log started on ' + time.ctime() + ' ---</b>'
if self.OOCLog.toPlainText(): if self.OOCLog.toPlainText():
self.OOCLog.append("\n"+logstart) self.OOCLog.append("\n"+logstart)

View File

@ -24,22 +24,22 @@ class PicButton(QtGui.QAbstractButton):
def setPixmap(self, pixmap): def setPixmap(self, pixmap):
self.pixmap = pixmap self.pixmap = pixmap
class lobby(QtGui.QWidget): class Lobby(QtGui.QWidget):
gamewindow = None mainWindow = None
tab = 0 tab = 0
def __init__(self, parent=None, demo=None): def __init__(self, parent=None, demo=None):
super(lobby, self).__init__(parent) super(Lobby, self).__init__(parent)
self.can_connect = False self.canConnect = False
self.svclicked = None self.svclicked = None
self.gamewindow = parent self.mainWindow = parent
self.pix_lobby = QtGui.QPixmap(AO2XPpath+'themes/default/lobbybackground.png') self.pixLobby = QtGui.QPixmap(AO2XPpath+'themes/default/lobbybackground.png')
self.pix_btn_public = QtGui.QPixmap(AO2XPpath+'themes/default/publicservers.png') self.pixBtnPublic = QtGui.QPixmap(AO2XPpath+'themes/default/publicservers.png')
self.pix_btn_favs = QtGui.QPixmap(AO2XPpath+'themes/default/favorites.png') self.pixBtnFavs = QtGui.QPixmap(AO2XPpath+'themes/default/favorites.png')
self.pix_btn_refresh = QtGui.QPixmap(AO2XPpath+'themes/default/refresh.png') self.pixBtnRefresh = QtGui.QPixmap(AO2XPpath+'themes/default/refresh.png')
self.pix_btn_addfav = QtGui.QPixmap(AO2XPpath+'themes/default/addtofav.png') self.pixBtnAddfav = QtGui.QPixmap(AO2XPpath+'themes/default/addtofav.png')
self.pix_btn_connect = QtGui.QPixmap(AO2XPpath+'themes/default/connect.png') self.pixBtnConnect = QtGui.QPixmap(AO2XPpath+'themes/default/connect.png')
self.pix_connecting = QtGui.QPixmap(AO2XPpath+'themes/default/loadingbackground.png') self.pixConnecting = QtGui.QPixmap(AO2XPpath+'themes/default/loadingbackground.png')
self.autoconnect = None self.autoconnect = None
@ -47,10 +47,10 @@ class lobby(QtGui.QWidget):
with open('serverlist.txt') as file: with open('serverlist.txt') as file:
self.favoriteslist = [line.rstrip().split(':') for line in file] self.favoriteslist = [line.rstrip().split(':') for line in file]
autoconnect_id = ini.read_ini_int("AO2XP.ini", "General", "auto connect", -1) autoconnectId = ini.read_ini_int("AO2XP.ini", "General", "auto connect", -1)
if autoconnect_id >= 0: if autoconnectId >= 0:
try: try:
self.autoconnect = self.favoriteslist[autoconnect_id] self.autoconnect = self.favoriteslist[autoconnectId]
except: except:
print "[debug] Can't autoconnect to server." print "[debug] Can't autoconnect to server."
else: else:
@ -58,49 +58,49 @@ class lobby(QtGui.QWidget):
#self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '127.0.0.1:27016:your server (port 27016)'.split(':'),] #self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '127.0.0.1:27016:your server (port 27016)'.split(':'),]
self.lobbyimg = QtGui.QLabel(self) self.lobbyimg = QtGui.QLabel(self)
self.lobbyimg.setPixmap(self.pix_lobby) self.lobbyimg.setPixmap(self.pixLobby)
self.lobbyimg.show() self.lobbyimg.show()
self.connectingimg = QtGui.QLabel(self) self.connectingimg = QtGui.QLabel(self)
self.connectingimg.setPixmap(self.pix_connecting) self.connectingimg.setPixmap(self.pixConnecting)
self.connectingimg.hide() self.connectingimg.hide()
self.btnSettings = QtGui.QPushButton(self) self.btnSettings = QtGui.QPushButton(self)
self.btnSettings.setText("Settings") self.btnSettings.setText("Settings")
self.btnSettings.resize(self.btnSettings.sizeHint()) self.btnSettings.resize(self.btnSettings.sizeHint())
self.btnSettings.move(self.pix_lobby.size().width() - self.btnSettings.size().width(), 0) self.btnSettings.move(self.pixLobby.size().width() - self.btnSettings.size().width(), 0)
self.btnSettings.clicked.connect(self.onSettingsClicked) self.btnSettings.clicked.connect(self.onSettingsClicked)
self.demobtn = QtGui.QPushButton(self) self.btnDemo = QtGui.QPushButton(self)
self.demobtn.setText("Play a demo") self.btnDemo.setText("Play a demo")
self.demobtn.resize(self.demobtn.sizeHint()) self.btnDemo.resize(self.btnDemo.sizeHint())
self.demobtn.move(self.btnSettings.x() - self.demobtn.size().width(), 0) self.btnDemo.move(self.btnSettings.x() - self.btnDemo.size().width(), 0)
self.demobtn.clicked.connect(self.on_demo_clicked) self.btnDemo.clicked.connect(self.onDemoClicked)
self.btn_public = PicButton(self.pix_btn_public, self) self.btnPublic = PicButton(self.pixBtnPublic, self)
self.btn_public.resize(self.btn_public.sizeHint()) self.btnPublic.resize(self.btnPublic.sizeHint())
self.btn_public.move(46, 88) self.btnPublic.move(46, 88)
self.btn_public.clicked.connect(self.onClicked_public) self.btnPublic.clicked.connect(self.onClickedPublic)
self.btn_favs = PicButton(self.pix_btn_favs, self) self.btnFavs = PicButton(self.pixBtnFavs, self)
self.btn_favs.resize(self.btn_favs.sizeHint()) self.btnFavs.resize(self.btnFavs.sizeHint())
self.btn_favs.move(164, 88) self.btnFavs.move(164, 88)
self.btn_favs.clicked.connect(self.onClicked_favs) self.btnFavs.clicked.connect(self.onClickedFavs)
self.btn_refresh = PicButton(self.pix_btn_refresh, self) self.btnRefresh = PicButton(self.pixBtnRefresh, self)
self.btn_refresh.resize(self.btn_refresh.sizeHint()) self.btnRefresh.resize(self.btnRefresh.sizeHint())
self.btn_refresh.move(56, 381) self.btnRefresh.move(56, 381)
self.btn_refresh.clicked.connect(self.onClicked_refresh) self.btnRefresh.clicked.connect(self.onClickedRefresh)
self.btn_addfav = PicButton(self.pix_btn_addfav, self) self.btnAddfav = PicButton(self.pixBtnAddfav, self)
self.btn_addfav.resize(self.btn_addfav.sizeHint()) self.btnAddfav.resize(self.btnAddfav.sizeHint())
self.btn_addfav.move(194, 381) self.btnAddfav.move(194, 381)
self.btn_addfav.clicked.connect(self.onClicked_addfav) self.btnAddfav.clicked.connect(self.onClickedAddfav)
self.btn_connect = PicButton(self.pix_btn_connect, self) self.btnConnect = PicButton(self.pixBtnConnect, self)
self.btn_connect.resize(self.btn_connect.sizeHint()) self.btnConnect.resize(self.btnConnect.sizeHint())
self.btn_connect.move(332, 381) self.btnConnect.move(332, 381)
self.btn_connect.clicked.connect(self.onClicked_connect) self.btnConnect.clicked.connect(self.onClickedConnect)
self.serverlist = QtGui.QListWidget(self) self.serverlist = QtGui.QListWidget(self)
self.serverlist.resize(286, 240) self.serverlist.resize(286, 240)
@ -108,7 +108,7 @@ class lobby(QtGui.QWidget):
p = self.serverlist.viewport().palette() p = self.serverlist.viewport().palette()
p.setColor(self.serverlist.viewport().backgroundRole(), QtGui.QColor(114,114,114)) p.setColor(self.serverlist.viewport().backgroundRole(), QtGui.QColor(114,114,114))
self.serverlist.viewport().setPalette(p) self.serverlist.viewport().setPalette(p)
self.serverlist.itemClicked.connect(self.onClicked_serverlist) self.serverlist.itemClicked.connect(self.onClickedServerlist)
self.onlineplayers = QtGui.QLabel(self) self.onlineplayers = QtGui.QLabel(self)
self.onlineplayers.setStyleSheet('color: white') self.onlineplayers.setStyleSheet('color: white')
@ -130,10 +130,10 @@ class lobby(QtGui.QWidget):
self.connectcancel.setText('Cancel') self.connectcancel.setText('Cancel')
self.connectcancel.resize(80, 20) self.connectcancel.resize(80, 20)
self.connectcancel.move(220, 220) self.connectcancel.move(220, 220)
self.connectcancel.clicked.connect(self.onClicked_cancelconnect) self.connectcancel.clicked.connect(self.onClickedCancelconnect)
self.connectcancel.hide() self.connectcancel.hide()
self.actual_serverlist = [] self.actualServerlist = []
self.lobbychatlog = QtGui.QTextEdit(self) self.lobbychatlog = QtGui.QTextEdit(self)
self.lobbychatlog.setReadOnly(True) self.lobbychatlog.setReadOnly(True)
@ -141,7 +141,7 @@ class lobby(QtGui.QWidget):
p = self.lobbychatlog.viewport().palette() p = self.lobbychatlog.viewport().palette()
p.setColor(self.lobbychatlog.viewport().backgroundRole(), QtGui.QColor(139,139,139)) p.setColor(self.lobbychatlog.viewport().backgroundRole(), QtGui.QColor(139,139,139))
self.lobbychatlog.viewport().setPalette(p) self.lobbychatlog.viewport().setPalette(p)
self.lobbychatlog.textChanged.connect(self.lobbychatlog_update) self.lobbychatlog.textChanged.connect(self.lobbychatlogUpdate)
self.whitecolor = QtGui.QColor(255, 255, 255) self.whitecolor = QtGui.QColor(255, 255, 255)
@ -159,35 +159,20 @@ class lobby(QtGui.QWidget):
self.connectprogress.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop) self.connectprogress.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop)
self.connectprogress.move(135-20, 92) self.connectprogress.move(135-20, 92)
self.oocname = 'Name'
self.OOCNameInput = QtGui.QLineEdit(self)
self.OOCNameInput.setText(self.oocname)
self.OOCNameInput.move(0, 646)
self.OOCNameInput.resize(91, 19)
self.OOCNameInput.setStyleSheet('background-color: rgb(87, 87, 87);')
self.OOCNameInput.textChanged.connect(self.setoocname)
self.lobbychatinput = QtGui.QLineEdit(self)
self.lobbychatinput.setPlaceholderText("Say something...")
self.lobbychatinput.move(90, 646)
self.lobbychatinput.resize(427, 19)
self.lobbychatinput.setStyleSheet('background-color: rgb(87, 87, 87);')
self.lobbychatinput.returnPressed.connect(self.lobby_sendchat)
self.aoserverinfo = AOServerInfo() self.aoserverinfo = AOServerInfo()
self.aoserverinfo.moveToGameSignal.connect(self.moveToGame) self.aoserverinfo.moveToGameSignal.connect(self.mainWindow.showGame)
self.aoserverinfo.msgbox_signal.connect(self.showMessageBox) self.aoserverinfo.msgboxSignal.connect(self.showMessageBox)
self.aoserverinfo.setOnlinePlayers.connect(self.onlineplayers.setText) self.aoserverinfo.setOnlinePlayers.connect(self.onlineplayers.setText)
self.aoserverinfo.returnToLobby.connect(self.onClicked_cancelconnect) self.aoserverinfo.returnToLobby.connect(self.onClickedCancelconnect)
self.aoserverinfo.setConnectProgress.connect(self.connectprogress.setText) self.aoserverinfo.setConnectProgress.connect(self.connectprogress.setText)
self.aoserverinfo.readySoon.connect(self.connectcancel.hide) self.aoserverinfo.readySoon.connect(self.connectcancel.hide)
self.aoserverinfo.setWindowTitle.connect(self.gamewindow.setWindowTitle) self.aoserverinfo.setWindowTitle.connect(self.mainWindow.setWindowTitle)
self.aoserverinfo.canConnect.connect(self.canConnect) self.aoserverinfo.canConnect.connect(self.setCanConnect)
self.masterserver = MasterServer() self.masterserver = MasterServer()
self.masterserver.gotServers.connect(self.onGetServers) self.masterserver.gotServers.connect(self.onGetServers)
self.masterserver.gotOOCMsg.connect(self.newOOCMessage) self.masterserver.gotOOCMsg.connect(self.newOOCMessage)
self.masterserver.msgbox_signal.connect(self.showMessageBox) self.masterserver.msgboxSignal.connect(self.showMessageBox)
self.masterserver.start() self.masterserver.start()
if not demo and self.autoconnect: if not demo and self.autoconnect:
@ -196,15 +181,15 @@ class lobby(QtGui.QWidget):
self.aoserverinfo.stop() self.aoserverinfo.stop()
self.aoserverinfo.start() self.aoserverinfo.start()
def canConnect(self): def setCanConnect(self):
self.can_connect = True self.canConnect = True
if self.autoconnect: if self.autoconnect:
self.autoconnect = None # We only want to autoconnect on first login after all self.autoconnect = None # We only want to autoconnect on first login after all
self.onClicked_connect() self.onClickedConnect()
def onGetServers(self, servers): def onGetServers(self, servers):
if self.tab == 0: self.serverlist.clear() if self.tab == 0: self.serverlist.clear()
self.actual_serverlist = [] self.actualServerlist = []
del servers[0] del servers[0]
del servers[-1] del servers[-1]
for server in servers: for server in servers:
@ -212,47 +197,33 @@ class lobby(QtGui.QWidget):
desc = server["description"] desc = server["description"]
ip = server["ip"] ip = server["ip"]
port = server["port"] port = server["port"]
ws_port = server["ws_port"] if "ws_port" in server else 0 wsPort = server["ws_port"] if "ws_port" in server else 0
wss_port = server["wss_port"] if "wss_port" in server else 0 wssPort = server["wss_port"] if "wss_port" in server else 0
serveritem = QtGui.QListWidgetItem(name) serveritem = QtGui.QListWidgetItem(name)
if self.tab == 0: self.serverlist.addItem(serveritem) if self.tab == 0: self.serverlist.addItem(serveritem)
self.actual_serverlist.append((ip, port, name, desc, ws_port, wss_port)) self.actualServerlist.append((ip, port, name, desc, wsPort, wssPort))
def moveToGame(self, stuff):
tcp, playerList, charList, musicList, background, evidence, areas, features, joinOOC, hpList, webAO_bucket = stuff
self.move_to_game(tcp, playerList, charList, musicList, background, evidence, areas, features, joinOOC, hpList, webAO_bucket)
def onSettingsClicked(self): def onSettingsClicked(self):
self.gamewindow.showSettings() self.mainWindow.showSettings()
def on_demo_clicked(self): def onDemoClicked(self):
self.gamewindow.show_demo_picker() self.mainWindow.showDemoPicker()
def showMessageBox(self, type, title, message): def onClickedPublic(self):
if type == 0: #critical
return QtGui.QMessageBox.critical(self, title, message)
elif type == 1: #information
return QtGui.QMessageBox.information(self, title, message)
elif type == 2: #question
return QtGui.QMessageBox.question(self, title, message)
elif type == 3: #warning
return QtGui.QMessageBox.warning(self, title, message)
def onClicked_public(self):
self.tab = 0 self.tab = 0
self.serverlist.clear() self.serverlist.clear()
for sv in self.actual_serverlist: for sv in self.actualServerlist:
self.serverlist.addItem(QtGui.QListWidgetItem(sv[2])) self.serverlist.addItem(QtGui.QListWidgetItem(sv[2]))
def onClicked_favs(self): def onClickedFavs(self):
self.tab = 1 self.tab = 1
self.serverlist.clear() self.serverlist.clear()
self.serverinfo.setText("") self.serverinfo.setText("")
for sv in self.favoriteslist: for sv in self.favoriteslist:
self.serverlist.addItem(QtGui.QListWidgetItem(sv[-1])) self.serverlist.addItem(QtGui.QListWidgetItem(sv[-1]))
def onClicked_refresh(self): def onClickedRefresh(self):
self.serverlist.clear() self.serverlist.clear()
if self.tab == 0: if self.tab == 0:
try: try:
@ -268,7 +239,7 @@ class lobby(QtGui.QWidget):
else: else:
self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '0.0.0.0:27017:serverlist.txt not found on base folder'.split(':')] self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '0.0.0.0:27017:serverlist.txt not found on base folder'.split(':')]
def onClicked_addfav(self): def onClickedAddfav(self):
if self.tab == 1 or not self.svclicked: if self.tab == 1 or not self.svclicked:
if self.tab == 1: if self.tab == 1:
QtGui.QMessageBox.information(self, "???", "Wait. That's illegal.") QtGui.QMessageBox.information(self, "???", "Wait. That's illegal.")
@ -276,35 +247,37 @@ class lobby(QtGui.QWidget):
for i in range(self.serverlist.count()): for i in range(self.serverlist.count()):
if self.serverlist.item(i) == self.svclicked: if self.serverlist.item(i) == self.svclicked:
ip = self.actual_serverlist[i][0] ip = self.actualServerlist[i][0]
port = str(self.actual_serverlist[i][1]) port = str(self.actualServerlist[i][1])
name = self.actual_serverlist[i][2] name = self.actualServerlist[i][2]
ws = self.actual_serverlist[i][4] ws = self.actualServerlist[i][4]
wss = self.actual_serverlist[i][5] wss = self.actualServerlist[i][5]
for sv in self.favoriteslist: for sv in self.favoriteslist:
if sv[0] == ip and sv[1] == port: if sv[0] == ip and sv[1] == port:
return QtGui.QMessageBox.information(self, "Error", "This server already exists in your favorites list, named '%s'" % sv[2]) return QtGui.QMessageBox.information(self, "AO2XP", "This server already exists in your favorites list, named '%s'" % sv[4])
self.favoriteslist.append([ip, port, ws, wss, name]) self.favoriteslist.append([ip, port, ws, wss, name])
with open('serverlist.txt', "a") as file: with open('serverlist.txt', "a") as file:
file.write("%s:%s:%s:%s:%s\n" % (ip, port, ws, wss, name)) file.write("%s:%s:%s:%s:%s\n" % (ip, port, ws, wss, name))
file.close() file.close()
def onClicked_connect(self): QtGui.QMessageBox.information(self, "AO2XP", "The server '%s' was added to your favorites." % name)
if not self.can_connect:
def onClickedConnect(self):
if not self.canConnect:
return return
self.btn_public.hide() self.btnPublic.hide()
self.btn_favs.hide() self.btnFavs.hide()
self.btn_refresh.hide() self.btnRefresh.hide()
self.btn_addfav.hide() self.btnAddfav.hide()
self.btn_connect.hide() self.btnConnect.hide()
self.serverlist.hide() self.serverlist.hide()
self.onlineplayers.hide() self.onlineplayers.hide()
self.serverinfo.hide() self.serverinfo.hide()
self.btnSettings.hide() self.btnSettings.hide()
self.demobtn.hide() self.btnDemo.hide()
self.connectprogress.setText('Connecting...') self.connectprogress.setText('Connecting...')
self.connectingimg.show() self.connectingimg.show()
@ -312,63 +285,60 @@ class lobby(QtGui.QWidget):
self.connectprogress.show() self.connectprogress.show()
self.aoserverinfo.tcp.send('askchaa#%') self.aoserverinfo.tcp.send('askchaa#%')
def onClicked_cancelconnect(self): def onClickedCancelconnect(self):
self.connectingimg.hide() self.connectingimg.hide()
self.connectcancel.hide() self.connectcancel.hide()
self.connectprogress.hide() self.connectprogress.hide()
self.btn_public.show() self.btnPublic.show()
self.btn_favs.show() self.btnFavs.show()
self.btn_refresh.show() self.btnRefresh.show()
self.btn_addfav.show() self.btnAddfav.show()
self.btn_connect.show() self.btnConnect.show()
self.serverlist.show() self.serverlist.show()
self.onlineplayers.show() self.onlineplayers.show()
self.serverinfo.show() self.serverinfo.show()
self.btnSettings.show() self.btnSettings.show()
self.demobtn.show() self.btnDemo.show()
def onClicked_serverlist(self, item): def onClickedServerlist(self, item):
self.svclicked = item self.svclicked = item
self.can_connect = False self.canConnect = False
self.onlineplayers.setText('Retrieving...') self.onlineplayers.setText('Retrieving...')
text = item.text() text = item.text()
print '[debug]', 'you clicked %s' % text print '[debug]', 'Selected %s' % text
for i in range(self.serverlist.count()): for i in range(self.serverlist.count()):
if self.serverlist.item(i) == item: if self.serverlist.item(i) == item:
if self.tab == 0: if self.tab == 0:
self.serverinfo.setText(self.actual_serverlist[i][3]) self.serverinfo.setText(self.actualServerlist[i][3])
self.aoserverinfo.setIP(text, self.actual_serverlist[i][0], self.actual_serverlist[i][1], self.actual_serverlist[i][4], self.actual_serverlist[i][5]) self.aoserverinfo.setIP(text, self.actualServerlist[i][0], self.actualServerlist[i][1], self.actualServerlist[i][4], self.actualServerlist[i][5])
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.actual_serverlist[i][0] + ', port: ' + str(self.actual_serverlist[i][1]) + ", websocket port: " + str(self.actual_serverlist[i][4]) + ", secure websocket port: " + str(self.actual_serverlist[i][5]) print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.actualServerlist[i][0] + ', port: ' + str(self.actualServerlist[i][1]) + ", websocket port: " + str(self.actualServerlist[i][4]) + ", secure websocket port: " + str(self.actualServerlist[i][5])
elif self.tab == 1: elif self.tab == 1:
self.aoserverinfo.setIP(text, self.favoriteslist[i][0], self.favoriteslist[i][1], self.favoriteslist[i][2], self.favoriteslist[i][3]) self.aoserverinfo.setIP(text, self.favoriteslist[i][0], self.favoriteslist[i][1], self.favoriteslist[i][2], self.favoriteslist[i][3])
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.favoriteslist[i][0] + ', port: ' + str(self.favoriteslist[i][1]) + ", websocket port: " + str(self.favoriteslist[i][2]) + ", secure websocket port: " + str(self.favoriteslist[i][3]) print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.favoriteslist[i][0] + ', port: ' + str(self.favoriteslist[i][1]) + ", websocket port: " + str(self.favoriteslist[i][2]) + ", secure websocket port: " + str(self.favoriteslist[i][3])
self.aoserverinfo.stop() self.aoserverinfo.stop()
self.aoserverinfo.start() self.aoserverinfo.start()
def move_to_game(self, tcp, playerList, charList, musicList, background, evidence, areas, features=[], joinOOC=[], hpList=[], webAO_bucket=""): def lobbychatlogUpdate(self):
self.gamewindow.showGame(tcp, playerList, charList, musicList, background, evidence, areas, features, joinOOC, hpList, webAO_bucket)
def lobby_sendchat(self):
#text = self.lobbychatinput.text().toUtf8()
#self.masterserver.ms_tcp.send('CT#' +self.oocname+ '#' + text + '#%')
self.lobbychatlog.append("Lobby chat is not supported on the new HTTP-based masterserver.")
self.lobbychatinput.clear()
def setoocname(self):
self.oocname = self.OOCNameInput.text().toUtf8()
def lobbychatlog_update(self):
if self.lobbychatlog.verticalScrollBar().value() == self.lobbychatlog.verticalScrollBar().maximum(): self.lobbychatlog.verticalScrollBar().setValue(self.lobbychatlog.verticalScrollBar().maximum()) if self.lobbychatlog.verticalScrollBar().value() == self.lobbychatlog.verticalScrollBar().maximum(): self.lobbychatlog.verticalScrollBar().setValue(self.lobbychatlog.verticalScrollBar().maximum())
def newOOCMessage(self, text): def newOOCMessage(self, text):
self.lobbychatlog.append(text) self.lobbychatlog.append(text)
def showMessageBox(self, type, title, message):
if type == 0: #critical
return QtGui.QMessageBox.critical(self, title, message)
elif type == 1: #information
return QtGui.QMessageBox.information(self, title, message)
elif type == 2: #question
return QtGui.QMessageBox.question(self, title, message)
elif type == 3: #warning
return QtGui.QMessageBox.warning(self, title, message)
class MasterServer(QtCore.QThread): class MasterServer(QtCore.QThread):
gotServers = QtCore.pyqtSignal(list) gotServers = QtCore.pyqtSignal(list)
gotOOCMsg = QtCore.pyqtSignal(str) gotOOCMsg = QtCore.pyqtSignal(str)
msgbox_signal = QtCore.pyqtSignal(int, str, str) msgboxSignal = QtCore.pyqtSignal(int, str, str)
def __init__(self): def __init__(self):
super(MasterServer, self).__init__() super(MasterServer, self).__init__()
@ -376,18 +346,18 @@ class MasterServer(QtCore.QThread):
def run(self): def run(self):
try: try:
tempdata = "" tempdata = ""
self.ms_http = requests.get("http://servers.aceattorneyonline.com/servers") self.msHttp = requests.get("http://servers.aceattorneyonline.com/servers")
self.ms_motd = requests.get("http://servers.aceattorneyonline.com/motd") self.msMotd = requests.get("http://servers.aceattorneyonline.com/motd")
if self.ms_http.ok: self.gotServers.emit(json.loads(self.ms_http.content)) if self.msHttp.ok: self.gotServers.emit(json.loads(self.msHttp.content))
if self.ms_motd.ok: self.gotOOCMsg.emit(self.ms_motd.content) if self.msMotd.ok: self.gotOOCMsg.emit(self.msMotd.content)
except Exception as e: except Exception as e:
print "[debug] Failed to load server list:", e print "[debug] Failed to load server list:", e
QtGui.QMessageBox.critical(None, "Error", "Failed to load the master server list. Please check your internet connection and try again.") QtGui.QMessageBox.critical(None, "Error", "Failed to load the master server list. Please check your internet connection and try again.")
class AOServerInfo(QtCore.QThread): class AOServerInfo(QtCore.QThread):
moveToGameSignal = QtCore.pyqtSignal(list) moveToGameSignal = QtCore.pyqtSignal(list)
msgbox_signal = QtCore.pyqtSignal(int, str, str) msgboxSignal = QtCore.pyqtSignal(int, str, str)
setOnlinePlayers = QtCore.pyqtSignal(str) setOnlinePlayers = QtCore.pyqtSignal(str)
setConnectProgress = QtCore.pyqtSignal(str) setConnectProgress = QtCore.pyqtSignal(str)
returnToLobby = QtCore.pyqtSignal() returnToLobby = QtCore.pyqtSignal()
@ -399,20 +369,20 @@ class AOServerInfo(QtCore.QThread):
super(AOServerInfo, self).__init__() super(AOServerInfo, self).__init__()
self.ip = "" self.ip = ""
self.port = 0 self.port = 0
self.ws_port = 0 self.wsPort = 0
self.wss_port = 0 self.wssPort = 0
self.name = "jm" self.name = "jm"
self.webAO_bucket = "" self.webAOBucket = ""
self.useWS = False self.useWS = False
self.connected = False self.connected = False
self.disconnect = False self.disconnect = False
self.musicHack = False self.musicHack = False
def setIP(self, name, ip, port, ws_port=0, wss_port=0): def setIP(self, name, ip, port, wsPort=0, wssPort=0):
self.ip = ip self.ip = ip
self.port = int(port) self.port = int(port)
self.ws_port = int(ws_port) self.wsPort = int(wsPort)
self.wss_port = int(wss_port) self.wssPort = int(wssPort)
self.name = name self.name = name
def stop(self): def stop(self):
@ -425,9 +395,9 @@ class AOServerInfo(QtCore.QThread):
self.disconnect = False self.disconnect = False
try: try:
if self.ws_port == 0 and self.wss_port == 0: raise Exception # make it jump to except: and use TCP if self.wsPort == 0 and self.wssPort == 0: raise Exception # make it jump to except: and use TCP
self.tcp = AOsocket.AOwebSocket() self.tcp = AOsocket.AOwebSocket()
self.connected = self.tcp.connect(self.ip, self.ws_port, self.wss_port) self.connected = self.tcp.connect(self.ip, self.wsPort, self.wssPort)
except: except:
self.tcp = AOsocket.AOtcpSocket() self.tcp = AOsocket.AOtcpSocket()
try: try:
@ -440,7 +410,7 @@ class AOServerInfo(QtCore.QThread):
print "[debug]", "Connected! websocket: %s" % self.tcp.isWS + " (secure)" if (self.tcp.isWS and self.tcp.isSecure) else "" print "[debug]", "Connected! websocket: %s" % self.tcp.isWS + " (secure)" if (self.tcp.isWS and self.tcp.isSecure) else ""
self.tcp.sock.settimeout(0.1) self.tcp.sock.settimeout(0.1)
got_stuff = False gotStuff = False
gotChars = False gotChars = False
hpList = [] hpList = []
joinOOC = [] joinOOC = []
@ -469,9 +439,9 @@ class AOServerInfo(QtCore.QThread):
if readytick == 0: if readytick == 0:
readytick = -1 readytick = -1
try: try:
self.moveToGameSignal.emit([self.tcp, playerList, charList, musicList, background, evidence, areas, features, joinOOC, hpList, self.webAO_bucket]) self.moveToGameSignal.emit([self.tcp, playerList, charList, musicList, background, evidence, areas, features, joinOOC, hpList, self.webAOBucket])
except Exception as err: except Exception as err:
self.msgbox_signal.emit(0, "Error caught while loading", traceback.format_exc(err)) self.msgboxSignal.emit(0, "Error caught while loading", traceback.format_exc(err))
self.returnToLobby.emit() self.returnToLobby.emit()
return return
@ -482,7 +452,7 @@ class AOServerInfo(QtCore.QThread):
if error == -2: # timeout if error == -2: # timeout
continue continue
elif error == -1: # disconnected elif error == -1: # disconnected
self.setOnlinePlayers.emit("Something wrong happened" if not got_stuff else "Connection lost") self.setOnlinePlayers.emit("Something wrong happened" if not gotStuff else "Connection lost")
return return
for network in totals: for network in totals:
@ -497,14 +467,14 @@ class AOServerInfo(QtCore.QThread):
maxplayers = int(network[2]) maxplayers = int(network[2])
self.canConnect.emit() self.canConnect.emit()
self.setOnlinePlayers.emit('%d/%d players online' % (players, maxplayers)) self.setOnlinePlayers.emit('%d/%d players online' % (players, maxplayers))
got_stuff = True gotStuff = True
elif header == "decryptor": elif header == "decryptor":
self.tcp.send("HI#%s#%%" % hardware.get_hdid()) self.tcp.send("HI#%s#%%" % hardware.get_hdid())
elif header == "ASS": # ha ha ha... elif header == "ASS": # ha ha ha...
self.webAO_bucket = network[1] self.webAOBucket = network[1]
print "[debug] URL:", self.webAO_bucket print "[debug] URL:", self.webAOBucket
elif header == "ID": elif header == "ID":
self.tcp.send("ID#AO2XP#%s#%%" % "2.11.0") # need to send this to tsuserver3 servers in order to get feature list (FL) self.tcp.send("ID#AO2XP#%s#%%" % "2.11.0") # need to send this to tsuserver3 servers in order to get feature list (FL)
@ -516,7 +486,7 @@ class AOServerInfo(QtCore.QThread):
elif header == 'BD': elif header == 'BD':
reason = network[1].decode("utf-8") if len(network) > 1 else "Failed to receive ban reason (old server version?)" # new in AO2 2.6 reason = network[1].decode("utf-8") if len(network) > 1 else "Failed to receive ban reason (old server version?)" # new in AO2 2.6
self.setOnlinePlayers.emit('Banned') self.setOnlinePlayers.emit('Banned')
self.msgbox_signal.emit(0, "Banned", "Reason:\n"+reason) self.msgboxSignal.emit(0, "Banned", "Reason:\n"+reason)
self.tcp.close() self.tcp.close()
return return
@ -540,7 +510,7 @@ class AOServerInfo(QtCore.QThread):
# Disable characters not found in filesystem # Disable characters not found in filesystem
for char in charList: for char in charList:
if not exists(AOpath + "characters/" + char[0].lower()): if not exists(BASE_PATH + "characters/" + char[0].lower()):
char[3] = False char[3] = False
self.setConnectProgress.emit('Requesting music list (%d)...' % maxmusic) self.setConnectProgress.emit('Requesting music list (%d)...' % maxmusic)

View File

@ -15,8 +15,7 @@ class Settings(QtGui.QDialog):
def __init__(self, parent): def __init__(self, parent):
super(Settings, self).__init__() super(Settings, self).__init__()
self.setModal(True) self.setModal(True)
self.gamewindow = parent self.mainWindow = parent
self.parent = parent
self.inifile = ConfigParser() self.inifile = ConfigParser()
self.setWindowTitle("AO2XP Settings") self.setWindowTitle("AO2XP Settings")
@ -126,8 +125,8 @@ class Settings(QtGui.QDialog):
layAutoPick = QtGui.QHBoxLayout() layAutoPick = QtGui.QHBoxLayout()
lblAutoPick = QtGui.QLabel("Pick this character automatically on join") lblAutoPick = QtGui.QLabel("Pick this character automatically on join")
self.cbCharacters = QtGui.QComboBox() self.cbCharacters = QtGui.QComboBox()
for folder in listdir(unicode(AOpath + 'characters')): for folder in listdir(unicode(BASE_PATH + 'characters')):
if exists(AOpath + 'characters/' + folder + '/char.ini'): if exists(BASE_PATH + 'characters/' + folder + '/char.ini'):
self.cbCharacters.addItem(folder) self.cbCharacters.addItem(folder)
self.cbCharacters.setEditable(1) self.cbCharacters.setEditable(1)
layAutoPick.addWidget(lblAutoPick) layAutoPick.addWidget(lblAutoPick)
@ -344,28 +343,28 @@ class Settings(QtGui.QDialog):
with open(AO2XPpath + "callwords.ini", "w") as f: with open(AO2XPpath + "callwords.ini", "w") as f:
f.write(self.callwords.toPlainText().toUtf8()) f.write(self.callwords.toPlainText().toUtf8())
self.gamewindow.gamewidget.textWaitTime = self.sbTextStayTime.value() self.mainWindow.gameWidget.textWaitTime = self.sbTextStayTime.value()
slideEnabled = self.cbEnableSlide.isChecked() slideEnabled = self.cbEnableSlide.isChecked()
self.gamewindow.gamewidget.slideEnabled = slideEnabled self.mainWindow.gameWidget.slideEnabled = slideEnabled
self.gamewindow.gamewidget.cbSlide.setEnabled(slideEnabled) self.mainWindow.gameWidget.cbSlide.setEnabled(slideEnabled)
if not slideEnabled: if not slideEnabled:
self.gamewindow.gamewidget.cbSlide.setChecked(False) self.mainWindow.gameWidget.cbSlide.setChecked(False)
if not self.themeState == self.cbThemes.currentText(): if not self.themeState == self.cbThemes.currentText():
self.gamewindow.gamewidget.loadTheme(True) self.mainWindow.gameWidget.loadTheme(True)
if not self.gamewindow.gamewidget.demoPlaying: if not self.mainWindow.gameWidget.demoPlaying:
if not (self.saveLogsState == self.cbSaveToLog.isChecked() and self.combineLogsState == self.cbCombineLogs.isChecked()): if not (self.saveLogsState == self.cbSaveToLog.isChecked() and self.combineLogsState == self.cbCombineLogs.isChecked()):
self.gamewindow.gamewidget.OOCLog.setLogFiles() self.mainWindow.gameWidget.OOCLog.setLogFiles()
self.gamewindow.gamewidget.ICLog.setLogFiles(self.gamewindow.gamewidget.OOCLog.logfile) self.mainWindow.gameWidget.ICLog.setLogFiles(self.mainWindow.gameWidget.OOCLog.logfile)
if not self.saveDemosState == self.cbSaveDemos.isChecked(): if not self.saveDemosState == self.cbSaveDemos.isChecked():
if self.cbSaveDemos.isChecked(): if self.cbSaveDemos.isChecked():
self.gamewindow.gamewidget.startDemoRecorder() self.mainWindow.gameWidget.startDemoRecorder()
else: else:
self.gamewindow.gamewidget.demoRecorder = None self.mainWindow.gameWidget.demoRecorder = None
self.hide() self.hide()
@ -373,7 +372,7 @@ class Settings(QtGui.QDialog):
self.hide() self.hide()
def onAboutClicked(self): def onAboutClicked(self):
self.gamewindow.aboutgui.exec_() self.mainWindow.showAboutBox()
def onUpdateClicked(self): def onUpdateClicked(self):
import updater import updater

View File

@ -78,16 +78,16 @@ def handlePackets(caller, total, record=True):
elif header == 'RT': elif header == 'RT':
testimony = network[1] testimony = network[1]
wtcefile = AOpath + "sounds/general/sfx-testimony2" wtcefile = BASE_PATH + "sounds/general/sfx-testimony2"
if caller.parent.wtceSfx: if caller.parent.wtceSfx:
audio.freeHandle(caller.parent.wtceSfx) audio.freeHandle(caller.parent.wtceSfx)
if testimony == 'judgeruling': if testimony == 'judgeruling':
variant = int(network[2]) variant = int(network[2])
if variant == 0: if variant == 0:
wtcefile = AOpath + "sounds/general/sfx-notguilty" wtcefile = BASE_PATH + "sounds/general/sfx-notguilty"
elif variant == 1: elif variant == 1:
wtcefile = AOpath + "sounds/general/sfx-guilty" wtcefile = BASE_PATH + "sounds/general/sfx-guilty"
else: else:
variant = 0 variant = 0
caller.parent.wtceSfx = audio.loadHandle(False, wtcefile+".opus" if exists(wtcefile+".opus") else wtcefile+".wav", 0, 0, 0) caller.parent.wtceSfx = audio.loadHandle(False, wtcefile+".opus" if exists(wtcefile+".opus") else wtcefile+".wav", 0, 0, 0)