(svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
authorsmatz
Fri, 25 Jul 2008 22:37:34 +0000
changeset 9714 5d785e184f2d
parent 9713 a1a2cbdb1090
child 9715 b3dbb8b51870
(svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
src/industry_cmd.cpp
src/lang/english.txt
src/misc_gui.cpp
src/newgrf_station.cpp
src/newgrf_station.h
src/station_cmd.cpp
src/tile_cmd.h
src/town_cmd.cpp
--- a/src/industry_cmd.cpp	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/industry_cmd.cpp	Fri Jul 25 22:37:34 2008 +0000
@@ -389,13 +389,18 @@
 static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
 {
 	const Industry *i = GetIndustryByTile(tile);
+	const IndustrySpec *is = GetIndustrySpec(i->type);
 
 	td->owner[0] = i->owner;
-	td->str = GetIndustrySpec(i->type)->name;
+	td->str = is->name;
 	if (!IsIndustryCompleted(tile)) {
 		SetDParamX(td->dparam, 0, td->str);
 		td->str = STR_2058_UNDER_CONSTRUCTION;
 	}
+
+	if (is->grf_prop.grffile != NULL) {
+		td->grf = GetGRFConfig(is->grf_prop.grffile->grfid)->name;
+	}
 }
 
 static CommandCost ClearTile_Industry(TileIndex tile, byte flags)
--- a/src/lang/english.txt	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/lang/english.txt	Fri Jul 25 22:37:34 2008 +0000
@@ -3126,6 +3126,10 @@
 STR_BRIBE_FAILED_2                                              :{WHITE}discovered by a regional investigator
 STR_BUILD_DATE                                                  :{BLACK}Built: {LTBLUE}{DATE_LONG}
 
+STR_TILEDESC_STATION_CLASS                                      :{BLACK}Station class: {LTBLUE}{STRING}
+STR_TILEDESC_STATION_TYPE                                       :{BLACK}Station type: {LTBLUE}{STRING}
+STR_TILEDESC_NEWGRF_NAME                                        :{BLACK}NewGRF: {LTBLUE}{RAW_STRING}
+
 STR_PERFORMANCE_DETAIL                                          :{WHITE}Detailed performance rating
 STR_PERFORMANCE_DETAIL_KEY                                      :{BLACK}Detail
 STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY                          :{BLACK}({CURRCOMPACT}/{CURRCOMPACT})
--- a/src/misc_gui.cpp	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/misc_gui.cpp	Fri Jul 25 22:37:34 2008 +0000
@@ -73,7 +73,7 @@
 
 class LandInfoWindow : public Window {
 	enum {
-		LAND_INFO_CENTERED_LINES   = 9,                        ///< Up to 9 centered lines
+		LAND_INFO_CENTERED_LINES   = 12,                       ///< Up to 12 centered lines
 		LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
 		LAND_INFO_LINE_END,
 
@@ -131,6 +131,11 @@
 		td.owner[2] = OWNER_NONE;
 		td.owner[3] = OWNER_NONE;
 
+		td.station_class = STR_NULL;
+		td.station_name = STR_NULL;
+
+		td.grf = NULL;
+
 		GetAcceptedCargo(tile, ac);
 		GetTileDesc(tile, &td);
 
@@ -186,6 +191,29 @@
 			line_nr++;
 		}
 
+		/* Station class */
+		if (td.station_class != STR_NULL) {
+			SetDParam(0, td.station_class);
+			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_CLASS, lastof(this->landinfo_data[line_nr]));
+			line_nr++;
+		}
+
+		/* Station type name */
+		if (td.station_name != STR_NULL) {
+			SetDParam(0, td.station_name);
+			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_TYPE, lastof(this->landinfo_data[line_nr]));
+			line_nr++;
+		}
+
+		/* NewGRF name */
+		if (td.grf != NULL) {
+			SetDParamStr(0, td.grf);
+			GetString(this->landinfo_data[line_nr], STR_TILEDESC_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';
 
--- a/src/newgrf_station.cpp	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/newgrf_station.cpp	Fri Jul 25 22:37:34 2008 +0000
@@ -835,7 +835,7 @@
 }
 
 
-static const StationSpec* GetStationSpec(TileIndex t)
+const StationSpec *GetStationSpec(TileIndex t)
 {
 	const Station* st;
 	uint specindex;
--- a/src/newgrf_station.h	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/newgrf_station.h	Fri Jul 25 22:37:34 2008 +0000
@@ -110,6 +110,7 @@
 StationClassID AllocateStationClass(uint32 cls);
 void SetStationClassName(StationClassID sclass, StringID name);
 StringID GetStationClassName(StationClassID sclass);
+const StationSpec *GetStationSpec(TileIndex t);
 
 uint GetNumStationClasses();
 uint GetNumCustomStations(StationClassID sclass);
--- a/src/station_cmd.cpp	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/station_cmd.cpp	Fri Jul 25 22:37:34 2008 +0000
@@ -43,6 +43,7 @@
 #include "oldpool_func.h"
 #include "animated_tile_func.h"
 #include "elrail_func.h"
+#include "newgrf.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -2312,6 +2313,18 @@
 	}
 	td->build_date = GetStationByTile(tile)->build_date;
 
+	const StationSpec *spec = GetStationSpec(tile);
+
+	if (spec != NULL) {
+		td->station_class = GetStationClassName(spec->sclass);
+		td->station_name = spec->name;
+
+		if (spec->grffile != NULL) {
+			const GRFConfig *gc = GetGRFConfig(spec->grffile->grfid);
+			td->grf = gc->name;
+		}
+	}
+
 	StringID str;
 	switch (GetStationType(tile)) {
 		default: NOT_REACHED();
--- a/src/tile_cmd.h	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/tile_cmd.h	Fri Jul 25 22:37:34 2008 +0000
@@ -52,6 +52,9 @@
 	Owner owner[4];
 	StringID owner_type[4];
 	Date build_date;
+	StringID station_class;
+	StringID station_name;
+	const char *grf;
 	uint64 dparam[2];
 };
 
--- a/src/town_cmd.cpp	Fri Jul 25 19:50:40 2008 +0000
+++ b/src/town_cmd.cpp	Fri Jul 25 22:37:34 2008 +0000
@@ -616,12 +616,19 @@
 
 static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
 {
-	td->str = GetHouseSpecs(GetHouseType(tile))->building_name;
+	const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
+
+	td->str = hs->building_name;
 	if (!IsHouseCompleted(tile)) {
 		SetDParamX(td->dparam, 0, td->str);
 		td->str = STR_2058_UNDER_CONSTRUCTION;
 	}
 
+	if (hs->grffile != NULL) {
+		const GRFConfig *gc = GetGRFConfig(hs->grffile->grfid);
+		td->grf = gc->name;
+	}
+
 	td->owner[0] = OWNER_TOWN;
 }