commit 2c7debef693365617e76815c31c83a4a117312bd
parent e4acff60ecfac436a7c76705de032af884eaf8d8
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 19 Oct 2020 19:29:12 -0500
now displaying and positioning name in still scenese
Diffstat:
3 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/game.py b/src/game.py
@@ -227,6 +227,9 @@ class GameInterface(GameSubsystem):
self.game.control_mode = CTRL_MODES.Turn_Normal
# TODO: Should this really be done here???
self.game.board_manager.load_overlay()
+ elif self.game.state_mode == STATE_MODES.Still_Scene_Mode:
+ if self.game.control_mode == CTRL_MODES.Still_Scene_Normal:
+ self.game.scene_manager.current_scene.continue_script()
def handle_mouse_release(self, event):
"""
diff --git a/src/scene.py b/src/scene.py
@@ -79,6 +79,8 @@ class StillScene(object):
# TODO: Pos vals should not be hardcoded like this
self.name_box = None
self.name_box_pos = (20, 480)
+ self.rendered_name = None
+ self.rendered_name_topleft = (0, 0) # Dynamically calculated
self.text_box = None
self.text_box_pos = (0, 508)
self.continue_prompt = None
@@ -95,6 +97,7 @@ class StillScene(object):
self.line_number = 0
self.current_line_starting_index = 0
self.current_font = None # An index of the 'fonts' value
+ self.current_name_font = None
self.current_font_height = 0
self.current_voice = None
self.voice_delay = 0
@@ -142,6 +145,7 @@ class StillScene(object):
# Next, load up the next segment
self.script_index += 1
self.current_font = self.fonts[self.script[self.script_index]["line_font"]]
+ self.current_name_font = self.fonts[self.script[self.script_index]["name_font"]]
self.current_font_height = self.current_font.get_height()
self.max_line = int((3 * SCREEN_WIDTH) / self.current_font_height)
self.total_lines = int(self.text_area_height / self.current_font_height)
@@ -151,6 +155,10 @@ class StillScene(object):
nc = vgo.VisibleGameObject(self.manager.game.sheet_manager.loaded_sheets[c["sheet"]], tuple(c["sprite"]))
nc.set_position(tuple(c["pos"]))
self.displayed_characters.add(nc)
+ if self.script[self.script_index]["speaker"] != None:
+ self.rendered_name = self.current_name_font.render(self.script[self.script_index]["speaker"], False, (255, 255, 255)).convert()
+ #self.rendered_name_topleft = (self.name_box_pos[0] + (self.rendered_name.get_width() / 2) + (self.name_box.image.get_width() / 2), self.name_box_pos[1] + (self.rendered_name.get_height() / 2) + (self.name_box.image.get_width() / 2))
+ self.rendered_name_topleft = (self.name_box_pos[0] + ((self.name_box.image.get_width() / 2) - (self.rendered_name.get_width() / 2)), self.name_box_pos[1] + ((self.name_box.image.get_height() / 2) - (self.rendered_name.get_height() / 2)))
def write_text(self):
"""
@@ -216,9 +224,6 @@ class StillScene(object):
"""
Play a voice sound along with the text write.
"""
- # TODO: This error checking should be a part of play()
- # This could be something for the bus to handle in
- # the future (internal errors)
# Voice delay calculations
if self.current_text_string[self.current_text_char_index] == " ":
self.voice_delay += 2
@@ -233,7 +238,7 @@ class StillScene(object):
Trigger the script cycle. Activated by something
else.
"""
- if self.script_index < len(self.script) - 1:
+ if self.continue_ready and self.script_index < len(self.script) - 1:
self.cycle_script_segment()
def update(self, surface = None):
@@ -246,6 +251,9 @@ class StillScene(object):
self.text_box.update(surface)
self.name_box.update(surface)
+ # Write the name in the namebox
+ surface.blit(self.rendered_name, self.rendered_name_topleft)
+
if self.continue_ready:
self.continue_prompt.update(surface)
diff --git a/src/sound.py b/src/sound.py
@@ -48,15 +48,13 @@ class SoundManager(manager.Manager):
a legal channel id int.
"""
# TODO: There could (should?) be some channel-checking logic here
- if channel != None and not self.channels[channel].get_busy():
- try:
- self.channels[channel].play(self.sounds[soundname])
- except IndexError:
- # TODO: Should be bus error here
- print("Failed to play sound on channel " + channel)
- elif not concurrent:
- if self.sounds[soundname].get_num_channels() == 0:
- self.sounds[soundname].play()
- else:
- self.sounds[soundname].play()
+ if soundname != None:
+ if channel != None and not self.channels[channel].get_busy():
+ try:
+ self.channels[channel].play(self.sounds[soundname])
+ except IndexError:
+ # TODO: Should be bus error here
+ print("Failed to play sound " + soundname + " on channel " + channel)
+ elif concurrent or self.sounds[soundname].get_num_channels() == 0:
+ self.sounds[soundname].play()