new Guy have problem with console

Jack106

06-11-2009 19:40:43

Hey guys,
i will try to write this post in english, i hope you will understand everything.
I used QuickGUI 9.10 know for 1day with ogre 1.61 and i have problem with the consol widget, i didn't find any post where the same problem is describted, thus i have to ask you :) . I hope the information about my system are enough, if not please point it out.
I had add an ConsoleInputHandler to my Consol.
Console Code:
QuickGUI::ConsoleDesc* cd = QuickGUI::DescManager::getSingletonPtr()->getDefaultConsoleDesc();
cd->resetToDefault();
cd->widget_name = "Debug Consol"; cd->widget_dimensions.position = QuickGUI::Point(0,0);
cd->widget_dimensions.size = QuickGUI::Size(400,100);
cd->console_inputBoxDefaultFontName = "micross.16";
debugbox = m_Sheet->createConsole(cd);
debugbox->setDragable(false);
debugbox->setVisible(false);
debugbox->setConsoleInputHandler(&MOB_Scene_Base::gDebug_prase,this);


ConsoleInputHandler:
void MOB_Scene_Base::gDebug_prase(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
{
clearInputBox = true;
addToDisplayArea = true;
}


When i used this, the text was add but with a few upheavals.
So I changed it to this:

void MOB_Scene_Base::gDebug_prase(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
{
clearInputBox = true;
addToDisplayArea = false;
c->addDisplayAreaText(c->getInputBoxText());
}


Then it works well when i only add one line text, but only without escape squenzes, witch you can see here:

void MOB_Scene_Base::gDebug_prase(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
{
clearInputBox = true;
addToDisplayArea = false;
c->addDisplayAreaText(c->getInputBoxText().append("\r"));
}


So i tryed to fit it with qt, in this way, but it didn't worked too.

clearInputBox = true;
addToDisplayArea = false;
//QuickGUI::Console::getInputBoxText();
QString textpre = QString::fromStdString((c->getDisplayAreaText().asUTF8()));
c->clearDisplayArea();
QString textnow = QString::fromStdString((c->getInputBoxText().asUTF8()));
c->clearInputBox();
QString text = "";
text = text.append(textpre);
text = text.append(textnow);
text = text.append("\n");
qDebug() << text;
c->addDisplayAreaText(text.toStdString());


Maybe i haden't find the thread and the solution is somewhere in this forum, but if it isn't maybe you could help me.

Thank you for reading and i hope for and answer soon.

Greetings Jack106

kungfoomasta

08-11-2009 01:35:54

Hi Jack106, sorry for the slow response. I'll look into this and see if I can repro. I didn't think about entering in strings with newline characters into the console input box, not sure how that affects things.

Jack106

08-11-2009 12:10:03

Hey no problem iam glad and its great that even somebody bother about my problem, in other "interface for ogre addon" forums it isn't a matter of course.

kungfoomasta

09-11-2009 20:05:08

When i used this, the text was add but with a few upheavals.

Can you explain what problems you found?

I've found scrolling to be broken, working on that part. Have yet to look into adding strings with newlines in it.

Jack106

09-11-2009 21:10:41

hey i will try to explain. I thought when i use this Code:

ConsoleInputHandler:
void MOB_Scene_Base::gDebug_prase(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
{
clearInputBox = true;
addToDisplayArea = true;
}


the input Text will be display in the areabox, and when i type a new word this word will be display with a new line between the words.
But the result was, that the first word was add with lots of new lines, the scrollingbar moved to the bottom. Then the next word was add but again with lots of newlines and again the scrollingbar moved to the bottom. So I tried to add the input text manuel, that works, but only when i don't make a new line. Then the words were displayed in sequence. But thats not what i wanted. So i thought maybe the problem is to find somewhere in the method append(), because i used this to put the word with the escape sequences together, to avoid that i tried to used qt to put everything together, but it didn't worked too. So i don't know where the problem come from. Maybe it is a problem with Ogre::Utf8String, maybe the function from quickgui to add a new word to the areabox and put it with the previous entries together is the guilty one. So I think the problem is that you can't add a new Line or to add more than one line in sequenz. But maybe iam wrong and almost everything works great and iam doing something wrong.

But i have found another problem when you use clearInputBox = false; Then the word is add again and again until you delete the word in the textbox manually or you click somewhere. I don't think that this works correctly, because if maybe someone don't want to delete the textareavalue but he want also that the word will be add only once, he have to do it manually. He has to save the inputtext, delete the word that is current enterd in the the textbox und have to refill the textbox with the word, i think that should work. I don't know if it is deliberately, but when not i think the "enter-button" entrie isnt deleted and the code to add new Text is executed all the time, because the condition if(enteredkey == enterbutton) is always true in that moment. Maybe thats the reason maybe not and maybe it should be working exactly in this way.

Hope thats enough to point out my problem, think you will solve it ;) and thanks for your help.

kungfoomasta

09-11-2009 22:16:11

But the result was, that the first word was add with lots of new lines, the scrollingbar moved to the bottom.

Can you type out the steps you used? I have pretty much the same code you do, I don't see this problem. Here is my code:

QuickGUI::ConsoleDesc* cd = QuickGUI::DescManager::getSingletonPtr()->getDefaultConsoleDesc();
cd->resetToDefault();
cd->widget_name = "Debug Consol"; cd->widget_dimensions.position = QuickGUI::Point(0,0);
cd->widget_dimensions.size = QuickGUI::Size(400,100);
cd->console_inputBoxDefaultFontName = "micross.16";
QuickGUI::Console* debugbox = mSheetFromFile->createConsole(cd);
debugbox->setDragable(false);
debugbox->setConsoleInputHandler(&MainForm::testConsoleHandler,this);


Steps:

1. Create Console
2. Type "1", press Enter
3. Type "2", press Enter
4. Type "3", press Enter

Result:

1
2
3

I also tried this code:
debugbox->addDisplayAreaText("1\n");
debugbox->addDisplayAreaText("2");


Result:

1
2

I have also fixed some scrolling issues with the TextBox, used by the Console, and updated some APIs:

/**
* Adds text to the output Display area.
*/
void addDisplayAreaText(Ogre::UTFString s, Ogre::Font* fp, const ColourValue& cv, bool newLine = true);
/**
* Adds text to the output Display area.
*/
void addDisplayAreaText(Ogre::UTFString s, const Ogre::String& fontName, const ColourValue& cv, bool newLine = true);
/**
* Adds text to the output Display area.
*/
void addDisplayAreaText(Ogre::UTFString s, bool newLine = true);
/**
* Adds text to the output Display area.
*/
void addDisplayAreaText(std::vector<TextSegment> segments, bool newLine = true);


If you can let me know what your steps/code is to expose the bug, I should be able to fix it. I need to know what 'actually' happened, and what you 'expected', then I can update things accordingly. :)

Jack106

14-11-2009 13:43:39

Hey i have done know exactly the steps you done too. With absolutely the same code.
I have made an video of the problem: http://tinypic.com/player.php?v=2d9yd6r&s=4 . Hope it helps.

I will try to combine a textarea with a textbox manually and than we will see if that dosent work too.

kungfoomasta

14-11-2009 20:29:43

Are you using linux? It looks like something might be going crazy with your input system.

Can you put a breakpoint into your input handler function, and see if it gets called repeatedly, after you press enter?


void MOB_Scene_Base::gDebug_prase(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
{
BREAKPOINT----> clearInputBox = true;
addToDisplayArea = true;
}


If you cannot set a breakpoint in there, you can also log some info out to the Ogre log. This would actually be a better way, to see what happens when you press enter in the console. I cannot reproduce the same behavior your see, pressing enter only adds whatever text is in the textbox when I try this.

The code to log would be something like this:

Ogre::LogManager::getSingleton().getDefaultLog()->log("************** Console Input Handler Entered");

Jack106

15-11-2009 10:16:24

Okay iam using windows 7, know i have used Ogre::Log.
The InputHandler was executet 19 times, but i have only added one letter.
Maybe my PC is too fast :lol: . The Log is to big to post, over 7000 lines.
In short:
11:12:09: ************** Console Input Handler Entered
11:12:09: ************** Console Input Handler Entered
11:12:09: Texture: qgui.scrollbar.vertical.png: Loading 1 faces(PF_A8R8G8B8,14x158x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,14x158x1.
11:12:09: Texture: qgui.scrollbar.vertical.bottom.png: Loading 1 faces(PF_A8R8G8B8,14x14x1) with 3 generated mipmaps from Image. Internal format is PF_A8R8G8B8,14x14x1.
11:12:09: Texture: qgui.scrollbar.vertical.slider.png: Loading 1 faces(PF_A8R8G8B8,14x44x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,14x44x1.
11:12:09: Texture: qgui.scrollbar.vertical.top.png: Loading 1 faces(PF_A8R8G8B8,14x14x1) with 3 generated mipmaps from Image. Internal format is PF_A8R8G8B8,14x14x1.
11:12:10: ************** Console Input Handler Entered
11:12:10: ************** Console Input Handler Entered
11:12:11: ************** Console Input Handler Entered
11:12:11: ************** Console Input Handler Entered
11:12:11: ************** Console Input Handler Entered
11:12:11: ************** Console Input Handler Entered

and so on...


Ps. it is executed infinitely when i don't click somewhere or do something like this. This means new lines were added until i do something.

Jack106

15-11-2009 11:17:25

Hey for a minute i have learn form my co-worker , that when he had comile quickgui, he had to do this:

[QuickGUIStringConverter.cpp:396,504,566,604]
--Ogre::vector<Ogre::String>::type vs = Ogre::StringUtil::split(ogreString," "); (deleted)
++std::vector<Ogre::String> vs = Ogre::StringUtil::split(ogreString," "); (added)

Because there is no Ogre::vector and no ::type in std

Maybe this cause the bug?

kungfoomasta

16-11-2009 04:22:29

I fixed that error in SVN, its because I'm building against Ogre HEAD, and 1.6 doesn't have Ogre::Vector. (oops) I'll probably put out 9.11 sometime which has the fix.

The InputHandler was executet 19 times, but i have only added one letter.

This sounds like some error in your input handling. When you press 'enter', the QuickGUI::GUIManager::injectKeyPressed function should be only called once, however on your machine its being called 19 times. Are you using OIS?

The next step in debugging is to put a breakpoint or Log a message in your application code, to see how many times you are calling QuickGUI::GUIManager::injectKeyPressed.

Jack106

16-11-2009 20:07:41

Okay i have found the bug and its my fault. QuickGui is running perfectly , love it.
I don't want to tell you the solution, it's to embarrassing^^ :oops: , but yeah you was right i have executed QuickGUI::GUIManager::injectKeyPressed to often. In fact i have executed it in the keyReleased function.
So thanks for your help and Shame on me ^^ :cry: .
Sry that i have stole your time, iam pleased that i can use QuickGui now complete operative.

So thanks again and don't worry i will ask again some questions in the future when i need help :lol:

Calder

17-11-2009 02:23:25

You have no idea how many moments I've had like this! :D

kungfoomasta

18-11-2009 23:17:45

Awesome, I'm glad its figured out! QuickGUI is a little more untested in widgets that manipulate text, so please post issues you find. I'll get there in my own project eventually, but chatting is one of the low priority TODOs for my game currently. :)