Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/ResearchProgress.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
constructor(selection, i) | constructor(selection, i) | ||||
{ | { | ||||
this.selection = selection; | this.selection = selection; | ||||
this.button = Engine.GetGUIObjectByName("researchStartedButton[" + i + "]"); | this.button = Engine.GetGUIObjectByName("researchStartedButton[" + i + "]"); | ||||
this.sprite = Engine.GetGUIObjectByName("researchStartedIcon[" + i + "]"); | this.sprite = Engine.GetGUIObjectByName("researchStartedIcon[" + i + "]"); | ||||
this.progress = Engine.GetGUIObjectByName("researchStartedProgressSlider[" + i + "]"); | this.progress = Engine.GetGUIObjectByName("researchStartedProgressSlider[" + i + "]"); | ||||
this.timeRemaining = Engine.GetGUIObjectByName("researchStartedTimeRemaining[" + i + "]"); | this.timeRemaining = Engine.GetGUIObjectByName("researchStartedTimeRemaining[" + i + "]"); | ||||
this.paused = Engine.GetGUIObjectByName("researchPausedIcon[" + i + "]"); | |||||
this.buttonHeight = this.button.size.bottom - this.button.size.top; | this.buttonHeight = this.button.size.bottom - this.button.size.top; | ||||
this.buttonTop = this.Margin + (this.Margin + this.buttonHeight) * i; | this.buttonTop = this.Margin + (this.Margin + this.buttonHeight) * i; | ||||
this.progressHeight = this.progress.size.bottom - this.progress.size.top; | this.progressHeight = this.progress.size.bottom - this.progress.size.top; | ||||
this.progressTop = this.progress.size.top; | this.progressTop = this.progress.size.top; | ||||
this.button.onPress = this.onPress.bind(this); | this.button.onPress = this.onPress.bind(this); | ||||
} | } | ||||
onResearchedProgress(offset, techName, researchStatus) | onResearchedProgress(offset, techName, researchStatus) | ||||
{ | { | ||||
this.researcher = researchStatus.researcher; | this.researcher = researchStatus.researcher; | ||||
let template = GetTechnologyData(techName, g_Players[g_ViewedPlayer].civ); | let template = GetTechnologyData(techName, g_Players[g_ViewedPlayer].civ); | ||||
this.sprite.sprite = "stretched:" + this.PortraitDirectory + template.icon; | let modifier = "stretched:"; | ||||
if (researchStatus.paused) | |||||
modifier += "color:0 0 0 127:grayscale:"; | |||||
this.sprite.sprite = modifier + this.PortraitDirectory + template.icon; | |||||
let size = this.button.size; | let size = this.button.size; | ||||
size.top = offset + this.buttonTop; | size.top = offset + this.buttonTop; | ||||
size.bottom = size.top + this.buttonHeight; | size.bottom = size.top + this.buttonHeight; | ||||
this.button.size = size; | this.button.size = size; | ||||
this.button.tooltip = getEntityNames(template); | this.button.tooltip = getEntityNames(template); | ||||
if (researchStatus.paused) | |||||
this.button.tooltip += "\n" + translate(this.PausedResearchString); | |||||
this.button.hidden = false; | this.button.hidden = false; | ||||
size = this.progress.size; | size = this.progress.size; | ||||
size.top = this.progressTop + this.progressHeight * researchStatus.progress; | size.top = this.progressTop + this.progressHeight * researchStatus.progress; | ||||
this.progress.size = size; | this.progress.size = size; | ||||
this.timeRemaining.caption = | this.timeRemaining.caption = | ||||
Engine.FormatMillisecondsIntoDateStringGMT( | Engine.FormatMillisecondsIntoDateStringGMT( | ||||
researchStatus.timeRemaining, | researchStatus.timeRemaining, | ||||
translateWithContext("countdown format", this.CountdownFormat)); | translateWithContext("countdown format", this.CountdownFormat)); | ||||
this.paused.hidden = !researchStatus.paused; | |||||
} | } | ||||
onPress() | onPress() | ||||
{ | { | ||||
this.selection.selectAndMoveTo(this.researcher); | this.selection.selectAndMoveTo(this.researcher); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Distance between consecutive buttons. | * Distance between consecutive buttons. | ||||
*/ | */ | ||||
ResearchProgressButton.prototype.Margin = 4; | ResearchProgressButton.prototype.Margin = 4; | ||||
/** | /** | ||||
* Directory containing all icons. | * Directory containing all icons. | ||||
*/ | */ | ||||
ResearchProgressButton.prototype.PortraitDirectory = "session/portraits/"; | ResearchProgressButton.prototype.PortraitDirectory = "session/portraits/"; | ||||
/** | /** | ||||
* This format is used when displaying the remaining time of the currently viewed techs in research. | * This format is used when displaying the remaining time of the currently viewed techs in research. | ||||
*/ | */ | ||||
ResearchProgressButton.prototype.CountdownFormat = markForTranslationWithContext("countdown format", "m:ss"); | ResearchProgressButton.prototype.CountdownFormat = markForTranslationWithContext("countdown format", "m:ss"); | ||||
// Translation: String displayed when the research is paused. E.g. by being garrisoned or when not the first item in the queue. | |||||
ResearchProgressButton.prototype.PausedResearchString = markForTranslation("(This item is paused.)"); |
Wildfire Games · Phabricator