Update from KeldorKatarn branch
This approximately corresponds to 971ba4928a5c7c7916fea55d91a3b6dd5bba140c, excluding the different virtual train build GUI, but including the basic changes to the original train build GUI for multiplayer to work. Fixup
This commit is contained in:
@@ -43,9 +43,10 @@ uint16 TRAIN_FRONT_SPACE = 16;
|
||||
|
||||
enum TemplateReplaceWindowWidgets {
|
||||
TCW_CAPTION,
|
||||
TCW_MATRIX_NEW_TMPL,
|
||||
TCW_NEW_TMPL_PANEL,
|
||||
TCW_INFO_PANEL,
|
||||
TCW_SCROLLBAR_NEW_TMPL,
|
||||
TCW_SCROLLBAR_H_NEW_TMPL,
|
||||
TCW_SCROLLBAR_V_NEW_TMPL,
|
||||
TCW_SELL_TMPL,
|
||||
TCW_NEW,
|
||||
TCW_OK,
|
||||
@@ -59,23 +60,25 @@ static const NWidgetPart _widgets[] = {
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, TCW_CAPTION), SetDataTip(STR_TMPL_CREATEGUI_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, TCW_MATRIX_NEW_TMPL), SetMinimalSize(216, 60), SetFill(1, 0), SetDataTip(0x1, STR_REPLACE_HELP_LEFT_ARRAY), SetResize(1, 0), SetScrollbar(TCW_SCROLLBAR_NEW_TMPL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, TCW_INFO_PANEL), SetMinimalSize(216,80), SetResize(1,1), EndContainer(),
|
||||
NWidget(NWID_HSCROLLBAR, COLOUR_GREY, TCW_SCROLLBAR_NEW_TMPL), SetResize(1,0),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, TCW_NEW_TMPL_PANEL), SetMinimalSize(250, 30), SetResize(1, 0), SetScrollbar(TCW_SCROLLBAR_H_NEW_TMPL), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, TCW_INFO_PANEL), SetMinimalSize(250, 100), SetResize(1, 1), SetScrollbar(TCW_SCROLLBAR_V_NEW_TMPL), EndContainer(),
|
||||
NWidget(NWID_HSCROLLBAR, COLOUR_GREY, TCW_SCROLLBAR_H_NEW_TMPL),
|
||||
EndContainer(),
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, TCW_SELL_TMPL), SetDataTip(0x0, STR_NULL), SetMinimalSize(23,23), SetResize(0, 1), SetFill(0, 1),
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, TCW_SELL_TMPL), SetMinimalSize(40, 40), SetDataTip(0x0, STR_NULL), SetResize(0, 1), SetFill(0, 1),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, TCW_SCROLLBAR_V_NEW_TMPL),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_OK), SetMinimalSize(52, 12), SetResize(1,0), SetDataTip(STR_TMPL_CONFIRM, STR_TMPL_CONFIRM),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_NEW), SetMinimalSize(52, 12), SetResize(1,0), SetDataTip(STR_TMPL_NEW, STR_TMPL_NEW),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, TCW_CLONE), SetMinimalSize(52, 12), SetResize(1,0), SetDataTip(STR_TMPL_CREATE_CLONE_VEH, STR_TMPL_CREATE_CLONE_VEH),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_REFIT), SetMinimalSize(52, 12), SetResize(1,0), SetDataTip(STR_TMPL_REFIT, STR_TMPL_REFIT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_CANCEL), SetMinimalSize(52, 12), SetResize(1,0), SetDataTip(STR_TMPL_CANCEL, STR_TMPL_CANCEL),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_OK), SetMinimalSize(52, 12), SetResize(1, 0), SetDataTip(STR_TMPL_CONFIRM, STR_TMPL_CONFIRM),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_NEW), SetMinimalSize(52, 12), SetResize(1, 0), SetDataTip(STR_TMPL_NEW, STR_TMPL_NEW),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, TCW_CLONE), SetMinimalSize(52, 12), SetResize(1, 0), SetDataTip(STR_TMPL_CREATE_CLONE_VEH, STR_TMPL_CREATE_CLONE_VEH),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_REFIT), SetMinimalSize(52, 12), SetResize(1, 0), SetDataTip(STR_TMPL_REFIT, STR_TMPL_REFIT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, TCW_CANCEL), SetMinimalSize(52, 12), SetResize(1, 0), SetDataTip(STR_TMPL_CANCEL, STR_TMPL_CANCEL),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
@@ -84,7 +87,7 @@ static WindowDesc _template_create_window_desc(
|
||||
"template create window", // const char* ini_key
|
||||
456, 100, // window size
|
||||
WC_CREATE_TEMPLATE, // window class
|
||||
WC_TEMPLATEGUI_MAIN, // parent window class
|
||||
WC_NONE, // parent window class
|
||||
WDF_CONSTRUCTION, // window flags
|
||||
_widgets, lengthof(_widgets) // widgets + num widgets
|
||||
);
|
||||
@@ -104,12 +107,13 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
|
||||
|
||||
if (wagon == v) return;
|
||||
|
||||
CmdMoveRailVehicle(INVALID_TILE, DC_EXEC, (_ctrl_pressed ? 1:0)<<20 | (1<<21) | v->index, wagon == NULL ? INVALID_VEHICLE : wagon->index, 0);
|
||||
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20 | 1 << 21, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE), CcVirtualTrainWaggonsMoved);
|
||||
}
|
||||
|
||||
class TemplateCreateWindow : public Window {
|
||||
private:
|
||||
Scrollbar *hscroll;
|
||||
Scrollbar *vscroll;
|
||||
int line_height;
|
||||
Train* virtual_train;
|
||||
bool editMode;
|
||||
@@ -124,8 +128,9 @@ public:
|
||||
TemplateCreateWindow(WindowDesc* _wdesc, TemplateVehicle *to_edit, bool *notice, bool *windowOpen, int step_h) : Window(_wdesc)
|
||||
{
|
||||
this->line_height = step_h;
|
||||
this->CreateNestedTree(_wdesc);
|
||||
this->hscroll = this->GetScrollbar(TCW_SCROLLBAR_NEW_TMPL);
|
||||
this->CreateNestedTree(_wdesc != NULL);
|
||||
this->hscroll = this->GetScrollbar(TCW_SCROLLBAR_H_NEW_TMPL);
|
||||
this->vscroll = this->GetScrollbar(TCW_SCROLLBAR_V_NEW_TMPL);
|
||||
this->FinishInitNested(VEH_TRAIN);
|
||||
/* a sprite */
|
||||
this->GetWidget<NWidgetCore>(TCW_SELL_TMPL)->widget_data = SPR_SELL_TRAIN;
|
||||
@@ -137,20 +142,25 @@ public:
|
||||
virtualTrainChangedNotice = false;
|
||||
this->editTemplate = to_edit;
|
||||
|
||||
if ( to_edit ) editMode = true;
|
||||
if (to_edit) editMode = true;
|
||||
else editMode = false;
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
|
||||
this->virtual_train = VirtualTrainFromTemplateVehicle(to_edit);
|
||||
if (to_edit) {
|
||||
DoCommandP(0, to_edit->index, 0, CMD_VIRTUAL_TRAIN_FROM_TEMPLATE_VEHICLE, CcSetVirtualTrain);
|
||||
}
|
||||
|
||||
this->resize.step_height = 1;
|
||||
}
|
||||
|
||||
~TemplateCreateWindow()
|
||||
{
|
||||
if ( virtual_train )
|
||||
delete virtual_train;
|
||||
if (virtual_train != nullptr) {
|
||||
DoCommandP(0, virtual_train->index, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
||||
virtual_train = nullptr;
|
||||
}
|
||||
|
||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||
|
||||
@@ -160,19 +170,22 @@ public:
|
||||
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void SetVirtualTrain(Train* const train)
|
||||
{
|
||||
switch (widget) {
|
||||
case TCW_MATRIX_NEW_TMPL:
|
||||
size->height = 20;
|
||||
break;
|
||||
if (virtual_train != nullptr) {
|
||||
DoCommandP(0, virtual_train->index, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
||||
}
|
||||
|
||||
virtual_train = train;
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
{
|
||||
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(TCW_MATRIX_NEW_TMPL);
|
||||
this->hscroll->SetCapacity(nwi->current_x);
|
||||
nwi->widget_data = (this->hscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
NWidgetCore *template_panel = this->GetWidget<NWidgetCore>(TCW_NEW_TMPL_PANEL);
|
||||
this->hscroll->SetCapacity(template_panel->current_x);
|
||||
|
||||
NWidgetCore *info_panel = this->GetWidget<NWidgetCore>(TCW_INFO_PANEL);
|
||||
this->vscroll->SetCapacity(info_panel->current_y);
|
||||
}
|
||||
|
||||
|
||||
@@ -180,12 +193,13 @@ public:
|
||||
{
|
||||
virtualTrainChangedNotice = true;
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
{
|
||||
switch(widget) {
|
||||
case TCW_MATRIX_NEW_TMPL: {
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(TCW_MATRIX_NEW_TMPL);
|
||||
ClickedOnVehiclePanel(pt.x - nwi->pos_x-TRAIN_FRONT_SPACE, pt.y - nwi->pos_y);
|
||||
case TCW_NEW_TMPL_PANEL: {
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(TCW_NEW_TMPL_PANEL);
|
||||
ClickedOnVehiclePanel(pt.x - nwi->pos_x, pt.y - nwi->pos_y);
|
||||
break;
|
||||
}
|
||||
case TCW_NEW: {
|
||||
@@ -204,10 +218,14 @@ public:
|
||||
break;
|
||||
}
|
||||
case TCW_OK: {
|
||||
TemplateVehicle *tv = NULL;
|
||||
if ( editMode ) tv = DeleteTemplateVehicle(editTemplate);
|
||||
editTemplate = TemplateVehicleFromVirtualTrain(virtual_train);
|
||||
if ( tv ) *noticeParent = true;
|
||||
uint32 templateIndex = (editTemplate != nullptr) ? editTemplate->index : INVALID_VEHICLE;
|
||||
|
||||
if (virtual_train != nullptr) {
|
||||
DoCommandP(0, templateIndex, virtual_train->index, CMD_REPLACE_TEMPLATE_VEHICLE);
|
||||
virtual_train = nullptr;
|
||||
} else if (templateIndex != INVALID_VEHICLE) {
|
||||
DoCommandP(0, templateIndex, 0, CMD_DELETE_TEMPLATE_VEHICLE);
|
||||
}
|
||||
delete this;
|
||||
break;
|
||||
}
|
||||
@@ -221,25 +239,30 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool OnVehicleSelect(const Vehicle *v)
|
||||
{
|
||||
// throw away the current virtual train
|
||||
if ( virtual_train )
|
||||
delete this->virtual_train;
|
||||
if (virtual_train != nullptr) {
|
||||
DoCommandP(0, virtual_train->index, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
||||
virtual_train = nullptr;
|
||||
}
|
||||
|
||||
// create a new one
|
||||
this->virtual_train = CloneVirtualTrainFromTrain((const Train*)v);
|
||||
DoCommandP(0, v->index, 0, CMD_VIRTUAL_TRAIN_FROM_TRAIN, CcSetVirtualTrain);
|
||||
this->ToggleWidgetLoweredState(TCW_CLONE);
|
||||
ResetObjectToPlace();
|
||||
this->SetDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
switch(widget) {
|
||||
case TCW_MATRIX_NEW_TMPL: {
|
||||
case TCW_NEW_TMPL_PANEL: {
|
||||
if ( this->virtual_train ) {
|
||||
DrawTrainImage(virtual_train, r.left+TRAIN_FRONT_SPACE, r.right, r.top+2, this->sel, EIT_PURCHASE, this->hscroll->GetPosition(), this->vehicle_over);
|
||||
DrawTrainImage(virtual_train, r.left+TRAIN_FRONT_SPACE, r.right-25, r.top+2, this->sel, EIT_PURCHASE, this->hscroll->GetPosition(), this->vehicle_over);
|
||||
SetDParam(0, CeilDiv(virtual_train->gcache.cached_total_length * 10, TILE_SIZE));
|
||||
SetDParam(1, 1);
|
||||
DrawString(r.left, r.right, r.top, STR_TINY_BLACK_DECIMAL, TC_BLACK, SA_RIGHT);
|
||||
@@ -248,27 +271,36 @@ public:
|
||||
}
|
||||
case TCW_INFO_PANEL: {
|
||||
if ( this->virtual_train ) {
|
||||
DrawPixelInfo tmp_dpi, *old_dpi;
|
||||
|
||||
if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left, r.bottom - r.top)) break;
|
||||
|
||||
old_dpi = _cur_dpi;
|
||||
_cur_dpi = &tmp_dpi;
|
||||
|
||||
/* Draw vehicle performance info */
|
||||
const GroundVehicleCache *gcache = this->virtual_train->GetGroundVehicleCache();
|
||||
SetDParam(2, this->virtual_train->GetDisplayMaxSpeed());
|
||||
SetDParam(1, gcache->cached_power);
|
||||
SetDParam(0, gcache->cached_weight);
|
||||
SetDParam(3, gcache->cached_max_te / 1000);
|
||||
DrawString(r.left+8, r.right, r.top+4, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
|
||||
DrawString(8, r.right, 4 - this->vscroll->GetPosition(), STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
|
||||
/* Draw cargo summary */
|
||||
CargoArray cargo_caps;
|
||||
for ( const Train *tmp=this->virtual_train; tmp; tmp=tmp->Next() )
|
||||
cargo_caps[tmp->cargo_type] += tmp->cargo_cap;
|
||||
int y = r.top+24;
|
||||
int y = 30 - this->vscroll->GetPosition();
|
||||
for (CargoID i = 0; i < NUM_CARGO; ++i) {
|
||||
if ( cargo_caps[i] > 0 ) {
|
||||
SetDParam(0, i);
|
||||
SetDParam(1, cargo_caps[i]);
|
||||
SetDParam(2, _settings_game.vehicle.freight_trains);
|
||||
DrawString(r.left+8, r.right, y, STR_TMPL_CARGO_SUMMARY, TC_WHITE, SA_LEFT);
|
||||
y += this->line_height/2;
|
||||
DrawString(8, r.right, y, STR_TMPL_CARGO_SUMMARY, TC_LIGHT_BLUE, SA_LEFT);
|
||||
y += this->line_height/3;
|
||||
}
|
||||
}
|
||||
|
||||
_cur_dpi = old_dpi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -278,7 +310,7 @@ public:
|
||||
}
|
||||
virtual void OnTick()
|
||||
{
|
||||
if ( virtualTrainChangedNotice ) {
|
||||
if (virtualTrainChangedNotice) {
|
||||
this->SetDirty();
|
||||
virtualTrainChangedNotice = false;
|
||||
}
|
||||
@@ -286,22 +318,20 @@ public:
|
||||
virtual void OnDragDrop(Point pt, int widget)
|
||||
{
|
||||
switch (widget) {
|
||||
case TCW_MATRIX_NEW_TMPL: {
|
||||
case TCW_NEW_TMPL_PANEL: {
|
||||
const Vehicle *v = NULL;
|
||||
VehicleID sel;
|
||||
if ( virtual_train ) sel = virtual_train->index;
|
||||
else sel = INVALID_VEHICLE;
|
||||
VehicleID sel = this->sel;
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->SetDirty();
|
||||
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(TCW_MATRIX_NEW_TMPL);
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(TCW_NEW_TMPL_PANEL);
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
|
||||
if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) {
|
||||
if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
|
||||
virtual_train = virtual_train->First();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -310,7 +340,14 @@ public:
|
||||
if (this->IsWidgetDisabled(widget)) return;
|
||||
if (this->sel == INVALID_VEHICLE) return;
|
||||
|
||||
virtual_train = DeleteVirtualTrain(virtual_train, Train::Get(this->sel));
|
||||
int sell_cmd = (_ctrl_pressed) ? 1 : 0;
|
||||
|
||||
Train* train_to_delete = Train::Get(this->sel);
|
||||
|
||||
if (virtual_train == train_to_delete)
|
||||
virtual_train = (_ctrl_pressed) ? nullptr : virtual_train->GetNextUnit();
|
||||
|
||||
DoCommandP(0, this->sel | sell_cmd << 20 | 1 << 21, 0, GetCmdSellVeh(VEH_TRAIN));
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
|
||||
@@ -325,14 +362,15 @@ public:
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
virtual void OnMouseDrag(Point pt, int widget)
|
||||
{
|
||||
if (this->sel == INVALID_VEHICLE) return;
|
||||
/* A rail vehicle is dragged.. */
|
||||
if (widget != TCW_MATRIX_NEW_TMPL) { // ..outside of the depot matrix.
|
||||
if (widget != TCW_NEW_TMPL_PANEL) { // ..outside of the depot matrix.
|
||||
if (this->vehicle_over != INVALID_VEHICLE) {
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
this->SetWidgetDirty(TCW_MATRIX_NEW_TMPL);
|
||||
this->SetWidgetDirty(TCW_NEW_TMPL_PANEL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -361,16 +399,33 @@ public:
|
||||
this->vehicle_over = new_vehicle_over;
|
||||
this->SetWidgetDirty(widget);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
{
|
||||
uint max_width = 32;
|
||||
uint min_width = 32;
|
||||
uint min_height = 30;
|
||||
uint width = 0;
|
||||
if ( virtual_train )
|
||||
for (Train *v = virtual_train; v != NULL; v = v->Next())
|
||||
width += v->GetDisplayImageWidth();
|
||||
uint height = 30;
|
||||
CargoArray cargo_caps;
|
||||
|
||||
max_width = max(max_width, width);
|
||||
this->hscroll->SetCount(max_width+25);
|
||||
if (virtual_train != nullptr) {
|
||||
for (Train *train = virtual_train; train != nullptr; train = train->Next()) {
|
||||
width += train->GetDisplayImageWidth();
|
||||
cargo_caps[train->cargo_type] += train->cargo_cap;
|
||||
}
|
||||
|
||||
for (CargoID i = 0; i < NUM_CARGO; ++i) {
|
||||
if ( cargo_caps[i] > 0 ) {
|
||||
height += this->line_height/3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
min_width = max(min_width, width);
|
||||
this->hscroll->SetCount(min_width + 50);
|
||||
|
||||
min_height = max(min_height, height);
|
||||
this->vscroll->SetCount(min_height);
|
||||
|
||||
this->DrawWidgets();
|
||||
}
|
||||
@@ -388,11 +443,14 @@ public:
|
||||
|
||||
uint count_width;
|
||||
uint header_width;
|
||||
DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
|
||||
|
||||
DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
|
||||
{
|
||||
const NWidgetCore *matrix_widget = this->GetWidget<NWidgetCore>(TCW_MATRIX_NEW_TMPL);
|
||||
const NWidgetCore *matrix_widget = this->GetWidget<NWidgetCore>(TCW_NEW_TMPL_PANEL);
|
||||
/* In case of RTL the widgets are swapped as a whole */
|
||||
if (_current_text_dir == TD_RTL) x = matrix_widget->current_x - x;
|
||||
|
||||
x -= TRAIN_FRONT_SPACE;
|
||||
|
||||
uint xm = x;
|
||||
|
||||
@@ -436,6 +494,7 @@ public:
|
||||
|
||||
if (sel != INVALID_VEHICLE) {
|
||||
this->sel = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||
} else if (v != NULL) {
|
||||
int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_PURCHASE);
|
||||
SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
|
||||
@@ -448,6 +507,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void RearrangeVirtualTrain()
|
||||
{
|
||||
virtual_train = virtual_train->First();
|
||||
}
|
||||
};
|
||||
|
||||
void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *noticeParent, bool *createWindowOpen, int step_h)
|
||||
@@ -456,4 +519,31 @@ void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *noticeParent, bool
|
||||
new TemplateCreateWindow(&_template_create_window_desc, to_edit, noticeParent, createWindowOpen, step_h);
|
||||
}
|
||||
|
||||
void CcSetVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
Window* window = FindWindowById(WC_CREATE_TEMPLATE, 0);
|
||||
if (window) {
|
||||
Train* train = Train::From(Vehicle::Get(_new_vehicle_id));
|
||||
((TemplateCreateWindow*)window)->SetVirtualTrain(train);
|
||||
window->InvalidateData();
|
||||
}
|
||||
}
|
||||
|
||||
void CcVirtualTrainWaggonsMoved(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
Window* window = FindWindowById(WC_CREATE_TEMPLATE, 0);
|
||||
if (window) {
|
||||
((TemplateCreateWindow*)window)->RearrangeVirtualTrain();
|
||||
window->InvalidateData();
|
||||
}
|
||||
}
|
||||
|
||||
void CcDeleteVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
VehicleID virtual_train_id = p2;
|
||||
DoCommandP(0, virtual_train_id, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
||||
}
|
Reference in New Issue
Block a user