From 169ce1c44ad8e28a453fac6aa36a47e8fd735ec1 Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 20 Feb 2025 14:12:26 -0300 Subject: [PATCH 1/5] private inventory is now persistent --- gameview.py | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/gameview.py b/gameview.py index eeb646d..624e317 100644 --- a/gameview.py +++ b/gameview.py @@ -1559,8 +1559,12 @@ class gui(QtGui.QWidget): del self.privateevidence[self.selectedevi] self.privatedropdown.removeItem(self.selectedevi) - def onExportEvidence(self): - path = str(QtGui.QFileDialog.getSaveFileName(self, "Save evidence", AOpath, "Evidence (*.ini)")) + def onExportEvidence(self, is_autosave=False): + 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: evidence = self.evidence if not self.privateinv else self.privateevidence inifile = ConfigParser() @@ -1579,15 +1583,19 @@ class gui(QtGui.QWidget): inifile.write(open(path, "wb")) - def onImportEvidence(self): - if not self.privateinv: - 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: - return - else: - 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 + def onImportEvidence(self, is_autoload=False): + if not is_autoload: + if not self.privateinv: + 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: + return + else: + 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): evidence = [] inifile = ConfigParser() @@ -1598,7 +1606,7 @@ class gui(QtGui.QWidget): image = ini.read_ini(inifile, section, "image", "empty.png") evidence.append([name, description, image]) - if self.privateinv: + if self.privateinv or is_autoload: dropdown = self.privatedropdown self.privateevidence = evidence if dropdown.count() > 0: @@ -1608,6 +1616,9 @@ class gui(QtGui.QWidget): for evi in evidence: dropdown.addItem(evi[0]) dropdown.setCurrentIndex(self.selectedevi) + + if not is_autoload: + self.onExportEvidence(True) elif evidence: if self.evidence: for i in range(len(self.evidence)): @@ -3029,7 +3040,6 @@ class gui(QtGui.QWidget): for area in areas[0]: areaitem = QtGui.QListWidgetItem() - areaitem.setText("Area\n aaa\n aaa") self.areaitems.addItem(areaitem) for pid in playerlist: @@ -3040,6 +3050,8 @@ class gui(QtGui.QWidget): 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.blipslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Blip volume", 100)) + + self.onImportEvidence(True) #thread.start_new_thread(self.tcp_thread, ()) self.tcpthread = TCP_Thread(self) @@ -3207,6 +3219,7 @@ class EditEvidenceDialog(QtGui.QDialog): else: self.gamegui.privateevidence.append([name, desc, self.filename]) self.gamegui.privatedropdown.addItem(name) + self.onExportEvidence(True) self.eviname.setText('') self.evidesc.setText('') From 2f0b5f27822bf9426dc1a74cc02e933b0b9b8679 Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 20 Feb 2025 14:29:37 -0300 Subject: [PATCH 2/5] change options dialog a bit --- options.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/options.py b/options.py index 5f40f5e..d67d784 100644 --- a/options.py +++ b/options.py @@ -42,12 +42,12 @@ class Settings(QtGui.QDialog): callwords_layout = QtGui.QVBoxLayout(callwords_tab) callwords_layout.setAlignment(QtCore.Qt.AlignTop) - savebtn = QtGui.QPushButton() - savebtn.setText("Save") - savebtn.clicked.connect(self.onSaveClicked) - cancelbtn = QtGui.QPushButton() - cancelbtn.setText("Cancel") - cancelbtn.clicked.connect(self.onCancelClicked) + self.savebtn = QtGui.QPushButton() + self.savebtn.setText("Save") + self.savebtn.clicked.connect(self.onSaveClicked) + self.cancelbtn = QtGui.QPushButton() + self.cancelbtn.setText("Cancel") + self.cancelbtn.clicked.connect(self.onCancelClicked) separators = [] for i in range(5): @@ -131,11 +131,11 @@ class Settings(QtGui.QDialog): savechangeswarn = QtGui.QLabel() 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(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(allowdownload) general_layout.addLayout(allowdownload_layout) @@ -196,10 +196,12 @@ class Settings(QtGui.QDialog): self.tabs.addTab(audio_tab, "Audio") self.tabs.addTab(callwords_tab, "Callwords") - save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight) - save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight) + save_layout.addWidget(self.savebtn, 100, QtCore.Qt.AlignRight) + save_layout.addWidget(self.cancelbtn, 0, QtCore.Qt.AlignRight) main_layout.addWidget(self.tabs) main_layout.addLayout(save_layout) + + self.savebtn.setFocus() def showSettings(self): if exists("AO2XP.ini"): From 5d62d97464a0c33351d742489c77cdffbfd470b9 Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 20 Feb 2025 14:31:50 -0300 Subject: [PATCH 3/5] pause music if muted --- audio.py | 6 ++++++ gameview.py | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/audio.py b/audio.py index f1012f3..13720d0 100644 --- a/audio.py +++ b/audio.py @@ -132,6 +132,12 @@ def playhandle(handle, restart): Play a handle """ return dll.BASS_ChannelPlay(handle, restart) + +def pausehandle(handle): + """ +Play a handle + """ + return dll.BASS_ChannelPause(handle) def stophandle(handle): """ diff --git a/gameview.py b/gameview.py index 624e317..24bebef 100644 --- a/gameview.py +++ b/gameview.py @@ -1255,6 +1255,10 @@ class gui(QtGui.QWidget): def changeMusicVolume(self, value): if self.music: 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): if self.sound: @@ -2868,6 +2872,8 @@ class gui(QtGui.QWidget): 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.playhandle(self.music, True) + if self.musicslider.value() == 0: + audio.pausehandle(self.music) elif ini.read_ini_bool("AO2XP.ini", "General", "download music", True): if mus.lower().startswith("http"): @@ -2884,6 +2890,8 @@ class gui(QtGui.QWidget): if self.music: audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0) audio.playhandle(self.music, True) + if self.musicslider.value() == 0: + audio.pausehandle(self.music) else: error = audio.getbasserror() print "[audio] Couldn't play music. Error", error @@ -2926,7 +2934,9 @@ class gui(QtGui.QWidget): else: 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.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=""): self.willDisconnect = False From 8c1093e00698b585edb4bf404a4b88703b7cf7e4 Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 20 Feb 2025 15:29:29 -0300 Subject: [PATCH 4/5] improve the behavior of volume sliders --- gameview.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gameview.py b/gameview.py index 24bebef..b0f6f7d 100644 --- a/gameview.py +++ b/gameview.py @@ -1131,8 +1131,8 @@ class gui(QtGui.QWidget): self.musicslider.setRange(0, 100) self.soundslider.setRange(0, 100) self.blipslider.setRange(0, 100) - self.musicslider.sliderMoved.connect(self.changeMusicVolume) - self.soundslider.sliderMoved.connect(self.changeSoundVolume) + self.musicslider.valueChanged.connect(self.changeMusicVolume) + self.soundslider.valueChanged.connect(self.changeSoundVolume) self.blipslider.valueChanged.connect(self.changeBlipVolume) self.sliderlabel1 = QtGui.QLabel("Music", self) self.sliderlabel2 = QtGui.QLabel("SFX", self) From 0b802b3e95ff9cb218ec07c762b9a83dda59c744 Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 20 Feb 2025 15:38:30 -0300 Subject: [PATCH 5/5] fix tabs + set window icon --- AO2XP.py | 73 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/AO2XP.py b/AO2XP.py index 5c0d681..bd8aeba 100644 --- a/AO2XP.py +++ b/AO2XP.py @@ -31,42 +31,43 @@ if not debugmode: os._exit(-2) class gamewindow(QtGui.QMainWindow): - def __init__(self): - super(gamewindow, self).__init__() - self.stackwidget = QtGui.QStackedWidget(self) - self.widget = mainmenu.lobby(self) - self.gamewidget = gameview.gui(self) - self.stackwidget.addWidget(self.widget) - self.stackwidget.addWidget(self.gamewidget) - self.setCentralWidget(self.stackwidget) - self.stackwidget.setCurrentWidget(self.widget) - self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) - self.center() - self.setWindowTitle("AO2XP") - self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) - - self.settingsgui = options.Settings() - - def center(self): - frameGm = self.frameGeometry() - centerPoint = QtGui.QDesktopWidget().availableGeometry().center() - 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 - 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 - self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) - self.widget.onClicked_cancelconnect() - self.stackwidget.setCurrentWidget(self.widget) - self.setWindowTitle("AO2XP") - - def showSettings(self): - self.settingsgui.showSettings() + def __init__(self): + super(gamewindow, self).__init__() + self.stackwidget = QtGui.QStackedWidget(self) + self.widget = mainmenu.lobby(self) + self.gamewidget = gameview.gui(self) + self.stackwidget.addWidget(self.widget) + self.stackwidget.addWidget(self.gamewidget) + self.setCentralWidget(self.stackwidget) + self.stackwidget.setCurrentWidget(self.widget) + self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) + self.center() + self.setWindowTitle("AO2XP") + self.setWindowIcon(QtGui.QIcon("AO2XP.ico")) + self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) + + self.settingsgui = options.Settings() + + def center(self): + frameGm = self.frameGeometry() + centerPoint = QtGui.QDesktopWidget().availableGeometry().center() + 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 + 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 + self.setFixedSize(self.widget.lobbyimg.size().width(), self.widget.lobbyimg.size().height()) + self.widget.onClicked_cancelconnect() + self.stackwidget.setCurrentWidget(self.widget) + self.setWindowTitle("AO2XP") + + def showSettings(self): + self.settingsgui.showSettings() if not debugmode: # Vanilla downloader