Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
simio 2025-02-20 18:52:51 -03:00
commit 48fcbd7574
4 changed files with 94 additions and 62 deletions

View File

@ -31,42 +31,43 @@ if not debugmode:
os._exit(-2) os._exit(-2)
class gamewindow(QtGui.QMainWindow): class gamewindow(QtGui.QMainWindow):
def __init__(self): def __init__(self):
super(gamewindow, self).__init__() super(gamewindow, self).__init__()
self.stackwidget = QtGui.QStackedWidget(self) self.stackwidget = QtGui.QStackedWidget(self)
self.widget = mainmenu.lobby(self) self.widget = mainmenu.lobby(self)
self.gamewidget = gameview.gui(self) self.gamewidget = gameview.gui(self)
self.stackwidget.addWidget(self.widget) self.stackwidget.addWidget(self.widget)
self.stackwidget.addWidget(self.gamewidget) self.stackwidget.addWidget(self.gamewidget)
self.setCentralWidget(self.stackwidget) self.setCentralWidget(self.stackwidget)
self.stackwidget.setCurrentWidget(self.widget) self.stackwidget.setCurrentWidget(self.widget)
self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height())
self.center() self.center()
self.setWindowTitle("AO2XP") self.setWindowTitle("AO2XP")
self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) self.setWindowIcon(QtGui.QIcon("AO2XP.ico"))
self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)
self.settingsgui = options.Settings()
self.settingsgui = options.Settings()
def center(self):
frameGm = self.frameGeometry() def center(self):
centerPoint = QtGui.QDesktopWidget().availableGeometry().center() frameGm = self.frameGeometry()
frameGm.moveCenter(centerPoint) centerPoint = QtGui.QDesktopWidget().availableGeometry().center()
self.move(frameGm.topLeft()) frameGm.moveCenter(centerPoint)
self.move(frameGm.topLeft())
def showGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
self.gamewidget.disconnectnow = False def showGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
self.gamewidget.startGame(tcp, playerlist, charlist, musiclist, background, evidence, areas, features, oocjoin, hplist, webAO_bucket) self.gamewidget.disconnectnow = False
self.stackwidget.setCurrentWidget(self.gamewidget) self.gamewidget.startGame(tcp, playerlist, charlist, musiclist, background, evidence, areas, features, oocjoin, hplist, webAO_bucket)
self.stackwidget.setCurrentWidget(self.gamewidget)
def returnToMenu(self):
self.gamewidget.disconnectnow = True def returnToMenu(self):
self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) self.gamewidget.disconnectnow = True
self.widget.onClicked_cancelconnect() self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height())
self.stackwidget.setCurrentWidget(self.widget) self.widget.onClicked_cancelconnect()
self.setWindowTitle("AO2XP") self.stackwidget.setCurrentWidget(self.widget)
self.setWindowTitle("AO2XP")
def showSettings(self):
self.settingsgui.showSettings() def showSettings(self):
self.settingsgui.showSettings()
if not debugmode: if not debugmode:
# Vanilla downloader # Vanilla downloader

View File

@ -132,6 +132,12 @@ def playhandle(handle, restart):
Play a handle Play a handle
""" """
return dll.BASS_ChannelPlay(handle, restart) return dll.BASS_ChannelPlay(handle, restart)
def pausehandle(handle):
"""
Play a handle
"""
return dll.BASS_ChannelPause(handle)
def stophandle(handle): def stophandle(handle):
""" """

View File

