Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/ResearchProgress.js
/** | /** | ||||
* This class is responsible for displaying the currently researched technologies in an overlay. | * This class is responsible for displaying the currently researched technologies in an overlay. | ||||
*/ | */ | ||||
class ResearchProgress | class ResearchProgress | ||||
{ | { | ||||
constructor(playerViewControl) | constructor(playerViewControl, selection) | ||||
{ | { | ||||
this.buttons = Engine.GetGUIObjectByName("researchStartedButtons").children; | this.buttons = Engine.GetGUIObjectByName("researchStartedButtons").children; | ||||
this.buttonHandlers = this.buttons.map((button, i) => new ResearchProgressButton(i)); | this.buttonHandlers = this.buttons.map((button, i) => new ResearchProgressButton(selection, i)); | ||||
/** | /** | ||||
* Top coordinate of the research list. | * Top coordinate of the research list. | ||||
* Changes depending on the number of displayed counters. | * Changes depending on the number of displayed counters. | ||||
*/ | */ | ||||
this.topOffset = 0; | this.topOffset = 0; | ||||
let updater = this.updateResearchProgress.bind(this); | let updater = this.updateResearchProgress.bind(this); | ||||
Show All 24 Lines | class ResearchProgress | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* This is an individual button displaying a tech currently researched by the currently viewed player. | * This is an individual button displaying a tech currently researched by the currently viewed player. | ||||
*/ | */ | ||||
class ResearchProgressButton | class ResearchProgressButton | ||||
{ | { | ||||
constructor(i) | constructor(selection, i) | ||||
{ | { | ||||
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.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; | ||||
Show All 22 Lines | onResearchedProgress(offset, techName, researchStatus) | ||||
this.timeRemaining.caption = | this.timeRemaining.caption = | ||||
Engine.FormatMillisecondsIntoDateStringGMT( | Engine.FormatMillisecondsIntoDateStringGMT( | ||||
researchStatus.timeRemaining, | researchStatus.timeRemaining, | ||||
translateWithContext("countdown format", this.CountdownFormat)); | translateWithContext("countdown format", this.CountdownFormat)); | ||||
} | } | ||||
onPress() | onPress() | ||||
{ | { | ||||
selectAndMoveTo(this.researcher); | this.selection.selectAndMoveTo(this.researcher); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Distance between consecutive buttons. | * Distance between consecutive buttons. | ||||
*/ | */ | ||||
ResearchProgressButton.prototype.Margin = 4; | ResearchProgressButton.prototype.Margin = 4; | ||||
Show All 9 Lines |
Wildfire Games · Phabricator