Changeset - r3650:52328e33959e
[Not reviewed]
master
0 3 0
peter1138 - 18 years ago 2006-04-23 22:33:10
peter1138@openttd.org
(svn r4561) - NewGRF: implement most of callback 0x23: additional text in vehicle purchase windows.
3 files changed with 17 insertions and 0 deletions:
0 comments (0 inline, 0 general)
newgrf_callbacks.h
Show inline comments
 
@@ -21,12 +21,16 @@ enum CallbackID {
 

	
 
	// Refit capacity, the passed vehicle needs to have its ->cargo_type set to
 
	// the cargo we are refitting to, returns the new cargo capacity
 
	CBID_VEHICLE_REFIT_CAPACITY     = 0x15,
 

	
 
	CBID_TRAIN_ARTIC_ENGINE         = 0x16,
 

	
 
	/* This callback is called from vehicle purchase lists. It returns a value to be
 
	 * used as a custom string ID in the 0xD000 range. */
 
	CBID_VEHICLE_ADDITIONAL_TEXT    = 0x23,
 
};
 

	
 
/**
 
 * Callback masks for vehicles, indicates which callbacks are used by a vehicle.
 
 * Some callbacks are always used and don't have a mask.
 
 */
vehicle_gui.c
Show inline comments
 
@@ -16,13 +16,15 @@
 
#include "command.h"
 
#include "gfx.h"
 
#include "variables.h"
 
#include "vehicle_gui.h"
 
#include "viewport.h"
 
#include "train.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_engine.h"
 
#include "newgrf_text.h"
 

	
 
Sorting _sorting;
 

	
 
static uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names
 
static uint32 _last_vehicle_idx;        // cached index to hopefully speed up name-sorting
 
static bool   _internal_sort_order;     // descending/ascending
 
@@ -253,12 +255,22 @@ CargoID DrawVehicleRefitWindow(const Veh
 
		}
 
	}
 

	
 
	return cargo;
 
}
 

	
 
/* Display additional text from NewGRF in the purchase information window */
 
int ShowAdditionalText(int x, int y, int w, EngineID engine)
 
{
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL);
 
	if (callback == CALLBACK_FAILED) return 0;
 

	
 
	DrawStringTruncated(x, y, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback), 16, w);
 
	return 10;
 
}
 

	
 
/************ Sorter functions *****************/
 
int CDECL GeneralOwnerSorter(const void *a, const void *b)
 
{
 
	return (*(const SortStruct*)a).owner - (*(const SortStruct*)b).owner;
 
}
 

	
vehicle_gui.h
Show inline comments
 
@@ -59,9 +59,10 @@ void DrawTrainWagonPurchaseInfo(int x, i
 
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number);
 
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number);
 
void DrawShipPurchaseInfo(int x, int y, EngineID engine_number);
 

	
 
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
 

	
 
int ShowAdditionalText(int x, int y, int w, EngineID engine_number);
 

	
 

	
 
#endif /* VEHICLE_GUI_H */
0 comments (0 inline, 0 general)