mirror of https://github.com/OpenTTD/OpenTTD
(svn r4551) - NewGRF: add string handling for newstations.
parent
baebc8d47e
commit
70bd867d71
18
newgrf.c
18
newgrf.c
|
@ -1716,7 +1716,6 @@ static void VehicleNewName(byte *buf, int len)
|
||||||
* (completely new scenarios changing all graphics and logically also
|
* (completely new scenarios changing all graphics and logically also
|
||||||
* factory names etc). We should then also support all languages (by
|
* factory names etc). We should then also support all languages (by
|
||||||
* name), not only the original four ones. --pasky
|
* name), not only the original four ones. --pasky
|
||||||
* TODO: Support for custom station class/type names.
|
|
||||||
* All of the above are coming. In Time. Some sooner than others :)*/
|
* All of the above are coming. In Time. Some sooner than others :)*/
|
||||||
|
|
||||||
uint8 feature;
|
uint8 feature;
|
||||||
|
@ -1760,17 +1759,22 @@ static void VehicleNewName(byte *buf, int len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
case GSF_STATION: {
|
||||||
case GSF_STATION:
|
byte station = GB(id, 0, 8);
|
||||||
|
if (station >= _cur_grffile->num_stations) {
|
||||||
|
grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", station);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (GB(id, 8, 8)) {
|
switch (GB(id, 8, 8)) {
|
||||||
case 0xC4: { /* Station class name */
|
case 0xC4: { /* Station class name */
|
||||||
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)].sclass;
|
StationClassID sclass = _cur_grffile->stations[station].sclass;
|
||||||
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, name));
|
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC5: /* Station name */
|
case 0xC5: /* Station name */
|
||||||
_cur_grffile->stations[GB(id, 0, 8)].name = AddGRFString(_cur_grffile->grfid, id, lang, name);
|
_cur_grffile->stations[station].name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1778,7 +1782,9 @@ static void VehicleNewName(byte *buf, int len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
case GSF_CANAL :
|
case GSF_CANAL :
|
||||||
case GSF_BRIDGE :
|
case GSF_BRIDGE :
|
||||||
case GSF_TOWNHOUSE :
|
case GSF_TOWNHOUSE :
|
||||||
|
|
|
@ -68,6 +68,39 @@ StationClassID AllocateStationClass(uint32 class)
|
||||||
return STAT_CLASS_DFLT;
|
return STAT_CLASS_DFLT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the name of a custom station class */
|
||||||
|
void SetStationClassName(StationClassID sclass, StringID name)
|
||||||
|
{
|
||||||
|
assert(sclass < STAT_CLASS_MAX);
|
||||||
|
station_classes[sclass].name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Retrieve the name of a custom station class */
|
||||||
|
StringID GetStationClassName(StationClassID sclass)
|
||||||
|
{
|
||||||
|
assert(sclass < STAT_CLASS_MAX);
|
||||||
|
return station_classes[sclass].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Build a list of station class name StringIDs to use in a dropdown list
|
||||||
|
* @return Pointer to a (static) array of StringIDs
|
||||||
|
*/
|
||||||
|
StringID *BuildStationClassDropdown(void)
|
||||||
|
{
|
||||||
|
/* Allow room for all station classes, plus a terminator entry */
|
||||||
|
static StringID names[STAT_CLASS_MAX + 1];
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
/* Add each name */
|
||||||
|
for (i = 0; i < STAT_CLASS_MAX && station_classes[i].id != 0; i++) {
|
||||||
|
names[i] = station_classes[i].name;
|
||||||
|
}
|
||||||
|
/* Terminate the list */
|
||||||
|
names[i] = INVALID_STRING_ID;
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of station classes in use.
|
* Get the number of station classes in use.
|
||||||
* @return Number of station classes.
|
* @return Number of station classes.
|
||||||
|
|
|
@ -84,6 +84,10 @@ typedef struct stationclass {
|
||||||
|
|
||||||
void ResetStationClasses(void);
|
void ResetStationClasses(void);
|
||||||
StationClassID AllocateStationClass(uint32 class);
|
StationClassID AllocateStationClass(uint32 class);
|
||||||
|
void SetStationClassName(StationClassID sclass, StringID name);
|
||||||
|
StringID GetStationClassName(StationClassID sclass);
|
||||||
|
StringID *BuildStationClassDropdown(void);
|
||||||
|
|
||||||
uint GetNumStationClasses(void);
|
uint GetNumStationClasses(void);
|
||||||
uint GetNumCustomStations(StationClassID sclass);
|
uint GetNumCustomStations(StationClassID sclass);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue