first implementation of delayed messages, no option to change delay yet

This commit is contained in:
cidoku 2025-02-26 18:20:08 -03:00
parent 0fc96465f1
commit c5dceaa7c3

View File

@ -757,6 +757,10 @@ class gui(QtGui.QWidget):
self.sfx_delay_timer.setSingleShot(True) self.sfx_delay_timer.setSingleShot(True)
self.sfx_delay_timer.timeout.connect(self.play_sfx) self.sfx_delay_timer.timeout.connect(self.play_sfx)
self.inbox_timer = QtCore.QTimer(self)
self.inbox_timer.setSingleShot(True)
self.inbox_timer.timeout.connect(self.inbox_timer_timeout)
self.modcall = None self.modcall = None
self.healthbars.connect(self.netmsg_hp) self.healthbars.connect(self.netmsg_hp)
@ -1200,6 +1204,7 @@ class gui(QtGui.QWidget):
self.charside = 'def' self.charside = 'def'
self.lastmsg = '' self.lastmsg = ''
self.msgqueue = [] self.msgqueue = []
self.inboxqueue = []
self.selectedmsg = -1 self.selectedmsg = -1
self.evidence = [] self.evidence = []
self.privateevidence = [] self.privateevidence = []
@ -2173,60 +2178,53 @@ class gui(QtGui.QWidget):
if int(p_contents[CHAR_ID]) in self.muted: # skip the self.chatmessage copy line below if int(p_contents[CHAR_ID]) in self.muted: # skip the self.chatmessage copy line below
return return
m_chatmessage = {}
for n_string in range(self.chatmessage_size): for n_string in range(self.chatmessage_size):
if n_string < len(p_contents) and (n_string < 16 or AO2chat): if n_string < len(p_contents) and (n_string < 16 or AO2chat):
self.m_chatmessage[n_string] = p_contents[n_string] m_chatmessage[n_string] = p_contents[n_string]
else: else:
self.m_chatmessage[n_string] = "" m_chatmessage[n_string] = ""
f_char_id = int(self.m_chatmessage[CHAR_ID]) f_char_id = int(m_chatmessage[CHAR_ID])
if f_char_id < 0 or f_char_id >= len(self.charlist): if f_char_id < 0 or f_char_id >= len(self.charlist):
return return
f_showname = "" f_showname = ""
if not self.m_chatmessage[SHOWNAME]: if not m_chatmessage[SHOWNAME]:
f_showname = self.m_chatmessage[CHARNAME] f_showname = m_chatmessage[CHARNAME]
else: else:
f_showname = self.m_chatmessage[SHOWNAME] f_showname = m_chatmessage[SHOWNAME]
self.text_state = 0
self.anim_state = 0
self.objectionview.stop()
self.char.stop()
self.chat_tick_timer.stop()
self.presentedevi.hide()
self.chatmessage_is_empty = self.m_chatmessage[CHATMSG] == " " or self.m_chatmessage[CHATMSG] == ""
if self.msgqueue: if self.msgqueue:
chatmsgcomp = (self.msgqueue[0].split('#')[5]).replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#') chatmsgcomp = (self.msgqueue[0].split('#')[5]).replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#')
examine = chatmsgcomp == ">" or chatmsgcomp == "<" examine = chatmsgcomp == ">" or chatmsgcomp == "<"
special = not chatmsgcomp or chatmsgcomp.isspace() special = not chatmsgcomp or chatmsgcomp.isspace()
if examine or (f_char_id == self.mychar and (special or self.m_chatmessage[CHATMSG] == chatmsgcomp)): # our message showed up if examine or (f_char_id == self.mychar and (special or m_chatmessage[CHATMSG] == chatmsgcomp)): # our message showed up
del self.msgqueue[0] del self.msgqueue[0]
self.msgqueueList.takeItem(0) self.msgqueueList.takeItem(0)
if self.additivebtn.isChecked(): if self.additivebtn.isChecked():
self.icchatinput.insert(" ") self.icchatinput.insert(" ")
self.m_chatmessage[CHARNAME] = self.m_chatmessage[CHARNAME].decode("utf-8") m_chatmessage[CHARNAME] = m_chatmessage[CHARNAME].decode("utf-8")
self.m_chatmessage[SHOWNAME] = self.m_chatmessage[SHOWNAME].decode('utf-8') m_chatmessage[SHOWNAME] = m_chatmessage[SHOWNAME].decode('utf-8')
f_char = self.m_chatmessage[CHARNAME] f_char = m_chatmessage[CHARNAME]
evidence = int(self.m_chatmessage[EVIDENCE])-1 evidence = int(m_chatmessage[EVIDENCE])-1
t = time.localtime() t = time.localtime()
logcharname = f_char logcharname = f_char
#TODO: UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if f_char.lower() != self.charlist[f_char_id][0].lower(): if f_char.lower() != self.charlist[f_char_id][0].lower():
logcharname = self.charlist[f_char_id][0] + ' (' + f_char.decode("utf-8") + ')' logcharname = self.charlist[f_char_id][0] + ' (' + f_char.decode("utf-8") + ')'
chatmsg = self.m_chatmessage[CHATMSG] chatmsg = m_chatmessage[CHATMSG]
if self.m_chatmessage[SHOWNAME] and self.m_chatmessage[SHOWNAME].lower() != f_char.lower(): if m_chatmessage[SHOWNAME] and m_chatmessage[SHOWNAME].lower() != f_char.lower():
try: try:
logcharname += " ("+self.m_chatmessage[SHOWNAME]+")" logcharname += " (" + m_chatmessage[SHOWNAME]+")"
except: except:
logcharname += " (???)" logcharname += " (???)"
@ -2241,18 +2239,23 @@ class gui(QtGui.QWidget):
self.icLog.append('[%d:%.2d] %s: %s\n%s presented an evidence: %s' % (t[3], t[4], logcharname, chatmsg, f_char, eviname)) self.icLog.append('[%d:%.2d] %s: %s\n%s presented an evidence: %s' % (t[3], t[4], logcharname, chatmsg, f_char, eviname))
self.is_additive = (self.m_chatmessage[ADDITIVE] == "1") self.is_additive = (m_chatmessage[ADDITIVE] == "1")
custom_objection = "custom" custom_objection = "custom"
try: objection_mod = int(self.m_chatmessage[SHOUT_MOD]) try: objection_mod = int(m_chatmessage[SHOUT_MOD])
except: except:
if "4&" in self.m_chatmessage[SHOUT_MOD]: # custom objection name if "4&" in m_chatmessage[SHOUT_MOD]: # custom objection name
objection_mod = 4 objection_mod = 4
custom_objection = self.m_chatmessage[SHOUT_MOD].split("4&")[1] # get the name custom_objection = m_chatmessage[SHOUT_MOD].split("4&")[1] # get the name
else: # just in case of mindfuckery else: # just in case of mindfuckery
objection_mod = 0 objection_mod = 0
if objection_mod <= 4 and objection_mod >= 1: if objection_mod <= 4 and objection_mod >= 1:
# Skip everything in the queue, show message immediately
self.inboxqueue = []
self.inboxqueue.append(m_chatmessage)
self.m_chatmessage = m_chatmessage
objections = ["holdit", "objection", "takethat", "custom_objections/"+custom_objection if custom_objection != "custom" else "custom"] objections = ["holdit", "objection", "takethat", "custom_objections/"+custom_objection if custom_objection != "custom" else "custom"]
self.objectionview.play(objections[objection_mod-1], f_char.lower()) self.objectionview.play(objections[objection_mod-1], f_char.lower())
self.playObjectionSnd(f_char.lower(), objection_mod) self.playObjectionSnd(f_char.lower(), objection_mod)
@ -2261,7 +2264,15 @@ class gui(QtGui.QWidget):
if emote_mod == 0: if emote_mod == 0:
self.m_chatmessage[EMOTE_MOD] = 1 self.m_chatmessage[EMOTE_MOD] = 1
else: else:
self.handle_chatmessage_2() # Add message to queue and wait, unless queue empty
self.inboxqueue.append(m_chatmessage)
if len(self.inboxqueue) == 1:
self.m_chatmessage = m_chatmessage
self.handle_chatmessage_2()
# Old behavior
#self.m_chatmessage = m_chatmessage
#self.handle_chatmessage_2()
def set_text_color(self): def set_text_color(self):
textcolor = int(self.m_chatmessage[TEXT_COLOR]) textcolor = int(self.m_chatmessage[TEXT_COLOR])
@ -2357,6 +2368,15 @@ class gui(QtGui.QWidget):
self.zoom.setZoom(False) self.zoom.setZoom(False)
self.char.stop() self.char.stop()
self.effectview.stop() self.effectview.stop()
self.text_state = 0
self.anim_state = 0
self.objectionview.stop()
self.char.stop()
self.chat_tick_timer.stop()
self.presentedevi.hide()
self.chatmessage_is_empty = self.m_chatmessage[CHATMSG] == " " or self.m_chatmessage[CHATMSG] == ""
if not self.m_chatmessage[SHOWNAME]: if not self.m_chatmessage[SHOWNAME]:
self.name.setText(self.m_chatmessage[CHARNAME]) self.name.setText(self.m_chatmessage[CHARNAME])
@ -2649,6 +2669,7 @@ class gui(QtGui.QWidget):
if self.chatmessage_is_empty: if self.chatmessage_is_empty:
self.text_state = 2 self.text_state = 2
self.inbox_timer.start(1000)
return return
self.inline_color_stack = [] self.inline_color_stack = []
@ -2663,6 +2684,8 @@ class gui(QtGui.QWidget):
self.chat_tick_timer.start(self.message_display_speed[self.current_display_speed]) self.chat_tick_timer.start(self.message_display_speed[self.current_display_speed])
self.blip = self.charlist[charid][2] self.blip = self.charlist[charid][2]
if not self.blip:
self.blip = self.m_chatmessage[BLIPS]
if exists(AOpath+"sounds/general/sfx-blip"+self.blip+".wav"): if exists(AOpath+"sounds/general/sfx-blip"+self.blip+".wav"):
self.blipsnd = audio.loadhandle(False, AOpath+"sounds/general/sfx-blip"+self.blip+".wav", 0, 0, 0) self.blipsnd = audio.loadhandle(False, AOpath+"sounds/general/sfx-blip"+self.blip+".wav", 0, 0, 0)
@ -2698,6 +2721,8 @@ class gui(QtGui.QWidget):
if self.anim_state != 4: if self.anim_state != 4:
self.anim_state = 3 self.anim_state = 3
self.char.play_idle(self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM], self.scaling[0]) self.char.play_idle(self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM], self.scaling[0])
self.inbox_timer.start(1000)
else: else:
f_character2 = f_message[self.tick_pos] f_character2 = f_message[self.tick_pos]
f_character = QtCore.QString(f_character2) f_character = QtCore.QString(f_character2)
@ -2870,6 +2895,13 @@ class gui(QtGui.QWidget):
self.chat_tick_timer.start(1) self.chat_tick_timer.start(1)
else: else:
self.chat_tick_timer.start(self.message_display_speed[self.current_display_speed]) self.chat_tick_timer.start(self.message_display_speed[self.current_display_speed])
def inbox_timer_timeout(self):
if len(self.inboxqueue) > 0:
del self.inboxqueue[0]
if len(self.inboxqueue) > 0:
self.m_chatmessage = self.inboxqueue[0]
self.handle_chatmessage_2()
def playRealization(self): def playRealization(self):
audio.playhandle(self.realizationsnd, True) audio.playhandle(self.realizationsnd, True)