File diff r14398:461a80e5f996 → r14399:3f819c0da60a
src/industry_gui.cpp
Show inline comments
 
@@ -382,52 +382,47 @@ public:
 
					SetDParam(0, str);
 
					DrawStringMultiLine(left, right, y, bottom, STR_JUST_STRING);
 
				}
 
			} break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void OnDoubleClick(Point pt, int widget)
 
	{
 
		if (widget != DPIW_MATRIX_WIDGET) return;
 
		this->OnClick(pt, DPIW_FUND_WIDGET);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case DPIW_MATRIX_WIDGET: {
 
				const IndustrySpec *indsp;
 
				int y = (pt.y - this->GetWidget<NWidgetBase>(DPIW_MATRIX_WIDGET)->pos_y) / this->resize.step_height + this->vscroll.GetPosition();
 

	
 
				if (y >= 0 && y < count) { // Is it within the boundaries of available data?
 
					this->selected_index = y;
 
					this->selected_type = this->index[y];
 
					indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type);
 

	
 
					this->SetDirty();
 

	
 
					if ((_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 
							this->selected_type == INVALID_INDUSTRYTYPE) {
 
						/* Reset the button state if going to prospecting or "build many industries" */
 
						this->RaiseButtons();
 
						ResetObjectToPlace();
 
					}
 

	
 
					this->SetWidgetDisabledState(DPIW_FUND_WIDGET, !this->enabled[this->selected_index]);
 
					if (this->enabled[this->selected_index] && click_count > 1) this->OnClick(pt, DPIW_FUND_WIDGET, 1);
 
				}
 
			} break;
 

	
 
			case DPIW_FUND_WIDGET: {
 
				if (this->selected_type == INVALID_INDUSTRYTYPE) {
 
					this->HandleButtonClick(DPIW_FUND_WIDGET);
 

	
 
					if (Town::GetNumItems() == 0) {
 
						ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, 0, 0);
 
					} else {
 
						extern void GenerateIndustries();
 
						_generating_world = true;
 
@@ -694,25 +689,25 @@ public:
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		if (widget== IVW_CAPTION) SetDParam(0, this->window_number);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget == IVW_INFO) size->height = this->info_height;
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		Industry *i;
 

	
 
		switch (widget) {
 
			case IVW_INFO: {
 
				i = Industry::Get(this->window_number);
 

	
 
				/* We should work if needed.. */
 
				if (!IsProductionAlterable(i)) return;
 
				uint x = pt.x;
 
				int line = (pt.y - this->production_offset_y) / FONT_HEIGHT_NORMAL;
 
				if (pt.y >= this->production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
 
@@ -1096,25 +1091,25 @@ public:
 
					d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
 
				}
 
				resize->height = d.height;
 
				d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
		}
 
	}
 

	
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case IDW_DROPDOWN_ORDER:
 
				this->industries.ToggleSortOrder();
 
				this->SetDirty();
 
				break;
 

	
 
			case IDW_DROPDOWN_CRITERIA:
 
				ShowDropDownMenu(this, IndustryDirectoryWindow::sorter_names, this->industries.SortType(), IDW_DROPDOWN_CRITERIA, 0, 0);
 
				break;
 

	
 
			case IDW_INDUSTRY_LIST: {