Source code for quest.modal

# Modal
# -------------------
# A modal window is a "pop-up" that creates a mode--it pauses the game until the 
# window

import arcade
from quest.text_label import TextLabelStack


        

[docs]class DialogueModal(Modal): """A modal window powered by a Dialogue object. """ def __init__(self, game, dialogue): self.dialogue = dialogue super().__init__(game)
[docs] def text_label_contents(self): return self.dialogue.get_content()
[docs] def option_label_contents(self): return self.dialogue.get_options()
[docs] def choose_option(self, value): self.dialogue.choose(value) if not self.dialogue.running: self.close()
[docs]class AlertModal(Modal): "A simple modal, just used to return a result." def __init__(self, game, message, response="OK"): self.message = message self.response = response super().__init__(game)
[docs] def text_label_contents(self): return [self.message]
[docs] def option_label_contents(self): return [self.response]
def handle_choice(self): self.choose_option(self.current_option)
[docs] def choose_option(self, value): self.close()