Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#3355 closed defect (fixed)

[PATCH] Move gamesetup strings to simulation/data/settings/

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by Stan)

Many strings are hardcoded in the gamesetup and used in other places like the lobby, session and summary screen and will also be used in the visual replay menu (#3258).

The affected settings are:

  • AI Difficulties
  • Ceasefire
  • GameSpeeds
  • GameTypes
  • MapTypes
  • MapSizes
  • PlayerDefaults
  • PopulationCapacity
  • StartingResources

The strings should be moved to simulation/data/settings/ and treated consistently, so that redundant code can be removed.

Notice: For visual replay menu, MapSizes and PlayerDefaults are not required to be moved, as they are present in functions_utility.js

Refs #3049

Attachments (28)

t3355_move_gamesetup_strings_v1.patch (81.7 KB ) - added by elexis 9 years ago.
t3355_move_gamesetup_strings_v1.1.patch (81.8 KB ) - added by elexis 9 years ago.
Doesn't remove the context of existing translation.
t3355_move_gamesetup_strings_v1.2.patch (83.7 KB ) - added by elexis 9 years ago.
Updates the translation extractor to support context for json files (to correctly extract the translated strings of our new files). To quickly verify the function, insert if templateSettings["output"] != "public-simulation-other.pot": continue; to L74 of updateTemplates.py.
t3355_move_gamesetup_strings_v2.patch (88.6 KB ) - added by elexis 9 years ago.
Now saves each GameType as an individual json file (better for mods). Atlas now properly recognizes MapSizes. Uses find and findIndex. More cleanup in aiconfig.js. Some issues leper noticed in irc thir morning.
t3355_move_gamesetup_strings_v2.1.patch (88.6 KB ) - added by elexis 9 years ago.
Fixes wrong TranslatedKeys entry in the GameTypes json files.
t3355_translate_json_files_with_context_v1.patch (2.8 KB ) - added by elexis 9 years ago.
Splitting the patch into many parts now. This patch allows translating JSON files with context. It tells the translation extractor to add the context, which is given as a parameter in the binaries/data/mods/mod/l10n/messages.json file.
t3355_move_player_limit_v1.patch (20.9 KB ) - added by elexis 9 years ago.
Moves "MaxPlayers": 8 and MaxTeams": 4 and creates the settings.js file needed for all further patches.
t3355_move_player_limit_v2.patch (22.5 KB ) - added by elexis 9 years ago.
Doesn't create player_limit.json but moves the constant to settings.js. Doesn't show a popup anymore, but returns immediatel on error. Needs to wait one onTick in session.js, otherwise it segfaults.
t3355_move_player_limit_v2.1.patch (22.8 KB ) - added by elexis 9 years ago.
Renamed variables, changed comments, added newlines.
t3355_move_player_limit_v3.patch (13.9 KB ) - added by elexis 9 years ago.
Split once more. This is the smallest patch possible to move the player limits.
t3355_move_player_limit_v3.1.patch (13.2 KB ) - added by elexis 9 years ago.
Rebased.
t3355_move_ceasefire_v1.patch (13.4 KB ) - added by elexis 9 years ago.
Also includes the 1-4min ceasefire options the community wished for.
t3355_move_ceasefire_v1.1.patch (13.4 KB ) - added by elexis 9 years ago.
Makes the translation context coherent for the case unknown.
t3355_move_ceasefire_v1.2.patch (13.1 KB ) - added by elexis 9 years ago.
Removes unused function translateCeasefire.
t3355_move_ceasefire_v2.patch (11.3 KB ) - added by elexis 9 years ago.
Broke uniform loading of files to remove redundant ceasefire translations. Also a simplification in gamesetup error handling and made g_Ceasefire const.
t3355_move_ceasefire_v2.1.patch (11.4 KB ) - added by elexis 9 years ago.
Alternative version where undefined instead of false is returned in case of error.
t3355_move_ceasefire_v2.2.patch (11.4 KB ) - added by elexis 9 years ago.
Uses lowercase filename dammit.
t3355_move_starting_resources_v1.patch (7.6 KB ) - added by elexis 9 years ago.
t3355_move_starting_resources_v1.1.patch (7.1 KB ) - added by elexis 9 years ago.
After a review by mimo: Renamed loadAvailableSettings and in case of error, print all erroneous files.
t3355_move_population_capacities_v1.patch (5.6 KB ) - added by elexis 9 years ago.
t3355_move_game_speeds_v1.patch (15.9 KB ) - added by elexis 9 years ago.
t3355_move_game_speeds_v1.1.patch (18.9 KB ) - added by elexis 9 years ago.
Simplifies that changed line in settings.js, renames m_IsReplay to m_IsVisualReplay and CGame::StartReplay to CGame::StartVisualReplay so that it's clear that this code is not run in non-visual replaymode (after a review by mimo).
t3355_move_gametypes_v1.patch (18.1 KB ) - added by elexis 9 years ago.
Don't forget to delete gui/gamesetup/victory_conditions/
t3355_move_gametypes_v2.patch (16.5 KB ) - added by elexis 9 years ago.
Derives the name element from the filename and changes variable names to "victory conditions", as we might support having multiple of them simultaneously in the future.
t3355_move_gametypes_v3.patch (17.3 KB ) - added by elexis 9 years ago.
Corrects the entries in atlas and finds a solution to both r16238 and r16840
t3355_move_maptypes_v1.patch (11.0 KB ) - added by elexis 9 years ago.
t3355_move_ai_difficulties_v1.patch (8.1 KB ) - added by elexis 9 years ago.
t3355_fix_translation_context_v1.patch (1.2 KB ) - added by elexis 9 years ago.
The translations of the starting resources were still extracted correctly after r17052, but the translation context wasn't handed over anymore to the actual translation call.

Download all attachments as: .zip

Change History (52)

comment:1 by elexis, 9 years ago

Keywords: patch review added
Milestone: BacklogAlpha 19
Summary: Move gamesetup strings to simulation/data/settings/[PATCH] Move gamesetup strings to simulation/data/settings/

Moves all the hardcoded values from lobby/gamesetup/session/summary to simulation/data. Doesn't break atlas. Notice that the AI difficulties, ceasefire times, starting resources and maptypes have their translation context removed. Includes some more ceasefire times desired by the community.

Reintroduces the code that was removed in r16840 for non-random maps, so that both #3001 and #3209 are covered. That code was necessary for a bug that was explained in IRC on 2015-01-27 at 4pm: < niektb> Pick a skirmish map, set the conditions to None and then change to a scenario that has a Conquest condition. You'll see that when you load the map no victory conditions are set.

You can test that all settings are accepted correctly by starting a game and comparing the settings in the commands.txt (improve json readability with http://jsonlint.com/)

comment:2 by elexis, 9 years ago

# 1. After applying the patch make sure the old files are actually removed
rm binaries/data/mods/public/simulation/data/game_speeds.json
rm binaries/data/mods/public/simulation/data/map_sizes.json
rm binaries/data/mods/public/simulation/data/player_defaults.json
rm -R binaries/data/mods/public/gui/gamesetup/victory_conditions

# AI difficulties were hardcoded in aiconfig.js
# Map types were hardcoded in gamesetup.js and lobby.js
# Ceasefire, starting resources, population capacity were hardcoded in gamesetup.js

# 2. Make sure the removed files are unrevisioned too
svn rm binaries/data/mods/public/simulation/data/game_speeds.json
svn rm binaries/data/mods/public/simulation/data/map_sizes.json
svn rm binaries/data/mods/public/simulation/data/player_defaults.json
svn rm binaries/data/mods/public/gui/gamesetup/victory_conditions/

# 3. Make sure the new files are all revisioned
svn add binaries/data/mods/public/gui/common/settings.js
svn add binaries/data/mods/public/simulation/data/settings/

Also "map_sizes.json" and "player_defaults.json" in http://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals should be updated.

by elexis, 9 years ago

Doesn't remove the context of existing translation.

by elexis, 9 years ago

Updates the translation extractor to support context for json files (to correctly extract the translated strings of our new files). To quickly verify the function, insert if templateSettings["output"] != "public-simulation-other.pot": continue; to L74 of updateTemplates.py.

by elexis, 9 years ago

Now saves each GameType as an individual json file (better for mods). Atlas now properly recognizes MapSizes. Uses find and findIndex. More cleanup in aiconfig.js. Some issues leper noticed in irc thir morning.

by elexis, 9 years ago

Fixes wrong TranslatedKeys entry in the GameTypes json files.

by elexis, 9 years ago

Splitting the patch into many parts now. This patch allows translating JSON files with context. It tells the translation extractor to add the context, which is given as a parameter in the binaries/data/mods/mod/l10n/messages.json file.

comment:3 by leper, 9 years ago

In 16942:

Enhance i18n extractor to support a single context for a json file. Patch by elexis. Refs #3355.

by elexis, 9 years ago

Moves "MaxPlayers": 8 and MaxTeams": 4 and creates the settings.js file needed for all further patches.

by elexis, 9 years ago

Doesn't create player_limit.json but moves the constant to settings.js. Doesn't show a popup anymore, but returns immediatel on error. Needs to wait one onTick in session.js, otherwise it segfaults.

by elexis, 9 years ago

Renamed variables, changed comments, added newlines.

by elexis, 9 years ago

Split once more. This is the smallest patch possible to move the player limits.

by elexis, 9 years ago

Rebased.

comment:4 by Itms, 9 years ago

In 16975:

Move player and team number limits to a centralized file which will also eventually hold various kinds of settings.
Patch by elexis, refs #3355

comment:5 by Itms, 9 years ago

In 16979:

Apparently SVN messed up when I applied the patch for r16975, so fix it.
Also include some fixes to elexis's oversights, refs #3355.

by elexis, 9 years ago

Also includes the 1-4min ceasefire options the community wished for.

by elexis, 9 years ago

Makes the translation context coherent for the case unknown.

by elexis, 9 years ago

Removes unused function translateCeasefire.

by elexis, 9 years ago

Broke uniform loading of files to remove redundant ceasefire translations. Also a simplification in gamesetup error handling and made g_Ceasefire const.

by elexis, 9 years ago

Alternative version where undefined instead of false is returned in case of error.

by elexis, 9 years ago

Uses lowercase filename dammit.

comment:6 by Itms, 9 years ago

In 17006:

Add the ceasefire settings to the new simulation settings system.
Patch by elexis, refs #3355.

by elexis, 9 years ago

After a review by mimo: Renamed loadAvailableSettings and in case of error, print all erroneous files.

comment:7 by mimo, 9 years ago

In 17007:

Add the starting resources to the new simulation settings system, refs #3355, patch by elexis

comment:8 by leper, 9 years ago

In 17012:

Move the population cap to the new simulation settings system. Patch by elexis. Refs #3355.

by elexis, 9 years ago

by elexis, 9 years ago

Simplifies that changed line in settings.js, renames m_IsReplay to m_IsVisualReplay and CGame::StartReplay to CGame::StartVisualReplay so that it's clear that this code is not run in non-visual replaymode (after a review by mimo).

comment:9 by mimo, 9 years ago

In 17017:

Rename some variables to point out that they are only used in visual replay. Add script function IsVisualReplay. Refs #9 #3355, patch by elexis

comment:10 by mimo, 9 years ago

In 17019:

Move the game speeds to the new simulation settings system. Patch by elexis. Refs #3355

by elexis, 9 years ago

Don't forget to delete gui/gamesetup/victory_conditions/

by elexis, 9 years ago

Derives the name element from the filename and changes variable names to "victory conditions", as we might support having multiple of them simultaneously in the future.

by elexis, 9 years ago

Corrects the entries in atlas and finds a solution to both r16238 and r16840

comment:11 by mimo, 9 years ago

In 17026:

Move the victory conditions to the new simulation settings system. Patch by elexis. Refs #3355,#3001

by elexis, 9 years ago

comment:12 by elexis, 9 years ago

Description: modified (diff)

comment:13 by mimo, 9 years ago

In 17031:

Move the map types to the new simulation settings system. Patch by elexis. Refs #3355.

comment:14 by Stan, 9 years ago

Description: modified (diff)

comment:15 by elexis, 9 years ago

Some comments for that patch:

  • aiconfig.js
    • function init(settings): moved both arrays used to settings.js and simplified
    • function selectAI(idx): id and name were unused
    • function returnAI(): only simplifications and style fix
  • gamesetup.js
    • doesn't transfer g_AIs anymore, since it is accessible from g_Settings
    • aiCodes: unused variable

Notice: For visual replay menu, MapSizes and PlayerDefaults are not required to be moved, as they are present in functions_utility.js. We might push this to A20 after the next commit.

comment:16 by Itms, 9 years ago

In 17034:

Move the AI data to the new simulation settings system. Patch by elexis. Refs #3355.

comment:17 by Itms, 9 years ago

Description: modified (diff)
Keywords: review removed
Milestone: Alpha 19Alpha 20

by elexis, 9 years ago

The translations of the starting resources were still extracted correctly after r17052, but the translation context wasn't handed over anymore to the actual translation call.

comment:18 by Itms, 9 years ago

In 17064:

Fix translation of starting resources, patch by elexis, refs #3355

comment:19 by elexis, 8 years ago

In 17332:

Move the playerdefaults to the settings directory. Refs #3355

comment:20 by Stan, 8 years ago

Description: modified (diff)

comment:21 by elexis, 8 years ago

In 17345:

Don't break the translation of the playerdefaults. Refs #3355

comment:22 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17373:

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.

comment:23 by elexis, 8 years ago

In 17374:

Actually remove the old file from the repository. Refs #3355

comment:24 by elexis, 8 years ago

In 17379:

Update atlas with the new map_sizes.json format. Refs #3355.

Note: See TracTickets for help on using tickets.