Changeset - r12401:939dd6623784
[Not reviewed]
master
0 14 0
alberth - 15 years ago 2009-07-16 16:22:23
alberth@openttd.org
(svn r16845) -Codechange: Introduction of constants for describing the bits in a WWT_MATRIX data field.
14 files changed with 46 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -53,7 +53,7 @@ struct AIListWindow : public Window {
 
		this->ai_info_list = AI::GetUniqueInfoList();
 
		this->resize.step_height = 14;
 
		this->vscroll.cap = (this->widget[AIL_WIDGET_LIST].bottom - this->widget[AIL_WIDGET_LIST].top) / 14 + 1;
 
		this->widget[AIL_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIL_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		SetVScrollCount(this, (int)this->ai_info_list->size() + 1);
 

	
 
		/* Try if we can find the currently selected AI */
 
@@ -181,7 +181,7 @@ struct AIListWindow : public Window {
 

	
 
		this->vscroll.cap += delta.y / 14;
 
		SetVScrollCount(this, (int)this->ai_info_list->size() + 1);
 
		this->widget[AIL_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIL_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
 
@@ -265,7 +265,7 @@ struct AISettingsWindow : public Window 
 
		this->ai_config = AIConfig::GetConfig(slot);
 
		this->resize.step_height = 14;
 
		this->vscroll.cap = (this->widget[AIS_WIDGET_BACKGROUND].bottom - this->widget[AIS_WIDGET_BACKGROUND].top) / 14 + 1;
 
		this->widget[AIS_WIDGET_BACKGROUND].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIS_WIDGET_BACKGROUND].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		SetVScrollCount(this, (int)this->ai_config->GetConfigList()->size());
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 
@@ -378,7 +378,7 @@ struct AISettingsWindow : public Window 
 
		}
 

	
 
		this->vscroll.cap += delta.y / 14;
 
		this->widget[AIS_WIDGET_BACKGROUND].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIS_WIDGET_BACKGROUND].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnTick()
 
@@ -505,6 +505,7 @@ struct AIConfigWindow : public Window {
 
		this->resize.step_height = 14;
 
		this->vscroll.cap = (this->widget[AIC_WIDGET_LIST].bottom - this->widget[AIC_WIDGET_LIST].top) / 14 + 1;
 
		this->widget[AIC_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIC_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		SetVScrollCount(this, MAX_COMPANIES);
 
		this->FindWindowPlacementAndResize(&_ai_config_desc);
 
	}
 
@@ -597,7 +598,7 @@ struct AIConfigWindow : public Window {
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.cap += delta.y / 14;
 
		this->widget[AIC_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[AIC_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnTick()
src/autoreplace_gui.cpp
Show inline comments
 
@@ -209,7 +209,7 @@ public:
 
		this->vscroll.cap = 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.cap << 8) + 1;
 
		widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		if (vehicletype != VEH_TRAIN) {
 
			/* Since it's not a train we will hide the train only widgets. */
 
@@ -409,7 +409,7 @@ public:
 

	
 
		Widget *widget = this->widget;
 

	
 
		widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll2.cap << 8) + 1;
 
		widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (this->vscroll.cap << 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.
src/bridge_gui.cpp
Show inline comments
 
@@ -226,7 +226,7 @@ public:
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 
		this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		SetVScrollCount(this, this->bridges->Length());
 

	
 
		this->last_size = max(this->vscroll.cap, this->last_size);
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -790,7 +790,7 @@ struct BuildVehicleWindow : Window {
 
		ResizeWindow(this, 0, vlh - 14);
 
		this->resize.step_height = vlh;
 
		this->vscroll.cap = 1;
 
		this->widget[BUILD_VEHICLE_WIDGET_LIST].data = 0x101;
 
		this->widget[BUILD_VEHICLE_WIDGET_LIST].data = (1 << MAT_ROW_START) | (1 << MAT_COL_START);
 

	
 
		this->resize.width  = this->width;
 
		this->resize.height = this->height;
 
@@ -1248,7 +1248,7 @@ struct BuildVehicleWindow : Window {
 
		if (delta.y == 0) return;
 

	
 
		this->vscroll.cap += delta.y / (int)GetVehicleListHeight(this->vehicle_type);
 
		this->widget[BUILD_VEHICLE_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[BUILD_VEHICLE_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
src/company_gui.cpp
Show inline comments
 
@@ -642,7 +642,7 @@ public:
 
				}
 
				this->height = 49 + livery_height[this->livery_class] * 14;
 
				this->widget[SCLW_WIDGET_MATRIX].bottom = this->height - 1;
 
				this->widget[SCLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
 
				this->widget[SCLW_WIDGET_MATRIX].data = (livery_height[this->livery_class] << MAT_ROW_START) | (1 << MAT_COL_START);
 
				MarkWholeScreenDirty();
 
				break;
 
			}
 
@@ -719,7 +719,7 @@ static const NWidgetPart _nested_select_
 
		NWidget(WWT_DROPDOWN, COLOUR_GREY, SCLW_WIDGET_PRI_COL_DROPDOWN), SetMinimalSize(125, 12), SetDataTip(STR_BLACK_STRING, STR_LIVERY_PRIMARY_TIP),
 
		NWidget(WWT_DROPDOWN, COLOUR_GREY, SCLW_WIDGET_SEC_COL_DROPDOWN), SetMinimalSize(125, 12), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN, STR_LIVERY_SECONDARY_TIP),
 
	EndContainer(),
 
	NWidget(WWT_MATRIX, COLOUR_GREY, SCLW_WIDGET_MATRIX), SetMinimalSize(400, 15), SetDataTip((1 << 8) | 1, STR_LIVERY_PANEL_TIP),
 
	NWidget(WWT_MATRIX, COLOUR_GREY, SCLW_WIDGET_MATRIX), SetMinimalSize(400, 15), SetDataTip((1 << MAT_ROW_START) | (1 << MAT_COL_START), STR_LIVERY_PANEL_TIP),
 
};
 

	
 
static const Widget _select_company_livery_widgets[] = {
src/depot_gui.cpp
Show inline comments
 
@@ -308,8 +308,8 @@ struct DepotWindow : Window {
 
		uint16 hnum;
 

	
 
		/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
 
		uint16 rows_in_display   = this->widget[DEPOT_WIDGET_MATRIX].data >> 8;
 
		uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
 
		uint16 rows_in_display   = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_ROW_START, MAT_ROW_BITS);
 
		uint16 boxes_in_each_row = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_COL_START, MAT_COL_BITS);
 

	
 
		/* setup disabled buttons */
 
		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
 
@@ -397,7 +397,7 @@ struct DepotWindow : Window {
 
	{
 
		uint xt, row, xm = 0, ym = 0;
 
		int pos, skip = 0;
 
		uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
 
		uint16 boxes_in_each_row = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_COL_START, MAT_COL_BITS);
 

	
 
		if (this->type == VEH_TRAIN) {
 
			xt = 0;
 
@@ -727,8 +727,8 @@ struct DepotWindow : Window {
 
		this->SetupStringsForDepotWindow(type);
 

	
 
		this->widget[DEPOT_WIDGET_MATRIX].data =
 
			(this->vscroll.cap * 0x100) // number of rows to draw on the background
 
			+ (type == VEH_TRAIN ? 1 : this->hscroll.cap); // number of boxes in each row. Trains always have just one
 
			(this->vscroll.cap << MAT_ROW_START) // number of rows to draw on the background
 
			+ ((type == VEH_TRAIN ? 1 : this->hscroll.cap) << MAT_COL_START); // number of boxes in each row. Trains always have just one
 

	
 

	
 
		this->SetWidgetsHiddenState(type != VEH_TRAIN,
 
@@ -1001,7 +1001,7 @@ struct DepotWindow : Window {
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 
		this->hscroll.cap += delta.x / (int)this->resize.step_width;
 
		this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.cap << 8) + (this->type == VEH_TRAIN ? 1 : this->hscroll.cap);
 
		this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + ((this->type == VEH_TRAIN ? 1 : this->hscroll.cap) << MAT_COL_START);
 
		ResizeDepotButtons(this);
 
	}
 

	
src/group_gui.cpp
Show inline comments
 
@@ -241,8 +241,8 @@ public:
 
				break;
 
		}
 

	
 
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << 8) + 1;
 
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		switch (this->vehicle_type) {
 
			default: NOT_REACHED();
 
@@ -671,8 +671,8 @@ public:
 
		this->vscroll2.cap += delta.y / PLY_WND_PRC__SIZE_OF_ROW_TINY;
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 

	
 
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << 8) + 1;
 
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
src/industry_gui.cpp
Show inline comments
 
@@ -356,7 +356,7 @@ public:
 
	{
 
		/* Adjust the number of items in the matrix depending of the rezise */
 
		this->vscroll.cap  += delta.y / (int)this->resize.step_height;
 
		this->widget[DPIW_MATRIX_WIDGET].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[DPIW_MATRIX_WIDGET].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnPlaceObject(Point pt, TileIndex tile)
src/network/network_content_gui.cpp
Show inline comments
 
@@ -693,7 +693,7 @@ public:
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 

	
 
		this->widget[NCLWW_MATRIX].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[NCLWW_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		SetVScrollCount(this, this->content.Length());
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -722,7 +722,7 @@ public:
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 

	
 
		this->widget[NGWW_MATRIX].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[NGWW_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		SetVScrollCount(this, this->servers.Length());
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -705,7 +705,7 @@ struct NewGRFWindow : public Window {
 
		}
 

	
 
		this->vscroll.cap += delta.y / 14;
 
		this->widget[SNGRFS_FILE_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[SNGRFS_FILE_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		this->SetupNewGRFWindow();
 
	}
src/vehicle_gui.cpp
Show inline comments
 
@@ -414,7 +414,7 @@ struct RefitWindow : public Window {
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 
		this->widget[VRW_MATRIX].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[VRW_MATRIX].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
 
@@ -967,7 +967,7 @@ struct VehicleListWindow : public BaseVe
 
		}
 

	
 

	
 
		this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		/* Set up sorting. Make the window-specific _sorting variable
 
		 * point to the correct global _sorting struct so we are freed
 
@@ -1184,7 +1184,7 @@ struct VehicleListWindow : public BaseVe
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 
		this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
@@ -1399,7 +1399,7 @@ struct VehicleDetailsWindow : Window {
 
			this->widget[VLD_WIDGET_MIDDLE_DETAILS].right += 12;
 
		}
 

	
 
		this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->owner = v->owner;
 

	
 
		this->tab = TDW_TAB_CARGO;
 
@@ -1603,7 +1603,7 @@ struct VehicleDetailsWindow : Window {
 
		if (delta.y == 0) return;
 

	
 
		this->vscroll.cap += delta.y / 14;
 
		this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1;
 
		this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
src/widget.cpp
Show inline comments
 
@@ -336,10 +336,10 @@ static inline void DrawMatrix(const Rect
 
{
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
 

	
 
	int num_columns = GB(data, 0, 8);  // Lower 8 bits of the widget data: Number of columns in the matrix.
 
	int num_columns = GB(data, MAT_COL_START, MAT_COL_BITS);  // Lower 8 bits of the widget data: Number of columns in the matrix.
 
	int column_width = (r.right - r.left + 1) / num_columns; // Width of a single column in the matrix.
 

	
 
	int num_rows = GB(data, 8, 8); // Upper 8 bits of the widget data: Number of rows in the matrix.
 
	int num_rows = GB(data, MAT_ROW_START, MAT_ROW_BITS); // Upper 8 bits of the widget data: Number of rows in the matrix.
 
	int row_height = (r.bottom - r.top + 1) / num_rows; // Height of a single row in the matrix.
 

	
 
	int col = _colour_gradient[colour & 0xF][6];
src/widget_type.h
Show inline comments
 
@@ -65,6 +65,17 @@ enum {
 
	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
 
};
 

	
 
/** Bits of the #WWT_MATRIX widget data. */
 
enum MatrixWidgetValues {
 
	/* Number of column bits of the WWT_MATRIX widget data. */
 
	MAT_COL_START = 0, ///< Lowest bit of the number of columns.
 
	MAT_COL_BITS  = 8, ///< Number of bits for the number of columns in the matrix.
 

	
 
	/* Number of row bits of the WWT_MATRIX widget data. */
 
	MAT_ROW_START = 8, ///< Lowest bit of the number of rows.
 
	MAT_ROW_BITS  = 8, ///< Number of bits for the number of rows in the matrix.
 
};
 

	
 
/**
 
 * Window widget types, nested widget types, and nested widget part types.
 
 */
 
@@ -81,7 +92,7 @@ enum WidgetType {
 
	WWT_TEXTBTN_2,  ///< Button with diff text when clicked
 
	WWT_LABEL,      ///< Centered label
 
	WWT_TEXT,       ///< Pure simple text
 
	WWT_MATRIX,     ///< Grid of rows and columns. Lower 8 bit of the widget data are the number of columns, upper 8 bit are the number of rows.
 
	WWT_MATRIX,     ///< Grid of rows and columns. @see MatrixWidgetValues
 
	WWT_SCROLLBAR,  ///< Vertical scrollbar
 
	WWT_FRAME,      ///< Frame
 
	WWT_CAPTION,    ///< Window caption (window title between closebox and stickybox)
0 comments (0 inline, 0 general)