Skip to content

Commit

Permalink
tts: Modal screens stop tts processing.
Browse files Browse the repository at this point in the history
The idea being to not read out things that are blocked by a modal
dialogue.

Fixes #3030.
  • Loading branch information
renpytom committed Sep 11, 2021
1 parent 123fb78 commit 788a39d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions renpy/display/core.py
Expand Up @@ -707,13 +707,18 @@ def _tts_common(self, default_alt=None, reverse=False):
else:
order = -1

speech = ""

for i in self.visit()[::order]:
if i is not None:
speech = i._tts()

if speech.strip():
rv.append(speech)

if isinstance(speech, renpy.display.tts.TTSDone):
break

rv = ": ".join(rv)
rv = rv.replace("::", ":")
rv = rv.replace(": :", ":")
Expand All @@ -726,6 +731,8 @@ def _tts_common(self, default_alt=None, reverse=False):
if alt is not None:
rv = renpy.substitutions.substitute(alt, scope={ "text" : rv })[0]

rv = type(speech)(rv)

return rv

def _tts(self):
Expand Down
9 changes: 9 additions & 0 deletions renpy/display/screen.py
Expand Up @@ -736,6 +736,15 @@ def event(self, ev, x, y, st):
def get_phase_name(self):
return phase_name[self.phase]

def _tts(self):
if (self.phase == OLD) or (self.phase == HIDE):
return ""

if self.modal:
return renpy.display.tts.TTSDone(self._tts_common())
else:
return self._tts_common()


# The name of the screen that is currently being displayed, or
# None if no screen is being currently displayed.
Expand Down

0 comments on commit 788a39d

Please sign in to comment.