175 } |
175 } |
176 |
176 |
177 // Draw the textmessage-box |
177 // Draw the textmessage-box |
178 void DrawTextMessage(void) |
178 void DrawTextMessage(void) |
179 { |
179 { |
180 int i, j; |
180 uint y, count; |
181 bool has_message; |
|
182 |
181 |
183 if (!_textmessage_dirty) return; |
182 if (!_textmessage_dirty) return; |
184 |
183 |
185 // First undraw if needed |
184 // First undraw if needed |
186 UndrawTextMessage(); |
185 UndrawTextMessage(); |
187 |
186 |
188 if (_iconsole_mode == ICONSOLE_FULL) return; |
187 if (_iconsole_mode == ICONSOLE_FULL) return; |
189 |
188 |
190 /* Check if we have anything to draw at all */ |
189 /* Check if we have anything to draw at all */ |
191 has_message = false; |
190 count = GetTextMessageCount(); |
192 for ( i = 0; i < MAX_CHAT_MESSAGES; i++) { |
191 if (count == 0) return; |
193 if (_textmsg_list[i].message[0] == '\0') break; |
|
194 |
|
195 has_message = true; |
|
196 } |
|
197 if (!has_message) return; |
|
198 |
192 |
199 // Make a copy of the screen as it is before painting (for undraw) |
193 // Make a copy of the screen as it is before painting (for undraw) |
200 memcpy_pitch( |
194 memcpy_pitch( |
201 _textmessage_backup, |
195 _textmessage_backup, |
202 _screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch, |
196 _screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch, |
203 _textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width); |
197 _textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width); |
204 |
198 |
205 // Switch to _screen painting |
199 _cur_dpi = &_screen; // switch to _screen painting |
206 _cur_dpi = &_screen; |
200 |
207 |
201 /* Paint a half-transparent box behind the text messages */ |
208 j = 0; |
202 GfxFillRect( |
209 // Paint the messages |
203 _textmsg_box.x, |
210 for (i = MAX_CHAT_MESSAGES - 1; i >= 0; i--) { |
204 _screen.height - _textmsg_box.y - count * 13 - 2, |
211 if (_textmsg_list[i].message[0] == '\0') continue; |
205 _textmsg_box.x + _textmsg_box.width - 1, |
212 |
206 _screen.height - _textmsg_box.y - 2, |
213 j++; |
207 0x322 | USE_COLORTABLE // black, but with some alpha for background |
214 GfxFillRect(_textmsg_box.x, _screen.height-_textmsg_box.y-j*13-2, _textmsg_box.x+_textmsg_box.width - 1, _screen.height-_textmsg_box.y-j*13+10, /* black, but with some alpha */ 0x322 | USE_COLORTABLE); |
208 ); |
215 |
209 |
216 DoDrawString(_textmsg_list[i].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - j * 13, _textmsg_list[i].color); |
210 /* Paint the messages starting with the lowest at the bottom */ |
217 } |
211 for (y = 13; count-- != 0; y += 13) { |
|
212 DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color); |
|
213 } |
218 |
214 |
219 // Make sure the data is updated next flush |
215 // Make sure the data is updated next flush |
220 _video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height); |
216 _video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height); |
221 |
217 |
222 _textmessage_visible = true; |
218 _textmessage_visible = true; |