This diff furthers the move from menu.js to the new files using new classes in the course of #5387.
The diff introduces an event subscription system in order to improve instead of worsen the performance footprint.
The following classes are added:
class BuildLabel class CivIcon class CounterManager class CounterPopulation class CounterResource class FollowPlayer class GameSpeedButton class GameSpeedControl class ObjectivesDialog class ObjectivesDialogButton class PauseControl class PauseOverlay class PlayerViewControl class TopPanel
The following events and subscriptions have been added:
registerEntitySelectionChangeHandler registerHotkeyChangeHandler registerPlayersFinishedHandler registerPlayersInitHandler registerSimulationUpdateHandler registerDiplomacyColorsChangeHandler registerPauseHandler registerPlayerIDChangeHandler registerPrePlayerChangeHandler registerViewedPlayerChangeHandler
The change was necessary in order to reduce the footprint as many updates were performed each turn but were only necessary on specific events.
Using one class per feature and minimizing each feature, we can fine tune when to update each GUI object and state,
make the objects agnostic of each other, improve the performance, improve extensibility, moddability, separation of concerns simultaneously.
According to my measurement, this reduces the time spent in onSimulationUpdate by roughly 30%, 7 milliseconds to 5 milliseconds each turn.
The time spent in that function was measured for the first 45 seconds in a 4v4 mainland with and without the patch.