File diff r13263:494f6eab0774 → r13264:26dbd06b1976
src/autoreplace_gui.cpp
Show inline comments
 
@@ -200,26 +200,25 @@ public:
 
	ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, vehicletype)
 
	{
 
		this->replace_engines  = true; // start with locomotives (all other vehicles will not read this bool)
 
		this->update_left      = true;
 
		this->update_right     = true;
 
		this->reset_sel_engine = true;
 
		this->sel_engine[0] = INVALID_ENGINE;
 
		this->sel_engine[1] = INVALID_ENGINE;
 

	
 
		this->resize.step_height = GetVehicleListHeight(vehicletype);
 
		this->vscroll.SetCapacity(this->resize.step_height == 14 ? 8 : 4);
 

	
 
		Widget *widget = this->widget;
 
		widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->widget[RVW_WIDGET_LEFT_MATRIX].data = this->widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		if (vehicletype != VEH_TRAIN) {
 
			/* Since it's not a train we will hide the train only widgets. */
 
			this->SetWidgetsHiddenState(true,
 
									RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE,
 
									RVW_WIDGET_TRAIN_FLUFF_LEFT,
 
									RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN,
 
									RVW_WIDGET_TRAIN_FLUFF_RIGHT,
 
									RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE,
 
									WIDGET_LIST_END);
 
		}
 

	
 
@@ -396,41 +395,39 @@ public:
 
		/* Rebuild the lists */
 
		this->update_left      = true;
 
		this->update_right     = true;
 
		this->reset_sel_engine = true;
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height);
 
		this->vscroll2.UpdateCapacity(delta.y / (int)this->resize.step_height);
 

	
 
		Widget *widget = this->widget;
 

	
 
		widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->widget[RVW_WIDGET_LEFT_MATRIX].data = this->widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		if (delta.x != 0) {
 
			/* We changed the width of the window so we have to resize the lists.
 
			 * Because ResizeButtons() makes each widget the same size it can't be used on the lists
 
			 * because then the lists would have the same size as the scrollbars.
 
			 * Instead we use it on the detail panels.
 
			 * Afterwards we use the new location of the detail panels (the middle of the window)
 
			 * to place the lists.
 
			 * This way the lists will have equal size while keeping the width of the scrollbars unchanged. */
 
			ResizeButtons(this, RVW_WIDGET_LEFT_DETAILS, RVW_WIDGET_RIGHT_DETAILS);
 
			widget[RVW_WIDGET_RIGHT_MATRIX].left    = widget[RVW_WIDGET_RIGHT_DETAILS].left;
 
			widget[RVW_WIDGET_LEFT_SCROLLBAR].right = widget[RVW_WIDGET_LEFT_DETAILS].right;
 
			widget[RVW_WIDGET_LEFT_SCROLLBAR].left  = widget[RVW_WIDGET_LEFT_SCROLLBAR].right - 11;
 
			widget[RVW_WIDGET_LEFT_MATRIX].right    = widget[RVW_WIDGET_LEFT_SCROLLBAR].left - 1;
 
			this->widget[RVW_WIDGET_RIGHT_MATRIX].left    = this->widget[RVW_WIDGET_RIGHT_DETAILS].left;
 
			this->widget[RVW_WIDGET_LEFT_SCROLLBAR].right = this->widget[RVW_WIDGET_LEFT_DETAILS].right;
 
			this->widget[RVW_WIDGET_LEFT_SCROLLBAR].left  = this->widget[RVW_WIDGET_LEFT_SCROLLBAR].right - 11;
 
			this->widget[RVW_WIDGET_LEFT_MATRIX].right    = this->widget[RVW_WIDGET_LEFT_SCROLLBAR].left - 1;
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (data != 0) {
 
			this->update_left = true;
 
		} else {
 
			this->update_right = true;
 
		}
 
	}
 
};