diff options
author | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
commit | 4203e641f8a507c017d10bf40f2c3882ce596da5 (patch) | |
tree | 883a2b182b8594de0b2048900956281c4efff861 /src/group_gui.cpp | |
parent | 97f85f7bfba286bf9a7c692b390eec8231cac9ae (diff) | |
download | openttd-4203e641f8a507c017d10bf40f2c3882ce596da5.tar.xz |
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r-- | src/group_gui.cpp | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp index c3ddc5812..97e7bce59 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -417,12 +417,7 @@ public: break; case GRP_WIDGET_LIST_GROUP: { // Matrix Group - uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / (int)this->tiny_step_height; - - if (id_g >= this->vscroll2.GetCapacity()) return; - - id_g += this->vscroll2.GetPosition(); - + 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; @@ -433,11 +428,7 @@ public: } case GRP_WIDGET_LIST_VEHICLE: { // Matrix Vehicle - uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_VEHICLE)->pos_y) / (int)this->resize.step_height; - if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds - - id_v += this->vscroll.GetPosition(); - + 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]; @@ -511,17 +502,11 @@ public: break; case GRP_WIDGET_LIST_GROUP: { // Maxtrix group - uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / (int)this->tiny_step_height; const VehicleID vindex = this->vehicle_sel; - this->vehicle_sel = INVALID_VEHICLE; - this->SetDirty(); - if (id_g >= this->vscroll2.GetCapacity()) return; - - id_g += this->vscroll2.GetPosition(); - + 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)); @@ -529,17 +514,11 @@ public: } case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle - uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_VEHICLE)->pos_y) / (int)this->resize.step_height; const VehicleID vindex = this->vehicle_sel; - this->vehicle_sel = INVALID_VEHICLE; - this->SetDirty(); - if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds - - id_v += this->vscroll.GetPosition(); - + 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]; |