@ -1131,8 +1131,8 @@ class gui(QtGui.QWidget):
self.musicslider.setRange(0, 100) self.musicslider.setRange(0, 100)
self.soundslider.setRange(0, 100) self.soundslider.setRange(0, 100)
self.blipslider.setRange(0, 100) self.blipslider.setRange(0, 100)
self.musicslider.sliderMoved.connect(self.changeMusicVolume) self.musicslider.valueChanged.connect(self.changeMusicVolume)
self.soundslider.sliderMoved.connect(self.changeSoundVolume) self.soundslider.valueChanged.connect(self.changeSoundVolume)
self.blipslider.valueChanged.connect(self.changeBlipVolume) self.blipslider.valueChanged.connect(self.changeBlipVolume)
self.sliderlabel1 = QtGui.QLabel("Music", self) self.sliderlabel1 = QtGui.QLabel("Music", self)
self.sliderlabel2 = QtGui.QLabel("SFX", self) self.sliderlabel2 = QtGui.QLabel("SFX", self)
@ -1255,6 +1255,10 @@ class gui(QtGui.QWidget):
def changeMusicVolume(self, value): def changeMusicVolume(self, value):
if self.music: if self.music:
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, value / 100.0) audio.sethandleattr(self.music, BASS_ATTRIB_VOL, value / 100.0)
if value == 0:
audio.pausehandle(self.music)
elif audio.handleisactive(self.music) == BASS_ACTIVE_PAUSED:
audio.playhandle(self.music, False)
def changeSoundVolume(self, value): def changeSoundVolume(self, value):
if self.sound: if self.sound:
@ -1559,8 +1563,12 @@ class gui(QtGui.QWidget):
del self.privateevidence[self.selectedevi] del self.privateevidence[self.selectedevi]
self.privatedropdown.removeItem(self.selectedevi) self.privatedropdown.removeItem(self.selectedevi)
def onExportEvidence(self): def onExportEvidence(self, is_autosave=False):
path = str(QtGui.QFileDialog.getSaveFileName(self, "Save evidence", AOpath, "Evidence (*.ini)")) if not exists("evidence"):
os.mkdir("evidence")
path = unicode(QtGui.QFileDialog.getSaveFileName(self, "Save evidence", "evidence", "Evidence (*.ini)")) if not is_autosave else "evidence/inventory.ini"
if path: if path:
evidence = self.evidence if not self.privateinv else self.privateevidence evidence = self.evidence if not self.privateinv else self.privateevidence
inifile = ConfigParser() inifile = ConfigParser()
@ -1579,15 +1587,19 @@ class gui(QtGui.QWidget):
inifile.write(open(path, "wb")) inifile.write(open(path, "wb"))
def onImportEvidence(self): def onImportEvidence(self, is_autoload=False):
if not self.privateinv: if not is_autoload:
if QtGui.QMessageBox.warning(self, "Import evidence", 'This will OVERWRITE the global evidence server-side.\n\nContinue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: if not self.privateinv:
return if QtGui.QMessageBox.warning(self, "Import evidence", 'This will OVERWRITE the global evidence server-side.\n\nContinue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
else: return
if QtGui.QMessageBox.warning(self, "Import evidence", 'This will OVERWRITE your private evidence.\n\nContinue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: else:
return if QtGui.QMessageBox.warning(self, "Import evidence", 'This will OVERWRITE your private evidence.\n\nContinue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return
if not exists("evidence"):
os.mkdir("evidence")
path = str(QtGui.QFileDialog.getOpenFileName(self, "Load evidence", AOpath, "Evidence (*.ini)")) path = unicode(QtGui.QFileDialog.getOpenFileName(self, "Load evidence", "evidence", "Evidence (*.ini)")) if not is_autoload else "evidence/inventory.ini"
if path and exists(path): if path and exists(path):
evidence = [] evidence = []
inifile = ConfigParser() inifile = ConfigParser()
@ -1598,7 +1610,7 @@ class gui(QtGui.QWidget):
image = ini.read_ini(inifile, section, "image", "empty.png") image = ini.read_ini(inifile, section, "image", "empty.png")
evidence.append([name, description, image]) evidence.append([name, description, image])
if self.privateinv: if self.privateinv or is_autoload:
dropdown = self.privatedropdown dropdown = self.privatedropdown
self.privateevidence = evidence self.privateevidence = evidence
if dropdown.count() > 0: if dropdown.count() > 0:
@ -1608,6 +1620,9 @@ class gui(QtGui.QWidget):
for evi in evidence: for evi in evidence:
dropdown.addItem(evi[0]) dropdown.addItem(evi[0])
dropdown.setCurrentIndex(self.selectedevi) dropdown.setCurrentIndex(self.selectedevi)
if not is_autoload:
self.onExportEvidence(True)
elif evidence: elif evidence:
if self.evidence: if self.evidence:
for i in range(len(self.evidence)): for i in range(len(self.evidence)):
@ -2857,6 +2872,8 @@ class gui(QtGui.QWidget):
self.music = audio.loadhandle(False, AOpath + 'sounds/music/' + musl, 0, 0, BASS_SAMPLE_LOOP) self.music = audio.loadhandle(False, AOpath + 'sounds/music/' + musl, 0, 0, BASS_SAMPLE_LOOP)
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0) audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0)
audio.playhandle(self.music, True) audio.playhandle(self.music, True)
if self.musicslider.value() == 0:
audio.pausehandle(self.music)
elif ini.read_ini_bool("AO2XP.ini", "General", "download music", True): elif ini.read_ini_bool("AO2XP.ini", "General", "download music", True):
if mus.lower().startswith("http"): if mus.lower().startswith("http"):
@ -2873,6 +2890,8 @@ class gui(QtGui.QWidget):
if self.music: if self.music:
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0) audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0)
audio.playhandle(self.music, True) audio.playhandle(self.music, True)
if self.musicslider.value() == 0:
audio.pausehandle(self.music)
else: else:
error = audio.getbasserror() error = audio.getbasserror()
print "[audio] Couldn't play music. Error", error print "[audio] Couldn't play music. Error", error
@ -2915,7 +2934,9 @@ class gui(QtGui.QWidget):
else: else:
self.music = audio.loadhandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP) self.music = audio.loadhandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0) audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0)
audio.playhandle(self.music, False) audio.playhandle(self.music, True)
if self.musicslider.value() == 0:
audio.pausehandle(self.music)
def startGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""): def startGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
self.willDisconnect = False self.willDisconnect = False
@ -3029,7 +3050,6 @@ class gui(QtGui.QWidget):
for area in areas[0]: for area in areas[0]:
areaitem = QtGui.QListWidgetItem() areaitem = QtGui.QListWidgetItem()
areaitem.setText("Area\n aaa\n aaa")
self.areaitems.addItem(areaitem) self.areaitems.addItem(areaitem)
for pid in playerlist: for pid in playerlist:
@ -3040,6 +3060,8 @@ class gui(QtGui.QWidget):
self.musicslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Music volume", 100)) self.musicslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Music volume", 100))
self.soundslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Sound volume", 100)) self.soundslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Sound volume", 100))
self.blipslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Blip volume", 100)) self.blipslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Blip volume", 100))
self.onImportEvidence(True)
#thread.start_new_thread(self.tcp_thread, ()) #thread.start_new_thread(self.tcp_thread, ())
self.tcpthread = TCP_Thread(self) self.tcpthread = TCP_Thread(self)
@ -3207,6 +3229,7 @@ class EditEvidenceDialog(QtGui.QDialog):
else: else:
self.gamegui.privateevidence.append([name, desc, self.filename]) self.gamegui.privateevidence.append([name, desc, self.filename])
self.gamegui.privatedropdown.addItem(name) self.gamegui.privatedropdown.addItem(name)
self.onExportEvidence(True)
self.eviname.setText('') self.eviname.setText('')
self.evidesc.setText('') self.evidesc.setText('')

