(svn r24167) -Codechange: Rename NewGRFClass::GetCount() to NewGRFClass::GetClassCount()

This commit is contained in:
frosch 2012-04-22 16:28:19 +00:00
parent 0f0e7e43cf
commit c841a78f69
7 changed files with 20 additions and 20 deletions

View File

@ -207,7 +207,7 @@ class BuildAirportWindow : public PickerWindowBase {
{ {
DropDownList *list = new DropDownList(); DropDownList *list = new DropDownList();
for (uint i = 0; i < AirportClass::GetCount(); i++) { for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false)); list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
} }
@ -268,7 +268,7 @@ public:
switch (widget) { switch (widget) {
case WID_AP_CLASS_DROPDOWN: { case WID_AP_CLASS_DROPDOWN: {
Dimension d = {0, 0}; Dimension d = {0, 0};
for (uint i = 0; i < AirportClass::GetCount(); i++) { for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
SetDParam(0, AirportClass::Get((AirportClassID)i)->name); SetDParam(0, AirportClass::Get((AirportClassID)i)->name);
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING)); d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
} }

View File

@ -49,9 +49,9 @@ public:
static void Reset(); static void Reset();
static Tid Allocate(uint32 global_id); static Tid Allocate(uint32 global_id);
static void Assign(Tspec *spec); static void Assign(Tspec *spec);
static uint GetClassCount();
static NewGRFClass *Get(Tid cls_id); static NewGRFClass *Get(Tid cls_id);
static uint GetCount();
static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index); static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index);
}; };

View File

