Procházet zdrojové kódy

Sample code cleanup.

Lasse Öörni před 12 roky
rodič
revize
796d8871b9
30 změnil soubory, kde provedl 178 přidání a 177 odebrání
  1. 1 1
      Source/Samples/01_HelloWorld/HelloWorld.cpp
  2. 2 3
      Source/Samples/01_HelloWorld/HelloWorld.h
  3. 5 9
      Source/Samples/02_HelloGUI/HelloGUI.h
  4. 1 1
      Source/Samples/03_Sprites/Sprites.cpp
  5. 4 4
      Source/Samples/03_Sprites/Sprites.h
  6. 1 1
      Source/Samples/04_StaticScene/StaticScene.cpp
  7. 6 6
      Source/Samples/04_StaticScene/StaticScene.h
  8. 6 6
      Source/Samples/05_AnimatingScene/AnimatingScene.cpp
  9. 7 7
      Source/Samples/05_AnimatingScene/AnimatingScene.h
  10. 11 11
      Source/Samples/06_SkeletalAnimation/SkeletalAnimation.cpp
  11. 8 8
      Source/Samples/06_SkeletalAnimation/SkeletalAnimation.h
  12. 10 10
      Source/Samples/07_Billboards/Billboards.cpp
  13. 9 9
      Source/Samples/07_Billboards/Billboards.h
  14. 2 2
      Source/Samples/08_Decals/Decals.cpp
  15. 7 7
      Source/Samples/08_Decals/Decals.h
  16. 10 10
      Source/Samples/09_MultipleViewports/MultipleViewports.cpp
  17. 8 8
      Source/Samples/09_MultipleViewports/MultipleViewports.h
  18. 1 1
      Source/Samples/10_RenderToTexture/RenderToTexture.cpp
  19. 6 6
      Source/Samples/10_RenderToTexture/RenderToTexture.h
  20. 10 10
      Source/Samples/11_Physics/Physics.cpp
  21. 9 9
      Source/Samples/11_Physics/Physics.h
  22. 10 10
      Source/Samples/12_PhysicsStressTest/PhysicsStressTest.cpp
  23. 9 9
      Source/Samples/12_PhysicsStressTest/PhysicsStressTest.h
  24. 2 2
      Source/Samples/13_Ragdolls/Ragdolls.cpp
  25. 9 9
      Source/Samples/13_Ragdolls/Ragdolls.h
  26. 3 3
      Source/Samples/14_SoundEffects/SoundEffects.h
  27. 2 2
      Source/Samples/15_Navigation/Navigation.cpp
  28. 8 8
      Source/Samples/15_Navigation/Navigation.h
  29. 9 3
      Source/Samples/16_Chat/Chat.cpp
  30. 2 2
      Source/Samples/16_Chat/Chat.h

+ 1 - 1
Source/Samples/01_HelloWorld/HelloWorld.cpp

@@ -76,7 +76,7 @@ void HelloWorld::CreateText()
 
 void HelloWorld::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(HelloWorld, HandleUpdate));
 }
 

+ 2 - 3
Source/Samples/01_HelloWorld/HelloWorld.h

@@ -44,11 +44,10 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs a new Text instance, containing the 'Hello World' String, and
-    /// adds it to the UI root element.
+    /// Construct a new Text instance, containing the 'Hello World' String, and add it to the UI root element.
     void CreateText();
     /// Subscribe to application-wide logic update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 };

+ 5 - 9
Source/Samples/02_HelloGUI/HelloGUI.h

@@ -44,19 +44,15 @@ public:
     virtual void Start();
 
 private:
-    /// Creates and initializes a Window control.
+    /// Create and initialize a Window control.
     void InitWindow();
-
-    /// Creates and add various common controls for demonstration purposes.
+    /// Create and add various common controls for demonstration purposes.
     void InitControls();
-
-    /// Convenience method for event subscription.
+    /// Subscribe to UI events.
     void SubscribeToEvents();
-
-    /// Callback method invoked whenever any control is clicked.
+    /// Handle any UI control being clicked.
     void HandleControlClicked(StringHash eventType, VariantMap& eventData);
