|
@@ -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;
|
|
|
|