The prototype of the state machine that I'm working on was further developed on the weekend. I finally added code to use CEGUI, with a singleton GuiManager class that does little more than init, deinit, and hand out references to certain CEGUI objects. I've also implemented the console (sans command management) and put in a menu.
Only the Play and Quit buttons work. There's nothing yet for Options or Profile to do so I haven't bothered implementing handlers for them yet.
The console is implemented as a game state, and also inherits from Ogre::LogListener. So it gets to slurp anything put into the log file. In addition, anything typed in gets put into the console window, but as stated earlier, nothing else is done to it. Yet.
There is a problem that I am suffering with the console, however. It deals with removing old lines. The implementation of Ogre::LogListener::write() in this class is:
void ConsoleState::write(const Ogre::String &name, const Ogre::String &message, Ogre::LogMessageLevel lml=LML_NORMAL, bool maskDebug=false)
// remove old lines if old text is more than 1k long
while (constext.length() > 1023 && constext.find("\n") != -1)
constext = constext.substr(constext.find("\n") + 1);
// add the new text afterwards
constext += message;
mConsole->setCaratIndex(constext.length() - 1);
The problem seems to be the "old line slurper" (lines 6 & 7 of the code) itself, but it doesn't manifest right away. (In the actual code it's commented out to keep the program from crashing.)
The crash itself takes place on line 13. For reasons I cannot discern, either std::string::length() or mConsole->setCaratIndex() takes offense to my code. Because I'm having problems with the debug memory manager of OGRE hating CEGUI's memory manager, I have to do Release builds which means I can't really trace the crash past this point. (Hopefully I can find some way of resolving the mem manager problem today and be able to debug properly.)
As well, CEGUI::String and std::string don't like working with each other. Unlike Ogre::String and std::string, which are actually the same (gotta love typedefs). CEGUI::String isn't std::basic_string