Changeset - r20724:8a815ccb9d18
[Not reviewed]
master
0 1 0
zuu - 11 years ago 2013-09-13 20:17:07
zuu@openttd.org
(svn r25766) -Codechange: Use FONT_HEIGHT_NORMAL instead of checking the height of a dummy string in Story gui
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/story_gui.cpp
Show inline comments
 
@@ -317,25 +317,25 @@ protected:
 
	 */
 
	uint CountPageElementLines(const StoryPageElement &pe, int max_width)
 
	{
 
		switch (pe.type) {
 
			case SPET_TEXT:
 
				SetDParamStr(0, pe.text);
 
				return GetStringLineCount(STR_BLACK_RAW_STRING, max_width);
 
				break;
 

	
 
			case SPET_GOAL:
 
			case SPET_LOCATION: {
 
				Dimension sprite_dim = GetSpriteSize(GetPageElementSprite(pe));
 
				int line_height = GetStringHeight(STR_JUST_NOTHING, INT_MAX);
 
				int line_height = FONT_HEIGHT_NORMAL;
 
				if (line_height == 0) return 1;
 
				return max((uint)1, sprite_dim.height / (uint)line_height);
 
				break;
 
			}
 
			default:
 
				NOT_REACHED();
 
		}
 
	}
 

	
 
	/**
 
	 * Count the number of lines in this window.
 
	 * @return the number of lines.
 
@@ -489,25 +489,25 @@ public:
 
		const int y = r.top + WD_FRAMETEXT_TOP;
 
		const int right = r.right - WD_FRAMETEXT_RIGHT;
 
		const int bottom = r.bottom - WD_FRAMETEXT_BOTTOM;
 

	
 
		/* Set up a clipping region for the panel. */
 
		DrawPixelInfo tmp_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, x, y, right - x + 1, r.bottom - y + 1)) return;
 

	
 
		DrawPixelInfo *old_dpi = _cur_dpi;
 
		_cur_dpi = &tmp_dpi;
 

	
 
		/* Draw content (now coordinates given to Draw** are local to the new clipping region). */
 
		int line_height = GetStringHeight(STR_JUST_NOTHING, INT_MAX);
 
		int line_height = FONT_HEIGHT_NORMAL;
 
		int y_offset = - this->vscroll->GetPosition() * line_height;
 

	
 
		/* Date */
 
		SetDParam(0, page->date);
 
		DrawString(0, right - x, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
 
		y_offset += line_height;
 

	
 
		/* Title */
 
		SetDParamStr(0, page->title != NULL ? page->title : this->selected_generic_title);
 
		y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, STR_STORY_BOOK_TITLE, TC_BLACK, SA_TOP | SA_HOR_CENTER);
 

	
 
		/* Page elements */
 
@@ -540,25 +540,26 @@ public:
 
				default: NOT_REACHED();
 
			}
 
		}
 

	
 
		/* Restore clipping region. */
 
		_cur_dpi = old_dpi;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return;
 

	
 
		Dimension d = GetStringBoundingBox(STR_JUST_NOTHING);
 
		Dimension d;
 
		d.height= FONT_HEIGHT_NORMAL;
 
		d.width = 0;
 

	
 
		switch(widget) {
 
			case WID_SB_SEL_PAGE: {
 

	
 
				/* Get max title width. */
 
				for (uint16 i = 0; i < this->story_pages.Length(); i++) {
 
					const StoryPage *s = this->story_pages[i];
 

	
 
					if (s->title != NULL) {
 
						SetDParamStr(0, s->title);
 
					} else {
0 comments (0 inline, 0 general)