Changeset - r25966:8233c136b1b0
[Not reviewed]
master
0 2 0
Bernard Teo - 3 years ago 2021-05-31 07:59:17
btzy1996@hotmail.com
Feature: Ctrl-Clicking GB_SHARED_ORDERS vehicle list opens order window
2 files changed with 19 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/group_gui.cpp
Show inline comments
 
@@ -3,48 +3,49 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file group_gui.cpp GUI for the group window. */
 

	
 
#include "stdafx.h"
 
#include "textbuf_gui.h"
 
#include "command_func.h"
 
#include "vehicle_gui.h"
 
#include "vehicle_base.h"
 
#include "string_func.h"
 
#include "strings_func.h"
 
#include "window_func.h"
 
#include "vehicle_func.h"
 
#include "autoreplace_gui.h"
 
#include "company_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "tilehighlight_func.h"
 
#include "vehicle_gui_base.h"
 
#include "core/geometry_func.hpp"
 
#include "company_base.h"
 
#include "company_gui.h"
 
#include "gui.h"
 

	
 
#include "widgets/group_widget.h"
 

	
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels
 

	
 
typedef GUIList<const Group*> GUIGroupList;
 

	
 
static const NWidgetPart _nested_group_widgets[] = {
 
	NWidget(NWID_HORIZONTAL), // Window header
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_GL_CAPTION),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		/* left part */
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_ALL_VEHICLES), SetFill(1, 0), EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_DEFAULT_VEHICLES), SetFill(1, 0), EndContainer(),
 
@@ -724,59 +725,61 @@ public:
 
				const Vehicle *v = nullptr;
 

	
 
				switch (this->grouping) {
 
					case GB_NONE: {
 
						const Vehicle *v2 = vehgroup.GetSingleVehicle();
 
						if (VehicleClicked(v2)) break;
 
						v = v2;
 
						break;
 
					}
 

	
 
					case GB_SHARED_ORDERS: {
 
						assert(vehgroup.NumVehicles() > 0);
 
						v = vehgroup.vehicles_begin[0];
 
						/*
 
						 * No VehicleClicked(v) support for now, because don't want
 
						 * to enable any contextual actions except perhaps clicking/ctrl-clicking to clone orders.
 
						 */
 
						break;
 
					}
 

	
 
					default:
 
						NOT_REACHED();
 
				}
 
				if (v) {
 
					this->vehicle_sel = v->index;
 

	
 
					if (_ctrl_pressed) {
 
						this->SelectGroup(v->group_id);
 
						if (this->grouping == GB_NONE) {
 
							this->SelectGroup(v->group_id);
 
						} else {
 
							ShowOrdersWindow(v);
 
						}
 
					} else {
 
						this->vehicle_sel = v->index;
 
						SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
 
						SetMouseCursorVehicle(v, EIT_IN_LIST);
 
						_cursor.vehchain = true;
 
						this->SetDirty();
 
					}
 

	
 
					SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
 
					SetMouseCursorVehicle(v, EIT_IN_LIST);
 
					_cursor.vehchain = true;
 

	
 
					this->SetDirty();
 
				}
 

	
 
				break;
 
			}
 

	
 
			case WID_GL_CREATE_GROUP: { // Create a new group
 
				DoCommandP(0, this->vli.vtype, this->vli.index, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
 
				break;
 
			}
 

	
 
			case WID_GL_DELETE_GROUP: { // Delete the selected group
 
				this->group_confirm = this->vli.index;
 
				ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT, this, DeleteGroupCallback);
 
				break;
 
			}
 

	
 
			case WID_GL_RENAME_GROUP: // Rename the selected roup
 
				this->ShowRenameGroupWindow(this->vli.index, false);
 
				break;
 

	
 
			case WID_GL_LIVERY_GROUP: // Set group livery
 
				ShowCompanyLiveryWindow(this->owner, this->vli.index);
 
				break;
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -1822,52 +1822,56 @@ public:
 

	
 
			case WID_VL_LIST: { // Matrix to show vehicles
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST);
 
				if (id_v >= this->vehgroups.size()) return; // click out of list bound
 

	
 
				const GUIVehicleGroup &vehgroup = this->vehgroups[id_v];
 
				switch (this->grouping) {
 
					case GB_NONE: {
 
						const Vehicle *v = vehgroup.GetSingleVehicle();
 
						if (!VehicleClicked(v)) {
 
							if (_ctrl_pressed) {
 
								ShowCompanyGroupForVehicle(v);
 
							} else {
 
								ShowVehicleViewWindow(v);
 
							}
 
						}
 
						break;
 
					}
 

	
 
					case GB_SHARED_ORDERS: {
 
						assert(vehgroup.NumVehicles() > 0);
 
						const Vehicle *v = vehgroup.vehicles_begin[0];
 
						/* We do not support VehicleClicked() here since the contextual action may only make sense for individual vehicles */
 

	
 
						if (vehgroup.NumVehicles() == 1) {
 
							ShowVehicleViewWindow(v);
 
						if (_ctrl_pressed) {
 
							ShowOrdersWindow(v);
 
						} else {
 
							ShowVehicleListWindow(v);
 
							if (vehgroup.NumVehicles() == 1) {
 
								ShowVehicleViewWindow(v);
 
							} else {
 
								ShowVehicleListWindow(v);
 
							}
 
						}
 
						break;
 
					}
 

	
 
					default: NOT_REACHED();
 
				}
 

	
 
				break;
 
			}
 

	
 
			case WID_VL_AVAILABLE_VEHICLES:
 
				ShowBuildVehicleWindow(INVALID_TILE, this->vli.vtype);
 
				break;
 

	
 
			case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
 
				ShowDropDownList(this, this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false), 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
 
				break;
 
			}
 

	
 
			case WID_VL_STOP_ALL:
 
			case WID_VL_START_ALL:
 
				DoCommandP(0, (1 << 1) | (widget == WID_VL_START_ALL ? (1 << 0) : 0), this->window_number, CMD_MASS_START_STOP);
 
				break;
 
		}
0 comments (0 inline, 0 general)