Exemple #1
0
 def __init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget):
     """ Initialize the widget """
     MenuWidget.__init__(self,
                         menu,
                         width,
                         height,
                         MenuEntryWidget=MenuEntryWidget)
     self.background = MenuBackgroundWidget(width, height)
Exemple #2
0
    def __init__(self, width, height, message, fullyDisplay=False):
        """ Builds the Message Box with the given message box """
        SizedWidget.__init__(self, width, height)
        self.message = message
        self.charsShown = 0
        self.font = pygame.font.SysFont("Times New Roman", 36)
        self.stringToDisplay = ""

        self.background = MenuBackgroundWidget(self.width, self.height)

        if fullyDisplay:
            self.showFully()
class MenuWithBackgroundWidget(MenuWidget):
    """ Represents the widget for a Menu With A Background """
    
    def __init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget):
        """ Initialize the widget """
        MenuWidget.__init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget)
        self.background = MenuBackgroundWidget(width, height)
        
    def buildSurface(self):
        """ Build the Men Surface """
        return self.background.draw()
Exemple #4
0
 def __init__(self, width, height, message, fullyDisplay=False):
     """ Builds the Message Box with the given message box """
     SizedWidget.__init__(self, width, height)
     self.message = message
     self.charsShown = 0
     self.font = pygame.font.SysFont("Times New Roman", 36)
     self.stringToDisplay = ""
     
     self.background = MenuBackgroundWidget(self.width, self.height)
     
     if fullyDisplay:
         self.showFully()
Exemple #5
0
class MenuWithBackgroundWidget(MenuWidget):
    """ Represents the widget for a Menu With A Background """
    def __init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget):
        """ Initialize the widget """
        MenuWidget.__init__(self,
                            menu,
                            width,
                            height,
                            MenuEntryWidget=MenuEntryWidget)
        self.background = MenuBackgroundWidget(width, height)

    def buildSurface(self):
        """ Build the Men Surface """
        return self.background.draw()
Exemple #6
0
class MessageBox(SizedWidget):
    """ Represents a message box on the screen """
    maxChars = 35

    def __init__(self, width, height, message, fullyDisplay=False):
        """ Builds the Message Box with the given message box """
        SizedWidget.__init__(self, width, height)
        self.message = message
        self.charsShown = 0
        self.font = pygame.font.SysFont("Times New Roman", 36)
        self.stringToDisplay = ""

        self.background = MenuBackgroundWidget(self.width, self.height)

        if fullyDisplay:
            self.showFully()

    def update(self):
        """ Updates the message box """
        if not self.isFullyShown():
            self.charsShown += 1

        self.stringToDisplay = self.message.getMessageSlice(self.charsShown)

    def drawSurface(self):
        """ Draws the message box """
        self.drawOnSurface(self.background.draw(), left=0, top=0)

        line1 = self.font.render(self.stringToDisplay[:self.maxChars], 1, (
            10, 10,
            10))  # Logic to split string to display may belong better in model
        line2 = self.font.render(self.stringToDisplay[self.maxChars:], 1,
                                 (10, 10, 10))

        self.drawOnSurface(line1, left=.05, centery=.33)
        self.drawOnSurface(line2, left=.05, centery=.66)

    def isFullyShown(self):
        """ Returns if the current message string is fully shown """
        return self.charsShown >= self.message.length()

    def showFully(self):
        """ Make the message display fully """
        self.charsShown = self.message.length()
Exemple #7
0
class MessageBox(SizedWidget):
    """ Represents a message box on the screen """
    maxChars = 35
    
    def __init__(self, width, height, message, fullyDisplay=False):
        """ Builds the Message Box with the given message box """
        SizedWidget.__init__(self, width, height)
        self.message = message
        self.charsShown = 0
        self.font = pygame.font.SysFont("Times New Roman", 36)
        self.stringToDisplay = ""
        
        self.background = MenuBackgroundWidget(self.width, self.height)
        
        if fullyDisplay:
            self.showFully()
    
    def update(self):
        """ Updates the message box """
        if not self.isFullyShown():
            self.charsShown += 1
            
        self.stringToDisplay = self.message.getMessageSlice(self.charsShown)
        
    def drawSurface(self):
        """ Draws the message box """
        self.drawOnSurface(self.background.draw(), left=0, top=0)
        
        line1 = self.font.render(self.stringToDisplay[:self.maxChars], 1, (10, 10, 10)) # Logic to split string to display may belong better in model
        line2 = self.font.render(self.stringToDisplay[self.maxChars:], 1, (10, 10, 10))
        
        self.drawOnSurface(line1, left=.05, centery=.33)
        self.drawOnSurface(line2, left=.05, centery=.66)
        
    def isFullyShown(self):
        """ Returns if the current message string is fully shown """
        return self.charsShown >= self.message.length()
        
    def showFully(self):
        """ Make the message display fully """
        self.charsShown = self.message.length()
 def __init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget):
     """ Initialize the widget """
     MenuWidget.__init__(self, menu, width, height, MenuEntryWidget=MenuEntryWidget)
     self.background = MenuBackgroundWidget(width, height)