Преглед на файлове

Use the else-if construct as the conditions are mutually exclusive.

Wei Tjong Yao преди 12 години
родител
ревизия
274c06d3a4
променени са 1 файла, в които са добавени 10 реда и са изтрити 11 реда
  1. 10 11
      Source/Samples/Sample.inl

+ 10 - 11
Source/Samples/Sample.inl

@@ -134,16 +134,15 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
     }
     }
 
 
     // Toggle console with F1
     // Toggle console with F1
-    if (key == KEY_F1)
+    else if (key == KEY_F1)
         GetSubsystem<Console>()->Toggle();
         GetSubsystem<Console>()->Toggle();
     
     
     // Toggle debug HUD with F2
     // Toggle debug HUD with F2
-    if (key == KEY_F2)
+    else if (key == KEY_F2)
         GetSubsystem<DebugHud>()->ToggleAll();
         GetSubsystem<DebugHud>()->ToggleAll();
     
     
     // Common rendering quality controls, only when UI has no focused element
     // Common rendering quality controls, only when UI has no focused element
-    UIElement* focusElement = GetSubsystem<UI>()->GetFocusElement();
-    if (!focusElement)
+    else if (!GetSubsystem<UI>()->GetFocusElement())
     {
     {
         Renderer* renderer = GetSubsystem<Renderer>();
         Renderer* renderer = GetSubsystem<Renderer>();
         
         
@@ -158,7 +157,7 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         }
         }
         
         
         // Material quality
         // Material quality
-        if (key == '2')
+        else if (key == '2')
         {
         {
             int quality = renderer->GetMaterialQuality();
             int quality = renderer->GetMaterialQuality();
             ++quality;
             ++quality;
@@ -168,15 +167,15 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         }
         }
         
         
         // Specular lighting
         // Specular lighting
-        if (key == '3')
+        else if (key == '3')
             renderer->SetSpecularLighting(!renderer->GetSpecularLighting());
             renderer->SetSpecularLighting(!renderer->GetSpecularLighting());
         
         
         // Shadow rendering
         // Shadow rendering
-        if (key == '4')
+        else if (key == '4')
             renderer->SetDrawShadows(!renderer->GetDrawShadows());
             renderer->SetDrawShadows(!renderer->GetDrawShadows());
         
         
         // Shadow map resolution
         // Shadow map resolution
-        if (key == '5')
+        else if (key == '5')
         {
         {
             int shadowMapSize = renderer->GetShadowMapSize();
             int shadowMapSize = renderer->GetShadowMapSize();
             shadowMapSize *= 2;
             shadowMapSize *= 2;
@@ -186,7 +185,7 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         }
         }
         
         
         // Shadow depth and filtering quality
         // Shadow depth and filtering quality
-        if (key == '6')
+        else if (key == '6')
         {
         {
             int quality = renderer->GetShadowQuality();
             int quality = renderer->GetShadowQuality();
             ++quality;
             ++quality;
@@ -196,7 +195,7 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         }
         }
         
         
         // Occlusion culling
         // Occlusion culling
-        if (key == '7')
+        else if (key == '7')
         {
         {
             bool occlusion = renderer->GetMaxOccluderTriangles() > 0;
             bool occlusion = renderer->GetMaxOccluderTriangles() > 0;
             occlusion = !occlusion;
             occlusion = !occlusion;
@@ -204,7 +203,7 @@ void Sample::HandleKeyDown(StringHash eventType, VariantMap& eventData)
         }
         }
         
         
         // Instancing
         // Instancing
-        if (key == '8')
+        else if (key == '8')
             renderer->SetDynamicInstancing(!renderer->GetDynamicInstancing());
             renderer->SetDynamicInstancing(!renderer->GetDynamicInstancing());
     }
     }
 }
 }