From 19743b5c47607ff33714a64bf0edccf394ff22bc Mon Sep 17 00:00:00 2001 From: cidoku Date: Mon, 27 Oct 2025 01:22:30 -0300 Subject: [PATCH] implement sound list and improved emote mod handling --- README.md | 2 ++ constants.py | 8 +++++++- gameview.py | 45 ++++++++++++++++++++++++++++++--------------- ini.py | 4 ---- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 6fa4482..50b6caa 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,10 @@ Features added since the last commit of - Pick a character and join an area automatically on join - Demo recording and playback with a seekbar, no need to send messages to OOC - Pair with players directly from the player list +- Moderators can kick and ban players directly from the player list - Playing music over HTTPS (on systems where the BASS library can't do it on its own) +- Sound list - Connections over secure websockets (wss) - FLAC playback - Module file playback (.mod, .xm, .it, .s3m) diff --git a/constants.py b/constants.py index 7702b50..4d233bc 100644 --- a/constants.py +++ b/constants.py @@ -1,4 +1,4 @@ -GAME_VERSION = "2.9.3" +GAME_VERSION = "2.9.4" AOpath = "base/" AO2XPpath = "AO2XPbase/" @@ -35,6 +35,12 @@ EFFECTS = 30 BLIPS = 31 SLIDE = 32 +NOPRE = 0 +PRE = 1 +PRE_SHOUT = 2 +NOPRE_ZOOM = 5 +NOPRE_ZOOM_SHOUT = 6 + INLINE_BLUE = 0 INLINE_GREEN = 1 INLINE_ORANGE = 2 diff --git a/gameview.py b/gameview.py index 1f5dd08..11d4ac8 100644 --- a/gameview.py +++ b/gameview.py @@ -1535,7 +1535,7 @@ class GUI(QtGui.QWidget): self.boxSounds.currentIndexChanged.connect(self.ICChatFocus) self.boxSounds.setToolTip('Play this sound effect') self.boxSounds.setObjectName('ui_sfx_dropdown') - self.boxSounds.addItem("Default") + self.populateSoundList() self.cbFlip = QtGui.QCheckBox(self) self.cbFlip.stateChanged.connect(self.changeFlipCheck) @@ -3117,8 +3117,9 @@ class GUI(QtGui.QWidget): text = "".join(l) emote = self.charEmotes[self.selectedEmote] + pre = (emote[1] != "-") - if self.cbNoInterrupt.isChecked(): + if self.cbNoInterrupt.isChecked() or not pre: modifier = 0 else: modifier = self.playPreanim @@ -3167,8 +3168,16 @@ class GUI(QtGui.QWidget): msg += emote[2] + "#" #anim msg += text + "#" msg += self.charSide + "#" - msg += (ini.get_sound(self.boxSounds.currentText(), self.charName) if self.boxSounds.currentIndex() > 0 else emote[4]) + "#" #sfx - msg += emote[4] + "#" + + # sfx + if self.boxSounds.currentIndex() > 0: + msg += unicode(self.boxSounds.currentText()) + "#" + elif pre and not self.playPreanim: + msg += "1#" + else: + msg += emote[4] + "#" + + #msg += emote[4] + "#" msg += str(modifier) + "#" #emote modifier msg += str(self.myChar) + "#" #character ID msg += emote[5] + "#" #sfx delay @@ -3461,9 +3470,9 @@ class GUI(QtGui.QWidget): fShowname = mChatMessage[SHOWNAME] if self.messageQueue: - chatMsgComp = decodeAOString(self.messageQueue[0].split('#')[5]) + chatMsgComp = decodeAOString(self.messageQueue[0].split('#')[5]).strip() examine = chatMsgComp == ">" or chatMsgComp == "<" or chatMsgComp == "=" - special = not chatMsgComp or chatMsgComp.isspace() + special = not chatMsgComp if examine or (fCharId == self.myChar and (special or mChatMessage[CHATMSG] == chatMsgComp)): # our message showed up del self.messageQueue[0] self.queueItems.takeItem(0) @@ -3480,6 +3489,7 @@ class GUI(QtGui.QWidget): # Some characters use " - " instead of "-" for no preanim. mChatMessage[PREANIM] = mChatMessage[PREANIM].strip() + # TODO: Make logging format customizable t = time.localtime() logcharName = fChar @@ -3715,7 +3725,6 @@ class GUI(QtGui.QWidget): side = self.mChatMessage[SIDE] emoteMod = int(self.mChatMessage[EMOTE_MOD]) - no_preanim = not self.mChatMessage[PREANIM] or self.mChatMessage[PREANIM] == "-" # AO 2.8: always offset player hor_offset = vert_offset = 0 @@ -3821,16 +3830,13 @@ class GUI(QtGui.QWidget): else: self.slideLastPos = None - if (emoteMod == 1 or emoteMod == 2 or emoteMod == 6) and self.mChatMessage[PREANIM] != "-": - # sfxDelay = int(self.mChatMessage[SFX_DELAY]) * 60 - # if sfxDelay > 0: - # self.sfxDelayTimer.start(sfxDelay) - # else: - # self.playSfx() + if (emoteMod == PRE or emoteMod == PRE_SHOUT or emoteMod == NOPRE_ZOOM_SHOUT): self.setBench(True) self.playPre(False) - elif emoteMod == 0 or emoteMod == 5 or no_preanim: - if self.mChatMessage[NO_INTERRUPT] == "0" or no_preanim: + elif emoteMod == NOPRE or emoteMod == NOPRE_ZOOM: + if self.mChatMessage[NO_INTERRUPT] == "0": + if self.mChatMessage[SFX] not in ["0", "1"]: + self.playSfx() self.handleChatMessage3() else: self.playPre(True) @@ -4267,6 +4273,15 @@ class GUI(QtGui.QWidget): self.sndObjection = audio.loadHandle(False, AOpath + 'sounds/general/sfx-objection.wav', 0, 0, 0) audio.setHandleAttr(self.sndObjection, BASS_ATTRIB_VOL, self.sliSoundVolume.value() / 100.0) audio.playHandle(self.sndObjection, True) + + def populateSoundList(self): + self.boxSounds.clear() + self.boxSounds.addItem("Default") + with open("base/soundlist.ini") as f: + for sound in f.read().split("\n"): + if not sound: continue + self.boxSounds.addItem(sound.strip()) + def playSfx(self): sfxName = self.mChatMessage[SFX] diff --git a/ini.py b/ini.py index 0dbbccd..c454d02 100644 --- a/ini.py +++ b/ini.py @@ -134,10 +134,6 @@ def get_effect_sound(fx_name, char): if fx_name == read_ini(inifile, section, "name", "").strip(): return read_ini(inifile, section, "sound", "").strip() return read_sectionless_ini(default_path, fx_name).strip() - -# TODO: Sound list not implemented -def get_sound(fx_name, char): - return "" def get_effects(char): p_effect = read_ini("base/characters/"+char+"/char.ini", "options", "effects", "default/effects")