Page MenuHomeWildfire Games

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

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



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:


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

rP 0 A.D. Public Repository
Automatic diff as part of commit; lint not applicable.
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:

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:

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