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

@ -43,6 +43,7 @@ class gamewindow(QtGui.QMainWindow):
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()

View File

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

View File

@ -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)
@ -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:
@ -1559,8 +1563,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,7 +1587,8 @@ class gui(QtGui.QWidget):
inifile.write(open(path, "wb"))
def onImportEvidence(self):
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
@ -1587,7 +1596,10 @@ class gui(QtGui.QWidget):
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
path = str(QtGui.QFileDialog.getOpenFileName(self, "Load evidence", AOpath, "Evidence (*.ini)"))
if not exists("evidence"):
os.mkdir("evidence")
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 +1610,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 +1620,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)):
@ -2857,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"):
@ -2873,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
@ -2915,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
@ -3029,7 +3050,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:
@ -3041,6 +3061,8 @@ class gui(QtGui.QWidget):
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)
self.tcpthread.MS_Chat.connect(self.netmsg_ms)
@ -3207,6 +3229,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('')

View File

@ -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,11 +196,13 @@ 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"):
self.inifile.read("AO2XP.ini")