(svn r6908) - Codechange: Modify DrawStringMultiLine() to return the number of pixel lines used, and use it for drawing NewGRF additional text (mart3p)
This commit is contained in:
		
							
								
								
									
										7
									
								
								gfx.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								gfx.c
									
									
									
									
									
								
							@@ -500,11 +500,13 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DrawStringMultiLine(int x, int y, StringID str, int maxw)
 | 
					
 | 
				
			||||||
 | 
					uint DrawStringMultiLine(int x, int y, StringID str, int maxw)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char buffer[512];
 | 
						char buffer[512];
 | 
				
			||||||
	uint32 tmp;
 | 
						uint32 tmp;
 | 
				
			||||||
	int num, mt;
 | 
						int num, mt;
 | 
				
			||||||
 | 
						uint total_height;
 | 
				
			||||||
	const char *src;
 | 
						const char *src;
 | 
				
			||||||
	byte c;
 | 
						byte c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -514,6 +516,7 @@ void DrawStringMultiLine(int x, int y, StringID str, int maxw)
 | 
				
			|||||||
	num = GB(tmp, 0, 16);
 | 
						num = GB(tmp, 0, 16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mt = GetCharacterHeight(GB(tmp, 16, 16));
 | 
						mt = GetCharacterHeight(GB(tmp, 16, 16));
 | 
				
			||||||
 | 
						total_height = (num + 1) * mt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	src = buffer;
 | 
						src = buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -527,7 +530,7 @@ void DrawStringMultiLine(int x, int y, StringID str, int maxw)
 | 
				
			|||||||
				y += mt;
 | 
									y += mt;
 | 
				
			||||||
				if (--num < 0) {
 | 
									if (--num < 0) {
 | 
				
			||||||
					_cur_fontsize = FS_NORMAL;
 | 
										_cur_fontsize = FS_NORMAL;
 | 
				
			||||||
					return;
 | 
										return total_height;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			} else if (c == ASCII_SETX) {
 | 
								} else if (c == ASCII_SETX) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								gfx.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gfx.h
									
									
									
									
									
								
							@@ -70,7 +70,7 @@ void GfxDrawLine(int left, int top, int right, int bottom, int color);
 | 
				
			|||||||
BoundingRect GetStringBoundingBox(const char *str);
 | 
					BoundingRect GetStringBoundingBox(const char *str);
 | 
				
			||||||
void LoadStringWidthTable(void);
 | 
					void LoadStringWidthTable(void);
 | 
				
			||||||
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
 | 
					void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
 | 
				
			||||||
void DrawStringMultiLine(int x, int y, StringID str, int maxw);
 | 
					uint DrawStringMultiLine(int x, int y, StringID str, int maxw);
 | 
				
			||||||
void DrawDirtyBlocks(void);
 | 
					void DrawDirtyBlocks(void);
 | 
				
			||||||
void SetDirtyBlocks(int left, int top, int right, int bottom);
 | 
					void SetDirtyBlocks(int left, int top, int right, int bottom);
 | 
				
			||||||
void MarkWholeScreenDirty(void);
 | 
					void MarkWholeScreenDirty(void);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -482,13 +482,14 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Display additional text from NewGRF in the purchase information window */
 | 
					/* Display additional text from NewGRF in the purchase information window */
 | 
				
			||||||
int ShowAdditionalText(int x, int y, int w, EngineID engine)
 | 
					uint ShowAdditionalText(int x, int y, int w, EngineID engine)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL);
 | 
						uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL);
 | 
				
			||||||
	if (callback == CALLBACK_FAILED) return 0;
 | 
						if (callback == CALLBACK_FAILED) return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DrawStringTruncated(x, y, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback), 16, w);
 | 
						// STR_02BD is used to start the string with {BLACK}
 | 
				
			||||||
	return 10;
 | 
						SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback));
 | 
				
			||||||
 | 
						return DrawStringMultiLine(x, y, STR_02BD, w);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,7 +50,7 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
 | 
					void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ShowAdditionalText(int x, int y, int w, EngineID engine);
 | 
					uint ShowAdditionalText(int x, int y, int w, EngineID engine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type);
 | 
					void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type);
 | 
				
			||||||
void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type);
 | 
					void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user