File diff r24596:eddf98238034 → r24597:afde5721a3b6
src/story_gui.cpp
Show inline comments
 
@@ -434,14 +434,14 @@ protected:
 
				/* Verify available width */
 
				const int min_required_width = 10 * FONT_HEIGHT_NORMAL;
 
				int left_offset = (left_width == 0) ? 0 : (left_width + element_dist);
 
				int right_offset = (right_width == 0) ? 0 : (right_width + element_dist);
 
				if (left_offset + right_offset + min_required_width >= max_width) {
 
					/* Width of floats leave too little for main content, push down */
 
					main_y = max(main_y, left_y);
 
					main_y = max(main_y, right_y);
 
					main_y = std::max(main_y, left_y);
 
					main_y = std::max(main_y, right_y);
 
					left_width = right_width = 0;
 
					left_offset = right_offset = 0;
 
					/* Do not add element_dist here, to keep together elements which were supposed to float besides each other. */
 
				}
 
				/* Determine height */
 
				const int available_width = max_width - left_offset - right_offset;
 
@@ -466,22 +466,22 @@ protected:
 
				main_y += height;
 
				ce.bounds.bottom = main_y;
 
				this->layout_cache.push_back(ce);
 
				main_y += element_dist;
 
				/* Clear all floats */
 
				left_width = right_width = 0;
 
				left_y = right_y = main_y = max(main_y, max(left_y, right_y));
 
				left_y = right_y = main_y = std::max({main_y, left_y, right_y});
 
				left_floats.clear();
 
				right_floats.clear();
 
			} else {
 
				/* Prepare references to correct column */
 
				int &cur_width = (fl == ElementFloat::Left) ? left_width : right_width;
 
				int &cur_y = (fl == ElementFloat::Left) ? left_y : right_y;
 
				std::vector<size_t> &cur_floats = (fl == ElementFloat::Left) ? left_floats : right_floats;
 
				/* Position element */
 
				cur_width = max(cur_width, this->GetPageElementFloatWidth(*pe));
 
				cur_width = std::max(cur_width, this->GetPageElementFloatWidth(*pe));
 
				LayoutCacheElement ce{ pe, {} };
 
				ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
 
				ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
 
				ce.bounds.top = cur_y;
 
				cur_y += GetPageElementHeight(*pe, cur_width);
 
				ce.bounds.bottom = cur_y;
 
@@ -504,13 +504,13 @@ protected:
 
	 */
 
	uint GetContentHeight()
 
	{
 
		this->EnsureStoryPageElementLayout();
 

	
 
		/* The largest bottom coordinate of any element is the height of the content */
 
		uint max_y = std::accumulate(this->layout_cache.begin(), this->layout_cache.end(), 0, [](uint max_y, const LayoutCacheElement &ce) -> uint { return max<uint>(max_y, ce.bounds.bottom); });
 
		uint max_y = std::accumulate(this->layout_cache.begin(), this->layout_cache.end(), 0, [](uint max_y, const LayoutCacheElement &ce) -> uint { return std::max<uint>(max_y, ce.bounds.bottom); });
 

	
 
		return max_y;
 
	}
 

	
 
	/**
 
	 * Draws a page element that is composed of a sprite to the left and a single line of
 
@@ -523,13 +523,13 @@ protected:
 
	 * @param string_id The string id to draw.
 
	 * @return the number of lines.
 
	 */
 
	void DrawActionElement(int &y_offset, int width, int line_height, SpriteID action_sprite, StringID string_id = STR_JUST_RAW_STRING) const
 
	{
 
		Dimension sprite_dim = GetSpriteSize(action_sprite);
 
		uint element_height = max(sprite_dim.height, (uint)line_height);
 
		uint element_height = std::max(sprite_dim.height, (uint)line_height);
 

	
 
		uint sprite_top = y_offset + (element_height - sprite_dim.height) / 2;
 
		uint text_top = y_offset + (element_height - line_height) / 2;
 

	
 
		DrawSprite(action_sprite, PAL_NONE, 0, sprite_top);
 
		DrawString(sprite_dim.width + WD_FRAMETEXT_LEFT, width, text_top, string_id, TC_BLACK);