-
-    /// Callback method invoked when the close button is pressed and released.
+    /// Handle close button pressed and released.
     void HandleClosePressed(StringHash eventType, VariantMap& eventData);
 
     /// The Window.

+ 1 - 1
Source/Samples/03_Sprites/Sprites.cpp

@@ -133,7 +133,7 @@ void Sprites::MoveSprites(float timeStep)
 
 void Sprites::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Sprites, HandleUpdate));
 }
 

+ 4 - 4
Source/Samples/03_Sprites/Sprites.h

@@ -46,13 +46,13 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the sprites.
+    /// Construct the sprites.
     void CreateSprites();
-    /// Moves the sprites using the delta time step given.
+    /// Move the sprites using the delta time step given.
     void MoveSprites(float timeStep);
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
     /// Vector to store the sprites for iterating through them.

+ 1 - 1
Source/Samples/04_StaticScene/StaticScene.cpp

@@ -187,7 +187,7 @@ void StaticScene::MoveCamera(float timeStep)
 
 void StaticScene::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(StaticScene, HandleUpdate));
 }
 

+ 6 - 6
Source/Samples/04_StaticScene/StaticScene.h

@@ -45,17 +45,17 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
     /// Scene.

+ 6 - 6
Source/Samples/05_AnimatingScene/AnimatingScene.cpp

@@ -148,6 +148,12 @@ void AnimatingScene::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
+void AnimatingScene::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(AnimatingScene, HandleUpdate));
+}
+
 void AnimatingScene::MoveCamera(float timeStep)
 {
     // Do not move if the UI has a focused element (the console)
@@ -181,12 +187,6 @@ void AnimatingScene::MoveCamera(float timeStep)
         cameraNode_->TranslateRelative(Vector3::RIGHT * MOVE_SPEED * timeStep);
 }
 
-void AnimatingScene::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(AnimatingScene, HandleUpdate));
-}
-
 void AnimatingScene::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 7 - 7
Source/Samples/05_AnimatingScene/AnimatingScene.h

@@ -45,17 +45,17 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
-    void MoveCamera(float timeStep);
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Read input and moves the camera.
+    void MoveCamera(float timeStep);
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
     /// Scene.

+ 11 - 11
Source/Samples/06_SkeletalAnimation/SkeletalAnimation.cpp

@@ -182,6 +182,17 @@ void SkeletalAnimation::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
+void SkeletalAnimation::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(SkeletalAnimation, HandleUpdate));
+    
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, sent after Renderer subsystem is
+    // done with defining the draw calls for the viewports (but before actually executing them.) We will request debug geometry
+    // rendering during that event
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(SkeletalAnimation, HandlePostRenderUpdate));
+}
+
 void SkeletalAnimation::MoveCamera(float timeStep)
 {
     // Do not move if the UI has a focused element (the console)
@@ -219,17 +230,6 @@ void SkeletalAnimation::MoveCamera(float timeStep)
         drawDebug_ = !drawDebug_;
 }
 
-void SkeletalAnimation::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(SkeletalAnimation, HandleUpdate));
-    
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, sent after Renderer subsystem is
-    // done with defining the draw calls for the viewports (but before actually executing them.) We will request debug geometry
-    // rendering during that event
-    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(SkeletalAnimation, HandlePostRenderUpdate));
-}
-
 void SkeletalAnimation::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 8 - 8
Source/Samples/06_SkeletalAnimation/SkeletalAnimation.h

@@ -47,19 +47,19 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
-    void MoveCamera(float timeStep);
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update and post-render update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Read input and moves the camera.
+    void MoveCamera(float timeStep);
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 10 - 10
Source/Samples/07_Billboards/Billboards.cpp

@@ -238,6 +238,16 @@ void Billboards::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
+void Billboards::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(Billboards, HandleUpdate));
+    
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
+    // debug geometry
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Billboards, HandlePostRenderUpdate));
+}
+
 void Billboards::MoveCamera(float timeStep)
 {
     // Do not move if the UI has a focused element (the console)
@@ -305,16 +315,6 @@ void Billboards::AnimateScene(float timeStep)
     }
 }
 
-void Billboards::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(Billboards, HandleUpdate));
-    
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
-    // debug geometry
-    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Billboards, HandlePostRenderUpdate));
-}
-
 void Billboards::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 9 - 9
