Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
+24
-55
@@ -31,6 +31,7 @@
|
||||
#include "town.h"
|
||||
#include "linkgraph/linkgraph.h"
|
||||
#include "zoom_func.h"
|
||||
#include "station_cmd.h"
|
||||
|
||||
#include "widgets/station_widget.h"
|
||||
|
||||
@@ -437,16 +438,6 @@ public:
|
||||
this->rating_width = this->rating_width * 16 / 10;
|
||||
break;
|
||||
|
||||
case WID_STL_CARGOALL:
|
||||
case WID_STL_FACILALL:
|
||||
case WID_STL_NOCARGOWAITING: {
|
||||
Dimension d = GetStringBoundingBox(widget == WID_STL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
|
||||
d.width += padding.width + 2;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (widget >= WID_STL_CARGOSTART) {
|
||||
Dimension d = GetStringBoundingBox(_sorted_cargo_specs[widget - WID_STL_CARGOSTART]->abbrev);
|
||||
@@ -526,24 +517,6 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_STL_NOCARGOWAITING: {
|
||||
int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0;
|
||||
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_STL_CARGOALL: {
|
||||
int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0;
|
||||
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_STL_FACILALL: {
|
||||
int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0;
|
||||
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (widget >= WID_STL_CARGOSTART) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART];
|
||||
@@ -783,17 +756,17 @@ static const NWidgetPart _nested_company_stations_widgets[] = {
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_BUS), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SHIP), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_AIRPLANE), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
||||
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(5, 0), SetFill(0, 1), EndContainer(),
|
||||
NWidgetFunction(CargoWidgets),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
|
||||
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_NONE, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_STL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten.
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_STL_SCROLLBAR), EndContainer(),
|
||||
@@ -1984,7 +1957,7 @@ struct StationViewWindow : public Window {
|
||||
break;
|
||||
|
||||
case WID_SV_CLOSE_AIRPORT:
|
||||
DoCommandP(0, this->window_number, 0, CMD_OPEN_CLOSE_AIRPORT);
|
||||
Command<CMD_OPEN_CLOSE_AIRPORT>::Post(this->window_number);
|
||||
break;
|
||||
|
||||
case WID_SV_TRAINS: // Show list of scheduled trains to this station
|
||||
@@ -2121,7 +2094,7 @@ struct StationViewWindow : public Window {
|
||||
{
|
||||
if (str == nullptr) return;
|
||||
|
||||
DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), nullptr, str);
|
||||
Command<CMD_RENAME_STATION>::Post(STR_ERROR_CAN_T_RENAME_STATION, this->window_number, str);
|
||||
}
|
||||
|
||||
void OnResize() override
|
||||
@@ -2322,13 +2295,13 @@ static const NWidgetPart _nested_select_station_widgets[] = {
|
||||
*/
|
||||
template <class T>
|
||||
struct SelectStationWindow : WindowPopup {
|
||||
CommandContainer select_station_cmd; ///< Command to build new station
|
||||
StationPickerCmdProc select_station_proc;
|
||||
TileArea area; ///< Location of new station
|
||||
Scrollbar *vscroll;
|
||||
|
||||
SelectStationWindow(WindowDesc *desc, const CommandContainer &cmd, TileArea ta) :
|
||||
SelectStationWindow(WindowDesc *desc, TileArea ta, StationPickerCmdProc&& proc) :
|
||||
WindowPopup(desc, WPUT_WIDGET_RELATIVE),
|
||||
select_station_cmd(cmd),
|
||||
select_station_proc(std::move(proc)),
|
||||
area(ta)
|
||||
{
|
||||
this->wpu_widget = WID_JS_PANEL;
|
||||
@@ -2400,12 +2373,8 @@ struct SelectStationWindow : WindowPopup {
|
||||
|
||||
if (distant_join && st_index >= _stations_nearby_list.size()) return;
|
||||
|
||||
/* Insert station to be joined into stored command */
|
||||
SB(this->select_station_cmd.p2, 16, 16,
|
||||
(distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
|
||||
|
||||
/* Execute stored Command */
|
||||
DoCommandP(&this->select_station_cmd);
|
||||
this->select_station_proc(false, distant_join ? _stations_nearby_list[st_index] : NEW_STATION);
|
||||
|
||||
/* Close Window; this might cause double frees! */
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
@@ -2471,7 +2440,7 @@ static WindowDesc _select_station_desc(
|
||||
* @return whether we need to show the station selection window.
|
||||
*/
|
||||
template <class T>
|
||||
static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
static bool StationJoinerNeeded(TileArea ta, const StationPickerCmdProc &proc)
|
||||
{
|
||||
/* Only show selection if distant join is enabled in the settings */
|
||||
if (!_settings_game.station.distant_join_stations) return false;
|
||||
@@ -2489,7 +2458,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
if (!citymania::_fn_mod) return false;
|
||||
|
||||
/* Now check if we could build there */
|
||||
if (DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))).Failed()) return false;
|
||||
if (!proc(true, INVALID_STATION)) return false;
|
||||
|
||||
/* Test for adjacent station or station below selection.
|
||||
* If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
|
||||
@@ -2505,32 +2474,32 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
* @tparam the class to find stations for
|
||||
*/
|
||||
template <class T>
|
||||
void ShowSelectBaseStationIfNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
void ShowSelectBaseStationIfNeeded(TileArea ta, StationPickerCmdProc&& proc)
|
||||
{
|
||||
if (StationJoinerNeeded<T>(cmd, ta)) {
|
||||
if (StationJoinerNeeded<T>(ta, proc)) {
|
||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
new SelectStationWindow<T>(&_select_station_desc, cmd, ta);
|
||||
new SelectStationWindow<T>(&_select_station_desc, ta, std::move(proc));
|
||||
} else {
|
||||
DoCommandP(&cmd);
|
||||
proc(false, INVALID_STATION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the station selection window when needed. If not, build the station.
|
||||
* @param cmd Command to build the station.
|
||||
* @param ta Area to build the station in
|
||||
* @param proc Function called to execute the build command.
|
||||
*/
|
||||
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
|
||||
{
|
||||
ShowSelectBaseStationIfNeeded<Station>(cmd, ta);
|
||||
ShowSelectBaseStationIfNeeded<Station>(ta, std::move(proc));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the waypoint selection window when needed. If not, build the waypoint.
|
||||
* @param cmd Command to build the waypoint.
|
||||
* @param ta Area to build the waypoint in
|
||||
* @param proc Function called to execute the build command.
|
||||
*/
|
||||
void ShowSelectWaypointIfNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
|
||||
{
|
||||
ShowSelectBaseStationIfNeeded<Waypoint>(cmd, ta);
|
||||
ShowSelectBaseStationIfNeeded<Waypoint>(ta, std::move(proc));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user