Ticket #1762: rallyPointRenderer.diff
File rallyPointRenderer.diff, 6.5 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/helpers/Commands.js
296 296 { 297 297 var cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint); 298 298 if (cmpRallyPoint) 299 cmpRallyPoint. Unset();299 cmpRallyPoint.Reset(); 300 300 } 301 301 break; 302 302 -
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 loading 6 // a new game. 7 8 // rebuild the RallyPointRenderers from the RallyPoints info 9 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
20 20 this.placementEntity = undefined; // = undefined or [templateName, entityID] 21 21 this.placementWallEntities = undefined; 22 22 this.placementWallLastAngle = 0; 23 this.rallyPoints = undefined;24 23 this.notifications = []; 25 24 this.renamedEntities = []; 26 25 }; -
binaries/data/mods/public/simulation/components/RallyPoint.js
43 43 this.data = []; 44 44 }; 45 45 46 RallyPoint.prototype.Reset = function() 47 { 48 this.Unset(); 49 var cmpRallyPointRenderer = Engine.QueryInterface(this.entity, IID_RallyPointRenderer); 50 if (cmpRallyPointRenderer) 51 cmpRallyPointRenderer.Reset(); 52 }; 53 46 54 Engine.RegisterComponentType(IID_RallyPoint, "RallyPoint", RallyPoint); -
source/simulation2/components/ICmpRallyPointRenderer.cpp
26 26 DEFINE_INTERFACE_METHOD_1("SetDisplayed", void, ICmpRallyPointRenderer, SetDisplayed, bool) 27 27 DEFINE_INTERFACE_METHOD_1("SetPosition", void, ICmpRallyPointRenderer, SetPosition, CFixedVector2D) 28 28 DEFINE_INTERFACE_METHOD_1("AddPosition", void, ICmpRallyPointRenderer, AddPosition_wrapper, CFixedVector2D) 29 DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpRallyPointRenderer, Reset) 29 30 END_INTERFACE_WRAPPER(RallyPointRenderer) -
source/simulation2/components/CCmpRallyPointRenderer.cpp
293 293 } 294 294 } 295 295 296 virtual void Reset() 297 { 298 m_RallyPoints.clear(); 299 RecomputeAllRallyPointPaths(); 300 } 301 296 302 private: 297 303 298 304 /** -
source/simulation2/components/ICmpRallyPointRenderer.h
41 41 /// to the previous one. 42 42 virtual void AddPosition_wrapper(CFixedVector2D position) = 0; 43 43 44 /// Reset the positions of this rally point marker 45 virtual void Reset() = 0; 46 44 47 DECLARE_INTERFACE_TYPE(RallyPointRenderer) 45 48 }; 46 49 -
source/simulation2/Simulation2.cpp
649 649 GetScriptInterface().CallFunctionVoid(GetScriptInterface().GetGlobalObject(), "InitGame", data); 650 650 } 651 651 652 void CSimulation2::InitSavedGame() 653 { 654 GetScriptInterface().CallFunctionVoid(GetScriptInterface().GetGlobalObject(), "InitSavedGame"); 655 } 656 652 657 void CSimulation2::Update(int turnLength) 653 658 { 654 659 std::vector<SimulationCommand> commands; -
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. 153 154 */ 154 155 void InitGame(const CScriptVal& data); 156 void InitSavedGame(); 155 157 156 158 void Update(int turnLength); 157 159 void Update(int turnLength, const std::vector<SimulationCommand>& commands); -
source/ps/Game.cpp
195 195 **/ 196 196 PSRETURN CGame::ReallyStartGame() 197 197 { 198 // Call the script function InitGame only for new games, notsaved games198 // Call the script function InitGame only for new games, and InitSavedGame for 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 else 206 { 207 m_Simulation2->InitSavedGame(); 208 } 205 209 206 210 // We need to do an initial Interpolate call to set up all the models etc, 207 211 // because Update might never interpolate (e.g. if the game starts paused)