Changeset View
Standalone View
binaries/data/mods/public/gui/replaymenu/replay_menu.js
Show All 30 Lines | |||||
/** | /** | ||||
* Sorted list of unique maptitles. Used by mapfilter. | * Sorted list of unique maptitles. Used by mapfilter. | ||||
*/ | */ | ||||
var g_MapNames = []; | var g_MapNames = []; | ||||
/** | /** | ||||
* Sorted list of the victory conditions occuring in the replays | * Sorted list of the victory conditions occuring in the replays | ||||
*/ | */ | ||||
var g_VictoryConditions = []; | var g_VictoryConditions = g_Settings && g_Settings.VictoryConditions; | ||||
/** | /** | ||||
* Directory name of the currently selected replay. Used to restore the selection after changing filters. | * Directory name of the currently selected replay. Used to restore the selection after changing filters. | ||||
*/ | */ | ||||
var g_SelectedReplayDirectory = ""; | var g_SelectedReplayDirectory = ""; | ||||
/** | /** | ||||
* Skip duplicate expensive GUI updates before init is complete. | * Skip duplicate expensive GUI updates before init is complete. | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | for (let replay of g_Replays) | ||||
replay.isCompatible = isReplayCompatible(replay); | replay.isCompatible = isReplayCompatible(replay); | ||||
sanitizeGameAttributes(replay.attribs); | sanitizeGameAttributes(replay.attribs); | ||||
// Extract map names | // Extract map names | ||||
if (g_MapNames.indexOf(replay.attribs.settings.Name) == -1 && replay.attribs.settings.Name != "") | if (g_MapNames.indexOf(replay.attribs.settings.Name) == -1 && replay.attribs.settings.Name != "") | ||||
g_MapNames.push(replay.attribs.settings.Name); | g_MapNames.push(replay.attribs.settings.Name); | ||||
// Extract victory conditions | |||||
if (replay.attribs.settings.GameType && g_VictoryConditions.indexOf(replay.attribs.settings.GameType) == -1) | |||||
g_VictoryConditions.push(replay.attribs.settings.GameType); | |||||
// Extract playernames | // Extract playernames | ||||
for (let playerData of replay.attribs.settings.PlayerData) | for (let playerData of replay.attribs.settings.PlayerData) | ||||
elexis: Last time I checked (some releases ago) one could save some performance just loading all… | |||||
Done Inline Actions(I'm really not confident anymore of this being worth the performance effort as opposed to loading it from settings.js. Probably better to replace it with the better than the worse alternative. And displaying gametypes that were never played before could be considered advertizement). elexis: (I'm really not confident anymore of this being worth the performance effort as opposed to… | |||||
Not Done Inline ActionsMaybe the reason it was extracted from maps was to add mod support? elexis: Maybe the reason it was extracted from maps was to add mod support?
Then we would need… | |||||
Not Done Inline Actions(notice this hunk is gone in next diff) bb: (notice this hunk is gone in next diff) | |||||
{ | { | ||||
if (!playerData || playerData.AI) | if (!playerData || playerData.AI) | ||||
continue; | continue; | ||||
// Remove rating from nick | // Remove rating from nick | ||||
let playername = playerData.Name; | let playername = playerData.Name; | ||||
let ratingStart = playername.indexOf(" ("); | let ratingStart = playername.indexOf(" ("); | ||||
if (ratingStart != -1) | if (ratingStart != -1) | ||||
playername = playername.substr(0, ratingStart); | playername = playername.substr(0, ratingStart); | ||||
if (g_Playernames.indexOf(playername) == -1) | if (g_Playernames.indexOf(playername) == -1) | ||||
g_Playernames.push(playername); | g_Playernames.push(playername); | ||||
++nonAIPlayers; | ++nonAIPlayers; | ||||
} | } | ||||
replay.isMultiplayer = nonAIPlayers > 1; | replay.isMultiplayer = nonAIPlayers > 1; | ||||
replay.isRated = nonAIPlayers == 2 && | replay.isRated = nonAIPlayers == 2 && | ||||
replay.attribs.settings.PlayerData.length == 2 && | replay.attribs.settings.PlayerData.length == 2 && | ||||
replay.attribs.settings.RatingEnabled; | replay.attribs.settings.RatingEnabled; | ||||
} | } | ||||
g_MapNames.sort(); | g_MapNames.sort(); | ||||
g_VictoryConditions.sort(); | |||||
// Reload filters (since they depend on g_Replays and its derivatives) | // Reload filters (since they depend on g_Replays and its derivatives) | ||||
initFilters(replaySelectionData && replaySelectionData.filters); | initFilters(replaySelectionData && replaySelectionData.filters); | ||||
// Restore user selection | // Restore user selection | ||||
if (replaySelectionData) | if (replaySelectionData) | ||||
{ | { | ||||
if (replaySelectionData.directory) | if (replaySelectionData.directory) | ||||
Show All 27 Lines | if (!attribs.settings.PlayerData) | ||||
attribs.settings.PlayerData = []; | attribs.settings.PlayerData = []; | ||||
if (!attribs.settings.PopulationCap) | if (!attribs.settings.PopulationCap) | ||||
attribs.settings.PopulationCap = 300; | attribs.settings.PopulationCap = 300; | ||||
if (!attribs.settings.mapType) | if (!attribs.settings.mapType) | ||||
attribs.settings.mapType = "skirmish"; | attribs.settings.mapType = "skirmish"; | ||||
if (!attribs.settings.GameType) | |||||
attribs.settings.GameType = "conquest"; | |||||
elexisUnsubmitted Not Done Inline Actions(How, why has this even been here... Don't tell me it was a silent default hardcoded everywhere) elexis: (How, why has this even been here... Don't tell me it was a silent default hardcoded everywhere) | |||||
bbAuthorUnsubmitted Not Done Inline ActionsI don't tell you bb: I don't tell you | |||||
elexisUnsubmitted Not Done Inline ActionsIt comes from r17054, was probably introduced for completeness. (Could nuke some others too, probably in a separate patch, probably something for after the release or for when being really certain that it doesn't break under any circumstance.) elexis: It comes from r17054, was probably introduced for completeness. (Could nuke some others too… | |||||
// Remove gaia | // Remove gaia | ||||
if (attribs.settings.PlayerData.length && attribs.settings.PlayerData[0] == null) | if (attribs.settings.PlayerData.length && attribs.settings.PlayerData[0] == null) | ||||
attribs.settings.PlayerData.shift(); | attribs.settings.PlayerData.shift(); | ||||
attribs.settings.PlayerData.forEach((pData, index) => { | attribs.settings.PlayerData.forEach((pData, index) => { | ||||
if (!pData.Name) | if (!pData.Name) | ||||
pData.Name = ""; | pData.Name = ""; | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | function displayReplayDetails() | ||||
if (!replaySelected) | if (!replaySelected) | ||||
return; | return; | ||||
let replay = g_ReplaysFiltered[selected]; | let replay = g_ReplaysFiltered[selected]; | ||||
Engine.GetGUIObjectByName("sgMapName").caption = translate(replay.attribs.settings.Name); | Engine.GetGUIObjectByName("sgMapName").caption = translate(replay.attribs.settings.Name); | ||||
Engine.GetGUIObjectByName("sgMapSize").caption = translateMapSize(replay.attribs.settings.Size); | Engine.GetGUIObjectByName("sgMapSize").caption = translateMapSize(replay.attribs.settings.Size); | ||||
Engine.GetGUIObjectByName("sgMapType").caption = translateMapType(replay.attribs.settings.mapType); | Engine.GetGUIObjectByName("sgMapType").caption = translateMapType(replay.attribs.settings.mapType); | ||||
Engine.GetGUIObjectByName("sgVictory").caption = translateVictoryCondition(replay.attribs.settings.GameType); | Engine.GetGUIObjectByName("sgVictory").caption = replay.attribs.settings.VictoryConditions.map(victoryConditionName => | ||||
translateVictoryCondition(victoryConditionName)).join(translate(", ")); | |||||
Not Done Inline Actionssame elexis: same | |||||
Not Done Inline Actions(Thought we had translation context somewhere, apparently not. So ok.) elexis: (Thought we had translation context somewhere, apparently not. So ok.) | |||||
Engine.GetGUIObjectByName("sgNbPlayers").caption = sprintf(translate("Players: %(numberOfPlayers)s"), | Engine.GetGUIObjectByName("sgNbPlayers").caption = sprintf(translate("Players: %(numberOfPlayers)s"), | ||||
{ "numberOfPlayers": replay.attribs.settings.PlayerData.length }); | { "numberOfPlayers": replay.attribs.settings.PlayerData.length }); | ||||
Engine.GetGUIObjectByName("replayFilename").caption = Engine.GetReplayDirectoryName(replay.directory); | Engine.GetGUIObjectByName("replayFilename").caption = Engine.GetReplayDirectoryName(replay.directory); | ||||
let metadata = Engine.GetReplayMetadata(replay.directory); | let metadata = Engine.GetReplayMetadata(replay.directory); | ||||
Engine.GetGUIObjectByName("sgPlayersNames").caption = | Engine.GetGUIObjectByName("sgPlayersNames").caption = | ||||
formatPlayerInfo( | formatPlayerInfo( | ||||
replay.attribs.settings.PlayerData, | replay.attribs.settings.PlayerData, | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
Last time I checked (some releases ago) one could save some performance just loading all options rather than extracting them from the maps, but not important to check now.