Add an 'explore map' option to the game setup.

This was SVN commit r14931.
This commit is contained in:
sanderd17 2014-04-14 19:52:49 +00:00
parent a9d0a3bcae
commit e1488fee56
6 changed files with 68 additions and 3 deletions

View File

@ -235,6 +235,15 @@ function initMain()
updateGameAttributes();
};
Engine.GetGUIObjectByName("exploreMap").onPress = function()
{ // Update attributes so other players can see change
g_GameAttributes.settings.ExploreMap = this.checked;
if (!g_IsInGuiUpdate)
updateGameAttributes();
};
Engine.GetGUIObjectByName("lockTeams").onPress = function()
{ // Update attributes so other players can see change
g_GameAttributes.settings.LockTeams = this.checked;
@ -933,6 +942,7 @@ function onGameAttributesChange()
// Controls common to all map types
var numPlayersSelection = Engine.GetGUIObjectByName("numPlayersSelection");
var revealMap = Engine.GetGUIObjectByName("revealMap");
var exploreMap = Engine.GetGUIObjectByName("exploreMap");
var victoryCondition = Engine.GetGUIObjectByName("victoryCondition");
var lockTeams = Engine.GetGUIObjectByName("lockTeams");
var mapSize = Engine.GetGUIObjectByName("mapSize");
@ -944,6 +954,7 @@ function onGameAttributesChange()
var mapSizeDesc = Engine.GetGUIObjectByName("mapSizeDesc");
var mapSizeText = Engine.GetGUIObjectByName("mapSizeText");
var revealMapText = Engine.GetGUIObjectByName("revealMapText");
var exploreMapText = Engine.GetGUIObjectByName("exploreMapText");
var victoryConditionText = Engine.GetGUIObjectByName("victoryConditionText");
var lockTeamsText = Engine.GetGUIObjectByName("lockTeamsText");
var enableCheatsText = Engine.GetGUIObjectByName("enableCheatsText");
@ -977,6 +988,7 @@ function onGameAttributesChange()
numPlayersSelection.hidden = false;
mapSize.hidden = false;
revealMap.hidden = false;
exploreMap.hidden = false;
victoryCondition.hidden = false;
lockTeams.hidden = false;
populationCap.hidden = false;
@ -985,6 +997,7 @@ function onGameAttributesChange()
numPlayersText.hidden = true;
mapSizeText.hidden = true;
revealMapText.hidden = true;
exploreMapText.hidden = true;
victoryConditionText.hidden = true;
lockTeamsText.hidden = true;
populationCapText.hidden = true;
@ -993,7 +1006,9 @@ function onGameAttributesChange()
mapSizeText.caption = "Map size:";
mapSize.selected = sizeIdx;
revealMapText.caption = "Reveal map:";
exploreMapText.caption = "Explore map:";
revealMap.checked = (mapSettings.RevealMap ? true : false);
exploreMap.checked = (mapSettings.ExploreMap ? true : false);
victoryConditionText.caption = "Victory condition:";
victoryCondition.selected = victoryIdx;
@ -1006,6 +1021,7 @@ function onGameAttributesChange()
numPlayersText.hidden = false;
mapSizeText.hidden = false;
revealMapText.hidden = false;
exploreMapText.hidden = false;
victoryConditionText.hidden = false;
lockTeamsText.hidden = false;
populationCap.hidden = true;
@ -1016,6 +1032,7 @@ function onGameAttributesChange()
numPlayersText.caption = numPlayers;
mapSizeText.caption = g_MapSizes.names[sizeIdx];
revealMapText.caption = (mapSettings.RevealMap ? "Yes" : "No");
exploreMapText.caption = (mapSettings.ExloreMap ? "Yes" : "No");
victoryConditionText.caption = VICTORY_TEXT[victoryIdx];
lockTeamsText.caption = (mapSettings.LockTeams ? "Yes" : "No");
}
@ -1033,6 +1050,7 @@ function onGameAttributesChange()
{
//Host
revealMap.hidden = false;
exploreMap.hidden = false;
victoryCondition.hidden = false;
lockTeams.hidden = false;
populationCap.hidden = false;
@ -1040,13 +1058,16 @@ function onGameAttributesChange()
numPlayersText.hidden = false;
revealMapText.hidden = true;
exploreMapText.hidden = true;
victoryConditionText.hidden = true;
lockTeamsText.hidden = true;
populationCapText.hidden = true;
startingResourcesText.hidden = true;
revealMapText.caption = "Reveal map:";
exploreMapText.caption = "Explore map:";
revealMap.checked = (mapSettings.RevealMap ? true : false);
exploreMap.checked = (mapSettings.ExploreMap ? true : false);
victoryConditionText.caption = "Victory condition:";
victoryCondition.selected = victoryIdx;
@ -1058,6 +1079,7 @@ function onGameAttributesChange()
// Client
numPlayersText.hidden = false;
revealMapText.hidden = false;
exploreMapText.hidden = false;
victoryConditionText.hidden = false;
lockTeamsText.hidden = false;
populationCap.hidden = true;
@ -1066,6 +1088,7 @@ function onGameAttributesChange()
startingResourcesText.hidden = false;
revealMapText.caption = (mapSettings.RevealMap ? "Yes" : "No");
exploreMapText.caption = (mapSettings.ExploreMap ? "Yes" : "No");
victoryConditionText.caption = VICTORY_TEXT[victoryIdx];
lockTeamsText.caption = (mapSettings.LockTeams ? "Yes" : "No");
}
@ -1078,12 +1101,14 @@ function onGameAttributesChange()
numPlayersSelection.hidden = true;
mapSize.hidden = true;
revealMap.hidden = true;
exploreMap.hidden = true;
victoryCondition.hidden = true;
lockTeams.hidden = true;
numPlayersText.hidden = false;
mapSizeText.hidden = true;
mapSizeDesc.hidden = true;
revealMapText.hidden = false;
exploreMapText.hidden = false;
victoryConditionText.hidden = false;
lockTeamsText.hidden = false;
populationCap.hidden = true;
@ -1094,6 +1119,7 @@ function onGameAttributesChange()
numPlayersText.caption = numPlayers;
mapSizeText.caption = "Default";
revealMapText.caption = (mapSettings.RevealMap ? "Yes" : "No");
exploreMapText.caption = (mapSettings.ExploreMap ? "Yes" : "No");
victoryConditionText.caption = VICTORY_TEXT[victoryIdx];
lockTeamsText.caption = (mapSettings.LockTeams ? "Yes" : "No");
Engine.GetGUIObjectByName("populationCap").selected = POPULATION_CAP_DEFAULTIDX;