@ -109,7 +109,7 @@ NewGRFClass<Tspec, Tid, Tmax> *NewGRFClass<Tspec, Tid, Tmax>::Get(Tid cls_id)
* Get the number of allocated classes. * Get the number of allocated classes.
* @return The number of classes. * @return The number of classes.
*/ */
DEFINE_NEWGRF_CLASS_METHOD(uint)::GetCount() DEFINE_NEWGRF_CLASS_METHOD(uint)::GetClassCount()
{ {
uint i; uint i;
for (i = 0; i < Tmax && classes[i].global_id != 0; i++) {} for (i = 0; i < Tmax && classes[i].global_id != 0; i++) {}
@ -162,6 +162,6 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id,
template void name::Insert(Tspec *spec); \ template void name::Insert(Tspec *spec); \
template void name::Assign(Tspec *spec); \ template void name::Assign(Tspec *spec); \
template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \ template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \
template uint name::GetCount(); \ template uint name::GetClassCount(); \
template const Tspec *name::GetSpec(uint index) const; \ template const Tspec *name::GetSpec(uint index) const; \
template const Tspec *name::GetByGrf(uint32 grfid, byte localidx, int *index); template const Tspec *name::GetByGrf(uint32 grfid, byte localidx, int *index);

View File

@ -42,7 +42,7 @@ public:
this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR); this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
this->vscroll->SetCapacity(5); this->vscroll->SetCapacity(5);
this->vscroll->SetPosition(0); this->vscroll->SetPosition(0);
this->vscroll->SetCount(ObjectClass::GetCount()); this->vscroll->SetCount(ObjectClass::GetClassCount());
this->FinishInitNested(desc, 0); this->FinishInitNested(desc, 0);
@ -77,7 +77,7 @@ public:
{ {
switch (widget) { switch (widget) {
case WID_BO_CLASS_LIST: { case WID_BO_CLASS_LIST: {
for (uint i = 0; i < ObjectClass::GetCount(); i++) { for (uint i = 0; i < ObjectClass::GetClassCount(); i++) {
size->width = max(size->width, GetStringBoundingBox(ObjectClass::Get((ObjectClassID)i)->name).width); size->width = max(size->width, GetStringBoundingBox(ObjectClass::Get((ObjectClassID)i)->name).width);
} }
size->width += padding.width; size->width += padding.width;
@ -155,7 +155,7 @@ public:
switch (GB(widget, 0, 16)) { switch (GB(widget, 0, 16)) {
case WID_BO_CLASS_LIST: { case WID_BO_CLASS_LIST: {
int y = r.top; int y = r.top;
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < ObjectClass::GetCount(); i++) { for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < ObjectClass::GetClassCount(); i++) {
SetDParam(0, ObjectClass::Get((ObjectClassID)i)->name); SetDParam(0, ObjectClass::Get((ObjectClassID)i)->name);
DrawString(r.left + WD_MATRIX_LEFT, r.right + WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, STR_JUST_STRING, DrawString(r.left + WD_MATRIX_LEFT, r.right + WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, STR_JUST_STRING,
((int)i == _selected_object_class) ? TC_WHITE : TC_BLACK); ((int)i == _selected_object_class) ? TC_WHITE : TC_BLACK);
@ -289,7 +289,7 @@ public:
switch (GB(widget, 0, 16)) { switch (GB(widget, 0, 16)) {
case WID_BO_CLASS_LIST: { case WID_BO_CLASS_LIST: {
int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height; int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
if (num_clicked >= (int)ObjectClass::GetCount()) break; if (num_clicked >= (int)ObjectClass::GetClassCount()) break;
_selected_object_class = (ObjectClassID)num_clicked; _selected_object_class = (ObjectClassID)num_clicked;
this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetCount(ObjectClass::Get(_selected_object_class)->GetSpecCount()); this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetCount(ObjectClass::Get(_selected_object_class)->GetSpecCount());

View File

@ -937,7 +937,7 @@ public:
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
if (!newstation || _railstation.station_class >= (int)StationClass::GetCount()) { if (!newstation || _railstation.station_class >= (int)StationClass::GetClassCount()) {
/* New stations are not available or changed, so ensure the default station /* New stations are not available or changed, so ensure the default station
* type is 'selected'. */ * type is 'selected'. */
_railstation.station_class = STAT_CLASS_DFLT; _railstation.station_class = STAT_CLASS_DFLT;
@ -949,7 +949,7 @@ public:
_railstation.station_type = min(_railstation.station_type, _railstation.station_count - 1); _railstation.station_type = min(_railstation.station_type, _railstation.station_count - 1);
int count = 0; int count = 0;
for (uint i = 0; i < StationClass::GetCount(); i++) { for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue; if (i == STAT_CLASS_WAYP) continue;
count++; count++;
} }
@ -1024,7 +1024,7 @@ public:
switch (widget) { switch (widget) {
case WID_BRAS_NEWST_LIST: { case WID_BRAS_NEWST_LIST: {
Dimension d = {0, 0}; Dimension d = {0, 0};
for (uint i = 0; i < StationClass::GetCount(); i++) { for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue; if (i == STAT_CLASS_WAYP) continue;
SetDParam(0, StationClass::Get((StationClassID)i)->name); SetDParam(0, StationClass::Get((StationClassID)i)->name);
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING)); d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
@ -1046,7 +1046,7 @@ public:
/* If newstations exist, compute the non-zero minimal size. */ /* If newstations exist, compute the non-zero minimal size. */
Dimension d = {0, 0}; Dimension d = {0, 0};
StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data; StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
for (StationClassID statclass = STAT_CLASS_BEGIN; statclass < (StationClassID)StationClass::GetCount(); statclass++) { for (StationClassID statclass = STAT_CLASS_BEGIN; statclass < (StationClassID)StationClass::GetClassCount(); statclass++) {
if (statclass == STAT_CLASS_WAYP) continue; if (statclass == STAT_CLASS_WAYP) continue;
StationClass *stclass = StationClass::Get(statclass); StationClass *stclass = StationClass::Get(statclass);
for (uint16 j = 0; j < stclass->GetSpecCount(); j++) { for (uint16 j = 0; j < stclass->GetSpecCount(); j++) {
@ -1102,7 +1102,7 @@ public:
case WID_BRAS_NEWST_LIST: { case WID_BRAS_NEWST_LIST: {
uint statclass = 0; uint statclass = 0;
uint row = 0; uint row = 0;
for (uint i = 0; i < StationClass::GetCount(); i++) { for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue; if (i == STAT_CLASS_WAYP) continue;
if (this->vscroll->IsVisible(statclass)) { if (this->vscroll->IsVisible(statclass)) {
SetDParam(0, StationClass::Get((StationClassID)i)->name); SetDParam(0, StationClass::Get((StationClassID)i)->name);
@ -1283,8 +1283,8 @@ public:
case WID_BRAS_NEWST_LIST: { case WID_BRAS_NEWST_LIST: {
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST, 0, this->line_height); int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST, 0, this->line_height);
if (y >= (int)StationClass::GetCount()) return; if (y >= (int)StationClass::GetClassCount()) return;
for (uint i = 0; i < StationClass::GetCount(); i++) { for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue; if (i == STAT_CLASS_WAYP) continue;
if (y == 0) { if (y == 0) {
if (_railstation.station_class != (StationClassID)i) { if (_railstation.station_class != (StationClassID)i) {
@ -1437,7 +1437,7 @@ static const WindowDesc _station_builder_desc(
/** Open station build window */ /** Open station build window */
static void ShowStationBuilder(Window *parent) static void ShowStationBuilder(Window *parent)
{ {
bool newstations = StationClass::GetCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1; bool newstations = StationClass::GetClassCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1;
new BuildRailStationWindow(&_station_builder_desc, parent, newstations); new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
} }

View File

@ -1105,7 +1105,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
if (!ValParamRailtype(rt)) return CMD_ERROR; if (!ValParamRailtype(rt)) return CMD_ERROR;
/* Check if the given station class is valid */ /* Check if the given station class is valid */
if ((uint)spec_class >= StationClass::GetCount() || spec_class == STAT_CLASS_WAYP) return CMD_ERROR; if ((uint)spec_class >= StationClass::GetClassCount() || spec_class == STAT_CLASS_WAYP) return CMD_ERROR;
if (spec_index >= StationClass::Get(spec_class)->GetSpecCount()) return CMD_ERROR; if (spec_index >= StationClass::Get(spec_class)->GetSpecCount()) return CMD_ERROR;
if (plat_len == 0 || numtracks == 0) return CMD_ERROR; if (plat_len == 0 || numtracks == 0) return CMD_ERROR;

View File

@ -163,7 +163,7 @@ struct TerraformToolbarWindow : Window {
{ {
/* Don't show the place object button when there are no objects to place. */ /* Don't show the place object button when there are no objects to place. */
NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT); NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT);
show_object->SetDisplayedPlane(ObjectClass::GetCount() != 0 ? 0 : SZSP_NONE); show_object->SetDisplayedPlane(ObjectClass::GetClassCount() != 0 ? 0 : SZSP_NONE);
} }
virtual void OnClick(Point pt, int widget, int click_count) virtual void OnClick(Point pt, int widget, int click_count)
@ -209,7 +209,7 @@ struct TerraformToolbarWindow : Window {
case WID_TT_PLACE_OBJECT: // Place object button case WID_TT_PLACE_OBJECT: // Place object button
/* Don't show the place object button when there are no objects to place. */ /* Don't show the place object button when there are no objects to place. */
if (ObjectClass::GetCount() == 0) return; if (ObjectClass::GetClassCount() == 0) return;
if (HandlePlacePushButton(this, WID_TT_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT)) { if (HandlePlacePushButton(this, WID_TT_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT)) {
ShowBuildObjectPicker(this); ShowBuildObjectPicker(this);
this->last_user_action = widget; this->last_user_action = widget;