Changeset - r12602:1c9d00727f7d
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-08-03 16:36:40
alberth@openttd.org
(svn r17055) -Codechange: Improve aligning of bridge sprites and descriptions in bridge gui.
1 file changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/bridge_gui.cpp
Show inline comments
 
@@ -189,13 +189,15 @@ public:
 

	
 
					SetDParam(2, this->bridges->Get(i)->cost);
 
					SetDParam(1, b->speed);
 
					SetDParam(0, b->material);
 
					text_dim = maxdim(text_dim, GetStringBoundingBox(STR_BUILD_BRIDGE_INFO));
 
				}
 
				resize->height = max(sprite_dim.height, text_dim.height) + 2;
 
				sprite_dim.height++; // Sprite is rendered one pixel down in the matrix field.
 
				text_dim.height++; // Allowing the bottom row pixels to be rendered on the edge of the matrix field.
 
				resize->height = max(sprite_dim.height, text_dim.height) + 2; // Max of both sizes + account for matrix edges.
 

	
 
				this->bridgetext_offset = WD_MATRIX_LEFT + sprite_dim.width + 1; // Left edge of text, 1 pixel distance from the sprite.
 
				size->width = this->bridgetext_offset + text_dim.width + WD_MATRIX_RIGHT;
 
				size->height = 4 * resize->height; // Smallest bridge gui is 4 entries high in the matrix.
 
				break;
 
			}
 
@@ -207,22 +209,22 @@ public:
 
		switch (widget) {
 
			case BBSW_DROPDOWN_ORDER:
 
				this->DrawSortButtonState(widget, this->bridges->IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
			case BBSW_BRIDGE_LIST: {
 
				uint y = r.top + 2;
 
				uint y = r.top;
 
				for (int i = this->vscroll.pos; i < this->vscroll.cap + this->vscroll.pos && i < (int)this->bridges->Length(); i++) {
 
					const BridgeSpec *b = this->bridges->Get(i)->spec;
 

	
 
					SetDParam(2, this->bridges->Get(i)->cost);
 
					SetDParam(1, b->speed);
 
					SetDParam(0, b->material);
 

	
 
					DrawSprite(b->sprite, b->pal, r.left + WD_MATRIX_LEFT, y);
 
					DrawStringMultiLine(r.left + this->bridgetext_offset, r.right, y, y + this->resize.step_height, STR_BUILD_BRIDGE_INFO);
 
					DrawSprite(b->sprite, b->pal, r.left + WD_MATRIX_LEFT, y + this->resize.step_height - 1 - GetSpriteSize(b->sprite).height);
 
					DrawStringMultiLine(r.left + this->bridgetext_offset, r.right, y + 2, y + this->resize.step_height, STR_BUILD_BRIDGE_INFO);
 
					y += this->resize.step_height;
 
				}
 
				break;
 
			}
 
		}
 
	}
0 comments (0 inline, 0 general)