View File

@ -276,21 +276,29 @@
<object size="0 0 100% 100%" type="text" style="ModernRightLabelText">Reveal Map:</object>
</object>
<object size="0 30 40% 58">
<object size="0 0 100% 100%" type="text" style="ModernRightLabelText">Explore Map:</object>
</object>
<object size="0 60 40% 88">
<object size="0 0 100% 100%" type="text" style="ModernRightLabelText">Teams Locked:</object>
</object>
<object size="0 60 40% 88" name="enableCheatsDesc" hidden="true">
<object size="0 90 40% 118" name="enableCheatsDesc" hidden="true">
<object size="0 0 100% 100%" type="text" style="ModernRightLabelText">Cheats:</object>
</object>
<object size="40% 0 100% 28">
<object name="revealMapText" size="0 0 100% 100%" type="text" style="ModernLeftLabelText"/>
<object name="revealMap" size="10 50%-8 26 50%+8" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip" tooltip="Toggle reveal map."/>
<object name="revealMap" size="10 50%-8 26 50%+8" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip" tooltip="Toggle reveal map(see everything)."/>
</object>
<object size="40% 30 100% 58">
<object name="exploreMapText" size="0 0 100% 100%" type="text" style="ModernLeftLabelText"/>
<object name="exploreMap" size="10 50%-8 26 50%+8" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip" tooltip="Toggle explore map (see everything apart from enemy units)."/>
</object>
<object size="40% 60 100% 88">
<object name="lockTeamsText" size="0 0 100% 100%" type="text" style="ModernLeftLabelText"/>
<object name="lockTeams" size="10 50%-8 26 50%+8" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip" tooltip="Toggle locked teams."/>
</object>
<object size="40% 60 100% 88">
<object size="40% 90 100% 1188">
<object name="enableCheatsText" size="0 0 100% 100%" type="text" style="ModernLeftLabelText" hidden="true"/>
<object name="enableCheats" size="10 50%-8 26 50%+8" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip" tooltip="Toggle the usability of cheats."/>
</object>

