← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/fh1-scenario-groundwork-emp1 into lp:widelands

 

Some nitpicking in the comments

Diff comments:

> 
> === removed file 'data/scripting/editor/format_editor.lua'
> --- data/scripting/editor/format_editor.lua	2016-09-01 15:43:01 +0000
> +++ data/scripting/editor/format_editor.lua	1970-01-01 00:00:00 +0000
> @@ -1,31 +0,0 @@
> --- RST
> --- format_editor.lua
> --- -----------------
> ---
> --- Functions used in the ingame editor help windows for formatting the text and pictures.
> -
> -include "scripting/formatting.lua"
> -
> --- RST
> --- .. function:: picture_li(imagepath, text)
> ---
> ---    Places a paragraph of text to the right of an image
> -
> ---    :arg imagepath: the full path to the image file
> ---    :arg text: the text to be placed next to the image
> ---
> ---    :returns: the text wrapped in a paragraph and placed next to the image
> -function picture_li(imagepath, text)
> -   return "<rt image=" .. imagepath .. " image-align=left>"
> -      .. p(text) .. "</rt>"
> -end
> -
> --- RST
> --- .. function:: spacer()
> ---
> ---    Adds a little space between two paragraphs
> ---
> ---    :returns: a small empty paragraph

add blank line

> -function spacer()
> -   return rt(p("font-size=3", ""))
> -end
> 
> === added file 'data/scripting/format_scenario.lua'
> --- data/scripting/format_scenario.lua	1970-01-01 00:00:00 +0000
> +++ data/scripting/format_scenario.lua	2017-12-17 11:22:56 +0000
> @@ -0,0 +1,85 @@
> +-- RST
> +-- format_scenario.lua
> +-- -------------------
> +--
> +-- Function to simplify and unique text formatting in scenarios.  Most of these
> +-- functions are simple wrapper functions that make working with widelands rich
> +-- text formatting system more bearable.
> +
> +
> +-- RST
> +-- .. function:: speech(img, clr, title, text)
> +--
> +--    Formats a text as spoken by one person in a scenario. Use it as follows:
> +--
> +--    .. code-block:: lua
> +--
> +--        function jundlina(title, text)
> +--           return speech("map:princess.png", "2F9131", title, text)
> +--        end
> +--
> +--    :arg img: name of the image to use for this speaker
> +--    :arg clr: a valid 6 char hex color to use for the name of this speaker
> +--    :arg title: Title of this text.
> +--    :arg text: The text itself. If this is nil, :const:`title` is used as text
> +--       instead and there will not be any title.
> +--    :returns: the formatted text.
> +--

replace -- with blank line or add a blank line

> +function speech(img, clr, g_title, g_text)
> +   local title, text = g_title, g_text
> +   if not text then
> +      title = nil
> +      text = g_title
> +   end
> +
> +   -- Surround the text with translatable ","
> +   text = (_'“%s”'):format(text)
> +
> +   local s = ""
> +   if title then
> +      s = rt("<p font-size=20 font-weight=bold font-face=serif " ..
> +         ("font-color=%s>"):format(clr) .. title ..
> +         "</p><p font-size=8> <br></p>"
> +      )
> +   end
> +
> +   return s .. rt(("image=%s"):format(img), p(text))
> +end
> +
> +
> +-- RST
> +-- .. function:: objective_text(heading, body)
> +--
> +--    Provides nice formatting for objective texts.
> +--
> +--    :returns: a rich text object that contains the formatted
> +--       objective text.
> +--
> +function objective_text(heading, body)
> +   return rt(h2(heading) .. p(body))
> +end
> +
> +
> +-- RST
> +-- Append an objective text with a header to a dialog box in a nice fashion.
> +-- For displaying objectives with an extra title when an advisor is talking
> +--
> +--    Provides nice formatting for objective texts.
> +--    the following arguments will be parsed:
> +--    number: the number of objectives described in the body
> +--    body: the objective text, e.g. created with function objective_text(heading, body)
> +--
> +--    :returns: a rich text object that contains the formatted
> +--       objective text & title.
> +--
> +function new_objectives(...)
> +   local sum = 0
> +   local s = ""
> +   for idx,obj in ipairs{...} do
> +      s = s .. obj.body
> +      sum = sum + obj.number
> +   end
> +   return rt("<p font-size=10> <br></p>" ..
> +      "<p font=serif font-size=18 font-weight=bold font-color=D1D1D1>"
> +      .. ngettext("New Objective", "New Objectives", sum) .. "</p>") .. s
> +end
> 
> === modified file 'data/scripting/richtext.lua'
> --- data/scripting/richtext.lua	2017-07-03 10:16:59 +0000
> +++ data/scripting/richtext.lua	2017-12-17 11:22:56 +0000
> @@ -336,12 +336,13 @@
>  --    :arg text: the text to be placed next to the image
>  --
>  --    :returns: the text wrapped in a paragraph and placed next to the image, The outer tag is a div.

