src/texteff.cpp
changeset 6692 983dbcb48cac
parent 6574 e1d1a12faaf7
child 6700 0cee66ecb04a
equal deleted inserted replaced
6691:e8c27a509894 6692:983dbcb48cac
   143 				_cursor.draw_pos.y <= _screen.height - _textmsg_box.y) {
   143 				_cursor.draw_pos.y <= _screen.height - _textmsg_box.y) {
   144 				UndrawMouseCursor();
   144 				UndrawMouseCursor();
   145 			}
   145 			}
   146 		}
   146 		}
   147 
   147 
       
   148 		int x      = _textmsg_box.x;
       
   149 		int y      = _screen.height - _textmsg_box.y - _textmsg_box.height;
       
   150 		int width  = _textmsg_box.width;
       
   151 		int height = _textmsg_box.height;
       
   152 		if (y < 0) {
       
   153 			height = max(height + y, min(_textmsg_box.height, _screen.height));
       
   154 			y = 0;
       
   155 		}
       
   156 		if (x + width >= _screen.width) {
       
   157 			width = _screen.width - x;
       
   158 		}
       
   159 
   148 		_textmessage_visible = false;
   160 		_textmessage_visible = false;
   149 		/* Put our 'shot' back to the screen */
   161 		/* Put our 'shot' back to the screen */
   150 		memcpy_pitch(
   162 		memcpy_pitch(
   151 			_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch,
   163 			_screen.dst_ptr + x + y * _screen.pitch,
   152 			_textmessage_backup,
   164 			_textmessage_backup,
   153 			_textmsg_box.width, _textmsg_box.height, _textmsg_box.width, _screen.pitch);
   165 			width, height, _textmsg_box.width, _screen.pitch);
   154 
   166 
   155 		/* And make sure it is updated next time */
   167 		/* And make sure it is updated next time */
   156 		_video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height);
   168 		_video_driver->make_dirty(x, y, width, height);
   157 
   169 
   158 		_textmessage_dirty = true;
   170 		_textmessage_dirty = true;
   159 	}
   171 	}
   160 }
   172 }
   161 
   173 
   184 }
   196 }
   185 
   197 
   186 /* Draw the textmessage-box */
   198 /* Draw the textmessage-box */
   187 void DrawTextMessage()
   199 void DrawTextMessage()
   188 {
   200 {
   189 	uint y, count;
       
   190 
       
   191 	if (!_textmessage_dirty) return;
   201 	if (!_textmessage_dirty) return;
   192 
   202 
   193 	/* First undraw if needed */
   203 	/* First undraw if needed */
   194 	UndrawTextMessage();
   204 	UndrawTextMessage();
   195 
   205 
   196 	if (_iconsole_mode == ICONSOLE_FULL) return;
   206 	if (_iconsole_mode == ICONSOLE_FULL) return;
   197 
   207 
   198 	/* Check if we have anything to draw at all */
   208 	/* Check if we have anything to draw at all */
   199 	count = GetTextMessageCount();
   209 	uint count = GetTextMessageCount();
   200 	if (count == 0) return;
   210 	if (count == 0) return;
   201 
   211 
       
   212 	int x      = _textmsg_box.x;
       
   213 	int y      = _screen.height - _textmsg_box.y - _textmsg_box.height;
       
   214 	int width  = _textmsg_box.width;
       
   215 	int height = _textmsg_box.height;
       
   216 	if (y < 0) {
       
   217 		height = max(height + y, min(_textmsg_box.height, _screen.height));
       
   218 		y = 0;
       
   219 	}
       
   220 	if (x + width >= _screen.width) {
       
   221 		width = _screen.width - x;
       
   222 	}
   202 	/* Make a copy of the screen as it is before painting (for undraw) */
   223 	/* Make a copy of the screen as it is before painting (for undraw) */
   203 	memcpy_pitch(
   224 	memcpy_pitch(
   204 		_textmessage_backup,
   225 		_textmessage_backup,
   205 		_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch,
   226 		_screen.dst_ptr + x + y * _screen.pitch,
   206 		_textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width);
   227 		width, height, _screen.pitch, _textmsg_box.width);
   207 
   228 
   208 	_cur_dpi = &_screen; // switch to _screen painting
   229 	_cur_dpi = &_screen; // switch to _screen painting
   209 
   230 
   210 	/* Paint a half-transparent box behind the text messages */
   231 	/* Paint a half-transparent box behind the text messages */
   211 	GfxFillRect(
   232 	GfxFillRect(
   215 			_screen.height - _textmsg_box.y - 2,
   236 			_screen.height - _textmsg_box.y - 2,
   216 			PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background
   237 			PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background
   217 		);
   238 		);
   218 
   239 
   219 	/* Paint the messages starting with the lowest at the bottom */
   240 	/* Paint the messages starting with the lowest at the bottom */
   220 	for (y = 13; count-- != 0; y += 13) {
   241 	for (uint y = 13; count-- != 0; y += 13) {
   221 		DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
   242 		DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
   222  	}
   243  	}
   223 
   244 
   224 	/* Make sure the data is updated next flush */
   245 	/* Make sure the data is updated next flush */
   225 	_video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height);
   246 	_video_driver->make_dirty(x, y, width, height);
   226 
   247 
   227 	_textmessage_visible = true;
   248 	_textmessage_visible = true;
   228 	_textmessage_dirty = false;
   249 	_textmessage_dirty = false;
   229 }
   250 }
   230 
   251