View File

@ -36,6 +36,16 @@ function LoadMapSettings(settings)
cmpObstructionManager.SetPassabilityCircular(true);
}
if (settings.ExploreMap)
{
// this needs to happen after changing the map to a circular one
// as by making the map circular, the explored tiles get reset
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
if (cmpRangeManager)
for (var i = 0; i < settings.PlayerData.length; i++)
cmpRangeManager.ExploreAllTiles(i+1);
}
var cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager);
if (settings.GameType)
cmpEndGameManager.SetGameType(settings.GameType);

View File

@ -1430,6 +1430,21 @@ public:
return m_SharedLosMasks[player];
}
void ExploreAllTiles(player_id_t p)
{
for (u16 j = 0; j < m_TerrainVerticesPerSide; ++j)
{
for (u16 i = 0; i < m_TerrainVerticesPerSide; ++i)
{
if (LosIsOffWorld(i,j))
continue;
u32 &explored = m_ExploredVertices.at(p);
explored += !(m_LosState[i + j*m_TerrainVerticesPerSide] & (LOS_EXPLORED << (2*(p-1))));
m_LosState[i + j*m_TerrainVerticesPerSide] |= (LOS_EXPLORED << (2*(p-1)));
}
}
}
void UpdateTerritoriesLos()
{
CmpPtr<ICmpTerritoryManager> cmpTerritoryManager(GetSystemEntity());

View File

@ -46,6 +46,7 @@ DEFINE_INTERFACE_METHOD_3("SetEntityFlag", void, ICmpRangeManager, SetEntityFlag
DEFINE_INTERFACE_METHOD_1("GetEntityFlagMask", u8, ICmpRangeManager, GetEntityFlagMask, std::string)
DEFINE_INTERFACE_METHOD_1("GetEntitiesByPlayer", std::vector<entity_id_t>, ICmpRangeManager, GetEntitiesByPlayer, player_id_t)
DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpRangeManager, SetDebugOverlay, bool)
DEFINE_INTERFACE_METHOD_1("ExploreAllTiles", void, ICmpRangeManager, ExploreAllTiles, player_id_t)
DEFINE_INTERFACE_METHOD_2("SetLosRevealAll", void, ICmpRangeManager, SetLosRevealAll, player_id_t, bool)
DEFINE_INTERFACE_METHOD_1("GetLosRevealAll", bool, ICmpRangeManager, GetLosRevealAll, player_id_t)
DEFINE_INTERFACE_METHOD_5("GetElevationAdaptedRange", entity_pos_t, ICmpRangeManager, GetElevationAdaptedRange, CFixedVector3D, CFixedVector3D, entity_pos_t, entity_pos_t, entity_pos_t)

View File

@ -332,6 +332,11 @@ public:
*/
std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player, bool forceRetainInFog);
/**
* Explore all tiles (but leave them in the FoW) for player p
*/
virtual void ExploreAllTiles(player_id_t p) = 0;
/**
* Set whether the whole map should be made visible to the given player.
* If player is -1, the map will be made visible to all players.