Page MenuHomeWildfire Games

Refactor trade dialog to use object orientation
ClosedPublic

Authored by elexis on Oct 13 2019, 5:18 AM.

Details

Summary

In the midst of #5387, this patch transforms the trade dialog and selection barter panel code to use class syntax.

As for the other patches, the purpose is to remove global procedures and functions, to group code to increase stronger relationships between the functions and states of an individual component and to make the different components agnostic of each other,
as such making it more extensible for future authors and modders.

As a minor change, this introduces new translated strings, thus making the code slightly slower.

Related code cleanups at rP19354, rP17553.

Test Plan

The correctness is to be tested for inserted and removed resources, atlas.
The performance was measured and it was slightly slower, presumably due to the new strings.
This however should not be a problem, since the performance is 100-200 microseconds total if and only if a market is selected or the trade dialog opened; i.e. it is exclusive and non-additive overhead.
In the future the translated strings can be updated only if the selected language changes.

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 13 2019, 5:18 AM

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

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

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

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

This revision was not accepted when it landed; it landed in state Needs Review.Oct 13 2019, 5:43 AM
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 13 2019, 5:43 AM

In the future the translated strings can be updated only if the selected language changes.

While the GUI selectively updates for certain config changes, this is not feasible for the language, because the strings defined in the XML file would not be updated.
Changing the language ingame currently means the mainmenu page is reloaded (switchpage), but this is out of reach currently for the session due to too many state variables that would be lost in the session.

If everything is in classes, all states separated and encapsulated, then there can be complete hotloading support and page reloading in case the language changed during the session.
Until then, the GUI object values that only depend on the chosen language can be initialized only on init, instead of each simulation update.

nani awarded a token.Oct 14 2019, 9:51 PM