Source/Samples/07_Billboards/Billboards.h

@@ -45,21 +45,21 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
+    /// Subscribe to application-wide logic update and post-render update events.
+    void SubscribeToEvents();
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Animates the scene.
+    /// Animate the scene.
     void AnimateScene(float timeStep);
-    /// Subscribes to application-wide logic update events.
-    void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 2 - 2
Source/Samples/08_Decals/Decals.cpp

@@ -196,10 +196,10 @@ void Decals::SetupViewport()
 
 void Decals::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Decals, HandleUpdate));
     
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Decals, HandlePostRenderUpdate));
 }

+ 7 - 7
Source/Samples/08_Decals/Decals.h

@@ -51,23 +51,23 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs user interface elements.
+    /// Construct user interface elements.
     void CreateUI();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update and post-render update events.
     void SubscribeToEvents();
     /// Reads input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Paints a decal using a ray cast from the mouse cursor.
+    /// Paint a decal using a ray cast from the mouse cursor.
     void PaintDecal();
     /// Utility function to raycast to the cursor position. Return true if hit
     bool Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawable);
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 10 - 10
Source/Samples/09_MultipleViewports/MultipleViewports.cpp

@@ -217,6 +217,16 @@ void MultipleViewports::SetupViewports()
     renderer->SetViewport(1, rearViewport);
 }
 
+void MultipleViewports::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() method for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(MultipleViewports, HandleUpdate));
+    
+    // Subscribe HandlePostRenderUpdate() method for processing the post-render update event, during which we request
+    // debug geometry
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(MultipleViewports, HandlePostRenderUpdate));
+}
+
 void MultipleViewports::MoveCamera(float timeStep)
 {
      // Do not move if the UI has a focused element (the console)
@@ -261,16 +271,6 @@ void MultipleViewports::MoveCamera(float timeStep)
         drawDebug_ = !drawDebug_;
 }
 
-void MultipleViewports::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(MultipleViewports, HandleUpdate));
-    
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
-    // debug geometry
-    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(MultipleViewports, HandlePostRenderUpdate));
-}
-
 void MultipleViewports::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 8 - 8
Source/Samples/09_MultipleViewports/MultipleViewports.h

@@ -44,19 +44,19 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up viewports.
+    /// Set up viewports.
     void SetupViewports();
-    /// Reads input and moves the camera.
-    void MoveCamera(float timeStep);
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update and post-render update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Read input and moves the camera.
+    void MoveCamera(float timeStep);
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 1 - 1
Source/Samples/10_RenderToTexture/RenderToTexture.cpp

@@ -269,7 +269,7 @@ void RenderToTexture::MoveCamera(float timeStep)
 
 void RenderToTexture::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(RenderToTexture, HandleUpdate));
 }
 

+ 6 - 6
Source/Samples/10_RenderToTexture/RenderToTexture.h

@@ -44,17 +44,17 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
-    void MoveCamera(float timeStep);
     /// Subscribe to application-wide logic update events.
     void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Read input and moves the camera.
+    void MoveCamera(float timeStep);
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
     /// Scene in which the user moves.

+ 10 - 10
Source/Samples/11_Physics/Physics.cpp

@@ -195,6 +195,16 @@ void Physics::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
+void Physics::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(Physics, HandleUpdate));
+    
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
+    // debug geometry
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Physics, HandlePostRenderUpdate));
+}
+
 void Physics::MoveCamera(float timeStep)
 {
     // Do not move if the UI has a focused element (the console)
@@ -264,16 +274,6 @@ void Physics::SpawnObject()
     body->SetLinearVelocity(cameraNode_->GetRotation() * Vector3(0.0f, 0.25f, 1.0f) * OBJECT_VELOCITY);
 }
 
-void Physics::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(Physics, HandleUpdate));
-    
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
-    // debug geometry
-    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Physics, HandlePostRenderUpdate));
-}
-
 void Physics::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 9 - 9
Source/Samples/11_Physics/Physics.h

@@ -45,21 +45,21 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
+    /// Subscribe to application-wide logic update and post-render update events.
+    void SubscribeToEvents();
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Spawns a physics object from the camera position.
+    /// Spawn a physics object from the camera position.
     void SpawnObject();
