Ticket #1762: rallyPointRenderer-2.diff
File rallyPointRenderer-2.diff, 7.2 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/helpers/InitSavedGame.js
1 function InitSavedGame()2 {3 // This will be called after the map settings have been loaded,4 // before the simulation has started.5 // This is only called at the start of a saved game, not when loading6 // a new game.7 8 // rebuild the RallyPointRenderers from the RallyPoints info9 var rallyPoints = Engine.GetEntitiesWithInterface(IID_RallyPoint);10 for each (var ent in rallyPoints)11 {12 var cmpRallyPointRenderer = Engine.QueryInterface(ent, IID_RallyPointRenderer);13 if (!cmpRallyPointRenderer)14 continue;15 var positions = Engine.QueryInterface(ent, IID_RallyPoint).GetPositions();16 for each (var pos in positions)17 cmpRallyPointRenderer.AddPosition({'x': pos.x, 'y': pos.z});18 }19 }20 21 Engine.RegisterGlobal("InitSavedGame", InitSavedGame); -
binaries/data/mods/public/simulation/components/GuiInterface.js
848 848 cmpRallyPointRenderer.AddPosition({'x': pos.x, 'y': pos.z}); // AddPosition takes a CFixedVector2D which has X/Y components, not X/Z 849 849 else if (cmd.queued == false) 850 850 cmpRallyPointRenderer.SetPosition({'x': pos.x, 'y': pos.z}); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z 851 // rebuild the renderer when not set (when reading saved game or in case of building update) 852 else if (!cmpRallyPointRenderer.IsSet()) 853 for each (var posi in cmpRallyPoint.GetPositions()) 854 cmpRallyPointRenderer.AddPosition({'x': posi.x, 'y': posi.z}); 855 851 856 cmpRallyPointRenderer.SetDisplayed(true); 852 857 853 858 // remember which entities have their rally points displayed so we can hide them again -
binaries/data/mods/public/simulation/components/Foundation.js
277 277 { 278 278 var rallyCoords = cmpRallyPoint.GetPositions(); 279 279 var rallyData = cmpRallyPoint.GetData(); 280 var cmpBuildingRallyPointRenderer = Engine.QueryInterface(building, IID_RallyPointRenderer);281 280 for (var i = 0; i < rallyCoords.length; ++i) 282 281 { 283 282 cmpBuildingRallyPoint.AddPosition(rallyCoords[i].x, rallyCoords[i].z); 284 283 cmpBuildingRallyPoint.AddData(rallyData[i]); 285 if (cmpBuildingRallyPointRenderer)286 cmpBuildingRallyPointRenderer.AddPosition({'x': rallyCoords[i].x, 'y': rallyCoords[i].z});287 284 } 288 285 } 289 286 -
source/ps/Game.cpp
195 195 **/ 196 196 PSRETURN CGame::ReallyStartGame() 197 197 { 198 // Call the script function InitGame only for new games, and InitSavedGame forsaved games198 // Call the script function InitGame only for new games, not saved games 199 199 if (!m_IsSavedGame) 200 200 { 201 201 CScriptVal settings; 202 202 m_Simulation2->GetScriptInterface().GetProperty(m_Simulation2->GetInitAttributes().get(), "settings", settings); 203 203 m_Simulation2->InitGame(settings); 204 204 } 205 else206 {207 m_Simulation2->InitSavedGame();208 }209 205 210 206 // We need to do an initial Interpolate call to set up all the models etc, 211 207 // because Update might never interpolate (e.g. if the game starts paused) -
source/simulation2/Simulation2.h
150 150 * Initialise a new game, based on some script data. (Called on CGame instantiation) 151 151 * (This mustn't be used when e.g. loading saved games, only when starting new ones.) 152 152 * This calls the InitGame function defined in helpers/InitGame.js. 153 * Saved games are initialized with InitSavedGame.154 153 */ 155 154 void InitGame(const CScriptVal& data); 156 void InitSavedGame();157 155 158 156 void Update(int turnLength); 159 157 void Update(int turnLength, const std::vector<SimulationCommand>& commands); -
source/simulation2/components/CCmpRallyPointRenderer.cpp
299 299 RecomputeAllRallyPointPaths(); 300 300 } 301 301 302 /** 303 * Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at. 304 */ 305 bool IsSet() 306 { 307 return !m_RallyPoints.empty(); 308 } 309 302 310 private: 303 311 304 312 /** … … 316 324 } 317 325 318 326 /** 319 * Returns true iff at least one display rally point is set; i.e., if we have a point to render our marker/line at.320 */321 bool IsSet()322 {323 return !m_RallyPoints.empty();324 }325 326 /**327 327 * Repositions the rally point markers; moves them outside of the world (ie. hides them), or positions them at the currently 328 328 * set rally points. Also updates the actor's variation according to the entity's current owning player's civilization. 329 329 * -
source/simulation2/components/ICmpRallyPointRenderer.h
44 44 /// Reset the positions of this rally point marker 45 45 virtual void Reset() = 0; 46 46 47 /// Returns true if at least one display rally point is set 48 virtual bool IsSet() = 0; 49 47 50 DECLARE_INTERFACE_TYPE(RallyPointRenderer) 48 51 }; 49 52 -
source/simulation2/components/ICmpRallyPointRenderer.cpp
27 27 DEFINE_INTERFACE_METHOD_1("SetPosition", void, ICmpRallyPointRenderer, SetPosition, CFixedVector2D) 28 28 DEFINE_INTERFACE_METHOD_1("AddPosition", void, ICmpRallyPointRenderer, AddPosition_wrapper, CFixedVector2D) 29 29 DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpRallyPointRenderer, Reset) 30 DEFINE_INTERFACE_METHOD_0("IsSet", bool, ICmpRallyPointRenderer, IsSet) 30 31 END_INTERFACE_WRAPPER(RallyPointRenderer) -
source/simulation2/Simulation2.cpp
652 652 GetScriptInterface().CallFunctionVoid(GetScriptInterface().GetGlobalObject(), "InitGame", data); 653 653 } 654 654 655 void CSimulation2::InitSavedGame()656 {657 GetScriptInterface().CallFunctionVoid(GetScriptInterface().GetGlobalObject(), "InitSavedGame");658 }659 660 655 void CSimulation2::Update(int turnLength) 661 656 { 662 657 std::vector<SimulationCommand> commands;