1
0
forked from 0ad/0ad

Allow to enable Cartography at the start of a match.

Adds a checkbox to the game setup to allow players to have Cartography
autoresearched from the start of the match.
Refs.
https://wildfiregames.com/forum/topic/27265-theres-any-mod-so-you-can-see-what-your-allies-see-from-the-start.

Patch by: @Jammyjamjamman
Differential revision: https://code.wildfiregames.com/D4191
Reviewed by: @Angen
Comments by: @andy5995, @Langbart
This was SVN commit r25869.
This commit is contained in:
Freagarach 2021-08-28 06:15:36 +00:00
parent 4b1270f841
commit dd90dbf8b5
8 changed files with 61 additions and 1 deletions

View File

@ -396,6 +396,11 @@ function getGameDescription(initAttributes, mapCache)
"value": initAttributes.settings.RevealMap
});
titles.push({
"label": translate("Allied View"),
"value": initAttributes.settings.AllyView
});
titles.push({
"label": translate("Cheats"),
"value": initAttributes.settings.CheatsEnabled

View File

@ -125,6 +125,7 @@
{ "nick": "Itms", "name": "Nicolas Auvray" },
{ "nick": "Jaison", "name": "Marco tom Suden" },
{ "nick": "jammus", "name": "James Scott" },
{ "nick": "Jammyjamjamman", "name": "James Sherratt" },
{ "nick": "Janwas", "name": "Jan Wassenberg" },
{ "nick": "javiergodas", "name": "Javier Godas Vieitez" },
{ "nick": "JCWasmx86" },

View File

@ -4,6 +4,7 @@ GameSettings.prototype.Attributes.MapExploration = class MapExploration extends
{
this.explored = false;
this.revealed = false;
this.allied = false;
this.settings.map.watch(() => this.onMapChange(), ["map"]);
}
@ -12,12 +13,14 @@ GameSettings.prototype.Attributes.MapExploration = class MapExploration extends
{
attribs.settings.RevealMap = this.revealed;
attribs.settings.ExploreMap = this.explored;
attribs.settings.AllyView = this.allied;
}
fromInitAttributes(attribs)
{
this.explored = !!this.getLegacySetting(attribs, "ExploreMap");
this.revealed = !!this.getLegacySetting(attribs, "RevealMap");
this.allied = !!this.getLegacySetting(attribs, "AllyView");
}
onMapChange(mapData)
@ -26,6 +29,7 @@ GameSettings.prototype.Attributes.MapExploration = class MapExploration extends
return;
this.setExplored(this.getMapSetting("ExploreMap"));
this.setRevealed(this.getMapSetting("RevealMap"));
this.setAllied(this.getMapSetting("AllyView"));
}
setExplored(enabled)
@ -38,5 +42,12 @@ GameSettings.prototype.Attributes.MapExploration = class MapExploration extends
{
this.explored = this.explored || enabled;
this.revealed = enabled;
this.allied = this.allied || enabled;
}
setAllied(enabled)
{
this.allied = enabled;
this.revealed = this.revealed && this.allied;
}
};

View File

@ -20,7 +20,8 @@ var g_GameSettingsLayout = [
"Nomad",
"Treasures",
"ExploredMap",
"RevealedMap"
"RevealedMap",
"AlliedView"
]
},
{

View File

@ -0,0 +1,30 @@
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();
}
};
// Translation: View what your allies can see.
GameSettingControls.AlliedView.prototype.TitleCaption =
translate("Allied View");
// Translation: Enable viewing what your allies can see from the start of the game.
GameSettingControls.AlliedView.prototype.Tooltip =
translate("Toggle allied view (see what your allies see).");

View File

@ -23,6 +23,7 @@ class GameDescription
g_GameSettings.map.watch(update, ["map", "type"]);
g_GameSettings.mapExploration.watch(update, ["explored"]);
g_GameSettings.mapExploration.watch(update, ["revealed"]);
g_GameSettings.mapExploration.watch(update, ["allied"]);
g_GameSettings.nomad.watch(update, ["enabled"]);
g_GameSettings.population.watch(update, ["perPlayer", "cap", "useWorldPop"]);
g_GameSettings.rating.watch(update, ["enabled"]);

View File

@ -68,6 +68,9 @@ function InitGame(settings)
if (settings.PopulationCap)
cmpPlayer.SetMaxPopulation(settings.PopulationCap);
if (settings.AllyView)
Engine.QueryInterface(cmpPlayer.entity, IID_TechnologyManager)?.ResearchTechnology(cmpPlayer.template.SharedLosTech);
}
if (settings.WorldPopulationCap)
Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).SetMaxWorldPopulation(settings.WorldPopulationCap);

View File

@ -39,6 +39,7 @@ enum
ID_MapName,
ID_MapDescription,
ID_MapReveal,
ID_MapAlly,
ID_MapType,
ID_MapPreview,
ID_MapTeams,
@ -169,6 +170,7 @@ void MapSettingsControl::CreateWidgets()
gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapPreview, wxEmptyString),
_("Texture used for map preview")), wxSizerFlags().Expand());
CREATE_CHECKBOX(this, gridSizer, "Reveal map", "If checked, players won't need to explore", ID_MapReveal);
CREATE_CHECKBOX(this, gridSizer, "Ally view", "If checked, players will be able to see what their teammates see and won't need to research cartography", ID_MapAlly);
CREATE_CHECKBOX(this, gridSizer, "Lock teams", "If checked, teams will be locked", ID_MapTeams);
sizer->Add(gridSizer, wxSizerFlags().Expand());
@ -233,6 +235,9 @@ void MapSettingsControl::ReadFromEngine()
// reveal map
wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->SetValue(wxString::FromUTF8(m_MapSettings["RevealMap"]) == "true");
// ally view
wxDynamicCast(FindWindow(ID_MapAlly), wxCheckBox)->SetValue(wxString::FromUTF8(m_MapSettings["AllyView"]) == "true");
// victory conditions
m_MapSettingsVictoryConditions.clear();
for (AtIter victoryCondition = m_MapSettings["VictoryConditions"]["item"]; victoryCondition.defined(); ++victoryCondition)
@ -364,6 +369,9 @@ AtObj MapSettingsControl::UpdateSettingsObject()
// reveal map
m_MapSettings.setBool("RevealMap", wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->GetValue());
// ally view
m_MapSettings.setBool("AllyView", wxDynamicCast(FindWindow(ID_MapAlly), wxCheckBox)->GetValue());
// victory conditions
#define INSERT_VICTORY_CONDITION_CHECKBOX(name, ID) \
if (wxDynamicCast(FindWindow(ID), wxCheckBox)->GetValue()) \