Changeset - r17775:953f66d4b3d1
[Not reviewed]
master
0 3 0
terkhen - 13 years ago 2011-06-12 20:51:38
terkhen@openttd.org
(svn r22570) -Codechange: Store the GrfID of the caller when opening a parent window in the NewGRF debug GUI.
3 files changed with 38 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/newgrf_debug.h
Show inline comments
 
@@ -35,7 +35,7 @@ struct NewGrfDebugSpritePicker {
 
extern NewGrfDebugSpritePicker _newgrf_debug_sprite_picker;
 

	
 
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index);
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index);
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid = 0);
 
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index);
 

	
 
GrfSpecFeature GetGrfSpecFeature(TileIndex tile);
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -141,6 +141,13 @@ public:
 
	virtual void SetStringParameters(uint index) const = 0;
 

	
 
	/**
 
	 * Get the GRFID of the file that includes this item.
 
	 * @param index index to check.
 
	 * @return GRFID of the item. 0 means that the item is not inspectable.
 
	 */
 
	virtual uint32 GetGRFID(uint index) const = 0;
 

	
 
	/**
 
	 * Resolve (action2) variable for a given index.
 
	 * @param index The (instance) index to resolve the variable for.
 
	 * @param var   The variable to actually resolve.
 
@@ -277,6 +284,9 @@ struct NewGRFInspectWindow : Window {
 
	/** The value for the variable 60 parameters. */
 
	static byte var60params[GSF_FAKE_END][0x20];
 

	
 
	/** GRFID of the caller of this window, 0 if it has no caller. */
 
	uint32 caller_grfid;
 

	
 
	/** The currently editted parameter, to update the right one. */
 
	byte current_edit_param;
 

	
 
@@ -292,6 +302,16 @@ struct NewGRFInspectWindow : Window {
 
		return IsInsideBS(variable, 0x60, 0x20);
 
	}
 

	
 
	/**
 
	 * Set the GRFID of the item opening this window.
 
	 * @param grfid GRFID of the item opening this window, or 0 if not opened by other window.
 
	 */
 
	void SetCallerGRFID(uint32 grfid)
 
	{
 
		this->caller_grfid = grfid;
 
		this->SetDirty();
 
	}
 

	
 
	NewGRFInspectWindow(const WindowDesc *desc, WindowNumber wno) : Window()
 
	{
 
		this->CreateNestedTree(desc);
 
@@ -442,8 +462,9 @@ struct NewGRFInspectWindow : Window {
 
	{
 
		switch (widget) {
 
			case NIW_PARENT: {
 
				uint index = GetFeatureHelper(this->window_number)->GetParent(GetFeatureIndex(this->window_number));
 
				::ShowNewGRFInspectWindow((GrfSpecFeature)GB(index, 24, 8), GetFeatureIndex(index));
 
				const NIHelper *nih   = GetFeatureHelper(this->window_number);
 
				uint index = nih->GetParent(GetFeatureIndex(this->window_number));
 
				::ShowNewGRFInspectWindow((GrfSpecFeature)GB(index, 24, 8), GetFeatureIndex(index), nih->GetGRFID(GetFeatureIndex(this->window_number)));
 
				break;
 
			}
 

	
 
@@ -516,13 +537,16 @@ static const WindowDesc _newgrf_inspect_
 
 * we want to inspect.
 
 * @param feature The feature we want to inspect.
 
 * @param index   The index/identifier of the feature to inspect.
 
 * @param grfid   GRFID of the item opening this window, or 0 if not opened by other window.
 
 */
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index)
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid)
 
{
 
	if (!IsNewGRFInspectable(feature, index)) return;
 

	
 
	WindowNumber wno = GetInspectWindowNumber(feature, index);
 
	AllocateWindowDescFront<NewGRFInspectWindow>(&_newgrf_inspect_desc, wno);
 
	NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(&_newgrf_inspect_desc, wno);
 
	if (w == NULL) w = (NewGRFInspectWindow *)FindWindowById(WC_NEWGRF_INSPECT, wno);
 
	w->SetCallerGRFID(grfid);
 
}
 

	
 
/**
src/table/newgrf_debug_data.h
Show inline comments
 
@@ -66,6 +66,7 @@ class NIHVehicle : public NIHelper {
 
	const void *GetInstance(uint index)const             { return Vehicle::Get(index); }
 
	const void *GetSpec(uint index) const                { return Engine::Get(Vehicle::Get(index)->engine_type); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? Engine::Get(Vehicle::Get(index)->engine_type)->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetVehicleResolver(ResolverObject *ro, uint index); GetVehicleResolver(ro, index); }
 
};
 

	
 
@@ -122,6 +123,7 @@ class NIHStation : public NIHelper {
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetStationSpec(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetStationResolver(ResolverObject *ro, uint index); GetStationResolver(ro, index); }
 
};
 

	
 
@@ -181,6 +183,7 @@ class NIHHouse : public NIHelper {
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return HouseSpec::Get(GetHouseType(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetHouseResolver(ResolverObject *ro, uint index); GetHouseResolver(ro, index); }
 
};
 

	
 
@@ -225,6 +228,7 @@ class NIHIndustryTile : public NIHelper 
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetIndustryTileSpec(GetIndustryGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetIndustryTileResolver(ResolverObject *ro, uint index); GetIndustryTileResolver(ro, index); }
 
};
 

	
 
@@ -290,6 +294,7 @@ class NIHIndustry : public NIHelper {
 
	const void *GetInstance(uint index)const             { return Industry::Get(index); }
 
	const void *GetSpec(uint index) const                { return GetIndustrySpec(Industry::Get(index)->type); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetIndustryResolver(ResolverObject *ro, uint index); GetIndustryResolver(ro, index); }
 
	uint GetPSASize(uint index, uint32 grfid) const      { return cpp_lengthof(PersistentStorage, storage); }
 

	
 
@@ -347,6 +352,7 @@ class NIHObject : public NIHelper {
 
	const void *GetInstance(uint index)const             { return Object::GetByTile(index); }
 
	const void *GetSpec(uint index) const                { return ObjectSpec::GetByTile(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetObjectResolver(ResolverObject *ro, uint index); GetObjectResolver(ro, index); }
 
};
 

	
 
@@ -373,6 +379,7 @@ class NIHRailType : public NIHelper {
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetRailTypeResolver(ResolverObject *ro, uint index); GetRailTypeResolver(ro, index); }
 
};
 

	
 
@@ -401,6 +408,7 @@ class NIHAirportTile : public NIHelper {
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return AirportTileSpec::Get(GetAirportGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; }
 
	void Resolve(ResolverObject *ro, uint32 index) const { extern void GetAirportTileTypeResolver(ResolverObject *ro, uint index); GetAirportTileTypeResolver(ro, index); }
 
};
 

	
 
@@ -433,6 +441,7 @@ class NIHTown : public NIHelper {
 
	const void *GetInstance(uint index)const             { return Town::Get(index); }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const { return TownGetVariable(var, param, avail, Town::Get(index), NULL); }
 
};
 

	
0 comments (0 inline, 0 general)