Page MenuHomeWildfire Games

Session event subscription system, refactor PlayerViewControl, TopPanel, Pause, GameSpeed, ObjectivesDialog, FollowPlayer to use object orientation
ClosedPublic

Authored by elexis on Oct 16 2019, 1:10 PM.

Details

Summary

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.

This also adds back the GameSpeed list update on ViewedPlayer change from rP20577 removed in rP21149.

Test Plan

Go through every line and ensure that the behavior is the same as before.
Ensure that the performed updates are as rare as possible.
Ensure that the objects refer to global functions and procedures as rarely as possible.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Oct 16 2019, 1:10 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/975/display/redirect

elexis edited the summary of this revision. (Show Details)Oct 16 2019, 1:11 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/460/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Oct 17 2019, 5:10 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Oct 17 2019, 5:10 PM
nani awarded a token.Oct 17 2019, 7:21 PM