|
|
@ -106,8 +106,7 @@ class ReplaceVehicleWindow : public Window {
|
|
|
|
GroupID sel_group; ///< Group selected to replace.
|
|
|
|
GroupID sel_group; ///< Group selected to replace.
|
|
|
|
int details_height; ///< Minimal needed height of the details panels (found so far).
|
|
|
|
int details_height; ///< Minimal needed height of the details panels (found so far).
|
|
|
|
RailType sel_railtype; ///< Type of rail tracks selected.
|
|
|
|
RailType sel_railtype; ///< Type of rail tracks selected.
|
|
|
|
Scrollbar *vscroll;
|
|
|
|
Scrollbar *vscroll[2];
|
|
|
|
Scrollbar *vscroll2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Figure out if an engine should be added to a list.
|
|
|
|
* Figure out if an engine should be added to a list.
|
|
|
@ -173,7 +172,7 @@ class ReplaceVehicleWindow : public Window {
|
|
|
|
if (this->engines[0].NeedRebuild()) {
|
|
|
|
if (this->engines[0].NeedRebuild()) {
|
|
|
|
/* We need to rebuild the left engines list */
|
|
|
|
/* We need to rebuild the left engines list */
|
|
|
|
this->GenerateReplaceVehList(true);
|
|
|
|
this->GenerateReplaceVehList(true);
|
|
|
|
this->vscroll->SetCount(this->engines[0].Length());
|
|
|
|
this->vscroll[0]->SetCount(this->engines[0].Length());
|
|
|
|
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
|
|
|
|
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
|
|
|
|
this->sel_engine[0] = this->engines[0][0];
|
|
|
|
this->sel_engine[0] = this->engines[0][0];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -187,7 +186,7 @@ class ReplaceVehicleWindow : public Window {
|
|
|
|
this->sel_engine[1] = INVALID_ENGINE;
|
|
|
|
this->sel_engine[1] = INVALID_ENGINE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this->GenerateReplaceVehList(false);
|
|
|
|
this->GenerateReplaceVehList(false);
|
|
|
|
this->vscroll2->SetCount(this->engines[1].Length());
|
|
|
|
this->vscroll[1]->SetCount(this->engines[1].Length());
|
|
|
|
if (this->reset_sel_engine && this->sel_engine[1] == INVALID_ENGINE && this->engines[1].Length() != 0) {
|
|
|
|
if (this->reset_sel_engine && this->sel_engine[1] == INVALID_ENGINE && this->engines[1].Length() != 0) {
|
|
|
|
this->sel_engine[1] = this->engines[1][0];
|
|
|
|
this->sel_engine[1] = this->engines[1][0];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -229,8 +228,8 @@ public:
|
|
|
|
this->sel_engine[1] = INVALID_ENGINE;
|
|
|
|
this->sel_engine[1] = INVALID_ENGINE;
|
|
|
|
|
|
|
|
|
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->vscroll = this->GetScrollbar(RVW_WIDGET_LEFT_SCROLLBAR);
|
|
|
|
this->vscroll[0] = this->GetScrollbar(RVW_WIDGET_LEFT_SCROLLBAR);
|
|
|
|
this->vscroll2 = this->GetScrollbar(RVW_WIDGET_RIGHT_SCROLLBAR);
|
|
|
|
this->vscroll[1] = this->GetScrollbar(RVW_WIDGET_RIGHT_SCROLLBAR);
|
|
|
|
this->FinishInitNested(desc, vehicletype);
|
|
|
|
this->FinishInitNested(desc, vehicletype);
|
|
|
|
|
|
|
|
|
|
|
|
this->owner = _local_company;
|
|
|
|
this->owner = _local_company;
|
|
|
@ -344,8 +343,8 @@ public:
|
|
|
|
case RVW_WIDGET_LEFT_MATRIX:
|
|
|
|
case RVW_WIDGET_LEFT_MATRIX:
|
|
|
|
case RVW_WIDGET_RIGHT_MATRIX: {
|
|
|
|
case RVW_WIDGET_RIGHT_MATRIX: {
|
|
|
|
int side = (widget == RVW_WIDGET_LEFT_MATRIX) ? 0 : 1;
|
|
|
|
int side = (widget == RVW_WIDGET_LEFT_MATRIX) ? 0 : 1;
|
|
|
|
EngineID start = side == 0 ? this->vscroll->GetPosition() : this->vscroll2->GetPosition(); // what is the offset for the start (scrolling)
|
|
|
|
EngineID start = this->vscroll[side]->GetPosition(); // what is the offset for the start (scrolling)
|
|
|
|
EngineID end = min((side == 0 ? this->vscroll->GetCapacity() : this->vscroll2->GetCapacity()) + start, this->engines[side].Length());
|
|
|
|
EngineID end = min(this->vscroll[side]->GetCapacity() + start, this->engines[side].Length());
|
|
|
|
|
|
|
|
|
|
|
|
/* Do the actual drawing */
|
|
|
|
/* Do the actual drawing */
|
|
|
|
DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
|
|
|
|
DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
|
|
|
@ -455,15 +454,13 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
case RVW_WIDGET_LEFT_MATRIX:
|
|
|
|
case RVW_WIDGET_LEFT_MATRIX:
|
|
|
|
case RVW_WIDGET_RIGHT_MATRIX: {
|
|
|
|
case RVW_WIDGET_RIGHT_MATRIX: {
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
byte click_side;
|
|
|
|
byte click_side;
|
|
|
|
if (widget == RVW_WIDGET_LEFT_MATRIX) {
|
|
|
|
if (widget == RVW_WIDGET_LEFT_MATRIX) {
|
|
|
|
i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, RVW_WIDGET_LEFT_MATRIX);
|
|
|
|
|
|
|
|
click_side = 0;
|
|
|
|
click_side = 0;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, RVW_WIDGET_RIGHT_MATRIX);
|
|
|
|
|
|
|
|
click_side = 1;
|
|
|
|
click_side = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
|
|
|
|
size_t engine_count = this->engines[click_side].Length();
|
|
|
|
size_t engine_count = this->engines[click_side].Length();
|
|
|
|
|
|
|
|
|
|
|
|
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
|
|
|
|
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
|
|
|
@ -485,8 +482,8 @@ public:
|
|
|
|
if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
|
|
|
|
if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
|
|
|
|
sel_railtype = temp;
|
|
|
|
sel_railtype = temp;
|
|
|
|
/* Reset scrollbar positions */
|
|
|
|
/* Reset scrollbar positions */
|
|
|
|
this->vscroll->SetPosition(0);
|
|
|
|
this->vscroll[0]->SetPosition(0);
|
|
|
|
this->vscroll2->SetPosition(0);
|
|
|
|
this->vscroll[1]->SetPosition(0);
|
|
|
|
/* Rebuild the lists */
|
|
|
|
/* Rebuild the lists */
|
|
|
|
this->engines[0].ForceRebuild();
|
|
|
|
this->engines[0].ForceRebuild();
|
|
|
|
this->engines[1].ForceRebuild();
|
|
|
|
this->engines[1].ForceRebuild();
|
|
|
@ -496,11 +493,11 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
virtual void OnResize()
|
|
|
|
virtual void OnResize()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->vscroll->SetCapacityFromWidget(this, RVW_WIDGET_LEFT_MATRIX);
|
|
|
|
this->vscroll[0]->SetCapacityFromWidget(this, RVW_WIDGET_LEFT_MATRIX);
|
|
|
|
this->vscroll2->SetCapacityFromWidget(this, RVW_WIDGET_RIGHT_MATRIX);
|
|
|
|
this->vscroll[1]->SetCapacityFromWidget(this, RVW_WIDGET_RIGHT_MATRIX);
|
|
|
|
|
|
|
|
|
|
|
|
this->GetWidget<NWidgetCore>(RVW_WIDGET_LEFT_MATRIX)->widget_data =
|
|
|
|
this->GetWidget<NWidgetCore>(RVW_WIDGET_LEFT_MATRIX)->widget_data =
|
|
|
|
this->GetWidget<NWidgetCore>(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
|
|
|
this->GetWidget<NWidgetCore>(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll[0]->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|