Changeset - r17378:417d56e77854
[Not reviewed]
master
0 2 0
frosch - 14 years ago 2011-02-23 20:45:52
frosch@openttd.org
(svn r22134) -Codechange: Move ReInit() of the landinfo window from DeleteNewGRFInspectWindow() into a InvalidateData call.
2 files changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -309,48 +309,58 @@ public:
 
				found = true;
 

	
 
				/* If the accepted value is less than 8, show it in 1/8:ths */
 
				if (acceptance[i] < 8) {
 
					SetDParam(0, acceptance[i]);
 
					SetDParam(1, CargoSpec::Get(i)->name);
 
					strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				} else {
 
					strp = GetString(strp, CargoSpec::Get(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				}
 
			}
 
		}
 
		if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
 
	}
 

	
 
	virtual bool IsNewGRFInspectable() const
 
	{
 
		return ::IsNewGRFInspectable(GetGrfSpecFeature(this->tile), this->tile);
 
	}
 

	
 
	virtual void ShowNewGRFInspectWindow() const
 
	{
 
		::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		switch (data) {
 
			case 1:
 
				/* ReInit, "debug" sprite might have changed */
 
				this->ReInit();
 
				break;
 
		}
 
	}
 
};
 

	
 
/**
 
 * Show land information window.
 
 * @param tile The tile to show information about.
 
 */
 
void ShowLandInfo(TileIndex tile)
 
{
 
	DeleteWindowById(WC_LAND_INFO, 0);
 
	new LandInfoWindow(tile);
 
}
 

	
 
/** Widgets for the land info window. */
 
enum AboutWidgets {
 
	AW_SCROLLING_TEXT,       ///< The actually scrolling text
 
	AW_WEBSITE,              ///< URL of OpenTTD website
 
};
 

	
 
static const NWidgetPart _nested_about_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_ABOUT_OPENTTD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY), SetPIP(4, 2, 4),
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -498,50 +498,49 @@ static const WindowDesc _newgrf_inspect_
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index)
 
{
 
	if (!IsNewGRFInspectable(feature, index)) return;
 

	
 
	WindowNumber wno = GetInspectWindowNumber(feature, index);
 
	AllocateWindowDescFront<NewGRFInspectWindow>(&_newgrf_inspect_desc, wno);
 
}
 

	
 
/**
 
 * Delete inspect window for a given feature and index.
 
 * The index is normally an in-game location/identifier, such
 
 * as a TileIndex or an IndustryID depending on the feature
 
 * we want to inspect.
 
 * @param feature The feature we want to delete the window for.
 
 * @param index   The index/identifier of the feature to delete.
 
 */
 
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
 
{
 
	if (feature == GSF_INVALID) return;
 

	
 
	WindowNumber wno = GetInspectWindowNumber(feature, index);
 
	DeleteWindowById(WC_NEWGRF_INSPECT, wno);
 

	
 
	/* Reinitialise the land information window to remove the "debug" sprite if needed. */
 
	Window *w = FindWindowById(WC_LAND_INFO, 0);
 
	if (w != NULL) w->ReInit();
 
	InvalidateWindowData(WC_LAND_INFO, 0, 1);
 
}
 

	
 
/**
 
 * Can we inspect the data given a certain feature and index.
 
 * The index is normally an in-game location/identifier, such
 
 * as a TileIndex or an IndustryID depending on the feature
 
 * we want to inspect.
 
 * @param feature The feature we want to inspect.
 
 * @param index   The index/identifier of the feature to inspect.
 
 * @return true if there is something to show.
 
 */
 
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
 
{
 
	const NIFeature *nif = GetFeature(GetInspectWindowNumber(feature, index));
 
	if (nif == NULL) return false;
 
	return nif->helper->IsInspectable(index);
 
}
 

	
 
/**
 
 * Get the GrfSpecFeature associated with the tile.
 
 * @param tile The tile to get the feature from.
 
 * @return the GrfSpecFeature.
 
 */
 
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
0 comments (0 inline, 0 general)