Changeset - r25967:74951d8178de
[Not reviewed]
master
0 3 0
Bernard Teo - 3 years ago 2021-05-31 09:02:21
btzy1996@hotmail.com
Feature: Button to open order window from VL_SHARED_ORDERS window
3 files changed with 33 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -316,24 +316,28 @@ STR_SORT_BY_RANGE                       
 
STR_SORT_BY_POPULATION                                          :Population
 
STR_SORT_BY_RATING                                              :Rating
 
STR_SORT_BY_NUM_VEHICLES                                        :Number of vehicles
 
STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR                              :Total profit last year
 
STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR                              :Total profit this year
 
STR_SORT_BY_AVERAGE_PROFIT_LAST_YEAR                            :Average profit last year
 
STR_SORT_BY_AVERAGE_PROFIT_THIS_YEAR                            :Average profit this year
 

	
 
# Group by options for vehicle list
 
STR_GROUP_BY_NONE                                               :None
 
STR_GROUP_BY_SHARED_ORDERS                                      :Shared orders
 

	
 
# Order button in shared orders vehicle list
 
STR_GOTO_ORDER_VIEW                                             :{BLACK}Orders
 
STR_GOTO_ORDER_VIEW_TOOLTIP                                     :{BLACK}Open the order view
 

	
 
# Tooltips for the main toolbar
 
###length 31
 
STR_TOOLBAR_TOOLTIP_PAUSE_GAME                                  :{BLACK}Pause game
 
STR_TOOLBAR_TOOLTIP_FORWARD                                     :{BLACK}Fast forward the game
 
STR_TOOLBAR_TOOLTIP_OPTIONS                                     :{BLACK}Options
 
STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME                      :{BLACK}Save game, abandon game, exit
 
STR_TOOLBAR_TOOLTIP_DISPLAY_MAP                                 :{BLACK}Display map, extra viewport or list of signs
 
STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY                      :{BLACK}Display town directory
 
STR_TOOLBAR_TOOLTIP_DISPLAY_SUBSIDIES                           :{BLACK}Display subsidies
 
STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_STATIONS            :{BLACK}Display list of company's stations
 
STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_FINANCES                    :{BLACK}Display company finances information
 
STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_GENERAL                     :{BLACK}Display general company information
src/vehicle_gui.cpp
Show inline comments
 
@@ -1358,25 +1358,31 @@ static inline void ChangeVehicleWindow(W
 
void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index)
 
{
 
	ChangeVehicleWindow(WC_VEHICLE_VIEW,      from_index, to_index);
 
	ChangeVehicleWindow(WC_VEHICLE_ORDERS,    from_index, to_index);
 
	ChangeVehicleWindow(WC_VEHICLE_REFIT,     from_index, to_index);
 
	ChangeVehicleWindow(WC_VEHICLE_DETAILS,   from_index, to_index);
 
	ChangeVehicleWindow(WC_VEHICLE_TIMETABLE, from_index, to_index);
 
}
 

	
 
