Changeset - r17028:73fd5bd51c09
[Not reviewed]
master
0 1 0
alberth - 13 years ago 2011-01-13 22:02:13
alberth@openttd.org
(svn r21775) -Add: Allow vertical resizing of the newobject gui.
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/object_gui.cpp
Show inline comments
 
@@ -92,12 +92,13 @@ public:
 
			case BOW_CLASS_LIST: {
 
				for (uint i = 0; i < ObjectClass::GetCount(); i++) {
 
					size->width = max(size->width, GetStringBoundingBox(ObjectClass::GetName((ObjectClassID)i)).width);
 
				}
 
				size->width += padding.width;
 
				this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
 
				resize->height = this->line_height;
 
				size->height = this->vscroll->GetCapacity() * this->line_height;
 
				break;
 
			}
 

	
 
			case BOW_OBJECT_MATRIX: {
 
				/* Get the right amount of buttons based on the current spec. */
 
@@ -283,12 +284,18 @@ public:
 
			int w = GB(spec->size, HasBit(_selected_object_view, 0) ? 4 : 0, 4);
 
			int h = GB(spec->size, HasBit(_selected_object_view, 0) ? 0 : 4, 4);
 
			SetTileSelectSize(w, h);
 
		}
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, BOW_CLASS_LIST);
 
		this->GetWidget<NWidgetCore>(BOW_CLASS_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case BOW_CLASS_LIST: {
 
				int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
 
				if (num_clicked >= (int)ObjectClass::GetCount()) break;
0 comments (0 inline, 0 general)