Properly cleanup the DetailedProfilerState when it's detached
This commit is contained in:
parent
ee58677ed9
commit
69ca84d377
@ -59,6 +59,8 @@ public class DetailedProfilerState extends BaseAppState {
|
|||||||
private ColorRGBA dimmedOrange = ColorRGBA.Orange.mult(0.7f);
|
private ColorRGBA dimmedOrange = ColorRGBA.Orange.mult(0.7f);
|
||||||
private ColorRGBA dimmedRed = ColorRGBA.Red.mult(0.7f);
|
private ColorRGBA dimmedRed = ColorRGBA.Red.mult(0.7f);
|
||||||
|
|
||||||
|
private ProfilerInputListener inputListener = new ProfilerInputListener();
|
||||||
|
|
||||||
public DetailedProfilerState() {
|
public DetailedProfilerState() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,23 +121,17 @@ public class DetailedProfilerState extends BaseAppState {
|
|||||||
if (inputManager != null) {
|
if (inputManager != null) {
|
||||||
inputManager.addMapping(TOGGLE_KEY, new KeyTrigger(KeyInput.KEY_F6));
|
inputManager.addMapping(TOGGLE_KEY, new KeyTrigger(KeyInput.KEY_F6));
|
||||||
inputManager.addMapping(CLICK_KEY, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
inputManager.addMapping(CLICK_KEY, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||||
inputManager.addListener(new ActionListener() {
|
inputManager.addListener(inputListener, TOGGLE_KEY, CLICK_KEY);
|
||||||
@Override
|
|
||||||
public void onAction(String name, boolean isPressed, float tpf) {
|
|
||||||
if (name.equals(TOGGLE_KEY) && isPressed) {
|
|
||||||
setEnabled(!isEnabled());
|
|
||||||
}
|
|
||||||
if (isEnabled() && name.equals(CLICK_KEY) && isPressed) {
|
|
||||||
handleClick(inputManager.getCursorPosition());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, TOGGLE_KEY, CLICK_KEY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(Application app) {
|
protected void cleanup(Application app) {
|
||||||
|
ui.detachAllChildren();
|
||||||
|
InputManager manager = getApplication().getInputManager();
|
||||||
|
manager.deleteMapping(TOGGLE_KEY);
|
||||||
|
manager.deleteMapping(CLICK_KEY);
|
||||||
|
manager.removeListener(inputListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -441,8 +437,18 @@ public class DetailedProfilerState extends BaseAppState {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return label.getText() + " - " + df.format(getMsFromNs(cpuValue)) + "ms / " + df.format(getMsFromNs(gpuValue)) + "ms";
|
return label.getText() + " - " + df.format(getMsFromNs(cpuValue)) + "ms / " + df.format(getMsFromNs(gpuValue)) + "ms";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProfilerInputListener implements ActionListener {
|
||||||
|
@Override
|
||||||
|
public void onAction(String name, boolean isPressed, float tpf) {
|
||||||
|
if (name.equals(TOGGLE_KEY) && isPressed) {
|
||||||
|
setEnabled(!isEnabled());
|
||||||
|
}
|
||||||
|
if (isEnabled() && name.equals(CLICK_KEY) && isPressed) {
|
||||||
|
handleClick(getApplication().getInputManager().getCursorPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user