commit adec7196ee3bfa7451cc8ed9935be67180e0d43b
parent 56af7de235495c7ab6ae76e2887136b6650af9cf
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 28 Dec 2020 10:49:14 -0600
just for posterity, gonna go a different direction with this
Diffstat:
M | src/dialog.py | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 68 insertions(+), 0 deletions(-)
diff --git a/src/dialog.py b/src/dialog.py
@@ -8,6 +8,7 @@ from .constants import *
# This file contains the following:
# 1. The DialogManager class, which controls the inter-mode bottom-of-the-screen conversation events
+# 2. The Dialog class, which represents a dialog sequence itself
###################################
# Section 1 - DialogManager class #
@@ -63,3 +64,70 @@ class DialogManager(manager.Manager):
self.dialog_sequence = DIALOGS[seq_id]
self.sequence_index = 0
+############################
+# Section 2 - Dialog class #
+############################
+
+class Dialog(object):
+ """
+ A Dialog is an interval of text that is displayed
+ during interactive modes, such as in battle.
+ """
+
+ def __init__(self, manager, dialogdef):
+
+ # Saved values
+ self.manager = manager
+
+ # Important values
+ self.name = None
+ self.script = []
+ self.fonts = {}
+ self.text_speed = 1
+ self.text_write_timer = 0
+ self.current_text_char_index = 0
+ self.continue_ready = False
+ self.max_line = 0
+ self.total_lines = 0
+
+ # Universal elements
+ # 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
+ self.continue_prompt_pos = (964, 748)
+ self.text_area_topleft = (48, 560)
+ self.text_area_height = 160
+ self.background = None
+
+ # Swap-in values
+ self.displayed_characters = [] # Must be an ordered list rather than a sprite group
+ self.current_text_string = ""
+ self.displayed_strings = [""] # list of text lines
+ self.rendered_text_surfaces = [None]
+ 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
+ self.script_index = -1
+
+ # Setup
+ sh = self.manager.bus.fetch("sheet_manager", "sheets")
+
+ # Load univeral elements
+ self.name_box = entity.Entity(sh["still_scene_name_box_1"])
+ self.name_box.set_position(self.name_box_pos)
+ self.text_box = entity.Entity(sh["still_scene_text_box_1"])
+ self.text_box.set_position(self.text_box_pos)
+ self.continue_prompt = entity.Entity(sh["continue_prompt_1"], (0, 0), sh["continue_prompt_1"].animations["shimmer"], True)
+ self.continue_prompt.set_position(self.continue_prompt_pos)
+
+ # Cycle in for the first time
+ self.cycle_script_segment()