Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
/**
|
|
|
|
|
* This class manages the population counter in the top panel.
|
|
|
|
|
* It flashes the counter if the training of any owned entity is blocked.
|
|
|
|
|
*/
|
|
|
|
|
class CounterPopulation
|
|
|
|
|
{
|
2020-12-10 00:13:46 -08:00
|
|
|
constructor(resCode, panel, icon, count, stats)
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
{
|
|
|
|
|
this.resCode = resCode;
|
|
|
|
|
this.panel = panel;
|
|
|
|
|
this.icon = icon;
|
|
|
|
|
this.count = count;
|
|
|
|
|
this.count.onTick = this.onTick.bind(this);
|
|
|
|
|
this.isTrainingBlocked = false;
|
|
|
|
|
this.color = this.DefaultPopulationColor;
|
2020-12-10 00:13:46 -08:00
|
|
|
this.stats = stats;
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rebuild(playerState, getAllyStatTooltip)
|
|
|
|
|
{
|
|
|
|
|
this.count.caption = sprintf(translate(this.CounterCaption), playerState);
|
2020-12-10 00:13:46 -08:00
|
|
|
let total = 0;
|
|
|
|
|
for (let resCode of g_ResourceData.GetCodes())
|
|
|
|
|
total += playerState.resourceGatherers[resCode];
|
2021-05-20 01:55:08 -07:00
|
|
|
|
2021-09-14 23:27:11 -07:00
|
|
|
this.stats.caption = coloredText(total, total ? this.DefaultTotalGatherersColor : this.DefaultTotalGatherersColorZero);
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
|
|
|
|
|
this.isTrainingBlocked = playerState.trainingBlocked;
|
|
|
|
|
|
|
|
|
|
this.panel.tooltip =
|
2021-05-20 01:55:08 -07:00
|
|
|
setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) +
|
2025-04-18 01:40:27 -07:00
|
|
|
getAllyStatTooltip(this.getTooltipData.bind(this));
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getTooltipData(playerState, playername)
|
|
|
|
|
{
|
|
|
|
|
return {
|
|
|
|
|
"playername": playername,
|
|
|
|
|
"statValue": sprintf(translate(this.AllyPopulationTooltip), playerState),
|
|
|
|
|
"orderValue": playerState.popCount
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onTick()
|
|
|
|
|
{
|
|
|
|
|
if (this.panel.hidden)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
let newColor = this.isTrainingBlocked && Date.now() % 1000 < 500 ?
|
|
|
|
|
this.PopulationAlertColor :
|
|
|
|
|
this.DefaultPopulationColor;
|
|
|
|
|
|
|
|
|
|
if (newColor == this.color)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.color = newColor;
|
|
|
|
|
this.count.textcolor = newColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-20 01:55:08 -07:00
|
|
|
// Translation: Do not insert spaces around the slash symbol for this exact string. Keep only one space between popLimit and popMax.
|
|
|
|
|
CounterPopulation.prototype.CounterCaption = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)");
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
|
2021-05-20 01:55:08 -07:00
|
|
|
CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population: current/limit (max)");
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
|
2021-05-20 01:55:08 -07:00
|
|
|
CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)");
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
|
2021-05-20 01:55:08 -07:00
|
|
|
/**
|
2021-09-14 23:27:11 -07:00
|
|
|
* Color to highlight the total number of gatherers at zero.
|
|
|
|
|
*/
|
|
|
|
|
CounterPopulation.prototype.DefaultTotalGatherersColorZero = "200 200 200";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Color to highlight the total number of gatherers.
|
2021-05-20 01:55:08 -07:00
|
|
|
*/
|
|
|
|
|
CounterPopulation.prototype.DefaultTotalGatherersColor = "gold";
|
2021-09-14 23:27:11 -07:00
|
|
|
|
Implement session event subscription system and rewrite TopPanel, PlayerViewControl, GameSpeed, Pausing, ObjectivesDialog to use object orientation, refs #5387.
New controller classes: PlayerViewControl, PauseControl,
GameSpeedControl
New viewer classes: ObjectivesDialog, PauseOverlay, FollowPlayer,
TopPanel (BuildLabel, CivIcon, CounterManager, CounterPopulation,
CounterResource refs 7e14a33411/D1113, GameSpeedButton,
ObjectivesDialogButton)
New events: SimulationUpdate, EntitySelectionChange, ViewedPlayerChange,
PreViewedPlayerChangeHandler, PlayerIDChange, PlayersInit,
PlayersFinished, Pause, DiplomacyColorsChange, HotkeyChange, refs #2604
Improves GUI onSimuationUpdate performance without selected entities by
allegedly 30%.
Delete misleading dead code resign command from leaveGame and rename to
endGame. The command is not sent via network (see fa85527baf) nor
processed in simulation, because the Game instance is deleted
immediately thereafter, introduced in fcedcae052, refs a3e1c68b9a,
39ffb0a6bd, 9f796068f8.
Remove explicitResume 0 value from e57c99c6f6 and 8ae67ed15f which
should have been a false if defined, and is equivalent to the default.
Restore fast forwarding option from cd571035bb/D595 for developers
changing the perspective to observer or player following 56308ec1ad.
Add pausing for the delete dialog missing following 7a7ebaa983.
Differential Revision: https://code.wildfiregames.com/D2378
This was SVN commit r23076.
2019-10-17 08:08:56 -07:00
|
|
|
/**
|
|
|
|
|
* Colors to flash when pop limit reached.
|
|
|
|
|
*/
|
|
|
|
|
CounterPopulation.prototype.DefaultPopulationColor = "white";
|
|
|
|
|
CounterPopulation.prototype.PopulationAlertColor = "orange";
|