View File

@ -42,12 +42,12 @@ class Settings(QtGui.QDialog):
callwords_layout = QtGui.QVBoxLayout(callwords_tab) callwords_layout = QtGui.QVBoxLayout(callwords_tab)
callwords_layout.setAlignment(QtCore.Qt.AlignTop) callwords_layout.setAlignment(QtCore.Qt.AlignTop)
savebtn = QtGui.QPushButton() self.savebtn = QtGui.QPushButton()
savebtn.setText("Save") self.savebtn.setText("Save")
savebtn.clicked.connect(self.onSaveClicked) self.savebtn.clicked.connect(self.onSaveClicked)
cancelbtn = QtGui.QPushButton() self.cancelbtn = QtGui.QPushButton()
cancelbtn.setText("Cancel") self.cancelbtn.setText("Cancel")
cancelbtn.clicked.connect(self.onCancelClicked) self.cancelbtn.clicked.connect(self.onCancelClicked)
separators = [] separators = []
for i in range(5): for i in range(5):
@ -131,11 +131,11 @@ class Settings(QtGui.QDialog):
savechangeswarn = QtGui.QLabel() savechangeswarn = QtGui.QLabel()
savechangeswarn.setText("* Change takes effect upon restarting the client") savechangeswarn.setText("* Change takes effect upon restarting the client")
general_layout.addWidget(self.savetolog)
general_layout.addWidget(self.savetolog_combine, 0, QtCore.Qt.AlignRight)
general_layout.addWidget(separators[0])
general_layout.addLayout(defaultoocname_layout) general_layout.addLayout(defaultoocname_layout)
general_layout.addLayout(defaultshowname_layout) general_layout.addLayout(defaultshowname_layout)
general_layout.addWidget(separators[0])
general_layout.addWidget(self.savetolog)
general_layout.addWidget(self.savetolog_combine)
general_layout.addWidget(separators[1]) general_layout.addWidget(separators[1])
general_layout.addWidget(allowdownload) general_layout.addWidget(allowdownload)
general_layout.addLayout(allowdownload_layout) general_layout.addLayout(allowdownload_layout)
@ -196,10 +196,12 @@ class Settings(QtGui.QDialog):
self.tabs.addTab(audio_tab, "Audio") self.tabs.addTab(audio_tab, "Audio")
self.tabs.addTab(callwords_tab, "Callwords") self.tabs.addTab(callwords_tab, "Callwords")
save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight) save_layout.addWidget(self.savebtn, 100, QtCore.Qt.AlignRight)
save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight) save_layout.addWidget(self.cancelbtn, 0, QtCore.Qt.AlignRight)
main_layout.addWidget(self.tabs) main_layout.addWidget(self.tabs)
main_layout.addLayout(save_layout) main_layout.addLayout(save_layout)
self.savebtn.setFocus()
def showSettings(self): def showSettings(self):
if exists("AO2XP.ini"): if exists("AO2XP.ini"):