File diff r11916:e3a8d08bf479 → r11917:612c11f7ab47
src/industry_gui.cpp
Show inline comments
 
@@ -476,31 +476,31 @@ class IndustryViewWindow : public Window
 
	byte editbox_line;        ///< The line clicked to open the edit box
 
	byte clicked_line;        ///< The line of the button that has been clicked
 
	byte clicked_button;      ///< The button that has been clicked (to raise)
 
	byte production_offset_y; ///< The offset of the production texts/buttons
 

	
 
public:
 
	IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->flags4 |= WF_DISABLE_VP_SCROLL;
 
		this->editbox_line = 0;
 
		this->clicked_line = 0;
 
		this->clicked_button = 0;
 
		InitializeWindowViewport(this, 3, 17, 254, 86, GetIndustry(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
 
		InitializeWindowViewport(this, 3, 17, 254, 86, Industry::Get(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		Industry *i = GetIndustry(this->window_number);
 
		Industry *i = Industry::Get(this->window_number);
 
		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
		int y = this->widget[IVW_INFO].top + 1;
 
		bool first = true;
 
		bool has_accept = false;
 

	
 
		SetDParam(0, this->window_number);
 
		this->DrawWidgets();
 

	
 
		if (HasBit(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) {
 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
				if (i->accepts_cargo[j] == CT_INVALID) continue;
 
				has_accept = true;
 
@@ -585,25 +585,25 @@ public:
 

	
 
		this->DrawViewport();
 
	}
 

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

	
 
		switch (widget) {
 
			case IVW_INFO: {
 
				int line, x;
 

	
 
				i = GetIndustry(this->window_number);
 
				i = Industry::Get(this->window_number);
 

	
 
				/* We should work if needed.. */
 
				if (!IsProductionAlterable(i)) return;
 
				x = pt.x;
 
				line = (pt.y - this->production_offset_y) / 10;
 
				if (pt.y >= this->production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
 
					if (IsInsideMM(x, 5, 25) ) {
 
						/* Clicked buttons, decrease or increase production */
 
						if (x < 15) {
 
							if (IsProductionMinimum(i, line)) return;
 
							i->production_rate[line] = max(i->production_rate[line] / 2, 0);
 
						} else {
 
@@ -619,25 +619,25 @@ public:
 
						this->clicked_line = line + 1;
 
						this->clicked_button = (x < 15 ? 1 : 2);
 
					} else if (IsInsideMM(x, 34, 160)) {
 
						/* clicked the text */
 
						this->editbox_line = line;
 
						SetDParam(0, i->production_rate[line] * 8);
 
						ShowQueryString(STR_CONFIG_SETTING_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, this, CS_ALPHANUMERAL, QSF_NONE);
 
					}
 
				}
 
			} break;
 

	
 
			case IVW_GOTO:
 
				i = GetIndustry(this->window_number);
 
				i = Industry::Get(this->window_number);
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
 
				} else {
 
					ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
 
				}
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		this->clicked_line = 0;
 
@@ -651,25 +651,25 @@ public:
 
		this->viewport->height           += delta.y;
 
		this->viewport->virtual_width    += delta.x;
 
		this->viewport->virtual_height   += delta.y;
 
		this->viewport->dest_scrollpos_x -= delta.x;
 
		this->viewport->dest_scrollpos_y -= delta.y;
 
		UpdateViewportPosition(this);
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (StrEmpty(str)) return;
 

	
 
		Industry *i = GetIndustry(this->window_number);
 
		Industry *i = Industry::Get(this->window_number);
 
		int line = this->editbox_line;
 

	
 
		i->production_rate[line] = ClampU(atoi(str), 0, 255);
 
		UpdateIndustryProduction(i);
 
		this->SetDirty();
 
	}
 
};
 

	
 
static void UpdateIndustryProduction(Industry *i)
 
{
 
	for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
		if (i->produced_cargo[j] != CT_INVALID) {