Last post update: August 15, 2013
Current Plugin Version: 0.99
Download: http://www.mediafire.com/download/pwaqr4vpx53369a/ConsoleAppState-v0.99.zip (available as plugin in SDK soon)
I’ve been working on an AppState that serves as a universal game wide console that shows when you push the grave key, a common feature of most PC games. The nifty gui project has a Console in it, but you need to incorporate nifty in to your game to use it. (Which means requiring the use of nifty, and all the code that goes with it).
My main goal with it is to keep it easy to include in to your project and to only use components that come with a fresh jmonkey install (besides needing to download the plugin/jar file of course). The console itself is just a few Quads and BitmapTexts on the guinode. Adding/removing console commands are similiar in nature to add/removing key mappings with the InputManager.
It’s an AppState, so all you need to do is attach it to the StateManager.
[java]
stateManager.attach(new ConsoleAppState());
stateManager.attach(new ConsoleDefaultCommandsAppState()); // optional app state that provides some default command mappings if you want them.
[/java]
I’ve been working on it since I made this post a week ago to make it “plugin” worthy. I’ve added a few new features to make the console more configurable.
Also as @zarch mentioned having a “DebugModeAppState” was a little confusing with the name. Instead of renaming it to “ConsoleDebugMode” I actually just canned it and made “ConsoleDefaultCommands” instead. the DefaultCommands appstate just contains a couple mappings that manipulate the console’s settings (rather than having the debug commands). Its main purpose is just so you can quickly add and test out the console.
Hopefully in the next few days I will be able to upload it to the contributions repository so anyone can easily download it as a jMonkey SDK plugin…
For now you can get the library and the sources+javadoc here: http://www.mediafire.com/download/pwaqr4vpx53369a/ConsoleAppState-v0.99.zip
Features:
- Easy to add to any game
- Well documented with javadoc
- Remembers input history that can be recalled by the user (up and down arrow keys)
- Uses a RawInputListener to listen for the grave key to show the Console.
- While console is shown it automatically eats all keyboard input. (to prevent performing game actions while using the console).
- Doesn’t consume any keys besides grave when console isn’t showing.
- Automatically sizes the console window based on the gui ViewPort Camera dimensions.
- Number of console lines is configurable.
- Console Font (and size) is configurable
- the alpha transparency effect of the console is configurable
- console can be set to be “fullscreen” of the gui viewport if you want it to be.
- Has its own “CommandParser” so you you don’t have to parse the input strings yourself.
- ConsoleDefaultCommandsAppState provides some default mappings: (eg console size, help, clear, hide, exit)
- Contains an example (TestConsoleAppState) that attaches the Console and registers custom commands with it.
Issues that I’m currently working on:
- Has not been extensively tested
- Console “error” output does not show up red (currently looks the same as regular output)
- Console input line currently does not wrap. (output window does though)
Here is a screenshot of it in action…