summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-08-12 11:21:30 +0000
committerfrosch <frosch@openttd.org>2010-08-12 11:21:30 +0000
commite5ff41ee53dfbc918410a1a7d9bdad9f8fe70c58 (patch)
treee3875cdb23596f6890de1031762c80ed52d075b1
parentc16dead108c4560b0d14e0702008b8509e7cfd04 (diff)
downloadopenttd-e5ff41ee53dfbc918410a1a7d9bdad9f8fe70c58.tar.xz
(svn r20464) -Codechange/Fix: Do not use a scrollbar to store the number of columns for non-train depot windows.
-rw-r--r--src/depot_gui.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 520694cd6..f5d7a34b9 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -222,6 +222,7 @@ struct DepotWindow : Window {
bool generate_list;
VehicleList vehicle_list;
VehicleList wagon_list;
+ uint num_columns; ///< Number of columns.
Scrollbar *hscroll; ///< Only for trains.
Scrollbar *vscroll;
@@ -233,6 +234,7 @@ struct DepotWindow : Window {
this->vehicle_over = INVALID_VEHICLE;
this->generate_list = true;
this->type = type;
+ this->num_columns = 1; // for non-trains this gets set in FinishInitNested()
this->CreateNestedTree(desc);
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(DEPOT_WIDGET_H_SCROLL) : NULL);
@@ -388,7 +390,7 @@ struct DepotWindow : Window {
} else {
xt = x / this->resize.step_width;
xm = x % this->resize.step_width;
- if (xt >= this->hscroll->GetCapacity()) return MODE_ERROR;
+ if (xt >= this->num_columns) return MODE_ERROR;
}
ym = y % this->resize.step_height;
@@ -414,7 +416,7 @@ struct DepotWindow : Window {
if (this->vehicle_list.Length() > pos) {
*veh = this->vehicle_list[pos];
/* Skip vehicles that are scrolled off the list */
- x += this->hscroll->GetPosition();
+ if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
} else {
pos -= this->vehicle_list.Length();
*veh = this->wagon_list[pos];
@@ -700,7 +702,7 @@ struct DepotWindow : Window {
this->vscroll->SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
this->hscroll->SetCount(max_width);
} else {
- this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->hscroll->GetCapacity()));
+ this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->num_columns));
}
/* Setup disabled buttons. */
@@ -1014,8 +1016,8 @@ struct DepotWindow : Window {
this->hscroll->SetCapacity(nwi->current_x - this->header_width - this->count_width);
nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
} else {
- this->hscroll->SetCapacityFromWidget(this, DEPOT_WIDGET_MATRIX);
- nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (this->hscroll->GetCapacity() << MAT_COL_START);
+ this->num_columns = nwi->current_x / nwi->resize_x;
+ nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (this->num_columns << MAT_COL_START);
}
}