Doc strings in Messages module
This commit is contained in:
		
							parent
							
								
									8239b22157
								
							
						
					
					
						commit
						ccd2e04d0e
					
				
					 1 changed files with 15 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -8,6 +8,18 @@ import tcod
 | 
			
		|||
from .geometry import Rect
 | 
			
		||||
 | 
			
		||||
class Message:
 | 
			
		||||
    '''A message in the message log
 | 
			
		||||
 | 
			
		||||
    Attributes
 | 
			
		||||
    ----------
 | 
			
		||||
    text : str
 | 
			
		||||
        The text of the message
 | 
			
		||||
    foreground : Tuple[int, int, int]
 | 
			
		||||
        The foreground color to render the message with
 | 
			
		||||
    count : int
 | 
			
		||||
        The number of times this message has stacked
 | 
			
		||||
    '''
 | 
			
		||||
 | 
			
		||||
    def __init__(self, text: str, fg: Optional[Tuple[int, int, int]] = None):
 | 
			
		||||
        self.text = text
 | 
			
		||||
        self.foreground = fg
 | 
			
		||||
| 
						 | 
				
			
			@ -53,10 +65,12 @@ class MessageLog:
 | 
			
		|||
            self.messages.append(Message(text, fg))
 | 
			
		||||
 | 
			
		||||
    def render_to_console(self, console: tcod.console.Console, rect: Rect):
 | 
			
		||||
        '''Render this message log to the given console in the given rect'''
 | 
			
		||||
        self.render_messages(console, rect, self.messages)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def render_messages(console: tcod.console.Console, rect: Rect, messages: Reversible[Message]):
 | 
			
		||||
        '''Render a list of messages to the console in the given rect'''
 | 
			
		||||
        y_offset = min(rect.size.height, len(messages))
 | 
			
		||||
 | 
			
		||||
        for message in reversed(messages):
 | 
			
		||||
| 
						 | 
				
			
			@ -69,4 +83,4 @@ class MessageLog:
 | 
			
		|||
                    break
 | 
			
		||||
 | 
			
		||||
            if y_offset < 0:
 | 
			
		||||
                break
 | 
			
		||||
                break
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue