Ticket #3915: visualrange_v0.1.patch
File visualrange_v0.1.patch, 4.5 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GuiInterface.js
845 845 GuiInterface.prototype.SetSelectionHighlight = function(player, cmd) 846 846 { 847 847 let playerColors = {}; // cache of owner -> color map 848 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 848 849 849 850 for each (let ent in cmd.entities) 850 851 { … … 868 869 playerColors[owner] = color; 869 870 } 870 871 872 let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 873 874 if (cmpIdentity.HasClass("Defensive") && owner == player) 875 cmpRangeManager.ShowRangeOverlay(ent, cmd.selected); 876 871 877 cmpSelectable.SetSelectionHighlight({ "r": color.r, "g": color.g, "b": color.b, "a": cmd.alpha }, cmd.selected); 872 878 } 873 879 }; -
source/simulation2/components/CCmpRangeManager.cpp
304 304 bool m_DebugOverlayDirty; 305 305 std::vector<SOverlayLine> m_DebugOverlayLines; 306 306 307 bool m_ShowRangeOverlayEnabled; 308 std::vector<SOverlayLine> m_RangeOverlayLines; 309 307 310 // Deserialization flag. A lot of different functions are called by Deserialize() 308 311 // and we don't want to pass isDeserializing bool arguments to all of them... 309 312 bool m_Deserializing; … … 1285 1288 1286 1289 void RenderSubmit(SceneCollector& collector) 1287 1290 { 1291 if (m_ShowRangeOverlayEnabled) 1292 for (size_t i = 0; i < m_RangeOverlayLines.size(); ++i) 1293 collector.Submit(&m_RangeOverlayLines[i]); 1294 1288 1295 if (!m_DebugOverlayEnabled) 1289 1296 return; 1290 1297 static CColor disabledRingColor(1, 0, 0, 1); // red … … 1421 1428 collector.Submit(&m_DebugOverlayLines[i]); 1422 1429 } 1423 1430 1431 virtual void ShowRangeOverlay(entity_id_t ent, bool enabled) 1432 { 1433 m_ShowRangeOverlayEnabled = enabled; 1434 static CColor rangeRingColor(1, 1, 1, 1); // TODO: should be player color 1435 1436 m_RangeOverlayLines.clear(); 1437 if (enabled) 1438 { 1439 for (std::map<tag_t, Query>::iterator it = m_Queries.begin(); it != m_Queries.end(); ++it) 1440 { 1441 Query& q = it->second; 1442 1443 CmpPtr<ICmpPosition> cmpSourcePosition(q.source); 1444 if (!cmpSourcePosition || !cmpSourcePosition->IsInWorld() || q.source.GetId() != ent) 1445 continue; 1446 1447 CFixedVector2D pos = cmpSourcePosition->GetPosition2D(); 1448 1449 m_RangeOverlayLines.push_back(SOverlayLine()); 1450 m_RangeOverlayLines.back().m_Color = rangeRingColor; 1451 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.maxRange.ToFloat(), m_RangeOverlayLines.back(), true); 1452 } 1453 } 1454 } 1455 1424 1456 virtual u8 GetEntityFlagMask(const std::string& identifier) 1425 1457 { 1426 1458 if (identifier == "normal") -
source/simulation2/components/ICmpRangeManager.cpp
48 48 DEFINE_INTERFACE_METHOD_1("GetEntitiesByPlayer", std::vector<entity_id_t>, ICmpRangeManager, GetEntitiesByPlayer, player_id_t) 49 49 DEFINE_INTERFACE_METHOD_0("GetNonGaiaEntities", std::vector<entity_id_t>, ICmpRangeManager, GetNonGaiaEntities) 50 50 DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpRangeManager, SetDebugOverlay, bool) 51 DEFINE_INTERFACE_METHOD_2("ShowRangeOverlay", void, ICmpRangeManager, ShowRangeOverlay, entity_id_t, bool) 51 52 DEFINE_INTERFACE_METHOD_1("ExploreAllTiles", void, ICmpRangeManager, ExploreAllTiles, player_id_t) 52 53 DEFINE_INTERFACE_METHOD_0("ExploreTerritories", void, ICmpRangeManager, ExploreTerritories) 53 54 DEFINE_INTERFACE_METHOD_2("SetLosRevealAll", void, ICmpRangeManager, SetLosRevealAll, player_id_t, bool) -
source/simulation2/components/ICmpRangeManager.h
204 204 virtual void SetDebugOverlay(bool enabled) = 0; 205 205 206 206 /** 207 * Display the range of a building/unit. 208 */ 209 virtual void ShowRangeOverlay(entity_id_t ent, bool enabled) = 0; 210 211 /** 207 212 * Returns the mask for the specified identifier. 208 213 */ 209 214 virtual u8 GetEntityFlagMask(const std::string& identifier) = 0;