I am developing an application that is in need of a console and I am interested in using SDL_console as opposed to doing it from scratch. However I am having trouble finding information on how to set it up and use it. If anyone can help me out with this subject it would be greatly appreciated.
Examples and headers are very important when dealing with “smaller” libraries. Make sure you look at “ConsoleExample.c” in the example directory. Also have the SDL_console.h from the include directory handy for API review.
As I understand it:
CON_Init(const char *FontName, SDL_Surface *DisplayScreen, int lines, SDL_Rect rect);
CON_SetExecuteFunction(ConsoleInformation *console, void(*CmdFunction)(ConsoleInformation console2, char command));
are the key players for a basic usage.
Init and Show should be rather self explanatory.
for SetExecuteFunction, you’ll need to have a function declared in the “void Function(ConsoleInformation console, char command)” fashion. This function will receive a pointer to the console which received the event, and it will also receive the char* command. You’ll need to write some helper functions for parsing it into commands and arguments.
In your event loop, add a portion that calls the Events function. eg:
if Events returns a null, there is nothing left for you to process, continue the loop and grab the next event. If it does return something, then the event wasn’t for the console, and process as you normally would.
I hope this helps. If you need more pointers, I’ll try my best to help.
Also a big note. I once wrote a map editor where I relied heavily on a console for switching brush types, creating new maps, saving, etc. Worked great for me, but only for me. I couldn’t explain to anyone else as to how to use it. Consoles are great for the savvy who know what they are doing, but not so great for the rest of the point and click world. But when used for debugging, testing, and interacting with a scripting engine it can be extremely powerful and helpful.
Kamo16 wrote:> I am developing an application that is in need of a console and I am interested in using SDL_console as opposed to doing it from scratch. However I am having trouble finding information on how to set it up and use it. If anyone can help me out with this subject it would be greatly appreciated.