From a2043b3ded2a2d1121124d71f9222b65cb6fe3a9 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Fri, 17 Feb 2012 01:05:50 +0000 Subject: [PATCH] Modified to tracks its enabled state so that it can really be disabled. I will move the statistics.clearFrame() on my next commit. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9158 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/app/StatsView.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/engine/src/core/com/jme3/app/StatsView.java b/engine/src/core/com/jme3/app/StatsView.java index 48df4a9a3..a94b4839d 100644 --- a/engine/src/core/com/jme3/app/StatsView.java +++ b/engine/src/core/com/jme3/app/StatsView.java @@ -67,6 +67,8 @@ public class StatsView extends Node implements Control { private String[] statLabels; private int[] statData; + private boolean enabled = true; + private final StringBuilder stringBuilder = new StringBuilder(); public StatsView(String name, AssetManager manager, Statistics stats){ @@ -92,12 +94,20 @@ public class StatsView extends Node implements Control { } public void update(float tpf) { + + if (!isEnabled()) + return; + statistics.getData(statData); for (int i = 0; i < labels.length; i++) { stringBuilder.setLength(0); stringBuilder.append(statLabels[i]).append(" = ").append(statData[i]); labels[i].setText(stringBuilder); } + + // Moved to SimpleApplication to make sure it is + // done even if there is no StatsView or the StatsView + // is disable. statistics.clearFrame(); } @@ -109,10 +119,11 @@ public class StatsView extends Node implements Control { } public void setEnabled(boolean enabled) { + this.enabled = enabled; } public boolean isEnabled() { - return true; + return enabled; } public void render(RenderManager rm, ViewPort vp) {