1
2function RunResultsMenu()
3	local background
4	local result
5
6	StopMusic()
7	if (GameResult == GameVictory) then
8		result = "Victory!"
9		if (GetPlayerData(GetThisPlayer(), "RaceName") == "dwarf") then
10			background = GetBackground("ui/backgrounds/yale.png")
11		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "gnome") then
12			background = GetBackground("ui/backgrounds/yale.png")
13		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "kobold") then
14			background = GetBackground("ui/backgrounds/wyrm.png")
15		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "germanic") then
16			background = GetBackground("ui/backgrounds/wyrm.png")
17		else
18			background = GetBackground("ui/backgrounds/gryphon.png")
19		end
20		PlayMusicByGroupAndFactionRandom("win", GetPlayerData(GetThisPlayer(), "RaceName"), GetPlayerData(GetThisPlayer(), "Faction"))
21	elseif (GameResult == GameDefeat) then
22		result = "Defeat!"
23		if (GetPlayerData(GetThisPlayer(), "RaceName") == "dwarf") then
24			background = GetBackground("ui/backgrounds/wyrm.png")
25		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "gnome") then
26			background = GetBackground("ui/backgrounds/wyrm.png")
27		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "goblin") then
28			background = GetBackground("ui/backgrounds/yale.png")
29		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "kobold") then
30			background = GetBackground("ui/backgrounds/yale.png")
31		elseif (GetPlayerData(GetThisPlayer(), "RaceName") == "germanic" or GetPlayerData(GetThisPlayer(), "RaceName") == "anglo-saxon" or GetPlayerData(GetThisPlayer(), "RaceName") == "english" or GetPlayerData(GetThisPlayer(), "RaceName") == "frankish" or GetPlayerData(GetThisPlayer(), "RaceName") == "goth" or GetPlayerData(GetThisPlayer(), "RaceName") == "norse" or GetPlayerData(GetThisPlayer(), "RaceName") == "suebi" or GetPlayerData(GetThisPlayer(), "RaceName") == "teuton") then
32			background = GetBackground("ui/backgrounds/wyrm.png")
33		else
34			background = GetBackground("ui/backgrounds/wyrm.png")
35		end
36		PlayMusicByGroupAndFactionRandom("lose", GetPlayerData(GetThisPlayer(), "RaceName"), GetPlayerData(GetThisPlayer(), "Faction"))
37	elseif (GameResult == GameDraw) then
38		result = "Draw!"
39		background = GetBackground("ui/backgrounds/gullinburst.png")
40	else
41		return -- quit to menu
42	end
43
44	local menu = WarMenu(nil, background)
45	local offx = (Video.Width - 640) / 2
46	local offy = (Video.Height - 480) / 2
47
48--	local names_font = Fonts["small-title"]
49	local names_font = Fonts["large"]
50	local top_offset = 57
51	local bottom_offset = 178
52	local description_offset = 30
53
54	local c = 0
55	for i=0,7 do
56		if (GetPlayerData(i, "TotalUnits") > 0 and Players[i].Type ~= PlayerRescuePassive and Players[i].Type ~= PlayerRescueActive) then
57			c = c + 1
58		end
59	end
60
61	local line_spacing = (432 - bottom_offset - description_offset) / c
62	local player_name_spacing = 104 / c
63	menu:addLabel(_("Outcome"), offx + 106, offy + top_offset)
64--	menu:addLabel(result, offx + 106, offy + top_offset + 21, Fonts["large-title"])
65	menu:addLabel(_(result), offx + 106, offy + top_offset + 21, Fonts["large"])
66
67	menu:addLabel(_("Units"), offx + 50, offy + bottom_offset, Fonts["large"], true)
68	menu:addLabel(_("Buildings"), offx + 140, offy + bottom_offset, Fonts["large"], true)
69	menu:addLabel(_("Copper"), offx + 230, offy + bottom_offset, Fonts["large"], true)
70	menu:addLabel(_("Lumber"), offx + 320, offy + bottom_offset, Fonts["large"], true)
71	menu:addLabel(_("Stone"), offx + 410, offy + bottom_offset, Fonts["large"], true)
72--	menu:addLabel("Oil", offx + 410, offy + bottom_offset, Fonts["large"], true)
73	menu:addLabel(_("Kills"), offx + 500, offy + bottom_offset, Fonts["large"], true)
74	menu:addLabel(_("Razings"), offx + 590, offy + bottom_offset, Fonts["large"], true)
75
76	c = 0
77	for i=0,(PlayerMax - 2) do
78		if (GetPlayerData(i, "TotalUnits") > 0 and Players[i].Type ~= PlayerRescuePassive and Players[i].Type ~= PlayerRescueActive and GetPlayerData(ThisPlayer.Index, "HasContactWith", i)) then
79			local name = _(GetPlayerData(i, "Name"))
80			if (ThisPlayer.Index == i) then
81				name = name .. " - " .. _("You")
82			elseif (ThisPlayer:IsAllied(Players[i])) then
83				name = name .. " - " .. _("Ally")
84			elseif (ThisPlayer:IsEnemy(Players[i])) then
85				name = name .. " - " .. _("Enemy")
86			else
87				name = name .. " - " .. _("Neutral")
88			end
89			menu:addLabel(name, offx + 320,
90				offy + bottom_offset + description_offset + player_name_spacing + line_spacing * c + 5,
91				names_font, true)
92			menu:addLabel(GetPlayerData(i, "TotalUnits"), offx + 10 + 40,
93				offy + bottom_offset + description_offset + line_spacing * c + 5,
94				Fonts["large"], true)
95			menu:addLabel(GetPlayerData(i, "TotalBuildings"), offx + 100 + 40,
96				offy + bottom_offset + description_offset + line_spacing * c + 5,
97				Fonts["large"], true)
98			menu:addLabel(GetPlayerData(i, "TotalResources", "copper"), offx + 190 + 40,
99				offy + bottom_offset + description_offset + line_spacing * c + 5,
100				Fonts["large"], true)
101			menu:addLabel(GetPlayerData(i, "TotalResources", "lumber"), offx + 280 + 40,
102				offy + bottom_offset + description_offset + line_spacing * c + 5,
103				Fonts["large"], true)
104			menu:addLabel(GetPlayerData(i, "TotalResources", "stone"), offx + 370 + 40,
105				offy + bottom_offset + description_offset + line_spacing * c + 5,
106				Fonts["large"], true)
107--			menu:addLabel(GetPlayerData(i, "TotalResources", "oil"), offx + 370 + 40,
108--				offy + bottom_offset + description_offset + line_spacing * c + 5,
109--			  Fonts["large"], true)
110			menu:addLabel(GetPlayerData(i, "TotalKills"), offx + 460 + 40,
111				offy + bottom_offset + description_offset + line_spacing * c + 5,
112				Fonts["large"], true)
113			menu:addLabel(GetPlayerData(i, "TotalRazings"), offx + 550 + 40,
114				offy + bottom_offset + description_offset + line_spacing * c + 5,
115				Fonts["large"], true)
116
117			c = c + 1
118
119			if (c >= 8) then
120				break
121			end
122		end
123	end
124
125--	menu:addFullButton("~!Save Replay", "s", offx + 150, offy + 440,
126--		function() RunSaveReplayMenu() end)
127
128--	menu:addFullButton(_("~!Continue"), "c", offx + 400, offy + 440,
129	menu:addFullButton(_("~!Continue"), "c", (Video.Width / 2) - 112, offy + 440,
130		function()
131			CleanPlayers()
132			StopMusic();
133			menu:stop()
134		end)
135
136	menu:run()
137end
138