This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for 0AD A25 * AllyMap -> AllyView + bump version. * All "Ally Map" changed to "Ally View". Also changed code names for consistency. * Bump version number * Add missing newlines (to meet unix file spec). * Remove pointless comments * Reduce code + more mod-friendly Rather than re-defining entire classes/ functions, just extend the code we want to extend (by e.g. saving game code temporarily an "old" variable and re-defining). Reduces code duplication + more friendly towards other mods that may want to modify the same classes/ functions.
- Loading branch information
1 parent
d2003fe
commit 7353985
Showing
9 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# CartographyMode | ||
|
||
A [0 A.D.](https://play0ad.com/) mod; adds an "ally view" option to the | ||
game set-up menu, which allows allies to share vision at game start. | ||
|
||
[Forum post](https://wildfiregames.com/forum/index.php?/topic/27265-theres-any-mod-so-you-can-see-what-your-allies-see-from-the-start/&do=findComment&comment=397504) | ||
|
||
This mod was created by | ||
[Jammyjamjamman](https://github.com/jammyjamjamman) and maintained by | ||
him and [Andy Alt](https://github.com/andy5995). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
/** | ||
* Sets an additional map label, map preview image and describes the chosen gamesettings more closely. | ||
* | ||
* Requires g_GameAttributes and g_VictoryConditions. | ||
*/ | ||
function getGameDescriptionList(initAttributes, mapCache) | ||
{ | ||
let titles = []; | ||
if (!initAttributes.settings.VictoryConditions.length) | ||
titles.push({ | ||
"label": translateWithContext("victory condition", "Endless Game"), | ||
"value": translate("No winner will be determined, even if everyone is defeated.") | ||
}); | ||
|
||
for (let victoryCondition of g_VictoryConditions) | ||
{ | ||
if (initAttributes.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | ||
continue; | ||
|
||
let title = translateVictoryCondition(victoryCondition.Name); | ||
if (victoryCondition.Name == "wonder") | ||
{ | ||
let wonderDuration = Math.round(initAttributes.settings.WonderDuration); | ||
title = sprintf( | ||
translatePluralWithContext( | ||
"victory condition", | ||
"Wonder (%(min)s minute)", | ||
"Wonder (%(min)s minutes)", | ||
wonderDuration | ||
), | ||
{ "min": wonderDuration }); | ||
} | ||
|
||
let isCaptureTheRelic = victoryCondition.Name == "capture_the_relic"; | ||
if (isCaptureTheRelic) | ||
{ | ||
let relicDuration = Math.round(initAttributes.settings.RelicDuration); | ||
title = sprintf( | ||
translatePluralWithContext( | ||
"victory condition", | ||
"Capture the Relic (%(min)s minute)", | ||
"Capture the Relic (%(min)s minutes)", | ||
relicDuration | ||
), | ||
{ "min": relicDuration }); | ||
} | ||
|
||
titles.push({ | ||
"label": title, | ||
"value": victoryCondition.Description | ||
}); | ||
|
||
if (isCaptureTheRelic) | ||
titles.push({ | ||
"label": translate("Relic Count"), | ||
"value": Math.round(initAttributes.settings.RelicCount) | ||
}); | ||
|
||
if (victoryCondition.Name == "regicide") | ||
if (initAttributes.settings.RegicideGarrison) | ||
titles.push({ | ||
"label": translate("Hero Garrison"), | ||
"value": translate("Heroes can be garrisoned.") | ||
}); | ||
else | ||
titles.push({ | ||
"label": translate("Exposed Heroes"), | ||
"value": translate("Heroes cannot be garrisoned and they are vulnerable to raids.") | ||
}); | ||
} | ||
|
||
if (initAttributes.settings.RatingEnabled && | ||
initAttributes.settings.PlayerData.length == 2) | ||
titles.push({ | ||
"label": translate("Rated game"), | ||
"value": translate("When the winner of this match is determined, the lobby score will be adapted.") | ||
}); | ||
|
||
if (initAttributes.settings.LockTeams) | ||
titles.push({ | ||
"label": translate("Locked Teams"), | ||
"value": translate("Players can't change the initial teams.") | ||
}); | ||
else | ||
titles.push({ | ||
"label": translate("Diplomacy"), | ||
"value": translate("Players can make alliances and declare war on allies.") | ||
}); | ||
|
||
if (initAttributes.settings.LastManStanding) | ||
titles.push({ | ||
"label": translate("Last Man Standing"), | ||
"value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.") | ||
}); | ||
else | ||
titles.push({ | ||
"label": translate("Allied Victory"), | ||
"value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.") | ||
}); | ||
|
||
let ceasefire = Math.round(initAttributes.settings.Ceasefire); | ||
titles.push({ | ||
"label": translate("Ceasefire"), | ||
"value": | ||
!ceasefire ? | ||
translate("disabled") : | ||
sprintf(translatePlural( | ||
"For the first minute, other players will stay neutral.", | ||
"For the first %(min)s minutes, other players will stay neutral.", | ||
ceasefire), | ||
{ "min": ceasefire }) | ||
}); | ||
|
||
if (initAttributes.map == "random") | ||
titles.push({ | ||
"label": translateWithContext("Map Selection", "Random Map"), | ||
"value": translate("Randomly select a map from the list.") | ||
}); | ||
else | ||
{ | ||
titles.push({ | ||
"label": translate("Map Name"), | ||
"value": mapCache.translateMapName( | ||
mapCache.getTranslatableMapName(initAttributes.mapType, initAttributes.map, initAttributes)) | ||
}); | ||
|
||
titles.push({ | ||
"label": translate("Map Description"), | ||
"value": mapCache.getTranslatedMapDescription(initAttributes.mapType, initAttributes.map) | ||
}); | ||
} | ||
|
||
titles.push({ | ||
"label": translate("Map Type"), | ||
"value": g_MapTypes.Title[g_MapTypes.Name.indexOf(initAttributes.mapType)] | ||
}); | ||
|
||
if (initAttributes.mapType == "random") | ||
{ | ||
let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(initAttributes.settings.Size)]; | ||
if (mapSize) | ||
titles.push({ | ||
"label": translate("Map Size"), | ||
"value": mapSize | ||
}); | ||
} | ||
|
||
if (initAttributes.settings.Biome) | ||
{ | ||
let biome = g_Settings.Biomes.find(b => b.Id == initAttributes.settings.Biome); | ||
titles.push({ | ||
"label": biome ? biome.Title : translateWithContext("biome", "Random Biome"), | ||
"value": biome ? biome.Description : translate("Randomly select a biome from the list.") | ||
}); | ||
} | ||
|
||
if (initAttributes.settings.TriggerDifficulty !== undefined) | ||
{ | ||
let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == initAttributes.settings.TriggerDifficulty); | ||
titles.push({ | ||
"label": triggerDifficulty.Title, | ||
"value": triggerDifficulty.Tooltip | ||
}); | ||
} | ||
|
||
if (initAttributes.settings.Nomad !== undefined) | ||
titles.push({ | ||
"label": initAttributes.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | ||
"value": | ||
initAttributes.settings.Nomad ? | ||
translate("Players start with only few units and have to find a suitable place to build their city.") : | ||
translate("Players start with a Civic Center.") | ||
}); | ||
|
||
if (initAttributes.settings.StartingResources !== undefined) | ||
titles.push({ | ||
"label": translate("Starting Resources"), | ||
"value": | ||
initAttributes.settings.PlayerData && | ||
initAttributes.settings.PlayerData.some(pData => pData && pData.Resources !== undefined) ? | ||
translateWithContext("starting resources", "Per Player") : | ||
sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), { | ||
"startingResourcesTitle": | ||
g_StartingResources.Title[ | ||
g_StartingResources.Resources.indexOf( | ||
initAttributes.settings.StartingResources)], | ||
"amount": initAttributes.settings.StartingResources | ||
}) | ||
}); | ||
|
||
if (initAttributes.settings.PopulationCap !== undefined) | ||
titles.push({ | ||
"label": translate("Population Limit"), | ||
"value": | ||
initAttributes.settings.PlayerData && | ||
initAttributes.settings.PlayerData.some(pData => pData && pData.PopulationLimit !== undefined) ? | ||
translateWithContext("population limit", "Per Player") : | ||
g_PopulationCapacities.Title[ | ||
g_PopulationCapacities.Population.indexOf( | ||
initAttributes.settings.PopulationCap)] | ||
}); | ||
|
||
if (initAttributes.settings.WorldPopulationCap !== undefined) | ||
titles.push({ | ||
"label": translate("World Population Cap"), | ||
"value": | ||
g_WorldPopulationCapacities.Title[ | ||
g_WorldPopulationCapacities.Population.indexOf( | ||
initAttributes.settings.WorldPopulationCap)] | ||
}); | ||
|
||
titles.push({ | ||
"label": translate("Treasures"), | ||
"value": initAttributes.settings.DisableTreasures ? | ||
translateWithContext("treasures", "Disabled") : | ||
translateWithContext("treasures", "As defined by the map.") | ||
}); | ||
|
||
titles.push({ | ||
"label": translate("Explored Map"), | ||
"value": initAttributes.settings.ExploreMap | ||
}); | ||
|
||
titles.push({ | ||
"label": translate("Revealed Map"), | ||
"value": initAttributes.settings.RevealMap | ||
}); | ||
|
||
titles.push({ | ||
"label": translate("Cheats"), | ||
"value": initAttributes.settings.CheatsEnabled | ||
}); | ||
|
||
return titles; | ||
} | ||
|
||
function modDescriptions(initAttributes, titles) { | ||
titles.push({ | ||
"label": translate("Allied View"), | ||
"value": initAttributes.settings.AllyView | ||
}); | ||
return titles; | ||
} | ||
|
||
function getGameDescription(initAttributes, mapCache) { | ||
let titles = getGameDescriptionList(initAttributes, mapCache); | ||
titles = modDescriptions(initAttributes, titles); | ||
return titles.map(title => sprintf(translate("%(label)s %(details)s"), { | ||
"label": coloredText(title.label, g_DescriptionHighlight), | ||
"details": | ||
title.value === true ? translateWithContext("game setup option", "enabled") : | ||
title.value || translateWithContext("game setup option", "disabled") | ||
})).join("\n"); | ||
} |
37 changes: 37 additions & 0 deletions
37
a25/gui/gamesettings/attributes/MapExploration_CartographyMode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
let initOld = GameSettings.prototype.Attributes.MapExploration.prototype.init; | ||
GameSettings.prototype.Attributes.MapExploration.prototype.init = function () { | ||
initOld.call(this); | ||
this.allied = false; | ||
} | ||
|
||
let toInitAttributesOld = GameSettings.prototype.Attributes.MapExploration.prototype.toInitAttributes; | ||
GameSettings.prototype.Attributes.MapExploration.prototype.toInitAttributes = function (attribs) { | ||
toInitAttributesOld.call(this, attribs); | ||
attribs.settings.AllyView = this.allied; | ||
} | ||
|
||
let fromInitAttributesOld = GameSettings.prototype.Attributes.MapExploration.prototype.fromInitAttributes; | ||
GameSettings.prototype.Attributes.MapExploration.prototype.fromInitAttributes = function (attribs) { | ||
fromInitAttributesOld.call(this, attribs); | ||
this.allied = !!this.getLegacySetting(attribs, "AllyView"); | ||
} | ||
|
||
let onMapChangeOld = GameSettings.prototype.Attributes.MapExploration.prototype.onMapChange; | ||
GameSettings.prototype.Attributes.MapExploration.prototype.onMapChange = function (mapData) { | ||
onMapChangeOld.call(this, mapData); | ||
this.setRevealed(this.getMapSetting("AllyView")); | ||
} | ||
|
||
let setRevealedOld = GameSettings.prototype.Attributes.MapExploration.prototype.setRevealed; | ||
GameSettings.prototype.Attributes.MapExploration.prototype.setRevealed = function (enabled) { | ||
setRevealedOld.call(this, enabled); | ||
this.allied = this.allied || enabled; | ||
} | ||
|
||
GameSettings.prototype.Attributes.MapExploration.prototype.setAllied = function (enabled) { | ||
this.allied = enabled; | ||
this.revealed = this.revealed && this.allied; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
a25/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingsLayout_CartographyMode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
g_GameSettingsLayout[0]["settings"].push("AlliedView"); |
28 changes: 28 additions & 0 deletions
28
a25/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/AlliedMap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
GameSettingControls.AlliedView = class AlliedView extends GameSettingControlCheckbox | ||
{ | ||
constructor(...args) | ||
{ | ||
super(...args); | ||
g_GameSettings.mapExploration.watch(() => this.render(), ["allied"]); | ||
g_GameSettings.map.watch(() => this.render(), ["type"]); | ||
this.render(); | ||
} | ||
|
||
render() | ||
{ | ||
this.setEnabled(g_GameSettings.map.type != "scenario"); | ||
this.setChecked(g_GameSettings.mapExploration.allied); | ||
} | ||
|
||
onPress(checked) | ||
{ | ||
g_GameSettings.mapExploration.setAllied(checked); | ||
this.gameSettingsController.setNetworkInitAttributes(); | ||
} | ||
}; | ||
|
||
GameSettingControls.AlliedView.prototype.TitleCaption = | ||
translate("Allied View"); | ||
|
||
GameSettingControls.AlliedView.prototype.Tooltip = | ||
translate("Toggle allied view (see what your allies see)."); |
8 changes: 8 additions & 0 deletions
8
a25/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription_CartographyMode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
let registerWatchersOld = GameDescription.prototype.registerWatchers; | ||
GameDescription.prototype.registerWatchers = function () { | ||
registerWatchersOld.call(this); | ||
let update = () => this.updateGameDescription(); | ||
g_GameSettings.mapExploration.watch(update, ["allied"]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#. Translation: Make sure to differentiate between the revealed map and | ||
#. ally view settings! | ||
#: gui/gamesetup/gamesetup_CartographMode.js | ||
msgid "Ally View" | ||
msgstr "Ally View" | ||
|
||
#. Translation: Make sure to differentiate between the revealed map and | ||
#. ally view settings! | ||
#: gui/gamesetup/gamesetup_CarographyMode.js | ||
msgid "Toggle allied view (see everything you + allies can see)." | ||
msgstr "Toggle allied view (see everything you + allies can see)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "CartographyMode", | ||
"version": "2.0.0", | ||
"label": "Cartography Mode", | ||
"description": "Start a game with \"cartography mode\" researched for all players. Everyone sees what their allies can see from the start of the game.", | ||
"dependencies": ["0ad=0.0.25"] | ||
} |
Oops, something went wrong.