Merge branch 'master' into jgrpp
# Conflicts: # src/articulated_vehicles.cpp # src/articulated_vehicles.h # src/autoreplace_cmd.cpp # src/build_vehicle_gui.cpp # src/company_gui.cpp # src/core/format.hpp # src/genworld_gui.cpp # src/gfx.cpp # src/group_gui.cpp # src/linkgraph/linkgraph_gui.cpp # src/misc/endian_buffer.hpp # src/music/music_driver.hpp # src/newgrf_gui.cpp # src/rail_cmd.cpp # src/road_gui.cpp # src/settings_type.h # src/strgen/strgen.cpp # src/strings.cpp # src/timetable_cmd.cpp # src/town.h # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehicle_gui_base.h # src/widget.cpp # src/widgets/dropdown.cpp # src/widgets/road_widget.h
This commit is contained in:
@@ -270,6 +270,21 @@ class ReplaceVehicleWindow : public Window {
|
||||
DoCommandP(0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform tasks after rail or road type is changed.
|
||||
*/
|
||||
void OnRailRoadTypeChange()
|
||||
{
|
||||
/* Reset scrollbar positions */
|
||||
this->vscroll[0]->SetPosition(0);
|
||||
this->vscroll[1]->SetPosition(0);
|
||||
/* Rebuild the lists */
|
||||
this->engines[0].ForceRebuild();
|
||||
this->engines[1].ForceRebuild();
|
||||
this->reset_sel_engine = true;
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
public:
|
||||
ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
|
||||
{
|
||||
@@ -294,11 +309,6 @@ public:
|
||||
widget->SetLowered(this->show_hidden_engines);
|
||||
this->FinishInitNested(vehicletype);
|
||||
|
||||
if (vehicletype == VEH_TRAIN || vehicletype == VEH_ROAD) {
|
||||
widget = this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
|
||||
widget->tool_tip = STR_REPLACE_HELP_RAILTYPE + vehicletype;
|
||||
}
|
||||
|
||||
this->sort_criteria = _engine_sort_last_criteria[vehicletype];
|
||||
this->descending_sort_order = _engine_sort_last_order[vehicletype];
|
||||
this->owner = _local_company;
|
||||
@@ -357,28 +367,21 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_RAIL_ROAD_TYPE_DROPDOWN: {
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN: {
|
||||
Dimension d = {0, 0};
|
||||
switch (this->window_number) {
|
||||
case VEH_TRAIN:
|
||||
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
||||
const RailTypeInfo *rti = GetRailTypeInfo(rt);
|
||||
/* Skip rail type if it has no label */
|
||||
if (rti->label == 0) continue;
|
||||
d = maxdim(d, GetStringBoundingBox(rti->strings.replace_text));
|
||||
}
|
||||
break;
|
||||
for (const RailType &rt : _sorted_railtypes) {
|
||||
d = maxdim(d, GetStringBoundingBox(GetRailTypeInfo(rt)->strings.replace_text));
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case VEH_ROAD:
|
||||
for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
/* Skip road type if it has no label */
|
||||
if (rti->label == 0) continue;
|
||||
d = maxdim(d, GetStringBoundingBox(rti->strings.replace_text));
|
||||
}
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN: {
|
||||
Dimension d = {0, 0};
|
||||
for (const RoadType &rt : _sorted_roadtypes) {
|
||||
d = maxdim(d, GetStringBoundingBox(GetRoadTypeInfo(rt)->strings.replace_text));
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
@@ -443,6 +446,14 @@ public:
|
||||
case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN:
|
||||
SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
|
||||
break;
|
||||
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN:
|
||||
SetDParam(0, this->sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(this->sel_railtype)->strings.replace_text);
|
||||
break;
|
||||
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN:
|
||||
SetDParam(0, this->sel_roadtype == INVALID_ROADTYPE ? STR_REPLACE_ALL_ROADTYPE : GetRoadTypeInfo(this->sel_roadtype)->strings.replace_text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,20 +514,6 @@ public:
|
||||
* or The selected vehicle has no replacement set up */
|
||||
this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
|
||||
|
||||
switch (this->window_number) {
|
||||
case VEH_TRAIN:
|
||||
/* Show the selected railtype in the pulldown menu */
|
||||
this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN)->widget_data = sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(sel_railtype)->strings.replace_text;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
/* Show the selected roadtype in the pulldown menu */
|
||||
this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN)->widget_data = sel_roadtype == INVALID_ROADTYPE ? STR_REPLACE_ALL_ROADTYPE : GetRoadTypeInfo(sel_roadtype)->strings.replace_text;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
this->DrawWidgets();
|
||||
|
||||
if (!this->IsShaded()) {
|
||||
@@ -574,16 +571,12 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_RAIL_ROAD_TYPE_DROPDOWN: // Rail/roadtype selection dropdown menu
|
||||
switch (this->window_number) {
|
||||
case VEH_TRAIN:
|
||||
ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
|
||||
break;
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN: // Railtype selection dropdown menu
|
||||
ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, widget);
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), sel_roadtype, WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
|
||||
break;
|
||||
}
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN: // Roadtype selection dropdown menu
|
||||
ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget);
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
@@ -675,34 +668,21 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_RV_RAIL_ROAD_TYPE_DROPDOWN:
|
||||
switch (this->window_number) {
|
||||
case VEH_TRAIN: {
|
||||
RailType temp = (RailType)index;
|
||||
if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
|
||||
sel_railtype = temp;
|
||||
break;
|
||||
}
|
||||
|
||||
case VEH_ROAD: {
|
||||
RoadType temp = (RoadType)index;
|
||||
if (temp == sel_roadtype) return; // we didn't select a new one. No need to change anything
|
||||
sel_roadtype = temp;
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
/* Reset scrollbar positions */
|
||||
this->vscroll[0]->SetPosition(0);
|
||||
this->vscroll[1]->SetPosition(0);
|
||||
/* Rebuild the lists */
|
||||
this->engines[0].ForceRebuild();
|
||||
this->engines[1].ForceRebuild();
|
||||
this->reset_sel_engine = true;
|
||||
this->SetDirty();
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN: {
|
||||
RailType temp = (RailType)index;
|
||||
if (temp == this->sel_railtype) return; // we didn't select a new one. No need to change anything
|
||||
this->sel_railtype = temp;
|
||||
this->OnRailRoadTypeChange();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN: {
|
||||
RoadType temp = (RoadType)index;
|
||||
if (temp == this->sel_roadtype) return; // we didn't select a new one. No need to change anything
|
||||
this->sel_roadtype = temp;
|
||||
this->OnRailRoadTypeChange();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
|
||||
this->replace_engines = index != 0;
|
||||
@@ -772,7 +752,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(STR_JUST_STRING, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
|
||||
@@ -835,7 +815,7 @@ static const NWidgetPart _nested_replace_road_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(STR_JUST_STRING, STR_REPLACE_HELP_ROADTYPE), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
|
Reference in New Issue
Block a user