pub fn draw(&self, renderer: &mut Renderer) {
        let mut y = self.inner_rect.y;
        let msg_padding = self.font.char_width() / 2;

        // Draw the text that the player is currently typing
        let encoded_buffer: Vec<_> = text::Encoder::new(&self.message_buffer).collect();
        y += draw_text(renderer, &self.font, &encoded_buffer, &self.inner_rect);
        y += self.font.line_height();

        // Draw the rest of the chat messages
        for message in self.messages.iter().rev() {
            y += draw_text(renderer, &self.font, &message.user_name,
                &Rect::new(self.inner_rect.x, y, self.inner_rect.width, self.inner_rect.height));

            y += draw_text(renderer, &self.font, &message.data,
                &Rect::new(self.inner_rect.x + msg_padding, y,
                self.inner_rect.width - msg_padding, self.inner_rect.height));

            y += self.font.line_height();
        }

        // Draw the chat border
        self.border.draw_box(renderer, self.outer_rect);
    }
/// Draws the chat box to the screen.
/// TODO: Cache the render result
Draws the chat box to the screen.
TODO: Cache the render result
Draws the chat box to the screen . TODO : Cache the render result
pub fn draw(&self, renderer: &mut Renderer) {
        let mut y = self.inner_rect.y;
        let msg_padding = self.font.char_width() / 2;
        // Draw the text that the player is currently typing
        let encoded_buffer: Vec<_> = text::Encoder::new(&self.message_buffer).collect();
        y += draw_text(renderer, &self.font, &encoded_buffer, &self.inner_rect);
        y += self.font.line_height();
        // Draw the rest of the chat messages
        for message in self.messages.iter().rev() {
            y += draw_text(renderer, &self.font, &message.user_name,
                &Rect::new(self.inner_rect.x, y, self.inner_rect.width, self.inner_rect.height));
            y += draw_text(renderer, &self.font, &message.data,
                &Rect::new(self.inner_rect.x + msg_padding, y,
                self.inner_rect.width - msg_padding, self.inner_rect.height));
            y += self.font.line_height();
        }
        // Draw the chat border
        self.border.draw_box(renderer, self.outer_rect);
    }
pub fn draw ( & self , renderer : & mut Renderer ) { let mut y = self . inner_rect . y ; let msg_padding = self . font . char_width ( ) / 2 ; // Draw the text that the player is currently typing let encoded_buffer : Vec < _ > = text :: Encoder :: new ( & self . message_buffer ) . collect ( ) ; y += draw_text ( renderer , & self . font , & encoded_buffer , & self . inner_rect ) ; y += self . font . line_height ( ) ; // Draw the rest of the chat messages for message in self . messages . iter ( ) . rev ( ) { y += draw_text ( renderer , & self . font , & message . user_name , & Rect :: new ( self . inner_rect . x , y , self . inner_rect . width , self . inner_rect . height ) ) ; y += draw_text ( renderer , & self . font , & message . data , & Rect :: new ( self . inner_rect . x + msg_padding , y , self . inner_rect . width - msg_padding , self . inner_rect . height ) ) ; y += self . font . line_height ( ) ; } // Draw the chat border self . border . draw_box ( renderer , self . outer_rect ) ; }
Draws the chat box to the screen.
Draws the chat box to the screen .
&self
renderer
&mut Renderer
&self
renderer
&mut Renderer