-    /// Subscribes to application-wide logic update events.
-    void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 10 - 10
Source/Samples/12_PhysicsStressTest/PhysicsStressTest.cpp

@@ -210,6 +210,16 @@ void PhysicsStressTest::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
+void PhysicsStressTest::SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for processing update events
+    SubscribeToEvent(E_UPDATE, HANDLER(PhysicsStressTest, HandleUpdate));
+    
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
+    // debug geometry
+    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(PhysicsStressTest, HandlePostRenderUpdate));
+}
+
 void PhysicsStressTest::MoveCamera(float timeStep)
 {
     // Do not move if the UI has a focused element (the console)
@@ -279,16 +289,6 @@ void PhysicsStressTest::SpawnObject()
     body->SetLinearVelocity(cameraNode_->GetRotation() * Vector3(0.0f, 0.25f, 1.0f) * OBJECT_VELOCITY);
 }
 
-void PhysicsStressTest::SubscribeToEvents()
-{
-    // Subscribes HandleUpdate() method for processing update events
-    SubscribeToEvent(E_UPDATE, HANDLER(PhysicsStressTest, HandleUpdate));
-    
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
-    // debug geometry
-    SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(PhysicsStressTest, HandlePostRenderUpdate));
-}
-
 void PhysicsStressTest::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Event parameters are always defined inside a namespace corresponding to the event's name

+ 9 - 9
Source/Samples/12_PhysicsStressTest/PhysicsStressTest.h

@@ -45,21 +45,21 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
+    /// Subscribe to application-wide logic update and post-render update events.
+    void SubscribeToEvents();
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Spawns a physics object from the camera position.
+    /// Spawn a physics object from the camera position.
     void SpawnObject();
-    /// Subscribes to application-wide logic update events.
-    void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 2 - 2
Source/Samples/13_Ragdolls/Ragdolls.cpp

@@ -272,10 +272,10 @@ void Ragdolls::SpawnObject()
 
 void Ragdolls::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Ragdolls, HandleUpdate));
     
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Ragdolls, HandlePostRenderUpdate));
 }

+ 9 - 9
Source/Samples/13_Ragdolls/Ragdolls.h

@@ -45,21 +45,21 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs an instruction text to the UI.
+    /// Construct an instruction text to the UI.
     void CreateInstructions();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Reads input and moves the camera.
+    /// Subscribe to application-wide logic update and post-render update events.
+    void SubscribeToEvents();
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Spawns a physics object from the camera position.
+    /// Spawn a physics object from the camera position.
     void SpawnObject();
-    /// Subscribes to application-wide logic update events.
-    void SubscribeToEvents();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 3 - 3
Source/Samples/14_SoundEffects/SoundEffects.h

@@ -45,11 +45,11 @@ public:
     virtual void Start();
 
 private:
-    /// Creates the UI and subscribes to UI events.
+    /// Create the UI and subscribes to UI events.
     void CreateUI();
-    /// Creates a button at position with specified text in it.
+    /// Create a button at position with specified text in it.
     Button* CreateButton(int x, int y, int xSize, int ySize, const String& text);
-    /// Creates a horizontal slider with specified text above it.
+    /// Create a horizontal slider with specified text above it.
     Slider* CreateSlider(int x, int y, int xSize, int ySize, const String& text);
     /// Handle a sound effect button click.
     void HandlePlaySound(StringHash eventType, VariantMap& eventData);

+ 2 - 2
Source/Samples/15_Navigation/Navigation.cpp

@@ -200,10 +200,10 @@ void Navigation::SetupViewport()
 
 void Navigation::SubscribeToEvents()
 {
-    // Subscribes HandleUpdate() method for processing update events
+    // Subscribe HandleUpdate() function for processing update events
     SubscribeToEvent(E_UPDATE, HANDLER(Navigation, HandleUpdate));
     
-    // Subscribes HandlePostRenderUpdate() method for processing the post-render update event, during which we request
+    // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
     // debug geometry
     SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(Navigation, HandlePostRenderUpdate));
 }

+ 8 - 8
Source/Samples/15_Navigation/Navigation.h

@@ -51,17 +51,17 @@ public:
     virtual void Start();
 
 private:
