src/texteff.cpp
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6700 0cee66ecb04a
child 6720 35756db7e577
equal deleted inserted replaced
6718:5a8b295aa345 6719:4cc327ad39d5
     1 /* $Id$ */
     1 /* $Id$ */
       
     2 
       
     3 /** @file texteff.cpp */
     2 
     4 
     3 #include "stdafx.h"
     5 #include "stdafx.h"
     4 #include "openttd.h"
     6 #include "openttd.h"
     5 #include "functions.h"
     7 #include "functions.h"
     6 #include "macros.h"
     8 #include "macros.h"
     7 #include "strings.h"
     9 #include "strings.h"
     8 #include "gfx.h"
    10 #include "gfx.h"
       
    11 #include "landscape.h"
     9 #include "viewport.h"
    12 #include "viewport.h"
    10 #include "saveload.h"
    13 #include "saveload.h"
    11 #include "hal.h"
    14 #include "hal.h"
    12 #include "console.h"
    15 #include "console.h"
    13 #include "string.h"
    16 #include "string.h"
   119 	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
   122 	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
   120 		_textmsg_list[i].message[0] = '\0';
   123 		_textmsg_list[i].message[0] = '\0';
   121 	}
   124 	}
   122 }
   125 }
   123 
   126 
   124 /* Hide the textbox */
   127 /** Hide the textbox */
   125 void UndrawTextMessage()
   128 void UndrawTextMessage()
   126 {
   129 {
   127 	if (_textmessage_visible) {
   130 	if (_textmessage_visible) {
   128 		/* Sometimes we also need to hide the cursor
   131 		/* Sometimes we also need to hide the cursor
   129 		 *   This is because both textmessage and the cursor take a shot of the
   132 		 *   This is because both textmessage and the cursor take a shot of the
   170 
   173 
   171 		_textmessage_dirty = true;
   174 		_textmessage_dirty = true;
   172 	}
   175 	}
   173 }
   176 }
   174 
   177 
   175 /* Check if a message is expired every day */
   178 /** Check if a message is expired every day */
   176 void TextMessageDailyLoop()
   179 void TextMessageDailyLoop()
   177 {
   180 {
   178 	uint i;
   181 	uint i;
   179 
   182 
   180 	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
   183 	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
   194 			i--;
   197 			i--;
   195 		}
   198 		}
   196 	}
   199 	}
   197 }
   200 }
   198 
   201 
   199 /* Draw the textmessage-box */
   202 /** Draw the textmessage-box */
   200 void DrawTextMessage()
   203 void DrawTextMessage()
   201 {
   204 {
   202 	if (!_textmessage_dirty) return;
   205 	if (!_textmessage_dirty) return;
   203 
   206 
   204 	/* First undraw if needed */
   207 	/* First undraw if needed */
   241 		);
   244 		);
   242 
   245 
   243 	/* Paint the messages starting with the lowest at the bottom */
   246 	/* Paint the messages starting with the lowest at the bottom */
   244 	for (uint y = 13; count-- != 0; y += 13) {
   247 	for (uint y = 13; count-- != 0; y += 13) {
   245 		DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
   248 		DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
   246  	}
   249 	}
   247 
   250 
   248 	/* Make sure the data is updated next flush */
   251 	/* Make sure the data is updated next flush */
   249 	_video_driver->make_dirty(x, y, width, height);
   252 	_video_driver->make_dirty(x, y, width, height);
   250 
   253 
   251 	_textmessage_visible = true;
   254 	_textmessage_visible = true;
   322 void DrawTextEffects(DrawPixelInfo *dpi)
   325 void DrawTextEffects(DrawPixelInfo *dpi)
   323 {
   326 {
   324 	const TextEffect* te;
   327 	const TextEffect* te;
   325 
   328 
   326 	switch (dpi->zoom) {
   329 	switch (dpi->zoom) {
   327 		case 0:
   330 		case ZOOM_LVL_NORMAL:
   328 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
   331 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
   329 				if (te->string_id != INVALID_STRING_ID &&
   332 				if (te->string_id != INVALID_STRING_ID &&
   330 						dpi->left <= te->right &&
   333 						dpi->left <= te->right &&
   331 						dpi->top  <= te->bottom &&
   334 						dpi->top  <= te->bottom &&
   332 						dpi->left + dpi->width  > te->x &&
   335 						dpi->left + dpi->width  > te->x &&
   334 					AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
   337 					AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
   335 				}
   338 				}
   336 			}
   339 			}
   337 			break;
   340 			break;
   338 
   341 
   339 		case 1:
   342 		case ZOOM_LVL_OUT_2X:
   340 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
   343 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
   341 				if (te->string_id != INVALID_STRING_ID &&
   344 				if (te->string_id != INVALID_STRING_ID &&
   342 						dpi->left <= te->right  * 2 - te->x &&
   345 						dpi->left <= te->right  * 2 - te->x &&
   343 						dpi->top  <= te->bottom * 2 - te->y &&
   346 						dpi->top  <= te->bottom * 2 - te->y &&
   344 						dpi->left + dpi->width  > te->x &&
   347 						dpi->left + dpi->width  > te->x &&
   345 						dpi->top  + dpi->height > te->y) {
   348 						dpi->top  + dpi->height > te->y) {
   346 					AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2);
   349 					AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2);
   347 				}
   350 				}
   348 			}
   351 			}
   349 			break;
   352 			break;
       
   353 
       
   354 		case ZOOM_LVL_OUT_4X:
       
   355 		case ZOOM_LVL_OUT_8X:
       
   356 		case ZOOM_LVL_OUT_16X:
       
   357 			break;
       
   358 
       
   359 		default: NOT_REACHED();
   350 	}
   360 	}
   351 }
   361 }
   352 
   362 
   353 void DeleteAnimatedTile(TileIndex tile)
   363 void DeleteAnimatedTile(TileIndex tile)
   354 {
   364 {