mirror of https://github.com/OpenTTD/OpenTTD
(svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
parent
2723128ba9
commit
68a3df82b9
|
@ -98,25 +98,6 @@ StringID GetStationClassName(StationClassID sclass)
|
||||||
return station_classes[sclass].name;
|
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()
|
|
||||||
{
|
|
||||||
/* 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.
|
||||||
|
|
|
@ -102,7 +102,6 @@ void ResetStationClasses();
|
||||||
StationClassID AllocateStationClass(uint32 cls);
|
StationClassID AllocateStationClass(uint32 cls);
|
||||||
void SetStationClassName(StationClassID sclass, StringID name);
|
void SetStationClassName(StationClassID sclass, StringID name);
|
||||||
StringID GetStationClassName(StationClassID sclass);
|
StringID GetStationClassName(StationClassID sclass);
|
||||||
StringID *BuildStationClassDropdown();
|
|
||||||
|
|
||||||
uint GetNumStationClasses();
|
uint GetNumStationClasses();
|
||||||
uint GetNumCustomStations(StationClassID sclass);
|
uint GetNumCustomStations(StationClassID sclass);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "sound_func.h"
|
#include "sound_func.h"
|
||||||
#include "player_func.h"
|
#include "player_func.h"
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
|
#include "widgets/dropdown_type.h"
|
||||||
#include "widgets/dropdown_func.h"
|
#include "widgets/dropdown_func.h"
|
||||||
|
|
||||||
#include "bridge_map.h"
|
#include "bridge_map.h"
|
||||||
|
@ -774,6 +775,18 @@ static void CheckSelectedSize(Window *w, const StationSpec *statspec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DropDownList *BuildStationClassDropDown()
|
||||||
|
{
|
||||||
|
DropDownList *list = new DropDownList();
|
||||||
|
|
||||||
|
for (uint i = 0; i < GetNumStationClasses(); i++) {
|
||||||
|
if (i == STAT_CLASS_WAYP) continue;
|
||||||
|
list->push_back(new DropDownListStringItem(GetStationClassName((StationClassID)i), i, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
static void StationBuildWndProc(Window *w, WindowEvent *e)
|
static void StationBuildWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -992,7 +1005,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case BRSW_NEWST_DROPDOWN:
|
case BRSW_NEWST_DROPDOWN:
|
||||||
case BRSW_NEWST_DROPDOWN_TEXT:
|
case BRSW_NEWST_DROPDOWN_TEXT:
|
||||||
ShowDropDownMenu(w, BuildStationClassDropdown(), _railstation.station_class, 23, 0, 1 << STAT_CLASS_WAYP);
|
ShowDropDownList(w, BuildStationClassDropDown(), _railstation.station_class, BRSW_NEWST_DROPDOWN_TEXT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BRSW_NEWST_LIST: {
|
case BRSW_NEWST_LIST: {
|
||||||
|
|
Loading…
Reference in New Issue