-    /// Constructs the scene content.
+    /// Construct the scene content.
     void CreateScene();
-    /// Constructs user interface elements.
+    /// Construct user interface elements.
     void CreateUI();
-    /// Sets up a viewport for displaying the scene.
+    /// Set up a viewport for displaying the scene.
     void SetupViewport();
-    /// Subscribes to application-wide logic update events.
+    /// Subscribe to application-wide logic update and post-render update events.
     void SubscribeToEvents();
-    /// Reads input and moves the camera.
+    /// Read input and moves the camera.
     void MoveCamera(float timeStep);
-    /// Sets path start or end point.
+    /// Set path start or end point.
     void SetPathPoint();
     /// Add or remove object.
     void AddOrRemoveObject();
@@ -71,9 +71,9 @@ private:
     bool Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawable);
     /// Recalculate path. Requires both start and endpoint defined.
     void RecalculatePath();
-    /// Callback method invoked when a logic update event is dispatched.
+    /// Handle the logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
-    /// Callback method invoked when the post-render update event is dispatched.
+    /// Handle the post-render update event.
     void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
     
     /// Scene.

+ 9 - 3
Source/Samples/16_Chat/Chat.cpp

@@ -164,6 +164,7 @@ void Chat::UpdateButtons()
     Connection* serverConnection = network->GetServerConnection();
     bool serverRunning = network->IsServerRunning();
     
+    // Show and hide buttons so that eg. Connect and Disconnect are never shown at the same time
     sendButton_->SetVisible(serverConnection != 0);
     connectButton_->SetVisible(!serverConnection && !serverRunning);
     disconnectButton_->SetVisible(serverConnection || serverRunning);
@@ -193,8 +194,7 @@ void Chat::HandleSend(StringHash eventType, VariantMap& eventData)
         msg.WriteString(text);
         // Send the chat message as in-order and reliable
         serverConnection->SendMessage(MSG_CHAT, true, true, msg);
-        
-        // Empty the editor after sending
+        // Empty the text edit after sending
         textEdit_->SetText(String::EMPTY);
     }
 }
@@ -205,8 +205,12 @@ void Chat::HandleConnect(StringHash eventType, VariantMap& eventData)
     String address = textEdit_->GetText().Trimmed();
     if (address.Empty())
         address = "localhost"; // Use localhost to connect if nothing else specified
+    // Empty the text edit after reading the address to connect to
+    textEdit_->SetText(String::EMPTY);
     
-    // Connect to server, do not specify a client scene as we are not using scene replication, just messages
+    // Connect to server, do not specify a client scene as we are not using scene replication, just messages.
+    // At connect time we could also send identity parameters (such as username) in a VariantMap, but in this
+    // case we skip it for simplicity
     network->Connect(address, CHAT_SERVER_PORT, 0);
     
     UpdateButtons();
@@ -216,8 +220,10 @@ void Chat::HandleDisconnect(StringHash eventType, VariantMap& eventData)
 {
     Network* network = GetSubsystem<Network>();
     Connection* serverConnection = network->GetServerConnection();
+    // If we were connected to server, disconnect
     if (serverConnection)
         serverConnection->Disconnect();
+    // Or if we were running a server, stop it
     else if (network->IsServerRunning())
         network->StopServer();
     

+ 2 - 2
Source/Samples/16_Chat/Chat.h

@@ -52,7 +52,7 @@ public:
 private:
     /// Create the UI.
     void CreateUI();
-    /// Subscribe to UI and network events.
+    /// Subscribe to log message, UI and network events.
     void SubscribeToEvents();
     /// Create a button.
     Button* CreateButton(const String& text, int width);
@@ -70,7 +70,7 @@ private:
     void HandleDisconnect(StringHash eventType, VariantMap& eventData);
     /// Handle pressing the start server button.
     void HandleStartServer(StringHash eventType, VariantMap& eventData);
-    /// Handle a network message.
+    /// Handle an incoming network message.
     void HandleNetworkMessage(StringHash eventType, VariantMap& eventData);
     /// Handle connection status change (just update the buttons that should be shown.)
     void HandleConnectionStatus(StringHash eventType, VariantMap& eventData);