forked from 0ad/0ad
Explain the new victory conditions and last man standing option in the gamesetup. Add an ingame dialog showing these explanations and all other chosen gamesetup options, so that players don't have to recall them and late observers don't have to ask. This was SVN commit r18692.
This commit is contained in:
parent
9b52dfb554
commit
317502d915
BIN
binaries/data/mods/public/art/textures/ui/session/icons/die.png
(Stored with Git LFS)
Normal file
BIN
binaries/data/mods/public/art/textures/ui/session/icons/die.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
binaries/data/mods/public/art/textures/ui/session/icons/objectives.png
(Stored with Git LFS)
BIN
binaries/data/mods/public/art/textures/ui/session/icons/objectives.png
(Stored with Git LFS)
Binary file not shown.
@ -121,40 +121,6 @@ function translateMapTitle(mapTitle)
|
||||
return mapTitle == "random" ? translateWithContext("map selection", "Random") : translate(mapTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns map description and preview image or placeholder.
|
||||
*/
|
||||
function getMapDescriptionAndPreview(mapType, mapName)
|
||||
{
|
||||
var mapData;
|
||||
if (mapType == "random" && mapName == "random")
|
||||
mapData = { "settings": { "Description": translate("A randomly selected map.") } };
|
||||
else if (mapType == "random" && Engine.FileExists(mapName + ".json"))
|
||||
mapData = Engine.ReadJSONFile(mapName + ".json");
|
||||
else if (Engine.FileExists(mapName + ".xml"))
|
||||
mapData = Engine.LoadMapSettings(mapName + ".xml");
|
||||
|
||||
return {
|
||||
"description": mapData && mapData.settings && mapData.settings.Description ? translate(mapData.settings.Description) : translate("Sorry, no description available."),
|
||||
"preview": mapData && mapData.settings && mapData.settings.Preview ? mapData.settings.Preview : "nopreview.png"
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mappreview image correctly.
|
||||
* It needs to be cropped as the engine only allows loading square textures.
|
||||
*
|
||||
* @param {string} guiObject
|
||||
* @param {string} filename
|
||||
*/
|
||||
function setMapPreviewImage(guiObject, filename)
|
||||
{
|
||||
let path = "session/icons/mappreview/";
|
||||
Engine.GetGUIObjectByName(guiObject).sprite =
|
||||
"cropped:" + 400/512 + "," + 300/512 + ":" +
|
||||
path + (Engine.FileExists("art/textures/ui/" + path + filename) ? filename : "nopreview.png");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert time in milliseconds to [hh:]mm:ss string representation.
|
||||
* @param time Time period in milliseconds (integer)
|
||||
@ -279,143 +245,3 @@ function notifyUser(userName, msgText)
|
||||
|
||||
g_LastNickNotification = timeNow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted string describing the player assignments.
|
||||
* Needs g_CivData to translate!
|
||||
*
|
||||
* @param {object} playerDataArray - As known from gamesetup and simstate.
|
||||
* @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player.
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatPlayerInfo(playerDataArray, playerStates)
|
||||
{
|
||||
let playerDescriptions = {};
|
||||
let playerIdx = 0;
|
||||
|
||||
for (let playerData of playerDataArray)
|
||||
{
|
||||
if (playerData == null || playerData.Civ && playerData.Civ == "gaia")
|
||||
continue;
|
||||
|
||||
++playerIdx;
|
||||
let teamIdx = playerData.Team;
|
||||
let isAI = playerData.AI && playerData.AI != "";
|
||||
let playerState = playerStates && playerStates[playerIdx] || playerData.State;
|
||||
let isActive = !playerState || playerState == "active";
|
||||
|
||||
let playerDescription;
|
||||
if (isAI)
|
||||
{
|
||||
if (playerData.Civ)
|
||||
{
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdifficulty)s %(AIname)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdifficulty)s %(AIname)s, %(state)s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(AIdifficulty)s %(AIname)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(AIdifficulty)s %(AIname)s, %(state)s)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerData.Offline)
|
||||
{
|
||||
// Can only occur in the lobby for now, so no strings with civ needed
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (OFFLINE)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (OFFLINE, %(state)s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerData.Civ)
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(state)s)");
|
||||
else
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(state)s)");
|
||||
}
|
||||
}
|
||||
|
||||
// Sort player descriptions by team
|
||||
if (!playerDescriptions[teamIdx])
|
||||
playerDescriptions[teamIdx] = [];
|
||||
|
||||
playerDescriptions[teamIdx].push(sprintf(playerDescription, {
|
||||
"playerName":
|
||||
'[color="' +
|
||||
(typeof getPlayerColor == 'function' ?
|
||||
(isAI ? "white" : getPlayerColor(playerData.Name)) :
|
||||
rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color)) +
|
||||
'"]' + escapeText(playerData.Name) + "[/color]",
|
||||
|
||||
"civ":
|
||||
!playerData.Civ ?
|
||||
translate("Unknown Civilization") :
|
||||
g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ?
|
||||
translate(g_CivData[playerData.Civ].Name) :
|
||||
playerData.Civ,
|
||||
|
||||
"state":
|
||||
playerState == "defeated" ?
|
||||
translateWithContext("playerstate", "defeated") :
|
||||
translateWithContext("playerstate", "won"),
|
||||
|
||||
"AIname": isAI ? translateAIName(playerData.AI) : "",
|
||||
"AIdifficulty": isAI ? translateAIDifficulty(playerData.AIDiff) : ""
|
||||
}));
|
||||
}
|
||||
|
||||
let teams = Object.keys(playerDescriptions);
|
||||
if (teams.indexOf("observer") > -1)
|
||||
teams.splice(teams.indexOf("observer"), 1);
|
||||
|
||||
let teamDescription = [];
|
||||
|
||||
// If there are no teams, merge all playersDescriptions
|
||||
if (teams.length == 1)
|
||||
teamDescription.push(playerDescriptions[teams[0]].join("\n"));
|
||||
|
||||
// If there are teams, merge "Team N:" + playerDescriptions
|
||||
else
|
||||
teamDescription = teams.map(team => {
|
||||
|
||||
let teamCaption = team == -1 ?
|
||||
translate("No Team") :
|
||||
sprintf(translate("Team %(team)s"), { "team": +team + 1 });
|
||||
|
||||
// Translation: Describe players of one team in a selected game, f.e. in the replay- or savegame menu or lobby
|
||||
return sprintf(translate("%(team)s:\n%(playerDescriptions)s"), {
|
||||
"team": '[font="sans-bold-14"]' + teamCaption + "[/font]",
|
||||
"playerDescriptions": playerDescriptions[team].join("\n")
|
||||
});
|
||||
});
|
||||
|
||||
if (playerDescriptions.observer)
|
||||
teamDescription.push(sprintf(translate("%(team)s:\n%(playerDescriptions)s"), {
|
||||
"team": '[font="sans-bold-14"]' + translatePlural("Observer", "Observers", playerDescriptions.observer.length) + "[/font]",
|
||||
"playerDescriptions": playerDescriptions.observer.join("\n")
|
||||
}));
|
||||
|
||||
return teamDescription.join("\n\n");
|
||||
}
|
||||
|
332
binaries/data/mods/public/gui/common/gamedescription.js
Normal file
332
binaries/data/mods/public/gui/common/gamedescription.js
Normal file
@ -0,0 +1,332 @@
|
||||
/**
|
||||
* Highlights the victory condition in the game-description.
|
||||
*/
|
||||
var g_DescriptionHighlight = "orange";
|
||||
|
||||
/**
|
||||
* Returns map description and preview image or placeholder.
|
||||
*/
|
||||
function getMapDescriptionAndPreview(mapType, mapName)
|
||||
{
|
||||
let mapData;
|
||||
if (mapType == "random" && mapName == "random")
|
||||
mapData = { "settings": { "Description": translate("A randomly selected map.") } };
|
||||
else if (mapType == "random" && Engine.FileExists(mapName + ".json"))
|
||||
mapData = Engine.ReadJSONFile(mapName + ".json");
|
||||
else if (Engine.FileExists(mapName + ".xml"))
|
||||
mapData = Engine.LoadMapSettings(mapName + ".xml");
|
||||
|
||||
return {
|
||||
"description": mapData && mapData.settings && mapData.settings.Description ? translate(mapData.settings.Description) : translate("Sorry, no description available."),
|
||||
"preview": mapData && mapData.settings && mapData.settings.Preview ? mapData.settings.Preview : "nopreview.png"
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mappreview image correctly.
|
||||
* It needs to be cropped as the engine only allows loading square textures.
|
||||
*
|
||||
* @param {string} guiObject
|
||||
* @param {string} filename
|
||||
*/
|
||||
function setMapPreviewImage(guiObject, filename)
|
||||
{
|
||||
let path = "session/icons/mappreview/";
|
||||
Engine.GetGUIObjectByName(guiObject).sprite =
|
||||
"cropped:" + 400/512 + "," + 300/512 + ":" +
|
||||
path + (Engine.FileExists("art/textures/ui/" + path + filename) ? filename : "nopreview.png");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted string describing the player assignments.
|
||||
* Needs g_CivData to translate!
|
||||
*
|
||||
* @param {object} playerDataArray - As known from gamesetup and simstate.
|
||||
* @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player.
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatPlayerInfo(playerDataArray, playerStates)
|
||||
{
|
||||
let playerDescriptions = {};
|
||||
let playerIdx = 0;
|
||||
|
||||
for (let playerData of playerDataArray)
|
||||
{
|
||||
if (playerData == null || playerData.Civ && playerData.Civ == "gaia")
|
||||
continue;
|
||||
|
||||
++playerIdx;
|
||||
let teamIdx = playerData.Team;
|
||||
let isAI = playerData.AI && playerData.AI != "";
|
||||
let playerState = playerStates && playerStates[playerIdx] || playerData.State;
|
||||
let isActive = !playerState || playerState == "active";
|
||||
|
||||
let playerDescription;
|
||||
if (isAI)
|
||||
{
|
||||
if (playerData.Civ)
|
||||
{
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdifficulty)s %(AIname)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(AIdifficulty)s %(AIname)s, %(state)s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(AIdifficulty)s %(AIname)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(AIdifficulty)s %(AIname)s, %(state)s)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerData.Offline)
|
||||
{
|
||||
// Can only occur in the lobby for now, so no strings with civ needed
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (OFFLINE)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (OFFLINE, %(state)s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerData.Civ)
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s)");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(civ)s, %(state)s)");
|
||||
else
|
||||
if (isActive)
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s");
|
||||
else
|
||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu
|
||||
playerDescription = translate("%(playerName)s (%(state)s)");
|
||||
}
|
||||
}
|
||||
|
||||
// Sort player descriptions by team
|
||||
if (!playerDescriptions[teamIdx])
|
||||
playerDescriptions[teamIdx] = [];
|
||||
|
||||
playerDescriptions[teamIdx].push(sprintf(playerDescription, {
|
||||
"playerName":
|
||||
'[color="' +
|
||||
(typeof getPlayerColor == 'function' ?
|
||||
(isAI ? "white" : getPlayerColor(playerData.Name)) :
|
||||
rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color)) +
|
||||
'"]' + escapeText(playerData.Name) + "[/color]",
|
||||
|
||||
"civ":
|
||||
!playerData.Civ ?
|
||||
translate("Unknown Civilization") :
|
||||
g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ?
|
||||
translate(g_CivData[playerData.Civ].Name) :
|
||||
playerData.Civ,
|
||||
|
||||
"state":
|
||||
playerState == "defeated" ?
|
||||
translateWithContext("playerstate", "defeated") :
|
||||
translateWithContext("playerstate", "won"),
|
||||
|
||||
"AIname": isAI ? translateAIName(playerData.AI) : "",
|
||||
"AIdifficulty": isAI ? translateAIDifficulty(playerData.AIDiff) : ""
|
||||
}));
|
||||
}
|
||||
|
||||
let teams = Object.keys(playerDescriptions);
|
||||
if (teams.indexOf("observer") > -1)
|
||||
teams.splice(teams.indexOf("observer"), 1);
|
||||
|
||||
let teamDescription = [];
|
||||
|
||||
// If there are no teams, merge all playersDescriptions
|
||||
if (teams.length == 1)
|
||||
teamDescription.push(playerDescriptions[teams[0]].join("\n"));
|
||||
|
||||
// If there are teams, merge "Team N:" + playerDescriptions
|
||||
else
|
||||
teamDescription = teams.map(team => {
|
||||
|
||||
let teamCaption = team == -1 ?
|
||||
translate("No Team") :
|
||||
sprintf(translate("Team %(team)s"), { "team": +team + 1 });
|
||||
|
||||
// Translation: Describe players of one team in a selected game, f.e. in the replay- or savegame menu or lobby
|
||||
return sprintf(translate("%(team)s:\n%(playerDescriptions)s"), {
|
||||
"team": '[font="sans-bold-14"]' + teamCaption + "[/font]",
|
||||
"playerDescriptions": playerDescriptions[team].join("\n")
|
||||
});
|
||||
});
|
||||
|
||||
if (playerDescriptions.observer)
|
||||
teamDescription.push(sprintf(translate("%(team)s:\n%(playerDescriptions)s"), {
|
||||
"team": '[font="sans-bold-14"]' + translatePlural("Observer", "Observers", playerDescriptions.observer.length) + "[/font]",
|
||||
"playerDescriptions": playerDescriptions.observer.join("\n")
|
||||
}));
|
||||
|
||||
return teamDescription.join("\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an additional map label, map preview image and describes the chosen gamesettings more closely.
|
||||
*
|
||||
* Requires g_GameAttributes and g_VictoryConditions.
|
||||
*/
|
||||
function getGameDescription(extended = false)
|
||||
{
|
||||
let titles = [];
|
||||
|
||||
let victoryIdx = g_VictoryConditions.Name.indexOf(g_GameAttributes.settings.GameType || g_VictoryConditions.Default);
|
||||
if (victoryIdx != -1)
|
||||
{
|
||||
let title = g_VictoryConditions.Title[victoryIdx];
|
||||
if (g_VictoryConditions.Name[victoryIdx] == "wonder")
|
||||
title = sprintf(
|
||||
translatePluralWithContext(
|
||||
"victory condition",
|
||||
"Wonder (%(min)s minute)",
|
||||
"Wonder (%(min)s minutes)",
|
||||
g_GameAttributes.settings.WonderDuration
|
||||
),
|
||||
{ "min": g_GameAttributes.settings.WonderDuration }
|
||||
);
|
||||
titles.push({
|
||||
"label": title,
|
||||
"value": g_VictoryConditions.Description[victoryIdx]
|
||||
});
|
||||
}
|
||||
|
||||
if (g_GameAttributes.settings.RatingEnabled &&
|
||||
g_GameAttributes.settings.PlayerData.length == 2)
|
||||
titles.push({
|
||||
"label": translate("Rated game"),
|
||||
"value": translate("When the winner of this match was determined, the lobby score will be adapted.")
|
||||
});
|
||||
|
||||
if (g_GameAttributes.settings.LockTeams)
|
||||
titles.push({
|
||||
"label": translate("Locked Teams"),
|
||||
"value": translate("Players can't change the initial teams.")
|
||||
});
|
||||
else
|
||||
titles.push({
|
||||
"label": translate("Diplomacy"),
|
||||
"value": translate("Players can setup alliances and declare war on allies.")
|
||||
});
|
||||
|
||||
if (g_GameAttributes.settings.LastManStanding)
|
||||
titles.push({
|
||||
"label": translate("Last Man Standing"),
|
||||
"value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.")
|
||||
});
|
||||
else
|
||||
titles.push({
|
||||
"label": translate("Allied Victory"),
|
||||
"value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.")
|
||||
});
|
||||
|
||||
if (extended)
|
||||
{
|
||||
titles.push({
|
||||
"label": translate("Ceasefire"),
|
||||
"value":
|
||||
g_GameAttributes.settings.Ceasefire == 0 ?
|
||||
translate("disabled") :
|
||||
sprintf(translatePlural(
|
||||
"For the first minute, enemies will stay neutral.",
|
||||
"For the first %(min)s minutes, enemies will stay neutral.",
|
||||
g_GameAttributes.settings.Ceasefire),
|
||||
{ "min": g_GameAttributes.settings.Ceasefire })
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Map Name"),
|
||||
"value": translate(g_GameAttributes.settings.Name)
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Map Type"),
|
||||
"value": g_MapTypes.Title[g_MapTypes.Name.indexOf(g_GameAttributes.mapType)]
|
||||
});
|
||||
|
||||
if (g_GameAttributes.mapType == "random")
|
||||
{
|
||||
let mapSize = g_MapSizes.LongName[g_MapSizes.Tiles.indexOf(g_GameAttributes.settings.Size)];
|
||||
if (mapSize)
|
||||
titles.push({
|
||||
"label": translate("Map Size"),
|
||||
"value": mapSize
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
titles.push({
|
||||
"label": translate("Map Description"),
|
||||
"value":
|
||||
g_GameAttributes.map == "random" ?
|
||||
translate("Randomly selects a map from the list") :
|
||||
g_GameAttributes.settings.Description ?
|
||||
translate(g_GameAttributes.settings.Description) :
|
||||
translate("Sorry, no description available."),
|
||||
});
|
||||
|
||||
if (extended)
|
||||
{
|
||||
titles.push({
|
||||
"label": translate("Starting Resources"),
|
||||
"value": sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), {
|
||||
"startingResourcesTitle":
|
||||
g_StartingResources.Title[
|
||||
g_StartingResources.Resources.indexOf(
|
||||
g_GameAttributes.settings.StartingResources)],
|
||||
"amount": g_GameAttributes.settings.StartingResources
|
||||
})
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Population Limit"),
|
||||
"value":
|
||||
g_PopulationCapacities.Title[
|
||||
g_PopulationCapacities.Population.indexOf(
|
||||
g_GameAttributes.settings.PopulationCap)]
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Disable Treasure"),
|
||||
"value": g_GameAttributes.settings.DisableTreasure
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Revealed Map"),
|
||||
"value": g_GameAttributes.settings.RevealMap
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Explored Map"),
|
||||
"value": g_GameAttributes.settings.ExploreMap
|
||||
});
|
||||
|
||||
titles.push({
|
||||
"label": translate("Cheats"),
|
||||
"value": g_GameAttributes.settings.CheatsEnabled
|
||||
});
|
||||
}
|
||||
|
||||
return titles.map(title => sprintf(translate("%(label)s %(details)s"), {
|
||||
"label": "[color=\"" + g_DescriptionHighlight + "\"]" + title.label + ":" + "[/color]",
|
||||
"details":
|
||||
title.value === true ? translateWithContext("gamesetup option", "enabled") :
|
||||
!title.value ? translateWithContext("gamesetup option", "disabled") :
|
||||
title.value
|
||||
})).join("\n");
|
||||
}
|
@ -226,7 +226,7 @@ function loadVictoryConditions()
|
||||
victoryConditions.push({
|
||||
"Name": "endless",
|
||||
"Title": translate("None"),
|
||||
"Description": translate("Endless Game"),
|
||||
"Description": translate("Endless game."),
|
||||
"Scripts": []
|
||||
});
|
||||
|
||||
|
@ -133,11 +133,6 @@ const g_UnassignedPlayerColor = "170 170 250";
|
||||
*/
|
||||
const g_ReadyColor = "green";
|
||||
|
||||
/**
|
||||
* Highlights the victory condition in the game-description.
|
||||
*/
|
||||
const g_VictoryColor = "orange";
|
||||
|
||||
/**
|
||||
* Placeholder item for the map-dropdownlist.
|
||||
*/
|
||||
@ -1454,7 +1449,7 @@ function updateGUIObjects()
|
||||
pColorPicker.selected = g_PlayerColors.findIndex(col => sameColor(col, color));
|
||||
}
|
||||
|
||||
updateMapDescription();
|
||||
updateGameDescription();
|
||||
resizeMoreOptionsWindow();
|
||||
|
||||
g_IsInGuiUpdate = false;
|
||||
@ -1472,60 +1467,14 @@ function updateGUIObjects()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an additional map label, map preview image and mapsettings description.
|
||||
*/
|
||||
function updateMapDescription()
|
||||
function updateGameDescription()
|
||||
{
|
||||
setMapPreviewImage("mapPreview", getMapPreview(g_GameAttributes.map));
|
||||
|
||||
Engine.GetGUIObjectByName("mapInfoName").caption =
|
||||
translateMapTitle(getMapDisplayName(g_GameAttributes.map));
|
||||
|
||||
let numPlayers = sprintf(
|
||||
translatePlural(
|
||||
"%(number)s player. ",
|
||||
"%(number)s players. ",
|
||||
g_GameAttributes.settings.PlayerData.length
|
||||
),
|
||||
{ "number": g_GameAttributes.settings.PlayerData.length }
|
||||
);
|
||||
|
||||
let mapDescription =
|
||||
g_GameAttributes.map == "random" ?
|
||||
translate("Randomly selects a map from the list") :
|
||||
g_GameAttributes.settings.Description ?
|
||||
translate(g_GameAttributes.settings.Description) :
|
||||
translate("Sorry, no description available.");
|
||||
|
||||
let victoryIdx = g_VictoryConditions.Name.indexOf(g_GameAttributes.settings.GameType || g_VictoryConditions.Default);
|
||||
let victoryTitle;
|
||||
|
||||
if (victoryIdx == -1)
|
||||
victoryTitle = translateWithContext("victory condition", "Unknown");
|
||||
else
|
||||
{
|
||||
if (g_VictoryConditions.Name[victoryIdx] == "wonder")
|
||||
victoryTitle = sprintf(
|
||||
translatePluralWithContext(
|
||||
"victory condition",
|
||||
"Wonder (%(min)s minute)",
|
||||
"Wonder (%(min)s minutes)",
|
||||
g_GameAttributes.settings.WonderDuration
|
||||
),
|
||||
{ "min": g_GameAttributes.settings.WonderDuration }
|
||||
);
|
||||
else
|
||||
victoryTitle = g_VictoryConditions.Title[victoryIdx];
|
||||
|
||||
if (victoryIdx != g_VictoryConditions.Default)
|
||||
victoryTitle = "[color=\"" + g_VictoryColor + "\"]" + victoryTitle + "[/color]";
|
||||
}
|
||||
|
||||
Engine.GetGUIObjectByName("mapInfoDescription").caption =
|
||||
numPlayers +
|
||||
translate("Victory Condition:") + " " + victoryTitle + ".\n\n" +
|
||||
mapDescription;
|
||||
Engine.GetGUIObjectByName("mapInfoDescription").caption = getGameDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@
|
||||
<script file="gui/common/functions_civinfo.js"/>
|
||||
<script file="gui/common/functions_global_object.js"/>
|
||||
<script file="gui/common/functions_utility.js"/>
|
||||
<script file="gui/common/gamedescription.js"/>
|
||||
<script file="gui/common/network.js"/>
|
||||
<script file="gui/common/settings.js"/>
|
||||
<script file="gui/common/timer.js"/>
|
||||
@ -208,7 +209,7 @@
|
||||
<object size="100%-425 529 100%-25 100%-60">
|
||||
<object name="mapInfoName" type="text" style="ModernLeftLabelText" size="0 0 100%-120 30"/>
|
||||
<object type="image" sprite="ModernDarkBoxGold" size="0 30 100% 100%">
|
||||
<object name="mapInfoDescription" type="text" style="MapDescription" size="0 0 100% 100%"/>
|
||||
<object name="mapInfoDescription" type="text" style="ModernText" size="0 0 100% 100%"/>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
|
@ -2,17 +2,6 @@
|
||||
|
||||
<styles>
|
||||
|
||||
<style name="MapDescription"
|
||||
buffer_zone="8"
|
||||
font="sans-12"
|
||||
scrollbar="true"
|
||||
scrollbar_style="ModernScrollBar"
|
||||
scroll_bottom="true"
|
||||
textcolor="white"
|
||||
text_align="left"
|
||||
text_valign="top"
|
||||
/>
|
||||
|
||||
<style name="ChatPanel"
|
||||
buffer_zone="5"
|
||||
font="sans-13"
|
||||
|
@ -4,6 +4,7 @@
|
||||
<script file="gui/common/color.js"/>
|
||||
<script file="gui/common/functions_global_object.js"/>
|
||||
<script file="gui/common/functions_utility.js"/>
|
||||
<script file="gui/common/gamedescription.js"/>
|
||||
<script file="gui/common/music.js"/>
|
||||
<script file="gui/common/settings.js"/>
|
||||
<script file="gui/common/timer.js"/>
|
||||
|
@ -6,6 +6,7 @@
|
||||
<script file="gui/common/color.js" />
|
||||
<script file="gui/common/functions_civinfo.js" />
|
||||
<script file="gui/common/functions_utility.js" />
|
||||
<script file="gui/common/gamedescription.js"/>
|
||||
<script file="gui/common/settings.js" />
|
||||
|
||||
<!-- Used to display message boxes. -->
|
||||
|
@ -7,6 +7,7 @@
|
||||
<script file="gui/common/functions_global_object.js" />
|
||||
<script file="gui/common/functions_utility.js" />
|
||||
<script file="gui/common/functions_utility_loadsave.js" />
|
||||
<script file="gui/common/gamedescription.js"/>
|
||||
<script file="gui/common/settings.js" />
|
||||
<script file="gui/savedgames/load.js" />
|
||||
|
||||
|
@ -35,6 +35,7 @@ var g_IsMenuOpen = false;
|
||||
|
||||
var g_IsDiplomacyOpen = false;
|
||||
var g_IsTradeOpen = false;
|
||||
var g_IsObjectivesOpen = false;
|
||||
|
||||
// Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui.
|
||||
var g_FlushTributing = function() {};
|
||||
@ -610,6 +611,45 @@ function toggleGameSpeed()
|
||||
let gameSpeed = Engine.GetGUIObjectByName("gameSpeed");
|
||||
gameSpeed.hidden = !gameSpeed.hidden;
|
||||
}
|
||||
|
||||
function toggleObjectives()
|
||||
{
|
||||
let open = g_IsObjectivesOpen;
|
||||
closeOpenDialogs();
|
||||
|
||||
if (!open)
|
||||
openObjectives();
|
||||
}
|
||||
|
||||
function openObjectives()
|
||||
{
|
||||
g_IsObjectivesOpen = true;
|
||||
|
||||
let player = g_Players[Engine.GetPlayerID()];
|
||||
let playerState = player && player.state;
|
||||
let isActive = !playerState || playerState == "active";
|
||||
|
||||
Engine.GetGUIObjectByName("gameDescriptionText").caption = getGameDescription(true);
|
||||
|
||||
let objectivesPlayerstate = Engine.GetGUIObjectByName("objectivesPlayerstate");
|
||||
objectivesPlayerstate.hidden = isActive;
|
||||
objectivesPlayerstate.caption = g_PlayerStateMessages[playerState] || "";
|
||||
|
||||
let gameDescription = Engine.GetGUIObjectByName("gameDescription");
|
||||
let gameDescriptionSize = gameDescription.size;
|
||||
gameDescriptionSize.top = Engine.GetGUIObjectByName(
|
||||
isActive ? "objectivesTitle" : "objectivesPlayerstate").size.bottom;
|
||||
gameDescription.size = gameDescriptionSize;
|
||||
|
||||
Engine.GetGUIObjectByName("objectivesPanel").hidden = false;
|
||||
}
|
||||
|
||||
function closeObjectives()
|
||||
{
|
||||
g_IsObjectivesOpen = false;
|
||||
Engine.GetGUIObjectByName("objectivesPanel").hidden = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows players to see their own summary.
|
||||
* If they have shared ally vision researched, they are able to see the summary of there allies too.
|
||||
@ -766,6 +806,7 @@ function closeOpenDialogs()
|
||||
closeChat();
|
||||
closeDiplomacy();
|
||||
closeTrade();
|
||||
closeObjectives();
|
||||
}
|
||||
|
||||
function formatTributeTooltip(playerID, resource, amount)
|
||||
|
@ -172,6 +172,11 @@ var g_IsChatAddressee = {
|
||||
addresseeGUID == Engine.GetPlayerGUID()
|
||||
};
|
||||
|
||||
var g_PlayerStateMessages = {
|
||||
"won": translate("You have won!"),
|
||||
"defeated": translate("You have been defeated!")
|
||||
};
|
||||
|
||||
/**
|
||||
* Chatmessage shown on diplomacy change.
|
||||
*/
|
||||
|
49
binaries/data/mods/public/gui/session/objectives_window.xml
Normal file
49
binaries/data/mods/public/gui/session/objectives_window.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<object
|
||||
name="objectivesPanel"
|
||||
size="50%-300 50%-225 50%+300 50%+175"
|
||||
type="image"
|
||||
hidden="true"
|
||||
sprite="ModernDialog"
|
||||
>
|
||||
<object
|
||||
name="objectivesTitle"
|
||||
type="text"
|
||||
style="TitleText"
|
||||
size="50%-128 -16 50%+128 16"
|
||||
>
|
||||
<translatableAttribute id="caption">Objectives</translatableAttribute>
|
||||
</object>
|
||||
|
||||
<object
|
||||
name="objectivesPlayerstate"
|
||||
size="20 40 100%-20 80"
|
||||
font="sans-bold-18"
|
||||
type="text"
|
||||
style="ModernText"
|
||||
text_align="left"
|
||||
ghost="true"
|
||||
/>
|
||||
|
||||
<object
|
||||
name="gameDescription"
|
||||
type="image"
|
||||
sprite="ModernDarkBoxGold"
|
||||
size="20 0 100%-20 100%-60"
|
||||
>
|
||||
<object
|
||||
name="gameDescriptionText"
|
||||
type="text"
|
||||
style="MapPlayerList"
|
||||
textcolor="white"
|
||||
size="0 0 100% 100%"
|
||||
/>
|
||||
</object>
|
||||
|
||||
<object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
|
||||
<translatableAttribute id="caption">Close</translatableAttribute>
|
||||
<action on="Press">closeObjectives();</action>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
@ -1,5 +1,13 @@
|
||||
const g_IsReplay = Engine.IsVisualReplay();
|
||||
|
||||
const g_Ceasefire = prepareForDropdown(g_Settings && g_Settings.Ceasefire);
|
||||
const g_GameSpeeds = prepareForDropdown(g_Settings && g_Settings.GameSpeeds.filter(speed => !speed.ReplayOnly || g_IsReplay));
|
||||
const g_MapSizes = prepareForDropdown(g_Settings && g_Settings.MapSizes);
|
||||
const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes);
|
||||
const g_PopulationCapacities = prepareForDropdown(g_Settings && g_Settings.PopulationCapacities);
|
||||
const g_StartingResources = prepareForDropdown(g_Settings && g_Settings.StartingResources);
|
||||
const g_VictoryConditions = prepareForDropdown(g_Settings && g_Settings.VictoryConditions);
|
||||
const g_WonderDurations = prepareForDropdown(g_Settings && g_Settings.WonderDurations);
|
||||
|
||||
/**
|
||||
* Colors to flash when pop limit reached.
|
||||
@ -666,11 +674,8 @@ function confirmExit()
|
||||
{
|
||||
closeOpenDialogs();
|
||||
|
||||
let subject = g_ConfirmExit == "won" ?
|
||||
translate("You have won!") :
|
||||
translate("You have been defeated!");
|
||||
|
||||
subject += "\n" + translate("Do you want to quit?");
|
||||
let subject = g_PlayerStateMessages[g_ConfirmExit] + "\n" +
|
||||
translate("Do you want to quit?");
|
||||
|
||||
if (g_IsNetworked && g_IsController)
|
||||
subject += "\n" + translate("Leaving will disconnect all other players.");
|
||||
|
@ -7,6 +7,7 @@
|
||||
<script file="gui/common/functions_civinfo.js"/>
|
||||
<script file="gui/common/functions_global_object.js"/>
|
||||
<script file="gui/common/functions_utility.js"/>
|
||||
<script file="gui/common/gamedescription.js"/>
|
||||
<script file="gui/common/l10n.js"/>
|
||||
<script file="gui/common/music.js"/>
|
||||
<script file="gui/common/network.js"/>
|
||||
@ -86,6 +87,7 @@
|
||||
<include file="gui/session/chat_window.xml"/>
|
||||
<include file="gui/session/developer_overlay.xml"/>
|
||||
<include file="gui/session/diplomacy_window.xml"/>
|
||||
<include file="gui/session/objectives_window.xml"/>
|
||||
<include file="gui/session/trade_window.xml"/>
|
||||
<include file="gui/session/top_panel.xml"/>
|
||||
<include file="gui/session/menu.xml"/>
|
||||
|
@ -26,7 +26,15 @@
|
||||
<!-- ================================ ================================ -->
|
||||
<!-- Switch the view perspective to another player's (for observers and for eased development) -->
|
||||
<!-- ================================ ================================ -->
|
||||
<object size="100%-415 5 100%-265 100%-5" name="viewPlayer" type="dropdown" hidden="true" z="50" style="ModernDropDown" tooltip_style="sessionToolTipBold">
|
||||
<object
|
||||
size="100%-448 5 100%-293 100%-5"
|
||||
name="viewPlayer"
|
||||
type="dropdown"
|
||||
hidden="true"
|
||||
z="50"
|
||||
style="ModernDropDown"
|
||||
tooltip_style="sessionToolTipBold"
|
||||
>
|
||||
<translatableAttribute id="tooltip">Choose player to view</translatableAttribute>
|
||||
<action on="SelectionChange">selectViewPlayer(this.selected - 1);</action>
|
||||
</object>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<object type="button"
|
||||
name="diplomacyButton1"
|
||||
size="100%-226 4 100%-198 32"
|
||||
size="100%-254 4 100%-226 32"
|
||||
style="iconButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
>
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<object>
|
||||
<object type="button"
|
||||
name="gameSpeedButton"
|
||||
size="100%-258 4 100%-230 32"
|
||||
style="iconButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
<object
|
||||
type="button"
|
||||
name="gameSpeedButton"
|
||||
size="100%-286 4 100%-258 32"
|
||||
style="iconButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
>
|
||||
<translatableAttribute id="tooltip">Game speed</translatableAttribute>
|
||||
<object size="5 5 100%-5 100%-5" type="image" sprite="stretched:session/icons/resources/time_small.png" ghost="true"/>
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<object
|
||||
type="button"
|
||||
name="objectivesButton"
|
||||
size="100%-194 4 100%-166 32"
|
||||
style="iconButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
>
|
||||
<object
|
||||
size="3 3 100%-3 100%-3"
|
||||
type="image"
|
||||
sprite="stretched:session/icons/objectives.png"
|
||||
ghost="true"
|
||||
/>
|
||||
<translatableAttribute id="tooltip">Objectives</translatableAttribute>
|
||||
<action on="Press">
|
||||
toggleObjectives();
|
||||
</action>
|
||||
</object>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<object type="button"
|
||||
name="tradeButton1"
|
||||
size="100%-194 4 100%-166 32"
|
||||
size="100%-222 4 100%-194 32"
|
||||
style="iconButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
>
|
||||
|
@ -3,7 +3,7 @@
|
||||
"Data":
|
||||
{
|
||||
"Title": "Conquest",
|
||||
"Description": "Defeat all opponents",
|
||||
"Description": "Defeat all opponents to win.",
|
||||
"Scripts":
|
||||
[
|
||||
"scripts/TriggerHelper.js",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"Data":
|
||||
{
|
||||
"Title": "Conquest Structures",
|
||||
"Description": "Destroy all structures of enemies",
|
||||
"Description": "Destroy all enemy structures to win.",
|
||||
"Scripts":
|
||||
[
|
||||
"scripts/TriggerHelper.js",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"Data":
|
||||
{
|
||||
"Title": "Conquest Units",
|
||||
"Description": "Kill all enemy units",
|
||||
"Description": "Kill all enemy units to win.",
|
||||
"Scripts":
|
||||
[
|
||||
"scripts/TriggerHelper.js",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"Data":
|
||||
{
|
||||
"Title": "Regicide",
|
||||
"Description": "Defeat opponents by killing their hero",
|
||||
"Description": "Defeat opponents by killing their hero.",
|
||||
"Scripts":
|
||||
[
|
||||
"scripts/TriggerHelper.js",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"Data":
|
||||
{
|
||||
"Title": "Wonder",
|
||||
"Description": "Build and protect a wonder to win",
|
||||
"Description": "Be the first to build or capture a wonder and keep it for a certain time to win the game.",
|
||||
"Scripts":
|
||||
[
|
||||
"scripts/TriggerHelper.js",
|
||||
|
Loading…
Reference in New Issue
Block a user