sound: more channels for sound effects + simplify effects list

This commit is contained in:
cidoku 2025-10-26 20:27:36 -03:00
parent 703a458160
commit 683af1ca34
2 changed files with 53 additions and 39 deletions

View File

@ -1033,7 +1033,13 @@ class Chatbox(QtGui.QLabel):
class GUI(QtGui.QWidget): class GUI(QtGui.QWidget):
gamewindow = None gamewindow = None
sound = None # In theory 3 sounds may play at the same time: character, evidence sweep,
# effect
soundChannels = 3
soundChannel = 0
sound = []
for i in range(soundChannels):
sound.append(None)
music = None music = None
nextCharacterIsNotSpecial = False nextCharacterIsNotSpecial = False
messageIsCentered = False messageIsCentered = False
@ -2250,7 +2256,8 @@ class GUI(QtGui.QWidget):
audio.playHandle(self.music, False) audio.playHandle(self.music, False)
def changeSoundVolume(self, value): def changeSoundVolume(self, value):
if self.sound: for s in self.sound:
if s:
audio.setHandleAttr(self.sound, BASS_ATTRIB_VOL, value / 100.0) audio.setHandleAttr(self.sound, BASS_ATTRIB_VOL, value / 100.0)
audio.setHandleAttr(self.sndRealization, BASS_ATTRIB_VOL, value / 100.0) audio.setHandleAttr(self.sndRealization, BASS_ATTRIB_VOL, value / 100.0)
audio.setHandleAttr(self.wtceSfx, BASS_ATTRIB_VOL, value / 100.0) audio.setHandleAttr(self.wtceSfx, BASS_ATTRIB_VOL, value / 100.0)
@ -3153,7 +3160,8 @@ class GUI(QtGui.QWidget):
msg += emote[2] + "#" #anim msg += emote[2] + "#" #anim
msg += text + "#" msg += text + "#"
msg += self.charSide + "#" msg += self.charSide + "#"
msg += (ini.get_effect_sound(self.boxEffects.currentText(), self.charName) if self.boxEffects.currentIndex() > 0 else emote[4])+"#" #sfx #msg += (ini.get_effect_sound(self.boxEffects.currentText(), self.charName) if self.boxEffects.currentIndex() > 0 else emote[4]) + "#" #sfx
msg += emote[4] + "#"
msg += str(modifier) + "#" #emote modifier msg += str(modifier) + "#" #emote modifier
msg += str(self.myChar) + "#" #character ID msg += str(self.myChar) + "#" #character ID
msg += emote[5] + "#" #sfx delay msg += emote[5] + "#" #sfx delay
@ -4259,18 +4267,24 @@ class GUI(QtGui.QWidget):
self.playSound(sfxName) self.playSound(sfxName)
def playSound(self, sfx): def playSound(self, sfx):
if self.sound: self.soundChannel = (self.soundChannel + 1) % self.soundChannels
if audio.handleIsActive(self.sound):
audio.stopHandle(self.sound)
audio.freeHandle(self.sound)
path = testPath(AOpath + 'sounds/general/' + sfx, AOpath + 'sounds/general/' + sfx + '.wav', AOpath + 'sounds/general/' + sfx + '.opus') if self.sound[self.soundChannel]:
if audio.handleIsActive(self.sound[self.soundChannel]):
audio.stopHandle(self.sound[self.soundChannel])
audio.freeHandle(self.sound[self.soundChannel])
path = testPath(
AOpath + 'sounds/general/' + sfx,
AOpath + 'sounds/general/' + sfx + '.wav',
AOpath + 'sounds/general/' + sfx + '.opus'
)
if path: if path:
self.sound = audio.loadHandle(False, path, 0, 0, 0) self.sound[self.soundChannel] = audio.loadHandle(False, path, 0, 0, 0)
audio.setHandleAttr(self.sound, BASS_ATTRIB_VOL, self.sliSoundVolume.value() / 100.0) audio.setHandleAttr(self.sound[self.soundChannel], BASS_ATTRIB_VOL, self.sliSoundVolume.value() / 100.0)
if self.sound: if self.sound[self.soundChannel]:
audio.playHandle(self.sound, True) audio.playHandle(self.sound[self.soundChannel], True)
def playMusic(self, mus): def playMusic(self, mus):
self.stopMusic() self.stopMusic()

14
ini.py
View File

@ -138,15 +138,15 @@ def get_effect_sound(fx_name, char):
def get_effects(char): def get_effects(char):
p_effect = read_ini("base/characters/"+char+"/char.ini", "options", "effects", "default/effects") p_effect = read_ini("base/characters/"+char+"/char.ini", "options", "effects", "default/effects")
p_path = "base/misc/"+p_effect+"/effects.ini" p_path = "base/misc/"+p_effect+"/effects.ini"
default_path = "AO2XPbase/themes/default/effects/effects.ini" # default_path = "AO2XPbase/themes/default/effects/effects.ini"
effects = [] # effects = []
if exists(default_path): # if exists(default_path):
with open(default_path, 'r') as file: # with open(default_path, 'r') as file:
for line in file: # for line in file:
effects.append(line.split("=")[0].strip()) # effects.append(line.split("=")[0].strip())
else: # else:
effects = ["realization", "hearts", "reaction", "impact"] effects = ["realization", "hearts", "reaction", "impact"]
if not exists(p_path): return effects if not exists(p_path): return effects