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
 
@@ -285,96 +285,106 @@ public:
 

	
 
		/* NewGRF name */
 
		if (td.grf != NULL) {
 
			SetDParamStr(0, td.grf);
 
			GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_NEWGRF_NAME, lastof(this->landinfo_data[line_nr]));
 
			line_nr++;
 
		}
 

	
 
		assert(line_nr < LAND_INFO_CENTERED_LINES);
 

	
 
		/* Mark last line empty */
 
		this->landinfo_data[line_nr][0] = '\0';
 

	
 
		/* Cargo acceptance is displayed in a extra multiline */
 
		char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
		bool found = false;
 

	
 
		for (CargoID i = 0; i < NUM_CARGO; ++i) {
 
			if (acceptance[i] > 0) {
 
				/* Add a comma between each item. */
 
				if (found) {
 
					*strp++ = ',';
 
					*strp++ = ' ';
 
				}
 
				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),
 
		NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_ORIGINAL_COPYRIGHT, STR_NULL),
 
		NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_VERSION, STR_NULL),
 
		NWidget(WWT_FRAME, COLOUR_GREY), SetPadding(0, 5, 1, 5),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, AW_SCROLLING_TEXT),
 
		EndContainer(),
 
		NWidget(WWT_LABEL, COLOUR_GREY, AW_WEBSITE), SetDataTip(STR_BLACK_RAW_STRING, STR_NULL),
 
		NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _about_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_GAME_OPTIONS, WC_NONE,
 
	0,
 
	_nested_about_widgets, lengthof(_nested_about_widgets)
 
);
 

	
 
static const char * const _credits[] = {
 
	"Original design by Chris Sawyer",
 
	"Original graphics by Simon Foster",
 
	"",
 
	"The OpenTTD team (in alphabetical order):",
 
	"  Albert Hofkamp (Alberth) - GUI expert",
 
	"  Jean-Fran\xC3\xA7ois Claeys (Belugas) - GUI, newindustries and more",
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -474,98 +474,97 @@ static const NWidgetPart _nested_newgrf_
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PANEL, COLOUR_GREY, NIW_MAINPANEL), SetMinimalSize(300, 0), SetScrollbar(NIW_SCROLLBAR), EndContainer(),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_GREY, NIW_SCROLLBAR),
 
			NWidget(WWT_RESIZEBOX, COLOUR_GREY),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _newgrf_inspect_desc(
 
	WDP_AUTO, 400, 300,
 
	WC_NEWGRF_INSPECT, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_newgrf_inspect_widgets, lengthof(_nested_newgrf_inspect_widgets)
 
);
 

	
 
/**
 
 * Show the 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 inspect.
 
 * @param index   The index/identifier of the feature to 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)
 
{
 
	switch (GetTileType(tile)) {
 
		default:              return GSF_INVALID;
 
		case MP_RAILWAY:      return GSF_RAILTYPES;
 
		case MP_ROAD:         return IsLevelCrossing(tile) ? GSF_RAILTYPES : GSF_INVALID;
 
		case MP_HOUSE:        return GSF_HOUSES;
 
		case MP_INDUSTRY:     return GSF_INDUSTRYTILES;
 
		case MP_OBJECT:       return GSF_OBJECTS;
 

	
 
		case MP_STATION:
 
			switch (GetStationType(tile)) {
 
				case STATION_RAIL:    return GSF_STATIONS;
 
				case STATION_AIRPORT: return GSF_AIRPORTTILES;
 
				default:              return GSF_INVALID;
 
			}
 
	}
 
}
 

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