0ad/binaries/data/mods/public/gui/gamesetup/Controllers/GameSettingsController.js

333 lines
10 KiB
JavaScript
Raw Normal View History

Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
/**
* Controller for the GUI handling of gamesettings.
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
*/
class GameSettingsController
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
constructor(setupWindow, netMessages, playerAssignmentsController, mapCache, isSavedGame)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
this.setupWindow = setupWindow;
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
this.mapCache = mapCache;
this.isSavedGame = isSavedGame;
this.persistentMatchSettings = new PersistentMatchSettings(g_IsNetworked);
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
this.guiData = new GameSettingsGuiData();
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
// When joining a game, the complete set of attributes
// may not have been received yet.
this.loading = true;
// If this is true, the ready controller won't reset readiness.
// TODO: ideally the ready controller would be somewhat independent from this one,
// possibly by listening to gamesetup messages itself.
this.gameStarted = false;
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
this.updateLayoutHandlers = new Set();
this.settingsChangeHandlers = new Set();
this.loadingChangeHandlers = new Set();
this.settingsLoadedHandlers = new Set();
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
setupWindow.registerLoadHandler(this.onLoad.bind(this));
setupWindow.registerGetHotloadDataHandler(this.onGetHotloadData.bind(this));
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
setupWindow.registerClosePageHandler(this.onClose.bind(this));
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
if (g_IsNetworked)
{
if (g_IsController)
playerAssignmentsController.registerClientJoinHandler(this.onClientJoin.bind(this));
else
// In MP, the host launches the game and switches right away,
// clients switch when they receive the appropriate message.
netMessages.registerNetMessageHandler("start", this.switchToLoadingPage.bind(this));
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
netMessages.registerNetMessageHandler("gamesetup", this.onGamesetupMessage.bind(this));
}
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
* @param handler will be called when the layout needs to be updated.
*/
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
registerUpdateLayoutHandler(handler)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
this.updateLayoutHandlers.add(handler);
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
* @param handler will be called when any setting change.
* (this isn't exactly what happens but the behaviour should be similar).
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
*/
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
registerSettingsChangeHandler(handler)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
this.settingsChangeHandlers.add(handler);
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
* @param handler will be called when the 'loading' state change.
*/
registerLoadingChangeHandler(handler)
{
this.loadingChangeHandlers.add(handler);
}
/**
* @param handler will be called when the initial settings have been loaded.
*/
registerSettingsLoadedHandler(handler)
{
this.settingsLoadedHandlers.add(handler);
}
onLoad(initData, hotloadData)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
if (!this.isSavedGame)
{
// This initial settings parsing in wrapped in a try-catch because it can fail unexpectedly,
// and particularly could fail with mods that change persistent settings, so this is
// difficult to fully fix from the gameSettings code.
// Also include hotloaded data because that can also fail and having to restart isn't very useful.
try
{
if (hotloadData)
this.parseSettings(hotloadData.initAttributes, false);
else if (g_IsController && (initData?.gameSettings || this.persistentMatchSettings.enabled))
{
// Allow opting-in to persistence when sending initial data (though default off)
if (initData?.gameSettings)
this.persistentMatchSettings.enabled = !!initData.gameSettings?.usePersistence;
const settings = initData?.gameSettings || this.persistentMatchSettings.loadFile();
if (settings)
this.parseSettings(settings, true);
}
}
catch(err)
{
error("There was an error loading game settings. You may need to disable persistent match settings.");
warn(err?.toString() ?? uneval(err));
if (err.stack)
warn(err.stack);
}
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
for (const guid in g_PlayerAssignments)
{
// If the new settings led to AI & players conflict, remove the AI.
if (g_PlayerAssignments[guid].player !== -1 &&
g_GameSettings.playerAI.get(g_PlayerAssignments[guid].player - 1))
g_GameSettings.playerAI.set(g_PlayerAssignments[guid].player - 1, undefined);
// If the updated settings assign a player to a slot still marked as “removed”, clear that flag.
if (g_PlayerAssignments[guid].player !== -1 &&
g_GameSettings.playerRemoved.get(g_PlayerAssignments[guid].player - 1))
g_GameSettings.playerRemoved.set(g_PlayerAssignments[guid].player - 1, false);
}
for (const handler of this.settingsLoadedHandlers)
handler(this.isSavedGame);
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
this.updateLayout();
this.setNetworkInitAttributes();
// If we are the controller, we are done loading.
if (hotloadData || !g_IsNetworked || g_IsController)
this.setLoading(false);
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
onClientJoin()
{
/**
* A note on network synchronization:
* The net server does not keep the current state of attributes,
* nor does it act like a message queue, so a new client
* will only receive updates after they've joined.
* In particular, new joiners start with no information,
* so the controller must first send them a complete copy of the settings.
* However, messages could be in-flight towards the controller,
* but the new client may never receive these or have already received them,
* leading to an ordering issue that might desync the new client.
*
* The simplest solution is to have the (single) controller
* act as the single source of truth. Any other message must
* first go through the controller, which will send updates.
* This enforces the ordering of the controller.
* In practical terms, if e.g. players controlling their own civ is implemented,
* the message will need to be ignored by everyone but the controller,
* and the controller will need to send an update once it rejects/accepts the changes,
* which will then update the other clients.
* Of course, the original client GUI may want to temporarily show a different state.
* Note that the final attributes are sent on game start anyways, so any
* synchronization issue that might happen at that point can be resolved.
*/
Engine.SendGameSetupMessage({
"type": "initial-update",
"initAttribs": this.getSettings()
});
}
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
onGetHotloadData(object)
{
object.initAttributes = this.getSettings();
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
onGamesetupMessage(message)
{
// For now, the controller only can send updates, so no need to listen to messages.
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
if (!message.data || g_IsController)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
return;
if (message.data.type !== "update" &&
message.data.type !== "initial-update")
{
error("Unknown message type " + message.data.type);
return;
}
if (message.data.type === "initial-update")
{
// Ignore initial updates if we've already received settings.
if (!this.loading)
return;
this.setLoading(false);
}
this.parseSettings(message.data.initAttribs, false);
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
// This assumes that messages aren't sent spuriously without changes
// (which is generally fair), but technically it would be good
// to check if the new data is different from the previous data.
for (const handler of this.settingsChangeHandlers)
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
handler();
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
* Returns the InitAttributes, augmented by GUI-specific data.
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
*/
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
getSettings()
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
const ret = g_GameSettings.toInitAttributes();
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
ret.guiData = this.guiData.Serialize();
return ret;
}
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
/**
* Parse the following settings.
*/
parseSettings(settings, fromPersistentSettings)
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
{
if (settings.guiData)
this.guiData.Deserialize(settings.guiData);
g_GameSettings.fromInitAttributes(settings, fromPersistentSettings);
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
}
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
setLoading(loading)
{
if (this.loading === loading)
return;
this.loading = loading;
for (const handler of this.loadingChangeHandlers)
handler(loading);
}
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
/**
* This should be called whenever the GUI layout needs to be updated.
* Triggers on the next GUI tick to avoid un-necessary layout.
*/
updateLayout()
{
if (this.layoutTimer)
return;
this.layoutTimer = setTimeout(() =>
{
for (const handler of this.updateLayoutHandlers)
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
handler();
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
delete this.layoutTimer;
}, 0);
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
* This function is to be called when a GUI control has initiated a value change.
*
* To avoid an infinite loop, do not call this function when a game setup message was
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
* received and the data had only been modified deterministically.
*
* This is run on a timer to avoid flooding the network with messages,
* e.g. when modifying a slider.
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
*/
setNetworkInitAttributes()
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
for (const handler of this.settingsChangeHandlers)
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
handler();
if (g_IsNetworked && this.timer === undefined)
this.timer = setTimeout(this.setNetworkInitAttributesImmediately.bind(this), this.Timeout);
}
setNetworkInitAttributesImmediately()
{
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
if (this.timer)
{
clearTimeout(this.timer);
delete this.timer;
}
// See note in onClientJoin on network synchronization.
if (g_IsController)
Engine.SendGameSetupMessage({
"type": "update",
"initAttribs": this.getSettings()
});
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
/**
* Cheat prevention:
*
* 1. Ensure that the host cannot start the game unless all clients agreed on the game settings using the ready system.
*
* TODO:
* 2. Ensure that the host cannot start the game with InitAttributes different from the agreed ones.
* This may be achieved by:
* - Determining the seed collectively.
* - passing the agreed game settings to the engine when starting the game instance
* - rejecting new game settings from the server after the game launch event
*/
launchGame()
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
{
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 34138a7764. Refs #3049 Differential Revision: https://code.wildfiregames.com/D3243 This was SVN commit r25077.
2021-03-18 06:59:53 -07:00
// Save the file before random settings are resolved.
this.savePersistentMatchSettings();
// Mark the game as started so the readyController won't reset state.
this.gameStarted = true;
// This will resolve random settings & send game start messages.
// TODO: this will trigger observers, which is somewhat wasteful.
g_GameSettings.launchGame(g_PlayerAssignments, true);
// Switch to the loading page right away,
// the GUI will otherwise show the unrandomised settings.
this.switchToLoadingPage();
}
switchToLoadingPage(attributes)
{
Engine.SwitchGuiPage("page_loading.xml", {
"attribs": attributes?.initAttributes || g_GameSettings.finalizedAttributes,
"playerAssignments": g_PlayerAssignments
});
}
onClose()
{
this.savePersistentMatchSettings();
}
savePersistentMatchSettings()
{
if (g_IsController && !this.isSavedGame)
// TODO: ought to only save a subset of settings.
this.persistentMatchSettings.saveFile(this.getSettings());
Gamesetup class rewrite, fixes #5322, refs #5387. * Decouples settings logically which in turn allows fixing many problems arising from previous coupling. * Fixes the persist-match-settings feature, refs #2963, refs #3049. * Improves performance of the matchsetup by rebuilding GUI objects only when necessary. Provides groundwork for: * UI to control per-player handicap, such as StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates, ..., refs #812. * Map specific settings (onMapChange event), refs #4838. * Chat notifications announcing which settings changed, refs D1195, * Multiple controllers setting up the game (since setting types can check for permissions in onUpdateGameAttributes without the need for a new data model or a second gamesetup data network message type), refs #3806, subsequently dedicated server, refs #3556. * MapBrowser (MapCache, MapTypes, onUpdateGameAttributes interface), refs D1703 and D1777, * Multiplayer saved games (decoupling and setting dependent unique logic), refs #1088. Refs https://wildfiregames.com/forum/index.php?/topic/20787-paid-development-2016/ https://wildfiregames.com/forum/index.php?/topic/20789-paid-development-2016/ Enable maps to restrict setting values: * If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013. Fix per player StartingResources, PopulationCap, StartingTechnologies, DisabledTechnologies, DisabledTemplates following 9177683653, refs #812, fixes #4504. Use this for DisabledTechnologies on Polar Sea. Persist user settings for Skirmish maps: * All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value. * Tickets relating to that Skirmish mapchange user setting persistance: - Selecting a map doesn't change the selected civilizations, fixes #3120 (together with 7cf83f19fd removing map specified Civs). - Selecting a map type doesn't reset the selected settings, fixes #5372. - Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions to every map.) - Consume the player color palette from Skirmish maps, refs 4996d28110 / #1580. Preserve the selected playercolors when switching the Skirmish/Random map by chosing the most similar colors if the map comes with a different palette. Rated games: * Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117. * Display conspicuous warning if the game is rated, so players are perfectly aware. Autostarted games: * Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and 15e2b42525, refs D11. Networking: * Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114. * The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in b4e5858f6d/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from f2550705d3/D852 and the difficulty from 9daa7520ef/D1189, RelicDuration, WonderDuration, LastManStanding, RegicideGarrison, TriggerScripts, CircularMap, Garrison, DisabledTemplates. Checkboxes: * Display values of disabled checkboxes with Yes/No labels, fixes D2349, reviewed by nani. Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883: * Delete useless values: - VictoryScripts, because they are redundant with TriggerScripts, introduced in 8915037631. - mapType which was written twice to g_GameAttributes following 9177683653 - Description, Keywords, Preview since that doesn't impact simulation and can be loaded from the MapCache - mapFilter, mapPath, SupportedBiomes, SupportedTriggerDifficulties since they are only used in the gamesetup * Delete conditional values if the condition is not met: - AIDiff, AIBehavior if there is no AI in that slot - Nomad and Size if the maptype is not Random - Biome, TriggerDifficulty if the map doesn't support that - WonderDuration, RegicideGarrison, RelicCount, RelicDuration if the according VictoryConditions are not enabled - LastManStanding if TeamsLocked - Rating if there are more than 2 players MapCache: * Refactor to MapCache class, store maps of all types and use it in the replaymenu, lobby and session as well. SettingTabsPanel: * Remove hardcodings and coupling of the SettingTabsPanel with biomes/difficulties/chat UI from D1027/ac7b5ce861. GamesetupPage.xml: * Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation. New defaults: * Check LockedTeams default in multiplayer (not only rated games). * Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting. * 60 FPS in menus since they are animated Autocomplete sorting fixed (playernames should be completed first). Refactoring encompasses the one proposed in Polakrity and bb D1651. Differential Revision: https://code.wildfiregames.com/D2483 Tested by: nani Discussed with: * nani for blackbox testing, code architecture, performance and MapBrowser in PMs on 2019-12-19, 2019-12-31, 2020-01-06 * Angen for the simulation diff on http://irclogs.wildfiregames.com/2020-01/2020-01-03-QuakeNet-%230ad-dev.log * bb on SettingsTabPanel on http://irclogs.wildfiregames.com/2020-01/2020-01-05-QuakeNet-%230ad-dev.log * Imarok on data model and revised multi-controller plans for #3806 on http://irclogs.wildfiregames.com/2020-01/2020-01-07-QuakeNet-%230ad-dev.log Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach This was SVN commit r23374.
2020-01-11 12:14:17 -08:00
}
}
/**
* Wait (at most) this many milliseconds before sending network messages.
*/
GameSettingsController.prototype.Timeout = 400;