GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1366725 into lp:widelands.
Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1366725 in widelands: "Building help assumes that every worker needs only one tool" https://bugs.launchpad.net/widelands/+bug/1366725 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1366725/+merge/233750 Bugfix: building help now displays multiple tools if needed, e.g. for the Imperial Vineyard -- https://code.launchpad.net/~widelands-dev/widelands/bug-1366725/+merge/233750 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1366725 into lp:widelands.
=== modified file 'tribes/scripting/format_help.lua' --- tribes/scripting/format_help.lua 2014-07-27 12:51:29 +0000 +++ tribes/scripting/format_help.lua 2014-09-08 16:21:38 +0000 @@ -667,7 +667,8 @@ local worker_description = building_description.working_positions[1] local becomes_description = nil local number_of_workers = 0 - local toolname = nil + local toolnames = {} + local number_of_tools = 0 for i, worker_description in ipairs(building_description.working_positions) do @@ -675,7 +676,8 @@ if(worker_description.buildable) then for j, buildcost in ipairs(worker_description.buildcost) do if( not (buildcost == "carrier" or buildcost == "none" or buildcost == nil)) then - toolname = buildcost + number_of_tools = number_of_tools + 1 + toolnames[number_of_tools] = buildcost end end end @@ -692,7 +694,9 @@ end end - if(toolname) then result = result .. building_help_tool_string(tribename, toolname, number_of_workers) end + if(number_of_tools > 0) then + result = result .. building_help_tool_string(tribename, toolnames, number_of_workers) + end if(becomes_description) then @@ -723,17 +727,20 @@ -- RST -- .. function building_help_tool_string(tribename, toolname) -- --- Displays a tool with an intro text and image +-- Displays tools with an intro text and images -- -- :arg tribename: e.g. "barbarians". --- :arg toolname: e.g. "felling_axe". --- :arg no_of_workers: the number of workers using the tool; for plural formatting. --- :returns: text_line for the tool +-- :arg toolnames: e.g. {"shovel", "basket"}. +-- :arg no_of_workers: the number of workers using the tools; for plural formatting. +-- :returns: text_line for the tools -- -function building_help_tool_string(tribename, toolname, no_of_workers) - local ware_description = wl.Game():get_ware_description(tribename, toolname) - return text_line((ngettext("Worker uses:","Workers use:", no_of_workers)), - ware_description.descname, ware_description.icon_name) +function building_help_tool_string(tribename, toolnames, no_of_workers) + local result = rt(h3(ngettext("Worker uses:","Workers use:", no_of_workers))) + for i, toolname in ipairs(toolnames) do + local ware_description = wl.Game():get_ware_description(tribename, toolname) + result = result .. image_line(ware_description.icon_name, 1, p(ware_description.descname)) + end + return result end -- RST
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp