1
0
forked from mirrors/0ad
Commit Graph

53 Commits

Author SHA1 Message Date
Dunedan 93ce94655d Use @stylistic/brace-style for eslint
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace
style for JavaScript code. This plugin was however updated the last time
over 9 years ago and will be incompatible with ESLint v10, as that
[removes `context.getSourceCode()`][1], the plugin relies on.

To keep the eslint config working with ESLint v10, this replaces
`eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule
from `@stylistic/eslint-plugin`, a package we already use.

While `@stylistic/brace-style` doesn't offer an option to format braces
in exactly the same way as before, the "allman" style seems to be the
one closest to the existing code.

[1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members
[2]: https://eslint.style/rules/brace-style
2026-01-12 21:33:52 +01:00
Ralph Sennhauser 0ce889ca6d Use stylistic for deprecated eslint rules
During the eslint 8 cycle the formatting rules were split out [1],
deprecating the corresponding rules in core.

This replaces all rules that where moved to @stylistic/eslint-plugin [2]
and accounts for the difference in the indenting rule behaviour.

To allow the pre-commit import hack to continue to work with the
stylisitc plugin for a recent nodejs version to be used.

[1] https://eslint.org/blog/2023/10/deprecating-formatting-rules/
[2] https://eslint.style/packages/default

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-10 21:23:23 +02:00
Ralph Sennhauser 519a215e1c Fix eslint rule 'prefer-const' in gui/common
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/gui/common

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-09 19:32:43 +02:00
Feldfeld b5256ce014 Include Player Placement setting in Game Description
The option was missing, so player placement was not shown in the game
description part of the game setup, and it was not shown in the objectives
page in-game.
2025-04-10 18:57:40 +02:00
Vantha 5741f77c6e Add a 'team population' gamesetting
Remove the world population setting from the game setup.
Add a dropdown for choosing the "Population Cap Type".
(-> containing Player Population, World Population, Team Population)

Use a single "Population Cap" dropdown adapting to the pop cap types.
Move all population data into a single .json file.

New system component "PopulationCapManager" for distributing pop caps.

Resolves: #6918
2025-03-06 13:25:43 +01:00
wraitii 007bf75264 Fix map previews/descriptions in the lobby game list.
Map previews are broken in the lobby game list, except for maps with
specific previews (such as biome RMs). Descriptions were broken in
general. The error lies in 1ae4f497e8, which forgot to add the xml
extension.

Differential Revision: https://code.wildfiregames.com/D3632
This was SVN commit r25010.
2021-03-04 18:31:33 +00:00
wraitii 1ae4f497e8 Fix noisy errors when joining hte lobby and someone is hosting a modded game.
Check for existence explicitly in the lobby GUI.
It would probably be better to not trigger errors in the cache
laoder/JSON code but instead print at the caller, depending, but that
requires changing a lot more code.

Reported by: Asger
Fixes #5988

Differential Revision: https://code.wildfiregames.com/D3506
This was SVN commit r24821.
2021-02-02 14:55:45 +00:00
Freagarach 88bc450b79 Correct some strings in the GUI.
Patch by: @Nescio
Differential Revision: D3007
This was SVN commit r24401.
2020-12-17 11:47:04 +00:00
bb 0a26c55513 Fix more JsDocs numbers/bools/strings
This was SVN commit r23992.
2020-08-24 11:50:31 +00:00
Freagarach edb956424e Allow world population capacity.
This allows to specify a world population capacity that is divided
evenly amongst living players.

Differential Revision: D2426
Reviewed by: @Angen
This was SVN commit r23873.
2020-07-23 09:00:34 +00:00
elexis 352d4ea78f Gamesetup slider support, use it for Ceasefire, RelicCount, RelicDuration, WonderDuration.
Use Math.round until the slider GUI object type supports fixed step
sizes, refs D406.

Differential Revision: https://code.wildfiregames.com/D2571
Comments By: Vladislav (irc), nani (PM), bb (irc), Stan
This was SVN commit r23430.
2020-01-22 21:37:14 +00:00
elexis 34138a7764 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 20:14:17 +00:00
elexis fbe57d2066 Commit files missing in previous commit e3f43f6352 / D2378.
This was SVN commit r23077.
2019-10-17 15:22:18 +00:00
elexis 1f421c266a Fix ESLint no-multi-assign, default-case, no-empty, no-shadow warnings, refs #5524.
Differential Revision: https://code.wildfiregames.com/D2146
Based on patch By: Krinkle
This was SVN commit r22655.
2019-08-12 14:48:10 +00:00
bb 2746514175 Order the victory checkboxes the same way as the descriptions are noticed by elexis
This was SVN commit r21535.
2018-03-13 15:25:26 +00:00
elexis 8cde469501 Biome specific mappreview support and previews for Aethiopia and Gulf Of Bothnia, fixes #4962, refs #4954.
This was SVN commit r21506.
2018-03-11 18:11:56 +00:00
bb 6d54ab4c1f Implement combine victory conditions
Excluding the changes to scenario and skirmisch maps
Transform gameType string to victoryCondition array in load/replaymenu
Adapt the gamesetup to use checkboxes for every victory condition and an
array for storing them
Allow multiple queries in conquestCommon
Remove conquest from regicide, wonder and capture the relic
Move the endless gamedescription from settings to gamedescription
Fixing wrong tabulation from a8a29271ce

This commit will break all scenario and skirmisch maps, their "Gametype"
string needs to be transformed in a "VictoryCondition" array as is done
in the tutorial map (counting endless as an empty array). This counts
for mods too!
Old svn replays and savegame will throw warnings/errors as they are
incompatible after this commit. So svn users will need to delete all
those.

Comments on ai and autostart games By: mimo
Comments on Atlas By: Vladislav
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D1240
fixes: #4014

This was SVN commit r21474.
2018-03-09 21:51:18 +00:00
elexis 626d89a726 Extend random biome systme to support map specific biomes, fixes #4954, refs D852 / f2550705d3.
This was SVN commit r21010.
2018-01-25 04:44:26 +00:00
mimo 9daa7520ef Allows trigger script with different difficulty levels
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D1189
This was SVN commit r20760.
2018-01-03 11:21:37 +00:00
elexis efabf76364 Small JS GUI settings simplification using 58b2e2baf4 / D1107, refs D1189.
This was SVN commit r20752.
2018-01-02 17:10:04 +00:00
mimo 3319c69d97 Choose AI behavior in gamesetup
Original patch from Sandarac, reworked by elexis and finalized by mimo

Discussed with elexis

Differential Revision: https://code.wildfiregames.com/D1159
This was SVN commit r20671.
2017-12-20 22:02:15 +00:00
elexis 571562d7d7 Revert 9c180f660f until there is someone maintaining AI behaviors, refs D746.
This was SVN commit r20654.
2017-12-14 13:31:00 +00:00
elexis 9c180f660f AI behavior gamesetup setting.
Based On Patch By: Sandarac
Differential Revision: https://code.wildfiregames.com/D746
Refs #812, #2550

This was SVN commit r20646.
2017-12-12 16:45:09 +00:00
elexis 7fda43d14e Expose the same file listing function to JS GUI, simulation and rmgen, refs #4868.
Removes the workaround and limitations of globalscripts Resources
(52f311da2b) and loadCivFiles (89055ef858), allowing them to actually
become actually global.
Rename to ListDirectoryFiles as proposed by wraitii.

Differential Revision: https://code.wildfiregames.com/D1103
Reviewed By: s0600204
Proofread by: echotangoecho
Comments by: wraitii
Relevant discussions with leper in #4868, D1062

This was SVN commit r20586.
2017-12-04 23:46:55 +00:00
elexis cd571035bb Allow fast-forwarding of matches with only AI players.
Differential Revision: https://code.wildfiregames.com/D595
Refs #4078
Accepted By: Grugnas
This was SVN commit r20577.
2017-12-04 02:37:21 +00:00
Imarok 6c5a8269f3 Fix some style issues noticed by our linter
Reviewed By: bb
Differential Revision: https://code.wildfiregames.com/D585
This was SVN commit r20322.
2017-10-21 17:31:05 +00:00
elexis 74bfe5fd55 Add biome descriptions.
Display biomes in the objectives dialog and gamesetup map description
panel.
Complete the mod support of 871ed04521 by leaving the code
biome-agnostic.
Fix an oversight in unknown nomad in 2c5a6052ea.

Differential Revision: https://code.wildfiregames.com/D884
Strings By: Hannibal_Barca
This was SVN commit r20139.
2017-09-09 00:10:08 +00:00
elexis f2550705d3 Select the biome of the random map in the gamesetup.
Differential Revision: https://code.wildfiregames.com/D852
Based on patch by: Grugnas
This was SVN commit r20115.
2017-09-05 12:57:22 +00:00
elexis 9cb0a60d73 Deepfreeze Aura, Technology and Resource Templates, Simulation states, GameAttributes and few other JS objects.
This reveals unintentional modifications to these objects which would
most often imply hidden bugs.

Differential Revision: https://code.wildfiregames.com/D829
Fixes #4257
Refs #3647

This was SVN commit r20100.
2017-09-03 16:37:09 +00:00
elexis 3c73b329f2 JS cleanup.
Mark global consts as variable if mods can legitimately modify them.
Keep global objects const if mods should insert their modifications at a
different place, refs D829.
Mark the few consts inside function scope as let or var for consistency.
Don't touch the AI, simulation test and rmgen folder.
Change some var to let.
Remove an unused variable in the mainmenu and summary screen.
Inline few variables.

This was SVN commit r20047.
2017-08-26 20:10:39 +00:00
elexis 661284a403 Fix some string issues and reveal the name of the next release (Ken Wood).
Change the tense of the Capture The Relic message, as proposed by brian
(WhiteTreePaladin).
Consistently use title case for buttons.
Use more descriptive and concise option titles.
Remove two unused strings.

Fixes #4718
Refs
https://wildfiregames.com/forum/index.php?/topic/22745-all-relics-captured-message/
Refs
https://wildfiregames.com/forum/index.php?/topic/22461-alpha-23-name-suggestions/
Reviewed by: brian (WhiteTreePaladin), leper, GunChleoc.
Release name agreed with Itms on 2017-07-29 on irc.

This was SVN commit r20000.
2017-08-19 11:47:24 +00:00
Itms db0570e71e String changes, based on feedback from translators.
Reviewed By: Phormio
Differential Revision: https://code.wildfiregames.com/D561
This was SVN commit r19726.
2017-06-03 16:30:18 +00:00
elexis 2599d0374e Get the index of the hovered element in GUI lists and use it to display item-specific tooltips in the gamesetup for the victory condition, maptype and starting resources.
Differential Revision: https://code.wildfiregames.com/D316
Fixes #3699
Patch By: Vladislav
This was SVN commit r19588.
2017-05-15 21:49:10 +00:00
elexis 35377c51a7 Capture The Relic gamemode.
Patch By: Sandarac
Differential Revision: https://code.wildfiregames.com/D152
This was SVN commit r19345.
2017-03-25 07:01:07 +00:00
elexis 7c3c5f6173 Fix some string issues reported on transifex.
This was SVN commit r18786.
2016-09-27 18:29:32 +00:00
elexis 317502d915 Objectives dialog. Icon by Lionkanzen. Reviewed by bb, fixes #3263 #4141.
Explain the new victory conditions and last man standing option in the
gamesetup.
Add an ingame dialog showing these explanations and all other chosen
gamesetup options,
so that players don't have to recall them and late observers don't have
to ask.

This was SVN commit r18692.
2016-09-03 09:11:02 +00:00
elexis 983ef2ed2c Add translation context to the "Unknown" strings, allowing to chose a different translation for every occurance.
This was SVN commit r18112.
2016-04-30 14:01:07 +00:00
elexis b2fdfeba53 New gamesetup option enabling the host to vary the time required to win the wonder-gamemode. Patch by svott, fixes #3234.
This was SVN commit r18075.
2016-04-20 21:01:58 +00:00
elexis 96003e8812 Correct the order of JSDoc arguments in so many places and use @returns instead of @return.
Remove some unneeded comments.

This was SVN commit r17445.
2015-12-12 14:53:28 +00:00
elexis a98a44875e Move mapsizes to the new simulation settings system. Fixes #3355.
Notice that initMapSizes() confusingly mapped from "LongName" to "names"
and from "Name" to "shortnames".
Now it's identical in both parts.

Also fixes a bug in the summary screen where it would show "Scenario"
for a skirmish map.

This was SVN commit r17373.
2015-12-04 12:24:58 +00:00
elexis 700859b2c3 Move the playerdefaults to the settings directory. Refs #3355
This was SVN commit r17332.
2015-11-30 01:33:59 +00:00
Itms de2f97a9cc Fix translation of starting resources, patch by elexis, refs #3355
This was SVN commit r17064.
2015-09-23 21:12:31 +00:00
Itms d64b95b28c An awesome Visual Replay menu, made by elexis. Fixes #3258.
This was SVN commit r17054.
2015-09-21 17:00:21 +00:00
Itms c19903936b Correct a missed translation comment and fix translation contexts in the simulation settings.
This was SVN commit r17048.
2015-09-20 10:37:45 +00:00
mimo 4235c67764 still another bunch of cleanup (mainly missing semicolon) signaled by jshint
This was SVN commit r17046.
2015-09-19 12:55:58 +00:00
Itms 4da5d571fc Move the AI data to the new simulation settings system. Patch by elexis. Refs #3355.
This was SVN commit r17034.
2015-09-18 16:36:52 +00:00
mimo 749637dc84 Move the map types to the new simulation settings system. Patch by elexis. Refs #3355.
This was SVN commit r17031.
2015-09-17 17:55:27 +00:00
mimo 21619a4705 Move the victory conditions to the new simulation settings system. Patch by elexis. Refs #3355,#3001
This was SVN commit r17026.
2015-09-16 09:22:36 +00:00
mimo e7f736fd0f Move the game speeds to the new simulation settings system. Patch by elexis. Refs #3355
This was SVN commit r17019.
2015-09-13 19:15:07 +00:00
leper bbcf996531 Move the population cap to the new simulation settings system. Patch by elexis. Refs #3355.
This was SVN commit r17012.
2015-09-13 00:32:34 +00:00