← Back to team overview

widelands-dev team mailing list archive

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

 

Sorry I disappeared for a bit, I was trying to finish up too many things at once and needed a break.

I have thought a bit about the performance issue - I attempted to convert everything before Build19, and the performance was better. However, the needed texture for the translators list was too high, which resulted in a black texture. So, I invented the RenderedText object to deal with that.

The problem here is that we render everything at once, and there are tons of rectangles needed for the lists. I can think of 2 strategies to improve performance:

1. If everything fits, give RenderedText only 1 rectangle with everything in it
2. Only parse the Lua scripts when each tab is loaded.

The messed up mixed fonts is a problem that we already have in trunk - it's the same as in the language selection menu. The underlying issue s that Arabic uses a bigger font size than Latin, and something is wrong with the hotspot calculation. I did quite a bit of dirty hacking to make this work in tables and lists, but this should be handled in the fit_line function, I guess.

I have addressed one of he comments, so this needs a quick test again to make sure that the Lua script won't crash.

I can't compile right now, so I'll wat for AppVeyor if nobody else gets around to it first.


Diff comments:

> 
> === modified file 'data/scripting/richtext.lua'
> --- data/scripting/richtext.lua	2017-07-03 10:16:59 +0000
> +++ data/scripting/richtext.lua	2017-12-19 18:07:21 +0000
> @@ -327,21 +327,24 @@
>  end
>  
>  -- RST
> --- .. function li_image(imagepath, text)
> +-- .. function li_image(imagepath, text[, vsp])
>  --
>  --    Places a paragraph of text to the right of an image
>  
>  --    :arg imagepath: the full path to the image file
>  --    :arg text_width_percent: the percentatge of space that the text will occupy

True, not used any more, I have removed it.

>  --    :arg text: the text to be placed next to the image
> +--    :arg vsp: Vertical spacing. Default is 6.
>  --
> ---    :returns: the text wrapped in a paragraph and placed next to the image, The outer tag is a div.
> -function li_image(imagepath, text_width_percent, text)
> -   return p("<br>") .. div("width=100%", "") ..
> -         div(p(img(imagepath))) ..
> +--    :returns: the text wrapped in a paragraph and placed next to the image, the outer tag is a div.
> +function li_image(imagepath, text, vsp)
> +   if vsp == nil then vsp = 6 end
> +   return
> +      div("width=100%",
> +         div(p(vspace(vsp) .. img(imagepath) .. space(6))) ..
>           div(p(space(6))) ..
> -         div("width="..text_width_percent.."%", p(text)) ..
> -         div("width=100%", "")
> +         div("width=*", p(vspace(vsp) .. text .. vspace(2 * vsp)))
> +      )
>  end
>  
>  -- RST
> 
> === modified file 'data/txts/AUTHORS.lua'
> --- data/txts/AUTHORS.lua	2016-03-14 11:37:49 +0000
> +++ data/txts/AUTHORS.lua	2017-12-19 18:07:21 +0000
> @@ -26,7 +26,7 @@
>  return {
>     title = _"Developers",
>     text = rt(
> -      title(_"Widelands Development Team") ..
> +      p_font("align=center", "size=28 color=2F9131", _"Widelands Development Team") ..

Because of the center alignment, which the h1 function doesn't cater for.

>        list_authors()
>     )
>  }
> 
> === modified file 'src/ui_basic/fileview_panel.cc'
> --- src/ui_basic/fileview_panel.cc	2017-08-08 17:39:40 +0000
> +++ src/ui_basic/fileview_panel.cc	2017-12-19 18:07:21 +0000
> @@ -51,8 +51,18 @@
>  	   std::unique_ptr<UI::Box>(new UI::Box(this, 0, 0, UI::Box::Vertical, 0, 0, padding_)));
>  	size_t index = boxes_.size() - 1;
>  
> -	textviews_.push_back(std::unique_ptr<UI::MultilineTextarea>(
> -	   new UI::MultilineTextarea(boxes_.at(index).get(), 0, 0, Scrollbar::kSize, 0, content)));
> +	UI::MultilineTextarea* textarea =
> +		   new UI::MultilineTextarea(boxes_.at(index).get(), 0, 0, Scrollbar::kSize, 0);
> +	try {
> +		textarea->force_new_renderer();
> +		textarea->set_text(content);
> +	} catch (const std::exception& e) {
> +		log("Fileview: falling back to OLD font renderer: %s\n", e.what());
> +		textarea->force_new_renderer(false);
> +		textarea->set_text(content);
> +	}
> +
> +	textviews_.push_back(std::unique_ptr<UI::MultilineTextarea>(std::move(textarea)));

I must admit that I did a quick copy/paste of some other code for that. Creating the unique_ptr directly doesn't work, because copy/assign is disallowed for this class.

>  	add((boost::format("about_%lu") % index).str(), title, boxes_.at(index).get(), "");
>  
>  	assert(boxes_.size() == textviews_.size());


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


References