Display KeyBindings in SimpleGames

I think it would be a good idea to display all the key bindings available in SimpleGame's.

Right now you always have to dig through the code to see which key does what.



Right now F1 is mapped to 'take screenshot'.



So instead of displaying 'F4 - toggle stats' we could display 'F1  - toggle help'

If you press F1 a list of Key- /Mousebindings is displayed.



F1 - toggle help

F2 - toggle parallel/perspective projection

F3 - toggle depth

F4 - toggle stats



r - memory report

c - camera location

etc.



BaseSimpleGame could also provide a protected method to add more information to this list.

protected void addInfo(String info);

This can be used in Test*Classes to add Test specific key bindings or informations.



Any other ideas?

Sounds good.



I'd recommend the following variation for the customizability aspect.


protected String getHelpText();



This way, the user can decide whether to prefix, append, sandwich, or totally replace what is displayed with F1:


@Override
protected String getHelpText() {
    return "My Fancy Program, (c) 2009nn" + super.getHelpText()
    + "nF13: Turbo modennContact me@acme.com for support";
}

In a Simplegame, additional Info can be added by calling:


        addInfo("E", "debug show/hide reflection and refraction textures");
        addInfo("F", "freeze/unfreeze waterquad movement");



That will reduce some redundant text creation code in the Tests and make them a bit shorter.

edit: removed old screenshot

whats the status on this?

i'm eager to put some help into scene worker and this would be perfect…

Currently i'm struggling a bit.

I tried to add a refresh method to update an existing text with a dynamic value like this:

"2/3    - increase/decrease blursize  [0.5]"

Where 0.5 is dynamic value.



But everytime something changes the Text object needs to be recreated, it works pretty much, but its not very nice implemented.



I'll post what i have today evening, but it needs more work or another approach to make it easy and flexible to use.



Patch can be found here: -> Click <-

The issues now are:
- Text does not support newlines, so we have to create a new Text object for every line. (not really a issue)
- when refreshing a Value ([xyz]) i recreate the whole text (should just get the Text from the TreeMap and update it)
- would be nice if the refreshInfoValue() wasn't necessary, but i have no idea how to do that currently
I need some fresh ideas :)  would be cool if you can take a look at it.

Usage in for example Testbloom currently is:


        // simeplInit()
      KeyBindingManager.getKeyBindingManager().set("2", KeyInput.KEY_2);
      KeyBindingManager.getKeyBindingManager().set("3", KeyInput.KEY_3);
      addInfo("2/3", "decrease / increase blursize", bloomRenderPass.getBlurSize());

...

         // simpleUpdate()
      if(KeyBindingManager.getKeyBindingManager().isValidCommand("2", false)) {
         bloomRenderPass.setBlurSize(bloomRenderPass.getBlurSize() - 0.001f);
         refreshInfoValue("2/3", bloomRenderPass.getBlurSize());
      }



Hmm this should also be available in DebugGamestate.



Maybe some kind of InfoTextManager singleton class with the addInfo / refreshInfo and render() Methods would be good?