(svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
Note: All windows get individual members with the same names, which are initialised via Window::GetScrollbar(). This caching is not required at all, but simplifies conversion.
This commit is contained in:
@@ -119,6 +119,7 @@ private:
|
||||
GroupID group_rename; ///< Group being renamed, INVALID_GROUP if none
|
||||
GUIGroupList groups; ///< List of groups
|
||||
uint tiny_step_height; ///< Step height for the group list
|
||||
Scrollbar *vscroll2;
|
||||
|
||||
/**
|
||||
* (Re)Build the group list.
|
||||
@@ -170,6 +171,9 @@ public:
|
||||
{
|
||||
this->CreateNestedTree(desc);
|
||||
|
||||
this->vscroll = this->GetScrollbar(GRP_WIDGET_LIST_VEHICLE_SCROLLBAR);
|
||||
this->vscroll2 = this->GetScrollbar(GRP_WIDGET_LIST_GROUP_SCROLLBAR);
|
||||
|
||||
this->vehicle_type = (VehicleType)GB(window_number, 11, 5);
|
||||
switch (this->vehicle_type) {
|
||||
default: NOT_REACHED();
|
||||
@@ -305,8 +309,8 @@ public:
|
||||
this->BuildGroupList(owner);
|
||||
this->groups.Sort(&GroupNameSorter);
|
||||
|
||||
this->vscroll2.SetCount(this->groups.Length());
|
||||
this->vscroll.SetCount(this->vehicles.Length());
|
||||
this->vscroll2->SetCount(this->groups.Length());
|
||||
this->vscroll->SetCount(this->vehicles.Length());
|
||||
|
||||
/* The drop down menu is out, *but* it may not be used, retract it. */
|
||||
if (this->vehicles.Length() == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
|
||||
@@ -365,8 +369,8 @@ public:
|
||||
|
||||
case GRP_WIDGET_LIST_GROUP: {
|
||||
int y1 = r.top + WD_FRAMERECT_TOP + 1;
|
||||
int max = min(this->vscroll2.GetPosition() + this->vscroll2.GetCapacity(), this->groups.Length());
|
||||
for (int i = this->vscroll2.GetPosition(); i < max; ++i) {
|
||||
int max = min(this->vscroll2->GetPosition() + this->vscroll2->GetCapacity(), this->groups.Length());
|
||||
for (int i = this->vscroll2->GetPosition(); i < max; ++i) {
|
||||
const Group *g = this->groups[i];
|
||||
|
||||
assert(g->owner == this->owner);
|
||||
@@ -423,7 +427,7 @@ public:
|
||||
break;
|
||||
|
||||
case GRP_WIDGET_LIST_GROUP: { // Matrix Group
|
||||
uint id_g = this->vscroll2.GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_GROUP, 0, this->tiny_step_height);
|
||||
uint id_g = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_GROUP, 0, this->tiny_step_height);
|
||||
if (id_g >= this->groups.Length()) return;
|
||||
|
||||
this->group_sel = this->groups[id_g]->index;
|
||||
@@ -434,7 +438,7 @@ public:
|
||||
}
|
||||
|
||||
case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle
|
||||
uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_VEHICLE);
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_VEHICLE);
|
||||
if (id_v >= this->vehicles.Length()) return; // click out of list bound
|
||||
|
||||
const Vehicle *v = this->vehicles[id_v];
|
||||
@@ -512,7 +516,7 @@ public:
|
||||
this->vehicle_sel = INVALID_VEHICLE;
|
||||
this->SetDirty();
|
||||
|
||||
uint id_g = this->vscroll2.GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_GROUP, 0, this->tiny_step_height);
|
||||
uint id_g = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_GROUP, 0, this->tiny_step_height);
|
||||
if (id_g >= this->groups.Length()) return;
|
||||
|
||||
DoCommandP(0, this->groups[id_g]->index, vindex, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE));
|
||||
@@ -524,7 +528,7 @@ public:
|
||||
this->vehicle_sel = INVALID_VEHICLE;
|
||||
this->SetDirty();
|
||||
|
||||
uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_VEHICLE);
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, GRP_WIDGET_LIST_VEHICLE);
|
||||
if (id_v >= this->vehicles.Length()) return; // click out of list bound
|
||||
|
||||
const Vehicle *v = this->vehicles[id_v];
|
||||
@@ -546,12 +550,12 @@ public:
|
||||
virtual void OnResize()
|
||||
{
|
||||
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(GRP_WIDGET_LIST_GROUP);
|
||||
this->vscroll2.SetCapacity(nwi->current_y / this->tiny_step_height);
|
||||
nwi->widget_data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
this->vscroll2->SetCapacity(nwi->current_y / this->tiny_step_height);
|
||||
nwi->widget_data = (this->vscroll2->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
|
||||
nwi = this->GetWidget<NWidgetCore>(GRP_WIDGET_LIST_VEHICLE);
|
||||
this->vscroll.SetCapacityFromWidget(this, GRP_WIDGET_LIST_VEHICLE);
|
||||
nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
this->vscroll->SetCapacityFromWidget(this, GRP_WIDGET_LIST_VEHICLE);
|
||||
nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
|
Reference in New Issue
Block a user