Skip to content

Commit

Permalink
fix engine selection quirky UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-kane committed Jul 29, 2024
1 parent 15bbc79 commit 41a686a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/cnv/chatlog/npc_chatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 <color red>Toothbreaker Jones</color> 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"))
Expand All @@ -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.
Expand Down
15 changes: 7 additions & 8 deletions src/cnv/engines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -326,20 +326,19 @@ 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.
log.error(f'No widget defined for variables like {varfunc}')

# changes to the value of this widget trip a generic 'reconfig'
# handler.


def _tkStringVar(self, index, key, frame):
# combo widget for strings
Expand Down
8 changes: 7 additions & 1 deletion src/cnv/tabs/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=}')
Expand Down Expand Up @@ -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
Expand Down
36 changes: 23 additions & 13 deletions src/cnv/voices/voice_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 41a686a

Please sign in to comment.