add blank line

> -function li_image(imagepath, text_width_percent, text)
> -   return p("<br>") .. div("width=100%", "") ..
> -         div(p(img(imagepath))) ..
> +function li_image(imagepath, text)
> +   return
> +      div("width=100%",
> +         div(p(vspace(6) .. img(imagepath) .. space(6))) ..
>           div(p(space(6))) ..
> -         div("width="..text_width_percent.."%", p(text)) ..
> -         div("width=100%", "")
> +         div("width=*", p(vspace(6) .. text .. vspace(12)))
> +      )
>  end
>  
>  -- RST
> @@ -423,3 +424,18 @@
>        return ("<div>") .. text_or_attributes .. "</div>"
>     end
>  end
> +
> +-- RST
> +-- .. function:: inline_header(t1, t2)
> +--
> +--    Creates a line of h3 formatted text followed by normal paragraph text.
> +--
> +--    :arg t1: text in h3 format.
> +--    :arg t2: text in p format.
> +--    :returns: header text followed by normal text.
> +--

remove -- and add blank line

> +function inline_header(header, text)
> +   return
> +      div("width=100%",  font("size=13 color=D1D1D1", header .. " ") ..
> +      font("size=12", text))
> +end
> 
> === renamed file 'data/scripting/format_scenario.lua' => 'data/scripting/richtext_scenarios.lua'
> --- data/scripting/format_scenario.lua	2016-10-19 09:00:29 +0000
> +++ data/scripting/richtext_scenarios.lua	2017-12-17 11:22:56 +0000
> @@ -20,31 +22,32 @@
>  --
>  --    :arg img: name of the image to use for this speaker
>  --    :arg clr: a valid 6 char hex color to use for the name of this speaker
> ---    :arg title: Title of this text.
> ---    :arg text: The text itself. If this is nil, :const:`title` is used as text
> ---       instead and there will not be any title.
> +--    :arg title: Title of this text. Use empty string if you don't want any.
> +--    :arg text: The text itself.
>  --    :returns: the formatted text.
>  --

same as above

> -function speech(img, clr, g_title, g_text)
> -   local title, text = g_title, g_text
> -   if not text then
> -      title = nil
> -      text = g_title
> +function speech(img, clr, title, text)
> +   if title ~= "" then
> +      title = h1(clr, title)
>     end
>  
>     -- Surround the text with translatable ","
>     text = (_'“%s”'):format(text)
>  
> -   local s = ""
> -   if title then
> -      s = rt("<p font-size=20 font-weight=bold font-face=serif " ..
> -         ("font-color=%s>"):format(clr) .. title ..
> -         "</p><p font-size=8> <br></p>"
> -      )
> -   end
> -
> -   return s .. rt(("image=%s"):format(img), p(text))
> -end
> +   return title .. li_image(img, p(text))
> +end
> +
> +-- RST
> +-- .. function:: paragraphdivider()
> +--
> +--    Closes a paragraph and opens a new paragraph. Use this when you format a string with the speech function
> +--    and need to divide the speech into multiple paragraphs.
> +--
> +--    :returns: close_p() .. open_p()

blank line

> +function paragraphdivider()
> +   return close_p() .. open_p()
> +end
> +
>  
>  
>  -- RST


-- 
https://code.launchpad.net/~widelands-dev/widelands/fh1-scenario-groundwork-emp1/+merge/335294
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fh1-scenario-groundwork-emp1 into lp:widelands.


References