TBTR: Delete duplicated build vehicle window.

Add a virtual train mode to the existing build vehicle window.
Simplify some of the inter-window notify logic.
Disable all buttons when a new template/edit is in progress.
This commit is contained in:
Jonathan G Rennison
2016-02-15 18:54:37 +00:00
parent 9132707eb9
commit 98fc4493c8
14 changed files with 95 additions and 947 deletions

View File

@@ -104,6 +104,8 @@ static WindowDesc _template_create_window_desc(
_widgets, lengthof(_widgets) // widgets + num widgets
);
void ShowTemplateTrainBuildVehicleWindow(Train **virtual_train);
static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
{
const Vehicle *v = Vehicle::Get(sel);
@@ -130,15 +132,13 @@ private:
int line_height;
Train* virtual_train;
bool editMode;
bool *noticeParent;
bool *createWindowOpen; /// used to notify main window of progress (dummy way of disabling 'delete' while editing a template)
bool virtualTrainChangedNotice;
VehicleID sel;
VehicleID vehicle_over;
TemplateVehicle *editTemplate;
public:
TemplateCreateWindow(WindowDesc* _wdesc, TemplateVehicle *to_edit, bool *notice, bool *windowOpen, int step_h) : Window(_wdesc)
TemplateCreateWindow(WindowDesc* _wdesc, TemplateVehicle *to_edit, bool *windowOpen, int step_h) : Window(_wdesc)
{
this->line_height = step_h;
this->CreateNestedTree(_wdesc != NULL);
@@ -150,9 +150,7 @@ public:
this->owner = _local_company;
noticeParent = notice;
createWindowOpen = windowOpen;
virtualTrainChangedNotice = false;
this->editTemplate = to_edit;
editMode = (to_edit != NULL);
@@ -181,6 +179,7 @@ public:
/* more cleanup */
*createWindowOpen = false;
DeleteWindowById(WC_BUILD_VIRTUAL_TRAIN, this->window_number);
InvalidateWindowClassesData(WC_TEMPLATEGUI_MAIN);
}
void SetVirtualTrain(Train* const train)
@@ -205,7 +204,7 @@ public:
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
virtualTrainChangedNotice = true;
this->SetDirty();
UpdateButtonState();
}
@@ -218,7 +217,7 @@ public:
break;
}
case TCW_NEW: {
ShowBuildVirtualTrainWindow(&virtual_train, &virtualTrainChangedNotice);
ShowTemplateTrainBuildVehicleWindow(&virtual_train);
break;
}
case TCW_CLONE: {
@@ -330,15 +329,6 @@ public:
}
}
virtual void OnTick()
{
if (virtualTrainChangedNotice) {
this->SetDirty();
virtualTrainChangedNotice = false;
UpdateButtonState();
}
}
virtual void OnDragDrop(Point pt, int widget)
{
switch (widget) {
@@ -546,10 +536,10 @@ public:
}
};
void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *noticeParent, bool *createWindowOpen, int step_h)
void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *createWindowOpen, int step_h)
{
if (BringWindowToFrontById(WC_CREATE_TEMPLATE, VEH_TRAIN) != NULL) return;
new TemplateCreateWindow(&_template_create_window_desc, to_edit, noticeParent, createWindowOpen, step_h);
new TemplateCreateWindow(&_template_create_window_desc, to_edit, createWindowOpen, step_h);
}
void CcSetVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)