From c0a10e853e385dfa5bfd1e558655c268660cfc58 Mon Sep 17 00:00:00 2001 From: cidoku Date: Sat, 1 Mar 2025 22:08:44 -0300 Subject: [PATCH] beta slides support (disabled by default) --- gameview.py | 179 +++++++++++++++++++++++++++------------------------- options.py | 11 +++- 2 files changed, 100 insertions(+), 90 deletions(-) diff --git a/gameview.py b/gameview.py index 42e4eca..a6a0524 100644 --- a/gameview.py +++ b/gameview.py @@ -883,12 +883,6 @@ class gui(QtGui.QWidget): self.court = QtGui.QLabel(self.viewport) self.court.resize(VIEWPORT_W, VIEWPORT_H) - self.slide_available = False - self.slide_has_overlay = False - self.slide_kind = 0 # 0 = def-pro, 1 = def-wit, 2 = pro-wit - self.slide_direction = 0 # 0 = left to right, 1 = right to left - self.slide_stage = 0 # 0 = start, 1 = show wit, 2 = end - self.slide_bg = QtGui.QLabel(self.viewport) self.slide_bg_animation = QtCore.QPropertyAnimation(self.slide_bg, "geometry") self.slide_bg_animation.finished.connect(self.slide_done) @@ -907,9 +901,9 @@ class gui(QtGui.QWidget): self.slide_witness = AOCharMovie(self.viewport) self.slide_witness.show_on_play = False self.slide_witness.hide() - self.slide_opponent = AOCharMovie(self.viewport) - self.slide_opponent.hide() - self.slide_opponent.show_on_play = False + self.slide_speaker = AOCharMovie(self.viewport) + self.slide_speaker.hide() + self.slide_speaker.show_on_play = False self.slide_overlay = QtGui.QLabel(self.viewport) self.slide_overlay_animation = QtCore.QPropertyAnimation(self.slide_overlay, "geometry") @@ -1359,6 +1353,23 @@ class gui(QtGui.QWidget): self.selectedplayer = -1 self.myflip = 0 self.playsfx = 1 + + self.slide_enabled = bool(get_option("General", "slide", False)) + self.slide_available = False + self.slide_has_overlay = False + self.slide_kind = 0 # 0 = def-pro, 1 = def-wit, 2 = pro-wit + self.slide_direction = 0 # 0 = left to right, 1 = right to left + + if self.slide_enabled: + self.slidebutton.setChecked(True) + + # slide_map[old_pos][new_pos] = [kind, direction] + self.slide_map = { + "def": { "pro": [0, 0], "wit": [1, 0] }, + "wit": { "def": [1, 1], "pro": [2, 0] }, + "pro": { "def": [0, 1], "wit": [2, 1] }, + } + self.loadSwapCharacters() self.iniswaplist.setCurrentIndex(0) self.evidence_editor = EditEvidenceDialog(self) @@ -1933,14 +1944,12 @@ class gui(QtGui.QWidget): self.changeEvidence(0, 0) def onClick_callMod(self): - self.do_slide() - - # if "modcall_reason" in self.features: - # reason, ok = QtGui.QInputDialog.getText(self, "Call a moderator", "Enter your reason.") - # if ok and reason: - # self.tcp.send("ZZ#"+reason.toUtf8()+"#%") - # else: - # self.tcp.send("ZZ#%") + if "modcall_reason" in self.features: + reason, ok = QtGui.QInputDialog.getText(self, "Call a moderator", "Enter your reason.") + if ok and reason: + self.tcp.send("ZZ#"+reason.toUtf8()+"#%") + else: + self.tcp.send("ZZ#%") def onClick_changeChar(self): #self.tcp.send('RD#%') @@ -2366,49 +2375,51 @@ class gui(QtGui.QWidget): self.char.hide() self.set_scene(True) - def do_slide(self, kind = 0, direction = 1): - self.setBackground("default") # testing only + def slide_start(self, value = [0, 0]): + self.chatbox.hide() - slide_time = 1000 + slide_time = 500 self.bench.hide() - self.slide_bg.show() - if self.slide_last_wit: - self.slide_witness.play_idle(self.slide_last_wit[0], self.slide_last_wit[1], self.slide_last_wit[2]) - def_pos = QtCore.QRect(0, 0, self.slide_bg.width(), VIEWPORT_H) - pro_pos = QtCore.QRect(-def_pos.size().width() + VIEWPORT_W, def_pos.top(), def_pos.size().width(), VIEWPORT_H) - wit_pos = QtCore.QRect(0, 0, self.slide_bg.width(), VIEWPORT_H) + pro_pos = QtCore.QRect(-(def_pos.size().width() - VIEWPORT_W), 0, def_pos.size().width(), VIEWPORT_H) + wit_pos = QtCore.QRect(-(self.slide_bg.width() / 2 - VIEWPORT_W / 2), 0, self.slide_bg.width(), VIEWPORT_H) - self.slide_kind = kind - self.slide_direction = direction - self.slide_stage = 0 + self.slide_kind = value[0] + self.slide_direction = value[1] - if kind == 0: - if direction == 0: + # TODO: play only first frame of preanim and figure out zooms + scaling = self.get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[CHARNAME] + '/char.ini', "options", "scaling").lower()) + self.slide_speaker.play_idle(self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM], scaling) + self.slide_speaker.show() + + if self.slide_kind == 0: + if self.slide_last_wit: + self.slide_witness.play_idle(self.slide_last_wit[0], self.slide_last_wit[1], self.slide_last_wit[2]) + self.slide_witness.show() + if self.slide_direction == 0: bg_start = def_pos bg_end = pro_pos else: bg_start = pro_pos bg_end = def_pos - elif kind == 1: - slide_time /= 2 - if direction == 0: + elif self.slide_kind == 1: + if self.slide_direction == 0: bg_start = def_pos bg_end = wit_pos else: bg_start = wit_pos bg_end = def_pos - elif kind == 2: - slide_time /= 2 - if direction == 0: + elif self.slide_kind == 2: + if self.slide_direction == 0: bg_start = wit_pos bg_end = pro_pos else: bg_start = pro_pos bg_end = wit_pos + self.slide_bg.setGeometry(bg_start) self.slide_bg_animation.setStartValue(bg_start) self.slide_bg_animation.setEndValue(bg_end) self.slide_bg_animation.setDuration(slide_time) @@ -2417,6 +2428,7 @@ class gui(QtGui.QWidget): if self.slide_has_overlay: self.slide_overlay.show() + self.slide_overlay.setGeometry(bg_start) self.slide_overlay_animation.setStartValue(bg_start) self.slide_overlay_animation.setEndValue(bg_end) self.slide_overlay_animation.setDuration(slide_time) @@ -2424,57 +2436,41 @@ class gui(QtGui.QWidget): self.slide_overlay_animation.start() def slide_changed(self): - x = self.slide_bg_animation.currentValue().toRect().x() + x = self.slide_bg.x() + # def-pro if self.slide_kind == 0: + if self.slide_last_wit: + self.slide_witness.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) if self.slide_direction == 0: - if self.slide_stage == 0: - if x > -VIEWPORT_W: - self.char.move_slide(x) - else: - self.char.hide() - if self.slide_last_wit: - self.slide_witness.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) - self.slide_witness.show() - self.slide_stage = 1 - elif self.slide_stage == 1: - if x <= -VIEWPORT_W and x >= -self.slide_bg.width() + self.slide_bg.width() / 2: - if self.slide_last_wit: - self.slide_witness.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) - else: - if self.slide_last_wit: - self.slide_witness.hide() - self.char.show() - self.slide_stage = 2 - pass - else: - self.char.move_slide(x + self.slide_bg.width() - VIEWPORT_W) + self.char.move_slide(x) + self.slide_speaker.move_slide(x + self.slide_bg.width() - VIEWPORT_W) else: - if self.slide_stage == 0: - if x < -self.slide_bg.width() + self.slide_bg.width() / 2: - self.char.move_slide(x + self.slide_bg.width() - VIEWPORT_W) - else: - self.char.hide() - if self.slide_last_wit: - self.slide_witness.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) - self.slide_witness.show() - self.slide_stage = 1 - elif self.slide_stage == 1: - if x <= -VIEWPORT_W and x >= -self.slide_bg.width() + self.slide_bg.width() / 2: - if self.slide_last_wit: - self.slide_witness.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) - else: - if self.slide_last_wit: - self.slide_witness.hide() - self.char.show() - self.slide_stage = 2 - pass - else: - self.char.move_slide(x) + self.char.move_slide(x + self.slide_bg.width() - VIEWPORT_W) + self.slide_speaker.move_slide(x) + # def-wit + elif self.slide_kind == 1: + if self.slide_direction == 0: + self.char.move_slide(x) + self.slide_speaker.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) + else: + self.char.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) + self.slide_speaker.move_slide(x) + # pro-wit + elif self.slide_kind == 2: + if self.slide_direction == 0: + self.char.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) + self.slide_speaker.move_slide(x + self.slide_bg.width() - VIEWPORT_W) + else: + self.char.move_slide(x + self.slide_bg.width() - VIEWPORT_W) + self.slide_speaker.move_slide(x + self.slide_bg.width() / 2 - VIEWPORT_W / 2) def slide_done(self): self.slide_bg.hide() self.slide_overlay.hide() + self.slide_witness.hide() + self.slide_speaker.hide() + self.handle_chatmessage_2() def netmsg_hp(self, type, health): if type == 1: @@ -2567,6 +2563,7 @@ class gui(QtGui.QWidget): # Skip everything in the queue, show message immediately self.inboxqueue = [] self.inboxqueue.append(m_chatmessage) + self.inbox_timer.stop() self.m_chatmessage = m_chatmessage objections = ["holdit", "objection", "takethat", "custom_objections/"+custom_objection if custom_objection != "custom" else "custom"] @@ -2581,8 +2578,7 @@ class gui(QtGui.QWidget): # 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() + self.handle_chatmessage_1(m_chatmessage) # Old behavior #self.m_chatmessage = m_chatmessage @@ -2690,7 +2686,19 @@ class gui(QtGui.QWidget): self.bench.hide() def objection_done(self): - self.handle_chatmessage_2() + self.handle_chatmessage_1() + + def handle_chatmessage_1(self, m_chatmessage = None): + if m_chatmessage: + self.m_chatmessage = m_chatmessage + + new_side = self.m_chatmessage[SIDE] + can_slide = self.slide_enabled and self.slide_available + + if can_slide and self.m_chatmessage[SLIDE] == "1" and self.slide_last_pos and new_side != self.slide_last_pos and new_side in ["def", "pro", "wit"]: + self.slide_start(self.slide_map[self.slide_last_pos][new_side]) + else: + self.handle_chatmessage_2() def handle_chatmessage_2(self): self.zoom.setZoom(False) @@ -3234,10 +3242,7 @@ class gui(QtGui.QWidget): if len(self.inboxqueue) > 0: del self.inboxqueue[0] if len(self.inboxqueue) > 0: - self.m_chatmessage = self.inboxqueue[0] - slide = self.m_chatmessage[SLIDE] - - self.handle_chatmessage_2() + self.handle_chatmessage_1(self.inboxqueue[0]) def playRealization(self): audio.playhandle(self.realizationsnd, True) diff --git a/options.py b/options.py index 9c5ceb0..562da0a 100644 --- a/options.py +++ b/options.py @@ -89,11 +89,11 @@ class Settings(QtGui.QDialog): textstaytime_layout.addWidget(textstaytime_label) textstaytime_layout.addWidget(self.textstaytime) - icoptions_layout = QtGui.QHBoxLayout() + slide_layout = QtGui.QHBoxLayout() self.enableslide = QtGui.QCheckBox() - self.enableslide.setText("Display courtroom slide (pan-tilt) animations") + self.enableslide.setText("(Experimental) Display courtroom slide (pan-tilt) animations") self.enableslide.setChecked(True) - icoptions_layout.addWidget(self.enableslide) + slide_layout.addWidget(self.enableslide) allowdownload = QtGui.QLabel() allowdownload.setText("Automatically download or stream online from WebAO:") @@ -158,6 +158,7 @@ class Settings(QtGui.QDialog): general_layout.addLayout(savetolog_layout) general_layout.addWidget(separators[0]) general_layout.addLayout(textstaytime_layout) + general_layout.addLayout(slide_layout) general_layout.addWidget(separators[1]) general_layout.addLayout(currtheme_layout) general_layout.addLayout(autoconnect_layout) @@ -239,6 +240,7 @@ class Settings(QtGui.QDialog): self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname").decode("utf-8")) except: self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname")) + self.enableslide.setChecked(ini.read_ini_bool(self.inifile, "General", "slide")) self.allowdownload_chars.setChecked(ini.read_ini_bool(self.inifile, "General", "download characters")) self.allowdownload_sounds.setChecked(ini.read_ini_bool(self.inifile, "General", "download sounds")) self.allowdownload_music.setChecked(ini.read_ini_bool(self.inifile, "General", "download music")) @@ -260,6 +262,7 @@ class Settings(QtGui.QDialog): self.savetolog_combine.setChecked(False) self.defaultoocname.setText("") self.defaultshowname.setText("") + self.enableslide.setChecked(False) self.allowdownload_sounds.setChecked(True) self.allowdownload_music.setChecked(True) self.allowdownload_evidence.setChecked(True) @@ -297,6 +300,7 @@ class Settings(QtGui.QDialog): self.inifile.set("General", "OOC name", self.defaultoocname.text().toUtf8()) self.inifile.set("General", "showname", self.defaultshowname.text().toUtf8()) self.inifile.set("General", "text stay time", self.textstaytime.value()) + self.inifile.set("General", "slide", self.enableslide.isChecked()) self.inifile.set("General", "download characters", self.allowdownload_chars.isChecked()) self.inifile.set("General", "download sounds", self.allowdownload_sounds.isChecked()) self.inifile.set("General", "download music", self.allowdownload_music.isChecked()) @@ -321,6 +325,7 @@ class Settings(QtGui.QDialog): self.gamewindow.gamewidget.text_wait_time = self.textstaytime.value() self.gamewindow.gamewidget.ooclog.set_logfiles() self.gamewindow.gamewidget.icLog.set_logfiles(self.gamewindow.gamewidget.ooclog.logfile) + self.gamewindow.gamewidget.slide_enabled = self.enableslide.isChecked() self.hide()