widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04211
[Merge] lp:~widelands-dev/widelands/bug-1201398 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1201398 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1201398 in widelands: "Save game claims win condition is Scenario, even when it isn't"
https://bugs.launchpad.net/widelands/+bug/1201398
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1201398/+merge/266182
Load the Win Condition's name when single player savegame is loaded, so ti will be saved with the next savegame.
Win Condition titles are now saved into savegames without localization.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1201398 into lp:widelands.
=== modified file 'scripting/win_conditions/collectors.lua'
--- scripting/win_conditions/collectors.lua 2015-05-06 07:15:40 +0000
+++ scripting/win_conditions/collectors.lua 2015-07-29 06:10:18 +0000
@@ -12,7 +12,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Collectors"
+local wc_name = "Collectors"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Collectors")
local wc_version = 2
local wc_desc = _ (
"You get points for precious wares in your warehouses. The player with " ..
@@ -25,7 +28,7 @@
func = function()
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- Simple flowing text. One Paragraph
local function p(s)
@@ -152,10 +155,10 @@
table.sort(points, function(a,b) return a[2] < b[2] end)
for i=1,#points-1 do
points[i][1]:send_message(lost_game_over.title, lost_game_over.body)
- wl.game.report_result(points[i][1], 0, make_extra_data(points[i][1], wc_name, wc_version, {score=points[i][2]}))
+ wl.game.report_result(points[i][1], 0, make_extra_data(points[i][1], wc_descname, wc_version, {score=points[i][2]}))
end
points[#points][1]:send_message(won_game_over.title, won_game_over.body)
- wl.game.report_result(points[#points][1], 1, make_extra_data(points[#points][1], wc_name, wc_version, {score=points[#points][2]}))
+ wl.game.report_result(points[#points][1], 1, make_extra_data(points[#points][1], wc_descname, wc_version, {score=points[#points][2]}))
end
-- Instantiate the hook to calculate points
@@ -185,7 +188,7 @@
local runs = 0
repeat
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
runs = runs + 1
until runs >= 120 -- 120 * 5000ms = 600000 ms = 10 minutes
remaining_time = remaining_time - 10
=== modified file 'scripting/win_conditions/defeat_all.lua'
--- scripting/win_conditions/defeat_all.lua 2015-01-31 08:39:43 +0000
+++ scripting/win_conditions/defeat_all.lua 2015-07-29 06:10:18 +0000
@@ -9,7 +9,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Autocrat"
+local wc_name = "Autocrat"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Autocrat")
local wc_version = 2
local wc_desc = _ "The tribe or team that can defeat all others wins the game!"
return {
@@ -19,20 +22,20 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- Iterate all players, if one is defeated, remove him
-- from the list, send him a defeated message and give him full vision
repeat
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
until count_factions(plrs) <= 1
-- Send congratulations to all remaining players
broadcast_win(plrs,
won_game.title,
won_game.body,{},
- wc_name, wc_version
+ wc_descname, wc_version
)
end,
=== modified file 'scripting/win_conditions/endless_game.lua'
--- scripting/win_conditions/endless_game.lua 2015-01-31 08:39:43 +0000
+++ scripting/win_conditions/endless_game.lua 2015-07-29 06:10:18 +0000
@@ -9,7 +9,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Endless Game"
+local wc_name = "Endless Game"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Endless Game")
local wc_version = 1
local wc_desc = _"This is an endless game without rules."
return {
@@ -19,13 +22,13 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- Iterate all players, if one is defeated, remove him
-- from the list, send him a defeated message and give him full vision
repeat
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
until count_factions(plrs) < 1
end
=== modified file 'scripting/win_conditions/endless_game_fogless.lua'
--- scripting/win_conditions/endless_game_fogless.lua 2015-01-31 08:39:43 +0000
+++ scripting/win_conditions/endless_game_fogless.lua 2015-07-29 06:10:18 +0000
@@ -9,8 +9,11 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Endless Game (no fog)"
-local wc_desc = _ "This is an endless game without rules. Fog of war is disabled."
+local wc_name = "Endless Game (no fog)"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Endless Game (no fog)")
+local wc_desc = _ "This is an endless game without rules. Fog of war is disabled."
local wc_version = 1
return {
name = wc_name,
@@ -19,7 +22,7 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- reveal the whole map for every player
local game = wl.Game()
@@ -40,7 +43,7 @@
-- from the list, send him a defeated message and give him full vision
repeat
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
until count_factions(plrs) < 1
end
=== modified file 'scripting/win_conditions/territorial_lord.lua'
--- scripting/win_conditions/territorial_lord.lua 2015-01-31 08:39:43 +0000
+++ scripting/win_conditions/territorial_lord.lua 2015-07-29 06:10:18 +0000
@@ -11,7 +11,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Territorial Lord"
+local wc_name = "Territorial Lord"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Territorial Lord")
local wc_version = 2
local wc_desc = _ (
"Each player or team tries to obtain more than half of the map’s " ..
@@ -25,7 +28,7 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- Get all valueable fields of the map
local fields = {}
@@ -178,7 +181,7 @@
-- Start a new coroutine that checks for defeated players
run(function()
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
end)
-- here is the main loop!!!
@@ -196,10 +199,10 @@
if candidateisteam and currentcandidate == p.team
or not candidateisteam and currentcandidate == p.name then
p:send_message(won_game_over.title, won_game_over.body)
- wl.game.report_result(p, 1, make_extra_data(p, wc_name, wc_version, {score=_landsizes[p.number]}))
+ wl.game.report_result(p, 1, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
else
p:send_message(lost_game_over.title, lost_game_over.body)
- wl.game.report_result(p, 0, make_extra_data(p, wc_name, wc_version, {score=_landsizes[p.number]}))
+ wl.game.report_result(p, 0, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
end
end
break
=== modified file 'scripting/win_conditions/territorial_time.lua'
--- scripting/win_conditions/territorial_time.lua 2015-01-31 08:39:43 +0000
+++ scripting/win_conditions/territorial_time.lua 2015-07-29 06:10:18 +0000
@@ -11,7 +11,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Territorial Time"
+local wc_name = "Territorial Time"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Territorial Time")
local wc_version = 1
local wc_desc = _ (
"Each player or team tries to obtain more than half of the map’s " ..
@@ -30,7 +33,7 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
-- Get all valueable fields of the map
local fields = {}
@@ -240,7 +243,7 @@
run(function()
sleep(5000)
check_player_defeated(plrs, lost_game.title,
- lost_game.body, wc_name, wc_version)
+ lost_game.body, wc_descname, wc_version)
end)
-- here is the main loop!!!
@@ -284,10 +287,10 @@
if points[i][1] == team_str:format(p.team) or points[i][1] == p.name then
if points[i][2] >= maxpoints then
p:send_message(won_game_over.title, wonmsg .. _status(points, "had"))
- wl.game.report_result(p, 1, make_extra_data(p, wc_name, wc_version, {score=_landsizes[p.number]}))
+ wl.game.report_result(p, 1, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
else
p:send_message(lost_game_over.title, lostmsg .. _status(points, "had"))
- wl.game.report_result(p, 0, make_extra_data(p, wc_name, wc_version, {score=_landsizes[p.number]}))
+ wl.game.report_result(p, 0, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
end
end
end
=== modified file 'scripting/win_conditions/wood_gnome.lua'
--- scripting/win_conditions/wood_gnome.lua 2015-03-21 13:18:02 +0000
+++ scripting/win_conditions/wood_gnome.lua 2015-07-29 06:10:18 +0000
@@ -10,7 +10,10 @@
include "scripting/win_condition_texts.lua"
-local wc_name = _ "Wood Gnome"
+local wc_name = "Wood Gnome"
+-- This needs to be exactly like wc_name, but localized, because wc_name
+-- will be used as the key to fetch the translation in C++
+local wc_descname = _("Wood Gnome")
local wc_version = 2
local wc_desc = _(
[[As wood gnome you like big forests, so your task is to have more trees on ]] ..
@@ -24,7 +27,7 @@
local plrs = wl.Game().players
-- set the objective with the game type for all players
- broadcast_objective("win_condition", wc_name, wc_desc)
+ broadcast_objective("win_condition", wc_descname, wc_desc)
local remaining_time = 4 * 60 -- 4 hours
@@ -97,7 +100,7 @@
-- Start a new coroutine that checks for defeated players
run(function()
sleep(5000)
- check_player_defeated(plrs, lost_game.title, lost_game.body, wc_name, wc_version)
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
end)
-- Install statistics hook
@@ -150,12 +153,12 @@
privmsg = lost_game_over.title
privmsg = privmsg .. msg
points[i][1]:send_message(lost_game_over.body, privmsg)
- wl.game.report_result(points[i][1], 0, make_extra_data(points[i][1], wc_name, wc_version, {score=points[i][2]}))
+ wl.game.report_result(points[i][1], 0, make_extra_data(points[i][1], wc_descname, wc_version, {score=points[i][2]}))
end
privmsg = won_game_over.title
privmsg = privmsg .. msg
points[#points][1]:send_message(won_game_over.body, privmsg)
wl.game.report_result(points[#points][1], 1,
- make_extra_data(points[#points][1], wc_name, wc_version, {score=points[#points][2]}))
+ make_extra_data(points[#points][1], wc_descname, wc_version, {score=points[#points][2]}))
end
}
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2015-04-07 06:49:51 +0000
+++ src/logic/game.cc 2015-07-29 06:10:18 +0000
@@ -394,6 +394,7 @@
Widelands::GamePreloadPacket gpdp;
gl.preload_game(gpdp);
std::string background(gpdp.get_background());
+ m_win_condition_displayname = gpdp.get_win_condition();
loaderUI.set_background(background);
player_nr = gpdp.get_player_nr();
set_ibase
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2015-01-31 16:03:59 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2015-07-29 06:10:18 +0000
@@ -305,7 +305,10 @@
std::string name = t->get_string("name");
std::string descr = t->get_string("description");
- m_wincondition.set_title(name);
+ {
+ i18n::Textdomain td("win_conditions");
+ m_wincondition.set_title(_(name));
+ }
m_wincondition.set_tooltip(descr.c_str());
} catch (LuaTableKeyError &) {
// might be that this is not a win condition after all.
=== modified file 'src/ui_fsmenu/launch_spg.cc'
--- src/ui_fsmenu/launch_spg.cc 2015-02-06 16:37:25 +0000
+++ src/ui_fsmenu/launch_spg.cc 2015-07-29 06:10:18 +0000
@@ -237,7 +237,10 @@
t->do_not_warn_about_unaccessed_keys();
const std::string name = t->get_string("name");
const std::string descr = t->get_string("description");
- m_wincondition.set_title(name);
+ {
+ i18n::Textdomain td("win_conditions");
+ m_wincondition.set_title(_(name));
+ }
m_wincondition.set_tooltip(descr.c_str());
} catch (LuaTableKeyError &) {
// might be that this is not a win condition after all.
=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc 2015-05-02 09:47:26 +0000
+++ src/ui_fsmenu/loadgame.cc 2015-07-29 06:10:18 +0000
@@ -352,7 +352,10 @@
m_ta_version.set_text(gamedata.version);
}
- m_ta_win_condition.set_text(gamedata.wincondition);
+ {
+ i18n::Textdomain td("win_conditions");
+ m_ta_win_condition.set_text(_(gamedata.wincondition));
+ }
std::string minimap_path = gamedata.minimap_path;
// Delete former image
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2014-11-30 18:49:38 +0000
+++ src/wui/game_main_menu_save_game.cc 2015-07-29 06:10:18 +0000
@@ -134,7 +134,10 @@
int player_nr = parent.game().player_manager()->get_number_of_players();
m_players_label.set_text(
(boost::format(ngettext("%i player", "%i players", player_nr)) % player_nr).str());
- m_win_condition.set_text(parent.game().get_win_condition_displayname());
+ {
+ i18n::Textdomain td("win_conditions");
+ m_win_condition.set_text(_(parent.game().get_win_condition_displayname()));
+ }
}
m_editbox->focus();
Follow ups