Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | function displaySingle(entState) | ||||
if (genericName && template.pack && template.pack.state == "packed") | if (genericName && template.pack && template.pack.state == "packed") | ||||
genericName = sprintf(translate("%(genericName)s — Packed"), { "genericName": genericName }); | genericName = sprintf(translate("%(genericName)s — Packed"), { "genericName": genericName }); | ||||
let playerState = g_Players[entState.player]; | let playerState = g_Players[entState.player]; | ||||
let civName = g_CivData[playerState.civ].Name; | let civName = g_CivData[playerState.civ].Name; | ||||
let civEmblem = g_CivData[playerState.civ].Emblem; | let civEmblem = g_CivData[playerState.civ].Emblem; | ||||
let playerName = playerState.name; | let playerName = playerState.name; | ||||
let playerColor = rgbToGuiColor(g_DisplayedPlayerColors[entState.player], 128); | |||||
// Indicate disconnected players by prefixing their name | // Indicate disconnected players by prefixing their name | ||||
if (g_Players[entState.player].offline) | if (g_Players[entState.player].offline) | ||||
playerName = sprintf(translate("\\[OFFLINE] %(player)s"), { "player": playerName }); | playerName = sprintf(translate("\\[OFFLINE] %(player)s"), { "player": playerName }); | ||||
// Rank | // Rank | ||||
if (entState.identity && entState.identity.rank && entState.identity.classes) | if (entState.identity && entState.identity.rank && entState.identity.classes) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (entState.capturePoints) | ||||
let setCaptureBarPart = function(playerID, startSize) { | let setCaptureBarPart = function(playerID, startSize) { | ||||
let unitCaptureBar = Engine.GetGUIObjectByName("captureBar[" + playerID + "]"); | let unitCaptureBar = Engine.GetGUIObjectByName("captureBar[" + playerID + "]"); | ||||
let sizeObj = unitCaptureBar.size; | let sizeObj = unitCaptureBar.size; | ||||
sizeObj.rleft = startSize; | sizeObj.rleft = startSize; | ||||
let size = 100 * Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); | let size = 100 * Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); | ||||
sizeObj.rright = startSize + size; | sizeObj.rright = startSize + size; | ||||
unitCaptureBar.size = sizeObj; | unitCaptureBar.size = sizeObj; | ||||
unitCaptureBar.sprite = "color:" + rgbToGuiColor(g_DisplayedPlayerColors[playerID], 128); | unitCaptureBar.sprite = "color:" + g_DiplomacyColors.getPlayerColor(playerID, 128); | ||||
unitCaptureBar.hidden = false; | unitCaptureBar.hidden = false; | ||||
return startSize + size; | return startSize + size; | ||||
}; | }; | ||||
// first handle the owner's points, to keep those points on the left for clarity | // first handle the owner's points, to keep those points on the left for clarity | ||||
let size = setCaptureBarPart(entState.player, 0); | let size = setCaptureBarPart(entState.player, 0); | ||||
for (let i in entState.capturePoints) | for (let i in entState.capturePoints) | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | function displaySingle(entState) | ||||
else | else | ||||
{ | { | ||||
resourceCarryingIcon.hidden = true; | resourceCarryingIcon.hidden = true; | ||||
resourceCarryingText.hidden = true; | resourceCarryingText.hidden = true; | ||||
} | } | ||||
Engine.GetGUIObjectByName("specific").caption = specificName; | Engine.GetGUIObjectByName("specific").caption = specificName; | ||||
Engine.GetGUIObjectByName("player").caption = playerName; | Engine.GetGUIObjectByName("player").caption = playerName; | ||||
Engine.GetGUIObjectByName("playerColorBackground").sprite = "color:" + playerColor; | |||||
Engine.GetGUIObjectByName("playerColorBackground").sprite = | |||||
"color:" + g_DiplomacyColors.getPlayerColor(entState.player, 128); | |||||
Engine.GetGUIObjectByName("generic").caption = genericName == specificName ? "" : | Engine.GetGUIObjectByName("generic").caption = genericName == specificName ? "" : | ||||
sprintf(translate("(%(genericName)s)"), { | sprintf(translate("(%(genericName)s)"), { | ||||
"genericName": genericName | "genericName": genericName | ||||
}); | }); | ||||
let isGaia = playerState.civ == "gaia"; | let isGaia = playerState.civ == "gaia"; | ||||
Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "stretched:grayscale:" + civEmblem; | Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "stretched:grayscale:" + civEmblem; | ||||
Engine.GetGUIObjectByName("player").tooltip = isGaia ? "" : civName; | Engine.GetGUIObjectByName("player").tooltip = isGaia ? "" : civName; | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | if (maxCapturePoints > 0) | ||||
{ | { | ||||
let unitCaptureBar = Engine.GetGUIObjectByName("captureBarMultiple[" + pID + "]"); | let unitCaptureBar = Engine.GetGUIObjectByName("captureBarMultiple[" + pID + "]"); | ||||
let sizeObj = unitCaptureBar.size; | let sizeObj = unitCaptureBar.size; | ||||
sizeObj.rtop = startSize; | sizeObj.rtop = startSize; | ||||
let size = 100 * Math.max(0, Math.min(1, capturePoints[pID] / maxCapturePoints)); | let size = 100 * Math.max(0, Math.min(1, capturePoints[pID] / maxCapturePoints)); | ||||
sizeObj.rbottom = startSize + size; | sizeObj.rbottom = startSize + size; | ||||
unitCaptureBar.size = sizeObj; | unitCaptureBar.size = sizeObj; | ||||
unitCaptureBar.sprite = "color:" + rgbToGuiColor(g_DisplayedPlayerColors[pID], 128); | unitCaptureBar.sprite = "color:" + g_DiplomacyColors.getPlayerColor(pID, 128); | ||||
unitCaptureBar.hidden = false; | unitCaptureBar.hidden = false; | ||||
return startSize + size; | return startSize + size; | ||||
}; | }; | ||||
let size = 0; | let size = 0; | ||||
for (let i in capturePoints) | for (let i in capturePoints) | ||||
if (i != playerID) | if (i != playerID) | ||||
size = setCaptureBarPart(i, size); | size = setCaptureBarPart(i, size); | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator