Răsfoiți Sursa

URL: http://jmonkeyengine.org/groups/contribution-depot-jme3/forum/topic/renaming-appstate-setactive-setenabled/
Renaming AppState.setActive()/isActive() to setEnabled()/isEnabled() for consistency

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7143 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

mul..va 14 ani în urmă
părinte
comite
16fc60c8a0

+ 19 - 3
engine/src/core/com/jme3/app/state/AbstractAppState.java

@@ -49,7 +49,7 @@ public class AbstractAppState implements AppState {
      * is set back to false.
      */
     protected boolean initialized = false;
-    private boolean active = true;
+    private boolean enabled = true;
 
     public void initialize(AppStateManager stateManager, Application app) {
         initialized = true;
@@ -59,12 +59,28 @@ public class AbstractAppState implements AppState {
         return initialized;
     }
 
+    /**
+     * Use setEnabled() instead
+     */
+    @Deprecated
     public void setActive(boolean active) {
-        this.active = active;
+        setEnabled(active);
     }
 
+    /**
+     * Use isEnabled() instead
+     */
+    @Deprecated
     public boolean isActive() {
-        return active;
+        return isEnabled();
+    }
+    
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+    
+    public boolean isEnabled() {
+        return enabled;
     }
 
     public void stateAttached(AppStateManager stateManager) {

+ 19 - 0
engine/src/core/com/jme3/app/state/AppState.java

@@ -64,21 +64,40 @@ public interface AppState {
     public boolean isInitialized();
 
     /**
+     * Use setEnabled() instead.
      * Activate or deactivate the functionality of the <code>AppState</code>.
      * The effect of this call depends on implementation. An 
      * <code>AppState</code> starts as being active by default.
      * 
      * @param active activate the AppState or not.
      */
+    @Deprecated
     public void setActive(boolean active);
 
     /**
+     * Use isEnabled() instead.
      * @return True if the <code>AppState</code> is active, false otherwise.
      * 
      * @see AppState#setActive(boolean)
      */
+    @Deprecated
     public boolean isActive();
 
+    /**
+     * Enable or disable the functionality of the <code>AppState</code>.
+     * The effect of this call depends on implementation. An 
+     * <code>AppState</code> starts as being enabled by default.
+     * 
+     * @param active activate the AppState or not.
+     */
+    public void setEnabled(boolean active);
+    
+    /**
+     * @return True if the <code>AppState</code> is enabled, false otherwise.
+     * 
+     * @see AppState#setEnabled(boolean)
+     */
+    public boolean isEnabled();
     /**
      * Called when the state was attached.
      *

+ 3 - 3
engine/src/core/com/jme3/app/state/AppStateManager.java

@@ -139,7 +139,7 @@ public class AppStateManager {
                 if (!state.isInitialized())
                     state.initialize(this, app);
 
-                if (state.isActive()) {
+                if (state.isEnabled()) {
                    state.update(tpf);
                 }
             }
@@ -158,7 +158,7 @@ public class AppStateManager {
                 if (!state.isInitialized())
                     state.initialize(this, app);
 
-                if (state.isActive()) {
+                if (state.isEnabled()) {
                    state.render(rm);
                 }
             }
@@ -177,7 +177,7 @@ public class AppStateManager {
                 if (!state.isInitialized())
                     state.initialize(this, app);
 
-                if (state.isActive()) {
+                if (state.isEnabled()) {
                    state.postRender();
                 }
             }

+ 20 - 3
engine/src/core/com/jme3/cinematic/Cinematic.java

@@ -198,16 +198,33 @@ public class Cinematic extends AbstractCinematicEvent implements Savable, AppSta
         return initialized;
     }
 
+    /**
+     * Use setEnabled() instead
+     */
+    @Deprecated
     public void setActive(boolean active) {
-        if (active) {
-            play();
-        }
+        setEnabled(active);
     }
 
+    /**
+     * Use isEnabled() instead
+     */
+    @Deprecated
     public boolean isActive() {
+        return isEnabled();
+    }
+    
+    public void setEnabled(boolean enabled) {
+        if (enabled) {
+            play();
+        }
+    }
+    
+    public boolean isEnabled() {
         return playState == PlayState.Playing;
     }
 
+
     public void stateAttached(AppStateManager stateManager) {
     }
 

+ 17 - 1
engine/src/jbullet/com/jme3/bullet/BulletAppState.java

@@ -149,11 +149,27 @@ public class BulletAppState implements AppState, PhysicsTickListener {
         return initialized;
     }
 
+    /**
+     * Use setEnabled() instead
+     */
+    @Deprecated
     public void setActive(boolean active) {
-        this.active = active;
+        setEnabled(active);
     }
 
+    /**
+     * Use isEnabled() instead
+     */
+    @Deprecated
     public boolean isActive() {
+        return isEnabled();
+    }
+    
+    public void setEnabled(boolean enabled) {
+        this.active = enabled;
+    }
+    
+    public boolean isEnabled() {
         return active;
     }