← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/fh1-multitexture into lp:widelands

 

Checked the lower 50% of the chnages now, still not complete.

The code reads much better (some exceptions inline).

please comment what happens with scaling and in the chat window.

will try to play now with different scalings and check lots of dialogs
(english and german only).

Will the font cache be active inside a Gmae only of for the liftime of
the Programm?



Diff comments:

> 
> === modified file 'src/logic/map_objects/map_object.cc'
> --- src/logic/map_objects/map_object.cc	2017-05-13 18:48:26 +0000
> +++ src/logic/map_objects/map_object.cc	2017-05-20 18:11:58 +0000
> @@ -463,30 +464,25 @@
>  	}
>  
>  	// Rendering text is expensive, so let's just do it for only a few sizes.
> -	scale = std::round(scale);
> -	if (scale == 0.f) {
> +	scale = std::round(2 * (scale > 1.f ? std::sqrt(scale) : std::pow(scale, 2))) / 2;

Please explain this sqrt/pow magic or make it a function,
looks like you want to guess a reasonbale size for different zoom factors?

how fill different zoom factors affect the RenderedText cache?

> +	if (scale < 1.f) {
>  		return;
>  	}
>  	const int font_size = scale * UI_FONT_SIZE_SMALL;
>  
>  	// We always render this so we can have a stable position for the statistics string.
> -	const Image* rendered_census_info =
> -	   UI::g_fh1->render(as_condensed(census, UI::Align::kCenter, font_size), 120);
> -
> -	const Vector2i base_pos = field_on_dst.cast<int>() - Vector2i(0, 48) * scale;
> -	Vector2i census_pos(base_pos);
> -	UI::correct_for_align(UI::Align::kCenter, rendered_census_info->width(), &census_pos);
> +	const UI::RenderedText* rendered_census =
> +	   UI::g_fh1->render(as_condensed(census, UI::Align::kCenter, font_size), 120 * scale);
> +	Vector2i position = field_on_dst.cast<int>() - Vector2i(0, 48) * scale;
>  	if (draw_text & TextToDraw::kCensus) {
> -		dst->blit(census_pos, rendered_census_info, BlendMode::UseAlpha);
> +		rendered_census->draw(*dst, position, UI::Align::kCenter);
>  	}
>  
>  	if (draw_text & TextToDraw::kStatistics && !statictics.empty()) {
> -		Vector2i statistics_pos =
> -		   base_pos + Vector2i(0, rendered_census_info->height() / 2 + 10 * scale);
> -		const Image* rendered_statictics =
> +		const UI::RenderedText* rendered_statistics =
>  		   UI::g_fh1->render(as_condensed(statictics, UI::Align::kCenter, font_size));
> -		UI::correct_for_align(UI::Align::kCenter, rendered_statictics->width(), &statistics_pos);
> -		dst->blit(statistics_pos, rendered_statictics, BlendMode::UseAlpha);
> +		position.y += rendered_census->height() + text_height(font_size) / 4;
> +		rendered_statistics->draw(*dst, position, UI::Align::kCenter);
>  	}
>  }
>  
> 
> === modified file 'src/wui/chatoverlay.cc'
> --- src/wui/chatoverlay.cc	2017-04-22 12:19:21 +0000
> +++ src/wui/chatoverlay.cc	2017-05-20 18:11:58 +0000
> @@ -167,13 +167,13 @@
>  	if (!m->havemessages_)
>  		return;
>  
> -	const Image* im = nullptr;
> +	const UI::RenderedText* im = nullptr;
>  	try {
>  		im = UI::g_fh1->render(m->all_text_, get_w());

This is user generated content and should not be cached for a longer time.
-> a lengthy chat will pump up the cache.

>  	} catch (RT::WidthTooSmall&) {
>  		// Oops, maybe one long word? We render again, not limiting the width, but
>  		// render everything in one single line.
> -		im = UI::g_fh1->render(m->all_text_, 0);
> +		im = UI::g_fh1->render(m->all_text_);
>  	}
>  	assert(im != nullptr);
>  
> 
> === modified file 'src/wui/waresdisplay.cc'
> --- src/wui/waresdisplay.cc	2017-05-13 13:14:29 +0000
> +++ src/wui/waresdisplay.cc	2017-05-20 18:11:58 +0000
> @@ -331,11 +331,10 @@
>  	dst.fill_rect(Recti(p + Vector2i(0, WARE_MENU_PIC_HEIGHT), w, WARE_MENU_INFO_SIZE),
>  	              info_color_for_ware(id));
>  
> -	const Image* text = UI::g_fh1->render(as_waresinfo(info_for_ware(id)));
> -	if (text)  // might be zero when there is no info text.
> -		dst.blit(p + Vector2i(w - text->width() - 1,
> -		                      WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + 1 - text->height()),
> -		         text);
> +	const UI::RenderedText* rendered_text = UI::g_fh1->render(as_waresinfo(info_for_ware(id)));

what happens now if there is no text?

> +	rendered_text->draw(
> +	   dst, Vector2i(p.x + w - rendered_text->width() - 1,
> +	                 p.y + WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + 1 - rendered_text->height()));
>  }
>  
>  // Wares highlighting/selecting


-- 
https://code.launchpad.net/~widelands-dev/widelands/fh1-multitexture/+merge/323903
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/fh1-multitexture.


References