From a97209abc3ceba514d9f3ed1ebb366074186cd1e Mon Sep 17 00:00:00 2001 From: Lari Nieminen Date: Sat, 13 Nov 2010 21:43:43 +0000 Subject: [PATCH] Applied patch #2201: show_turn_counter for win conditions. --- data/core/about.cfg | 3 +++ data/lua/wml/objectives.lua | 31 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/data/core/about.cfg b/data/core/about.cfg index 6d59f8ab80a..65f7573a2a8 100644 --- a/data/core/about.cfg +++ b/data/core/about.cfg @@ -1092,6 +1092,9 @@ [entry] name = "Serge Martin (EdB)" [/entry] + [entry] + name = "Simon Forsyth (Alarantalara)" + [/entry] [entry] name = "Simon Smith (Simons Mith)" comment = "Style guide, help with the application of the style guide, and some tips" diff --git a/data/lua/wml/objectives.lua b/data/lua/wml/objectives.lua index 1b86540d4b0..04decdcf138 100644 --- a/data/lua/wml/objectives.lua +++ b/data/lua/wml/objectives.lua @@ -58,6 +58,21 @@ local function generate_objectives(cfg) local show_if = helper.get_child(obj, "show_if") if not show_if or wesnoth.eval_conditional(show_if) then local condition = obj.condition + local turn_counter = "" + + if obj.show_turn_counter then + local current_turn = wesnoth.current.turn + local turn_limit = wesnoth.game_config.last_turn + + if turn_limit >= current_turn then + if turn_limit - current_turn + 1 > 1 then + turn_counter = " " .. string.format(tostring(_"(%d turns left)"), turn_limit - current_turn + 1) .. "" + else + turn_counter = " " .. _"(this turn left)" .. "" + end + end + end + if condition == "win" then local caption = obj.caption @@ -65,23 +80,9 @@ local function generate_objectives(cfg) win_objectives = win_objectives .. caption .. "\n" end - win_objectives = win_objectives .. color_prefix(0, 255, 0) .. bullet .. obj.description .. "" .. "\n" + win_objectives = win_objectives .. color_prefix(0, 255, 0) .. bullet .. obj.description .. turn_counter .. "" .. "\n" elseif condition == "lose" then local caption = obj.caption - local turn_counter = "" - - if obj.show_turn_counter then - local current_turn = wesnoth.current.turn - local turn_limit = wesnoth.game_config.last_turn - - if turn_limit >= current_turn then - if turn_limit - current_turn + 1 > 1 then - turn_counter = " " .. string.format(tostring(_"(%d turns left)"), turn_limit - current_turn + 1) .. "" - else - turn_counter = " " .. "(this turn left)" .. "" - end - end - end if caption then lose_objectives = lose_objectives .. caption .. "\n"