static const NWidgetPart _nested_vehicle_list[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_VL_CAPTION),
 
		NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_CAPTION_SELECTION),
 
			NWidget(WWT_CAPTION, COLOUR_GREY, WID_VL_CAPTION),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_CAPTION, COLOUR_GREY, WID_VL_CAPTION_SHARED_ORDERS),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VL_ORDER_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_GOTO_ORDER_VIEW, STR_GOTO_ORDER_VIEW_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 

	
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_VL_GROUP_ORDER), SetMinimalSize(81, 12), SetFill(0, 1), SetDataTip(STR_STATION_VIEW_GROUP, STR_TOOLTIP_GROUP_ORDER),
 
		NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VL_GROUP_BY_PULLDOWN), SetMinimalSize(167, 12), SetFill(0, 1), SetDataTip(0x0, STR_TOOLTIP_GROUP_ORDER),
 
		NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(12, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
 
	EndContainer(),
 

	
 
	NWidget(NWID_HORIZONTAL),
 
@@ -1633,45 +1639,54 @@ void BaseVehicleListWindow::UpdateVehicl
 
 * 8-10 window type (use flags in vehicle_gui.h)
 
 * 11-15 vehicle type (using VEH_, but can be compressed to fewer bytes if needed)
 
 * 16-31 StationID or OrderID depending on window type (bit 8-10)
 
 */
 
struct VehicleListWindow : public BaseVehicleListWindow {
 
private:
 
	/** Enumeration of planes of the button row at the bottom. */
 
	enum ButtonPlanes {
 
		BP_SHOW_BUTTONS, ///< Show the buttons.
 
		BP_HIDE_BUTTONS, ///< Show the empty panel.
 
	};
 

	
 
	/** Enumeration of planes of the title row at the top. */
 
	enum CaptionPlanes {
 
		BP_NORMAL,        ///< Show shared orders caption and buttons.
 
		BP_SHARED_ORDERS, ///< Show the normal caption.
 
	};
 

	
 
public:
 
	VehicleListWindow(WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
 
	{
 
		this->CreateNestedTree();
 

	
 
		this->vscroll = this->GetScrollbar(WID_VL_SCROLLBAR);
 

	
 
		this->BuildVehicleList();
 
		this->SortVehicleList();
 

	
 
		/* Set up the window widgets */
 
		this->GetWidget<NWidgetCore>(WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype;
 

	
 
		NWidgetStacked *nwi = this->GetWidget<NWidgetStacked>(WID_VL_CAPTION_SELECTION);
 
		if (this->vli.type == VL_SHARED_ORDERS) {
 
			this->GetWidget<NWidgetCore>(WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
 
			this->GetWidget<NWidgetCore>(WID_VL_CAPTION_SHARED_ORDERS)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
 
			/* If we are in the shared orders window, then disable the group-by dropdown menu.
 
			 * Remove this when the group-by dropdown menu has another option apart from grouping by shared orders. */
 
			this->SetWidgetDisabledState(WID_VL_GROUP_ORDER, true);
 
			this->SetWidgetDisabledState(WID_VL_GROUP_BY_PULLDOWN, true);
 
			nwi->SetDisplayedPlane(BP_SHARED_ORDERS);
 
		} else {
 
			this->GetWidget<NWidgetCore>(WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype;
 
			nwi->SetDisplayedPlane(BP_NORMAL);
 
		}
 

	
 
		this->FinishInitNested(window_number);
 
		if (this->vli.company != OWNER_NONE) this->owner = this->vli.company;
 
	}
 

	
 
	~VehicleListWindow()
 
	{
 
		*this->sorting = this->vehgroups.GetListing();
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
@@ -1709,25 +1724,26 @@ public:
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_VL_AVAILABLE_VEHICLES:
 
				SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
 
				break;
 

	
 
			case WID_VL_CAPTION: {
 
			case WID_VL_CAPTION:
 
			case WID_VL_CAPTION_SHARED_ORDERS: {
 
				switch (this->vli.type) {
 
					case VL_SHARED_ORDERS: // Shared Orders
 
						if (this->vehicles.size() == 0) {
 
							/* We can't open this window without vehicles using this order
 
							 * and we should close the window when deleting the order. */
 
							NOT_REACHED();
 
						}
 
						SetDParam(0, this->vehicles.size());
 
						break;
 

	
 
					case VL_STANDARD: // Company Name
 
						SetDParam(0, STR_COMPANY_NAME);
 
@@ -1797,24 +1813,30 @@ public:
 
		/* Set text of group by dropdown widget. */
 
		this->GetWidget<NWidgetCore>(WID_VL_GROUP_BY_PULLDOWN)->widget_data = this->vehicle_group_by_names[this->grouping];
 

	
 
		/* Set text of sort by dropdown widget. */
 
		this->GetWidget<NWidgetCore>(WID_VL_SORT_BY_PULLDOWN)->widget_data = this->GetVehicleSorterNames()[this->vehgroups.SortType()];
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
		    case WID_VL_ORDER_VIEW: // Open the shared orders window
 
				assert(this->vli.type == VL_SHARED_ORDERS);
 
				assert(!this->vehicles.empty());
 
				ShowOrdersWindow(this->vehicles[0]);
 
				break;
 

	
 
			case WID_VL_SORT_ORDER: // Flip sorting method ascending/descending
 
				this->vehgroups.ToggleSortOrder();
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_VL_GROUP_BY_PULLDOWN: // Select sorting criteria dropdown menu
 
				ShowDropDownMenu(this, this->vehicle_group_by_names, this->grouping, WID_VL_GROUP_BY_PULLDOWN, 0, 0);
 
				return;
 

	
 
			case WID_VL_SORT_BY_PULLDOWN: // Select sorting criteria dropdown menu
 
				ShowDropDownMenu(this, this->GetVehicleSorterNames(), this->vehgroups.SortType(), WID_VL_SORT_BY_PULLDOWN, 0,
 
						(this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10));
src/widgets/vehicle_widget.h
Show inline comments
 
@@ -52,25 +52,28 @@ enum VehicleDetailsWidgets {
 
	WID_VD_SERVICING_INTERVAL,          ///< Information about the servicing interval.
 
	WID_VD_MIDDLE_DETAILS,              ///< Details for non-trains.
 
	WID_VD_MATRIX,                      ///< List of details for trains.
 
	WID_VD_SCROLLBAR,                   ///< Scrollbar for train details.
 
	WID_VD_DETAILS_CARGO_CARRIED,       ///< Show carried cargo per part of the train.
 
	WID_VD_DETAILS_TRAIN_VEHICLES,      ///< Show all parts of the train with their description.
 
	WID_VD_DETAILS_CAPACITY_OF_EACH,    ///< Show the capacity of all train parts.
 
	WID_VD_DETAILS_TOTAL_CARGO,         ///< Show the capacity and carried cargo amounts aggregated per cargo of the train.
 
};
 

	
 
/** Widgets of the #VehicleListWindow class. */
 
enum VehicleListWidgets {
 
	WID_VL_CAPTION,                  ///< Caption of window.
 
	WID_VL_CAPTION,                  ///< Caption of window (for non shared orders windows).
 
	WID_VL_CAPTION_SHARED_ORDERS,    ///< Caption of window (for shared orders windows).
 
	WID_VL_CAPTION_SELECTION,        ///< Selection for caption.
 
	WID_VL_ORDER_VIEW,               ///< Button to open order window (for shared orders windows).
 
	WID_VL_GROUP_ORDER,              ///< Group order.
 
	WID_VL_GROUP_BY_PULLDOWN,        ///< Group by dropdown list.
 
	WID_VL_SORT_ORDER,               ///< Sort order.
 
	WID_VL_SORT_BY_PULLDOWN,         ///< Sort by dropdown list.
 
	WID_VL_LIST,                     ///< List of the vehicles.
 
	WID_VL_SCROLLBAR,                ///< Scrollbar for the list.
 
	WID_VL_HIDE_BUTTONS,             ///< Selection to hide the buttons.
 
	WID_VL_AVAILABLE_VEHICLES,       ///< Available vehicles.
 
	WID_VL_MANAGE_VEHICLES_DROPDOWN, ///< Manage vehicles dropdown list.
 
	WID_VL_STOP_ALL,                 ///< Stop all button.
 
	WID_VL_START_ALL,                ///< Start all button.
 
};
0 comments (0 inline, 0 general)