summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_gui.cpp40
-rw-r--r--src/script/api/game/game_window.hpp.sq1
-rw-r--r--src/script/api/script_window.hpp1
-rw-r--r--src/widgets/autoreplace_widget.h1
4 files changed, 37 insertions, 6 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index ecc8a47fc..00eb02225 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -86,6 +86,7 @@ class ReplaceVehicleWindow : public Window {
int details_height; ///< Minimal needed height of the details panels (found so far).
byte sort_criteria; ///< Criteria of sorting vehicles.
bool descending_sort_order; ///< Order of sorting vehicles.
+ bool show_hidden_engines; ///< Whether to show the hidden engines.
RailType sel_railtype; ///< Type of rail tracks selected.
Scrollbar *vscroll[2];
@@ -126,6 +127,7 @@ class ReplaceVehicleWindow : public Window {
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) {
+ if (!draw_left && !this->show_hidden_engines && e->IsHidden(_local_company)) continue;
EngineID eid = e->index;
if (type == VEH_TRAIN && !this->GenerateReplaceRailList(eid, draw_left, this->replace_engines)) continue; // special rules for trains
@@ -234,10 +236,16 @@ public:
this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
this->sel_engine[0] = INVALID_ENGINE;
this->sel_engine[1] = INVALID_ENGINE;
+ this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
this->CreateNestedTree();
this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
+
+ NWidgetCore *widget = this->GetWidget<NWidgetCore>(WID_RV_SHOW_HIDDEN_ENGINES);
+ widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
+ widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
+ widget->SetLowered(this->show_hidden_engines);
this->FinishInitNested(vehicletype);
this->sort_criteria = _engine_sort_last_criteria[vehicletype];
@@ -463,6 +471,14 @@ public:
this->SetDirty();
break;
+ case WID_RV_SHOW_HIDDEN_ENGINES:
+ this->show_hidden_engines ^= true;
+ _engine_sort_show_hidden_engines[this->window_number] = this->show_hidden_engines;
+ this->engines[1].ForceRebuild();
+ this->SetWidgetLoweredState(widget, this->show_hidden_engines);
+ this->SetDirty();
+ break;
+
case WID_RV_SORT_DROPDOWN:
DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
break;
@@ -596,9 +612,15 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
- NWidget(NWID_HORIZONTAL),
- NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASSENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
+ NWidget(NWID_VERTICAL),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASSENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
+ EndContainer(),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
+ NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
+ EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
@@ -652,9 +674,15 @@ static const NWidgetPart _nested_replace_vehicle_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
- NWidget(NWID_HORIZONTAL),
- NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASSENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
+ NWidget(NWID_VERTICAL),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASSENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
+ EndContainer(),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
+ NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
+ EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq
index 14328ec00..6b1159885 100644
--- a/src/script/api/game/game_window.hpp.sq
+++ b/src/script/api/game/game_window.hpp.sq
@@ -214,6 +214,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_AP_BTN_DOHILIGHT, "WID_AP_BTN_DOHILIGHT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_CAPTION, "WID_RV_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SORT_ASSENDING_DESCENDING, "WID_RV_SORT_ASSENDING_DESCENDING");
+ SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SHOW_HIDDEN_ENGINES, "WID_RV_SHOW_HIDDEN_ENGINES");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SORT_DROPDOWN, "WID_RV_SORT_DROPDOWN");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_LEFT_MATRIX, "WID_RV_LEFT_MATRIX");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_LEFT_SCROLLBAR, "WID_RV_LEFT_SCROLLBAR");
diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp
index 417283fd0..0f6e3e0ed 100644
--- a/src/script/api/script_window.hpp
+++ b/src/script/api/script_window.hpp
@@ -925,6 +925,7 @@ public:
/* Sort dropdown at the right. */
WID_RV_SORT_ASSENDING_DESCENDING = ::WID_RV_SORT_ASSENDING_DESCENDING, ///< Ascending/descending sort order button.
+ WID_RV_SHOW_HIDDEN_ENGINES = ::WID_RV_SHOW_HIDDEN_ENGINES, ///< Toggle whether to display the hidden vehicles.
WID_RV_SORT_DROPDOWN = ::WID_RV_SORT_DROPDOWN, ///< Dropdown for the sort criteria.
/* Left and right matrix + details. */
diff --git a/src/widgets/autoreplace_widget.h b/src/widgets/autoreplace_widget.h
index 940282ac8..b1afc8d75 100644
--- a/src/widgets/autoreplace_widget.h
+++ b/src/widgets/autoreplace_widget.h
@@ -18,6 +18,7 @@ enum ReplaceVehicleWidgets {
/* Sort dropdown at the right. */
WID_RV_SORT_ASSENDING_DESCENDING, ///< Ascending/descending sort order button.
+ WID_RV_SHOW_HIDDEN_ENGINES, ///< Toggle whether to display the hidden vehicles.
WID_RV_SORT_DROPDOWN, ///< Dropdown for the sort criteria.
/* Left and right matrix + details. */