From 41a686ad83b1e3646d8b41cc792ef441a66baf66 Mon Sep 17 00:00:00 2001 From: Jason Kane Date: Mon, 29 Jul 2024 09:01:31 -0700 Subject: [PATCH] fix engine selection quirky UI --- src/cnv/chatlog/npc_chatter.py | 8 ++++---- src/cnv/engines/base.py | 15 +++++++------- src/cnv/tabs/character.py | 8 +++++++- src/cnv/voices/voice_editor.py | 36 ++++++++++++++++++++++------------ 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/cnv/chatlog/npc_chatter.py b/src/cnv/chatlog/npc_chatter.py index 8fa3c97..631d04f 100644 --- a/src/cnv/chatlog/npc_chatter.py +++ b/src/cnv/chatlog/npc_chatter.py @@ -555,7 +555,7 @@ def tail(self): self.speaking_queue.put((None, (" ".join(lstring[4:])), "system")) elif lstring[0] == "You": - if lstring[1] in ["found", "stole"]: + if lstring[1] in ["found", "stole", "begin", "finished"]: # You found a face mask that is covered in some kind of mold. It appears to be pulsing like it's breathing. You send a short video to Watkins for evidence. # You stole the money! dialog = plainstring(" ".join(lstring)) @@ -632,7 +632,7 @@ def tail(self): if special is None: special = "" else: - special = special.strip("()").title() + special = special.strip("() \t\n\r\x0b\x0c").title() d = models.Damage( hero_id=self.hero.id, @@ -697,7 +697,7 @@ def tail(self): action = lstring[-3] # joined or quit self.speaking_queue.put((None, f"Player {name} has {action} the team", "system")) - elif lstring[:2] == ["The", "name"]: + elif lstring[:2] in ["The", "name", "The", "whiteboard"]: # The name Toothbreaker Jones keeps popping up, and these Skulls were nice enough to tell you where to find him. Time to pay him a visit. dialog = plainstring(" ".join(lstring)) self.speaking_queue.put((None, dialog, "system")) @@ -719,7 +719,7 @@ def tail(self): ) # single word things to speak, mostly clicky descriptions - elif lstring[0] in ["Something's", "This", "You've"]: + elif lstring[0] in ["Something's", "In", "Jones", "This", "You've", "Where"]: # Something's not right with this spot on the floor... # This blotch of petroleum on the ground seems fresh, perhaps leaked by a 'zoombie' and a sign that they're near. You take a photo and send it to Watkins. # You've found a photocopy of a highly detailed page from a medical notebook, with wildly complex notes about cybernetics. diff --git a/src/cnv/engines/base.py b/src/cnv/engines/base.py index b5c0396..04435a2 100644 --- a/src/cnv/engines/base.py +++ b/src/cnv/engines/base.py @@ -303,12 +303,12 @@ def save_character(self, name, category): def draw_config_meta(self, parent): # now we build it. Row 0 is taken by the engine selector, the rest is ours. - # column sizing is handled upstream, we need to stay clean with - parent.columnconfigure(0, minsize=125, uniform="ttsengine") - parent.columnconfigure(1, weight=2, uniform="ttsengine") + # column sizing is handled upstream, we need to stay clean + self.columnconfigure(0, minsize=125, weight=0, uniform="ttsengine") + self.columnconfigure(1, weight=2, uniform="ttsengine") for index, m in enumerate(self.get_config_meta()): - ctk.CTkLabel(parent, text=m.cosmetic, anchor="e").grid( + ctk.CTkLabel(self, text=m.cosmetic, anchor="e").grid( row=index + 1, column=0, sticky="e", padx=10 ) @@ -326,12 +326,12 @@ def draw_config_meta(self, parent): # create the widget itself if m.varfunc == "StringVar": - self._tkStringVar(index + 1, m.key, parent) + self._tkStringVar(index + 1, m.key, self) elif m.varfunc == "DoubleVar": - self._tkDoubleVar(index + 1, m.key, parent, m.cfgdict) + self._tkDoubleVar(index + 1, m.key, self, m.cfgdict) self.config_vars[m.key].trace_add("write", self.reconfig) elif m.varfunc == "BooleanVar": - self._tkBooleanVar(index + 1, m.key, parent) + self._tkBooleanVar(index + 1, m.key, self) self.config_vars[m.key].trace_add("write", self.reconfig) else: # this will fail, but at least it will fail with a log message. @@ -339,7 +339,6 @@ def draw_config_meta(self, parent): # changes to the value of this widget trip a generic 'reconfig' # handler. - def _tkStringVar(self, index, key, frame): # combo widget for strings diff --git a/src/cnv/tabs/character.py b/src/cnv/tabs/character.py index 400b40c..09a42c6 100644 --- a/src/cnv/tabs/character.py +++ b/src/cnv/tabs/character.py @@ -223,6 +223,10 @@ def __init__(self, parent, hero, *args, **kwargs): data_xp.append(xp_gain) data_inf.append(inf_gain) + + if xp_gain is None: + xp_gain = 0 + rolling_xp_list.append(xp_gain) log.debug(f'{rolling_xp_list=}') @@ -433,7 +437,9 @@ def refresh_damage_panel(self): rowspan=height ) - p['typed'][('Total', '')] = {'total': total_damage, 'count': hits} + if len(p['typed']) > 1: + p['typed'][('Total', '')] = {'total': total_damage, 'count': hits} + for damage_type, special in p['typed']: if damage_type == "": continue diff --git a/src/cnv/voices/voice_editor.py b/src/cnv/voices/voice_editor.py index 56f37b7..66bc575 100644 --- a/src/cnv/voices/voice_editor.py +++ b/src/cnv/voices/voice_editor.py @@ -407,24 +407,28 @@ def say_it(self, use_secondary=False): tk.messagebox.showerror(title="Error", message=f"Engine {engine_name} did not provide audio") -class EngineSelectAndConfigure(ttk.LabelFrame): +class EngineSelectAndConfigure(ctk.CTkFrame): """ Responsible for everything inside the "Engine" section of the detailside. There is one instance of this object per layer of engine (primary, secondary, etc..) """ def __init__(self, rank, *args, **kwargs): - kwargs['text'] = 'Engine' super().__init__(*args, **kwargs) log.debug(f'EngineSelectAndConfigure.__init__({rank=}') self.rank = rank self.engine_parameters = None - - self.columnconfigure(0, minsize=125, uniform="ttsengine") - self.columnconfigure(1, weight=2, uniform="ttsengine") - + + self.columnconfigure(0, weight=1) + self.rowconfigure(0, weight=1) + #-- Row 0 -------------------------------------- - ctk.CTkLabel(self, text="Text to Speech Engine", anchor="e").grid( + speech_engine_selection = ctk.CTkFrame(self) + + speech_engine_selection.columnconfigure(0, minsize=125, weight=0, uniform="ttsengine") + speech_engine_selection.columnconfigure(1, weight=2, uniform="ttsengine") + + ctk.CTkLabel(speech_engine_selection, text="Speech Engine", anchor="e").grid( row=0, column=0, sticky="e", padx=10 ) @@ -433,20 +437,27 @@ def __init__(self, rank, *args, **kwargs): "write", self.change_selected_engine ) + base_tts = ctk.CTkComboBox( - self, + speech_engine_selection, variable=self.selected_engine, state='readonly', values=[e.cosmetic for e in engines.ENGINE_LIST] ) - # base_tts["values"] = [e.cosmetic for e in engines.ENGINE_LIST] - # base_tts["state"] = "readonly" + base_tts.grid( column=1, row=0, sticky="new" ) - #-- Row 1 -------------------------------------- + speech_engine_selection.grid( + column=0, row=0, sticky="new" + ) + ######################################### + # end of row 0 - #-- Row 2 -------------------------------------- + # gap for engine parameters. load_character_engines will + # call set_engine which will fill this in. + + # start of row 2 self.engine_parameters = None self.phrase_selector = WavfileMajorFrame( self.rank, self @@ -470,7 +481,6 @@ def set_engine(self, engine_name): # which will in turn set a value for engine_parameters self.selected_engine.set(engine_name) - def change_selected_engine(self, a, b, c): """ 1. the user changed the engine for this character.