HomeWildfire Games

Separate Game Settings from the GUI Gamesetup


Separate Game Settings from the GUI Gamesetup

Split the gamesetup in two: the 'GameAttributes' part into gamesettings/ and the GUI/Presentation part in gamesetup/. This makes it easier to separate the presentation from the data.

The immediate benefit is that campaigns & autostart scripts don't need to load the gamesetup folder at all. This also makes it much easier for any modder that would want to to change the GameSetup itself.

Each 'game attribute' is given a unique class extending GameSetting (with a few exceptions), in charge of:

  • 'Serializing' to the JSON-compatible 'InitAttributes' format, which is used for persisted settings, network synchronization, map script settings, hotloading.
  • Deserializing from the same format.
  • Watching for settings it depends on (such that e.g. unexploring the map also unreveals it).

The GUI controls remain in charge of presenting the state accurately, however they now directly subscribe to changes of the GameSettings for update. The updating logic in general has been lightened on the GUI side, making it more straightforward to know when something will update, and reducing un-necessary computations (in theory - in practice, I believe the gamesetup was already fairly good about this).
The 'Controller' class of the gamesetup have also been lightened, since more responsibility now lies with GameSettings. In particular, this include code to actually launch a game.

In general the GameSettings class is permissive - the GUI gamesetup has tighter restriction for what the player can/cannot modify. This is intended to give flexibility for campaign maps, which may want to change arbitrary settings.

Further work would be useful, non-exhaustively:

  • the setting of default values remains messy. They currently exist somethings in GameSettings, sometimes in the GUI gamesetup, and in the simulation itself (in case attributes are not set).
  • the availability and 'lockedness' of settings remains a work-in-progress.
  • some attributes, like disabled technologies, should probably be removed and triggers used instead.
  • the Handling of AI and player-specific data could be improved.
  • settings Persistence should follow its own path - not all settings are worth persisting.
  • GAIA settings are added simulation-side but not in the GUI, which is confusing.

Thanks langbart & Freagarach for testing.

Follows the gamesetup rewrite in rP23374.

Refs #3049

Differential Revision: https://code.wildfiregames.com/D3243

Event Timeline

Langbart raised a concern with this commit.Mar 19 2021, 2:01 PM
Langbart added subscribers: submariner, Langbart.

@submariner found a bug, go to GameSetup screen and try to adjust AI settings (not possible).
The bug first appeared with the changeset rP25077

This commit now has outstanding concerns.Mar 19 2021, 2:01 PM

I found another error regarding the "population cap", it cannot be adjusted. It always remains at 300.

Langbart added a comment.EditedMar 20 2021, 4:29 PM

I found another bug in the Multiplayer placement, which can first be noticed with this set of changes.
It seems that you are not able to set your name to player n+1 (n>=1) , you are stuck with player1.

Langbart resigned from this commit.Mar 21 2021, 10:45 AM
This commit no longer requires audit.Mar 21 2021, 10:45 AM
Langbart raised a concern with this commit.May 30 2021, 6:39 AM

With changeset rP25076 I get different Biomes when I select Random, but with changeset rP25077 I get only Alpine biomes for the map Mainland (see #6190).

This commit now has outstanding concerns.May 30 2021, 6:39 AM
This commit no longer requires audit.May 31 2021, 9:37 AM
Imarok added a subscriber: Imarok.EditedMay 31 2021, 10:47 PM
This comment has been deleted.

This ignores maps with arrays as SupportedBiomes.

Imarok added inline comments.May 31 2021, 10:52 PM

This was lost.

Langbart raised a concern with this commit.Sep 3 2021, 7:50 PM

I noticed a small bug with the Map size see #6312.

This commit now has outstanding concerns.Sep 3 2021, 7:50 PM
Langbart resigned from this commit.Sep 3 2021, 8:56 PM

I noticed a small bug with the Map size see #6312.

The bug was fixed with the changeset rP25889.

This commit no longer requires audit.Sep 3 2021, 8:56 PM
Langbart raised a concern with this commit.Jun 2 2022, 4:25 PM
This commit now has outstanding concerns.Jun 2 2022, 4:25 PM
This commit no longer requires audit.Jun 11 2022, 4:03 PM