Improvements to the objectives dialog:

...made each objective and other note be prefixed with a bullet, added
support for an optional caption= key to [objective], added a few new
helper macros for adding footnotes to objectives and converted all
current alternative and bonus objective texts accordingly.
This commit is contained in:
Lari Nieminen 2010-08-07 16:31:29 +00:00
parent 1eb70d2b37
commit 0a76931dd6
22 changed files with 86 additions and 51 deletions

View File

@ -84,8 +84,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='#00ff00'>Defeat all enemy leaders</span> <small>(different bonus for each)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders"+{OBJECTIVE_FOOTNOTE "(different bonus for each)"}
condition=win
[/objective]

View File

@ -20,8 +20,8 @@
[/objective]
#ifdef HARD
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat the enemy leader</span> <small>(special bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat the enemy leader"+{OBJECTIVE_FOOTNOTE "(special bonus)"}
condition=win
[/objective]
#endif

View File

@ -20,8 +20,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat all enemy leaders</span> <small>(early finish bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -22,8 +22,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat Muff Malal</span> <small>(early finish bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat Muff Malal"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -20,8 +20,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat all enemy leaders</span> <small>(special bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders"+{OBJECTIVE_FOOTNOTE "(special bonus)"}
condition=win
[/objective]
[objective]

View File

@ -19,8 +19,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Eradicate the liches</span> <small>(early finish bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Eradicate the liches"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -22,8 +22,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Bonus objective:</span>
<span color='green'>Defeat all Death Knights first</span>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat all Death Knights first"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -827,8 +827,8 @@ Soooo... It is you who sent your subordinates to attack us. Now when we've destr
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Optional objective:</span>
<span color='green'>Rescue the sergeant</span>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Rescue the sergeant"
condition=win
[/objective]
[objective]

View File

@ -24,8 +24,13 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Optional objective:</span>
<span color='green'>Help the Wose fend off the undead attack</span>"
# There's no actual bonus to be gained yet...
[show_if]
[not]
[/not]
[/show_if]
{BONUS_OBJECTIVE_CAPTION}
description= _ "Help the Wose fend off the undead attack"
condition=win
[/objective]
[objective]

View File

@ -40,8 +40,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Bonus objective:</span>
<span color='green'>Defeat all enemy leaders</span>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders"
condition=win
[/objective]
[objective]

View File

@ -508,8 +508,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat Grugl</span>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat Grugl"
condition=win
[/objective]
[objective]

View File

@ -846,7 +846,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='gold'>Bonus objective: Defeat Urudin </span>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat Urudin"
condition=win
[/objective]
[/objectives]

View File

@ -127,8 +127,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat Glildur</span> <small>(early finish bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat Glildur"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -31,8 +31,8 @@
[/objective]
[objective]
condition=win
description=_ "<span color='white'>Bonus objective:</span>
<span color='green'>Defeat the enemy leader</span> <small>(early finish bonus)</small>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat the enemy leader"+{EARLY_FINISH_BONUS_FOOTNOTE}
[/objective]
[objective]
condition=lose
@ -277,8 +277,8 @@
[/objective]
[objective]
condition=win
description=_ "<span color='white'>Bonus objective:</span>
<span color='green'>Defeat the enemy leader</span> <small>(early finish bonus)</small>"
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat the enemy leader"+{EARLY_FINISH_BONUS_FOOTNOTE}
[/objective]
[objective]
condition=lose

View File

@ -21,8 +21,8 @@
condition=win
[/objective]
[objective]
description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat Shan Taum</span> <small>(early finish bonus)</small>"
{ALTERNATIVE_OBJECTIVE_CAPTION}
description= _ "Defeat Shan Taum"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -227,21 +227,23 @@
[objectives]
side=1
[objective]
description= _ "Cowardly: Flee on the First Ship"
caption= _ "Cowardly:"
description= _ "Flee on the First Ship"
condition=win
[/objective]
[objective]
description= _ "Normal: Flee on the Second Ship"
caption= _ "Normal:"
description= _ "Flee on the Second Ship"
condition=win
[/objective]
[objective]
description= _ "Heroic: Flee on the Third Ship"+"
"+{EARLY_FINISH_BONUS_CAPTION}
caption= _ "Heroic:"
description= _ "Flee on the Third Ship"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]
description= _ "Heroic: Defeat all enemy leaders"+"
"+{EARLY_FINISH_BONUS_CAPTION}
caption= _ "Heroic:"
description= _ "Defeat all enemy leaders"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -189,8 +189,8 @@
[/objective]
# FIXME: looks like only one orc leader needs to be killed
[objective]
description= _ "Heroic: In addition to above, kill all enemy leaders"+"
"+{EARLY_FINISH_BONUS_CAPTION}
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -126,8 +126,8 @@
condition=win
[/objective]
[objective]
description= _ "Defeat all enemy leaders and Prince Haldric exits the sewer"+"
"+{EARLY_FINISH_BONUS_CAPTION}
{BONUS_OBJECTIVE_CAPTION}
description= _ "Defeat all enemy leaders and Prince Haldric exits the sewer"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -212,8 +212,8 @@
condition=win
[/objective]
[objective]
description= _ "Heroic: Slay the Dragon and defeat all enemies"+"
"+{EARLY_FINISH_BONUS_CAPTION}
{BONUS_OBJECTIVE_CAPTION}
description= _ "Slay the Dragon and defeat all enemy leaders"+{EARLY_FINISH_BONUS_FOOTNOTE}
condition=win
[/objective]
[objective]

View File

@ -14,6 +14,9 @@ _"No early finish bonus."#enddef
#define EARLY_FINISH_BONUS_CAPTION
_"<small>(early finish bonus)</small>"#enddef
#define EARLY_FINISH_BONUS_FOOTNOTE
"<span foreground='white'><small> " + _"(early finish bonus)" + "</small></span>"#enddef
#define NO_GOLD_CARRYOVER_NOTE
_"No gold carried over to the next scenario."#enddef

View File

@ -34,6 +34,18 @@ x,y=1-999,1-999 #enddef
[/objectives]
#enddef
#define OBJECTIVE_FOOTNOTE TEXT
"<span foreground='white'><small> " + {TEXT} + "</small></span>"
#enddef
#define ALTERNATIVE_OBJECTIVE_CAPTION
caption= _ "Alternative objective:"
#enddef
#define BONUS_OBJECTIVE_CAPTION
caption= _ "Bonus objective:"
#enddef
#define VICTORY_CONDITION DESCRIPTION
# Used in conjunction with SET_OBJECTIVES this sets a victory condition
# (marked green).

View File

@ -34,16 +34,28 @@ local function generate_objectives(cfg)
local gold_carryover_string = cfg.gold_carryover_string or _ "Gold carryover:"
local notes_string = cfg.notes_string or _ "Notes:"
local bullet = "&#8226; "
for obj in helper.child_range(cfg, "objective") do
local show_if = helper.get_child(obj, "show_if")
if not show_if or wesnoth.eval_conditional(show_if) then
local condition = obj.condition
if condition == "win" then
win_objectives = win_objectives .. color_prefix(0, 255, 0) ..
insert_before_nl(obj.description, "</span>") .. "\n"
local caption = obj.caption
if caption ~= nil then
win_objectives = win_objectives .. caption .. "\n"
end
win_objectives = win_objectives .. color_prefix(0, 255, 0) .. bullet .. obj.description .. "</span>" .. "\n"
elseif condition == "lose" then
lose_objectives = lose_objectives .. color_prefix(255, 0 ,0) ..
insert_before_nl(obj.description, "</span>") .. "\n"
local caption = obj.caption
if caption ~= nil then
lose_objectives = lose_objectives .. caption .. "\n"
end
lose_objectives = lose_objectives .. color_prefix(255, 0, 0) .. bullet .. obj.description .. "</span>" .. "\n"
else
wesnoth.message "Unknown condition, ignoring."
end
@ -53,20 +65,20 @@ local function generate_objectives(cfg)
for obj in helper.child_range(cfg, "gold_carryover") do
if obj.bonus ~= nil then
if obj.bonus then
gold_carryover = color_prefix(255, 255, 192) .. "<small>" .. _"Early finish bonus." .. "</small></span>\n"
gold_carryover = color_prefix(255, 255, 192) .. bullet .. "<small>" .. _"Early finish bonus." .. "</small></span>\n"
else
gold_carryover = color_prefix(255, 255, 192) .. "<small>" .. _"No early finish bonus." .. "</small></span>\n"
gold_carryover = color_prefix(255, 255, 192) .. bullet .. "<small>" .. _"No early finish bonus." .. "</small></span>\n"
end
end
if obj.carryover_percentage then
gold_carryover = gold_carryover .. color_prefix(255, 255, 192) .. "<small>" .. string.format(tostring(_ "%d%% of gold carried over to the next scenario."), obj.carryover_percentage) .. "</small></span>\n"
gold_carryover = gold_carryover .. color_prefix(255, 255, 192) .. bullet .. "<small>" .. string.format(tostring(_ "%d%% of gold carried over to the next scenario."), obj.carryover_percentage) .. "</small></span>\n"
end
end
for note in helper.child_range(cfg, "note") do
if note.description ~= nil then
notes = notes .. color_prefix(255, 255, 255) .. "<small>" .. note.description .. "</small></span>\n"
notes = notes .. color_prefix(255, 255, 255) .. bullet .. "<small>" .. note.description .. "</small></span>\n"
end
end