added custom sfx

This commit is contained in:
cidoku 2025-02-12 20:30:18 -03:00
parent 2e589f1b36
commit 2cae4b194d

View File

@ -760,18 +760,13 @@ class gui(QtGui.QWidget):
self.ooclog = ChatLogs(self, 1) self.ooclog = ChatLogs(self, 1)
self.ooclog.setReadOnly(True) self.ooclog.setReadOnly(True)
#p = self.ooclog.viewport().palette()
#p.setColor(self.ooclog.viewport().backgroundRole(), QtGui.QColor(139,139,139))
#self.ooclog.viewport().setPalette(p)
self.ooclog.textChanged.connect(self.ooclog_update) self.ooclog.textChanged.connect(self.ooclog_update)
self.oocnameinput = QtGui.QLineEdit(self) self.oocnameinput = QtGui.QLineEdit(self)
self.oocnameinput.setPlaceholderText('Enter a name...') self.oocnameinput.setPlaceholderText('Enter a name...')
#self.oocnameinput.setStyleSheet('background-color: rgb(139, 139, 139);')
self.oocinput = QtGui.QLineEdit(self) self.oocinput = QtGui.QLineEdit(self)
self.oocinput.setPlaceholderText('Server chat/OOC chat...') self.oocinput.setPlaceholderText('Server chat/OOC chat...')
#self.oocinput.setStyleSheet('background-color: rgb(139, 139, 139);')
self.oocinput.returnPressed.connect(self.onOOCreturn) self.oocinput.returnPressed.connect(self.onOOCreturn)
self.ooclogin = QtGui.QPushButton("Login", self) self.ooclogin = QtGui.QPushButton("Login", self)
@ -1011,7 +1006,7 @@ class gui(QtGui.QWidget):
self.guiltybtn.show() self.guiltybtn.show()
self.presenting = -1 self.presenting = -1
self.presentedevi = QtGui.QLabel(self) self.presentedevi = QtGui.QLabel(self)
self.presentedevi.setGeometry(16, 16, 70, 70) self.presentedevi.setGeometry(16, 16, 140, 140)
self.presentedevi.hide() self.presentedevi.hide()
self.showname = "" self.showname = ""
@ -1051,6 +1046,7 @@ class gui(QtGui.QWidget):
self.selectedemote = 0 self.selectedemote = 0
self.charname = '' self.charname = ''
self.charside = 'def' self.charside = 'def'
self.lastmsg = ''
self.msgqueue = [] self.msgqueue = []
self.selectedmsg = -1 self.selectedmsg = -1
self.evidence = [] self.evidence = []
@ -1168,11 +1164,18 @@ class gui(QtGui.QWidget):
def onChangeShowname(self, text): def onChangeShowname(self, text):
self.showname = str(text.toUtf8()) self.showname = str(text.toUtf8())
def setEvidenceImg(self, guiobj, image): def setEvidenceImg(self, guiobj, image, scale=False):
if exists(AOpath + 'evidence/' + image): if exists(AOpath + 'evidence/' + image):
guiobj.setPixmap(QtGui.QPixmap(AOpath + "evidence/%s" % image)) if scale:
guiobj.setPixmap(QtGui.QPixmap(AOpath + "evidence/%s" % image).scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
else:
guiobj.setPixmap(QtGui.QPixmap(AOpath + "evidence/%s" % image))
else: else:
guiobj.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png')) if scale:
guiobj.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png').scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))
else:
guiobj.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png'))
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/../", "")
@ -1285,6 +1288,10 @@ class gui(QtGui.QWidget):
self.charemotes = [] self.charemotes = []
self.selectedemote = 0 self.selectedemote = 0
self.current_emote_page = 0 self.current_emote_page = 0
# TESTTEST
print type(charname)
print type(AOpath + 'characters/' + charname + '/char.ini')
effectslist = ini.get_effects(charname) effectslist = ini.get_effects(charname)
self.effectdropdown.setVisible(bool(effectslist)) self.effectdropdown.setVisible(bool(effectslist))
@ -1444,7 +1451,8 @@ 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.setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1) + '_on.png')) button.path = AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1)
button.setPixmap(QtGui.QPixmap(button.path + '_on.png'))
else: else:
button.setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1) + '_off.png')) button.setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1) + '_off.png'))
@ -1637,12 +1645,17 @@ class gui(QtGui.QWidget):
fx = self.effectdropdown.currentText() if self.effectdropdown.currentIndex() > 0 else "" fx = self.effectdropdown.currentText() if self.effectdropdown.currentIndex() > 0 else ""
fx_sound = ini.get_effect_sound(fx, self.charname) fx_sound = 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(AOpath+"characters/"+self.charname+"/char.ini", "options", "effects")
msg += fx + "|" + p_effect + "|" + fx_sound + "#" # I have to encode it because otherwise accented characters make the client crash
msg += str(fx + "|" + p_effect + "|" + fx_sound + "#").encode('utf-8')
self.effectdropdown.setCurrentIndex(0) self.effectdropdown.setCurrentIndex(0)
msg += "%" msg += "%"
self.msgqueueList.addItem(self.icchatinput.text())
self.msgqueue.append(msg) # Avoid duplicate messages
if self.lastmsg != msg:
self.msgqueueList.addItem(self.icchatinput.text())
self.msgqueue.append(msg)
self.lastmsg = msg
self.icchatinput.clear() self.icchatinput.clear()
self.realizationbtn.setPressed(False) self.realizationbtn.setPressed(False)
@ -1975,6 +1988,11 @@ class gui(QtGui.QWidget):
self.play_preanim(False) self.play_preanim(False)
elif emote_mod == 0 or emote_mod == 5 or self.m_chatmessage[PREANIM] == "-": elif emote_mod == 0 or emote_mod == 5 or self.m_chatmessage[PREANIM] == "-":
if self.m_chatmessage[NO_INTERRUPT] == "0" or self.m_chatmessage[PREANIM] == "-": if self.m_chatmessage[NO_INTERRUPT] == "0" or self.m_chatmessage[PREANIM] == "-":
sfx_delay = int(self.m_chatmessage[SFX_DELAY]) * 60
if sfx_delay > 0:
self.sfx_delay_timer.start(sfx_delay)
else:
self.play_sfx()
self.handle_chatmessage_3() self.handle_chatmessage_3()
else: else:
self.play_preanim(True) self.play_preanim(True)
@ -2036,12 +2054,12 @@ class gui(QtGui.QWidget):
f_image = self.evidence[f_evi_id-1][2] f_image = self.evidence[f_evi_id-1][2]
is_left_side = not (f_side == "def" or f_side == "hlp" or f_side == "jud" or f_side == "jur") is_left_side = not (f_side == "def" or f_side == "hlp" or f_side == "jud" or f_side == "jur")
self.setEvidenceImg(self.presentedevi, f_image) self.setEvidenceImg(self.presentedevi, f_image, True)
if not is_left_side: if not is_left_side:
self.presentedevi.move(170, 16) self.presentedevi.move(170*2, 16*2)
else: else:
self.presentedevi.move(16, 16) self.presentedevi.move(16*2, 16*2)
self.presentedevi.show() self.presentedevi.show()
else: else:
self.presentedevi.hide() self.presentedevi.hide()
@ -2380,8 +2398,13 @@ class gui(QtGui.QWidget):
if audio.handleisactive(self.sound): if audio.handleisactive(self.sound):
audio.stophandle(self.sound) audio.stophandle(self.sound)
audio.freehandle(self.sound) audio.freehandle(self.sound)
if exists(AOpath + 'sounds/general/' + sfx + '.wav'): if exists(AOpath + 'sounds/general/' + sfx):
self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx, 0, 0, 0)
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0)
audio.playhandle(self.sound, True)
elif exists(AOpath + 'sounds/general/' + sfx + '.wav'):
self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx + '.wav', 0, 0, 0) self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx + '.wav', 0, 0, 0)
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0) audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0)
audio.playhandle(self.sound, True) audio.playhandle(self.sound, True)
@ -2680,6 +2703,7 @@ class EmoteButton(QtGui.QLabel):
self.resize(40, 40) self.resize(40, 40)
self.move(x, y) self.move(x, y)
self.emoteid = id self.emoteid = id
self.path = ''
def paintEvent(self, event): def paintEvent(self, event):
if self.gamewindow.mychar == -1: if self.gamewindow.mychar == -1:
@ -2695,8 +2719,9 @@ class EmoteButton(QtGui.QLabel):
if self.pixmap(): if self.pixmap():
if self.pixmap().isNull(): if self.pixmap().isNull():
painter.fillRect(0, 0, 39, 39, QtGui.QColor(0, 0, 0)) button_img = QtGui.QPixmap(self.path + '_off.png')
painter.drawText(0, 0, str(self.emoteid)) painter.setOpacity(0.5)
painter.drawPixmap(0, 0, button_img)
else: else:
painter.drawPixmap(0, 0, self.pixmap()) painter.drawPixmap(0, 0, self.pixmap())
else: else: