MyGUI::Message::createMessage

Alessan

30-10-2008 20:59:31

Hi,

I am testing MyGUI for my project, all was works fine until i get this problem with Messages.

The problem is that i can't see the message widget but if i press in middel of screen the delegated function works.

I use the default core skin, font, etc.

i can login and change to next gamestate.
i can quit the game if i push in the middel of screen (invisible message widget).

Any idea what is the problem?


//--------------------------------------------------------------------------------
void LoginState::enter()
{
//sNetworkManager.disconnect();
printf("enter: loginstate.\n");
configureGUI();
}
//--------------------------------------------------------------------------------
void LoginState::handleBtQuit(MyGUI::WidgetPtr _sender)
{
MyGUI::MessagePtr pGUIMsg = MyGUI::Message::createMessage(Ogre::String("aaaaa"),Ogre::String("Salir"), true,
MyGUI::Message::IconWarning | MyGUI::Message::Ok);
pGUIMsg->eventMessageBoxEnd = MyGUI::newDelegate(this, &LoginState::notifyMessageBoxEnd);

}
//--------------------------------------------------------------------------------
void LoginState::handleBtLogin(MyGUI::WidgetPtr _sender)
{
MyGUI::EditPtr edusername = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Edit>("edLogin");
MyGUI::EditPtr edpassword = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Edit>("edPassword");

string username = edusername->getCaption();
string password = edpassword->getCaption();
if(!sNetworkManager.Conected)
{
sNetworkManager.connect();
}
if(sNetworkManager.Conected)
sMsgHandler.SendLoginRequest(username, password);
}
//--------------------------------------------------------------------------------
void LoginState::configureGUI(void)
{
MyGUI::VectorWidgetPtr VWP = MyGUI::LayoutManager::getInstance().loadLayout("loginGUI.layout");
MyGUI::ButtonPtr btLogin = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Button>("btLogin");
btLogin->eventMouseButtonClick = MyGUI::newDelegate(this, &LoginState::handleBtLogin);
MyGUI::ButtonPtr btQuit = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Button>("btQuit");
btQuit->eventMouseButtonClick = MyGUI::newDelegate(this, &LoginState::handleBtQuit);
}
//--------------------------------------------------------------------------------
void LoginState::notifyMessageBoxEnd(MyGUI::WidgetPtr _sender, MyGUI::Message::ViewInfo _button)
{
if (_button == MyGUI::Message::Ok)
{
this->requestShutdown();
}
}
//--------------------------------------------------------------------------------

Altren

30-10-2008 21:24:07

Hm, I tried your code - everything works fine. May be you have some large widgets on upper layers that can overlap your message?

Alessan

30-10-2008 22:02:30

Hi,

No, if i make this changes... i got a empty windows that exit when i push in the invisble message widget.

I am compiling the last svn, then i tell you if the problem continues.

Thanks.



//--------------------------------------------------------------------------------
void LoginState::enter()
{
//sNetworkManager.disconnect();
printf("enter: loginstate.\n");
//configureGUI();
MyGUI::MessagePtr pGUIMsg = MyGUI::Message::createMessage(Ogre::String("aaaaa"),Ogre::String("Salir"), true,
MyGUI::Message::IconWarning | MyGUI::Message::Ok);
pGUIMsg->eventMessageBoxEnd = MyGUI::newDelegate(this, &LoginState::notifyMessageBoxEnd);
}
//--------------------------------------------------------------------------------
void LoginState::handleBtQuit(MyGUI::WidgetPtr _sender)
{
/*MyGUI::MessagePtr pGUIMsg = MyGUI::Message::createMessage(Ogre::String("aaaaa"),Ogre::String("Salir"), true,
MyGUI::Message::IconWarning | MyGUI::Message::Ok);
pGUIMsg->eventMessageBoxEnd = MyGUI::newDelegate(this, &LoginState::notifyMessageBoxEnd);*/

}
//--------------------------------------------------------------------------------
void LoginState::handleBtLogin(MyGUI::WidgetPtr _sender)
{
/* MyGUI::EditPtr edusername = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Edit>("edLogin");
MyGUI::EditPtr edpassword = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Edit>("edPassword");

string username = edusername->getCaption();
string password = edpassword->getCaption();
if(!sNetworkManager.Conected)
{
sNetworkManager.connect();
}
if(sNetworkManager.Conected)
sMsgHandler.SendLoginRequest(username, password);*/
}
//--------------------------------------------------------------------------------
void LoginState::configureGUI(void)
{
/*MyGUI::VectorWidgetPtr VWP = MyGUI::LayoutManager::getInstance().loadLayout("loginGUI.layout");
MyGUI::ButtonPtr btLogin = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Button>("btLogin");
btLogin->eventMouseButtonClick = MyGUI::newDelegate(this, &LoginState::handleBtLogin);
MyGUI::ButtonPtr btQuit = MyGUI::WidgetManager::getInstance().findWidget<MyGUI::Button>("btQuit");
btQuit->eventMouseButtonClick = MyGUI::newDelegate(this, &LoginState::handleBtQuit);*/
}
//--------------------------------------------------------------------------------
void LoginState::notifyMessageBoxEnd(MyGUI::WidgetPtr _sender, MyGUI::Message::ViewInfo _button)
{
if (_button == MyGUI::Message::Ok)
{
this->requestShutdown();
}
}
//--------------------------------------------------------------------------------

Alessan

30-10-2008 22:42:50

Hi,

the problem persist....

if you can figure what is the ploblem plase tell me, i continue trying locate the problem.

thanks.

Altren

30-10-2008 23:13:07

Try to run only this line in you appMyGUI::MessagePtr pGUIMsg = MyGUI::Message::createMessage(Ogre::String("aaaaa"),Ogre::String("Salir"), true,
MyGUI::Message::IconWarning | MyGUI::Message::Ok);
and try to add them to void DemoKeeper::createScene() in DemoKeper.cpp in TestApp in MyGUI sln.

Does other widgets looks normal? Try to create Window.

Alessan

31-10-2008 00:42:01

hi,

in new default ogre project i can create and view eindows, edits and all code created widgets, but i can't see this message windget.

in demokeeper yes, i can see the message :D

here are 1:36 am, tomorrow i look for what is missing.

thanks.

new empty ogre proyect: (here i can see the edit but i not see the message.


// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Ogre.h>
// ----------------------------------------------------------------------------
// Include the OGRE example framework
// This includes the classes defined to make getting an OGRE application running
// a lot easier. It automatically sets up all the main objects and allows you to
// just override the bits you want to instead of writing it all from scratch.
// ----------------------------------------------------------------------------
#include <ExampleApplication.h>
#include "MyGUI.h"

// ----------------------------------------------------------------------------
// Define the application object
// This is derived from ExampleApplication which is the class OGRE provides to
// make it easier to set up OGRE without rewriting the same code all the time.
// You can override extra methods of ExampleApplication if you want to further
// specialise the setup routine, otherwise the only mandatory override is the
// 'createScene' method which is where you set up your own personal scene.
// ----------------------------------------------------------------------------
class SampleApp : public ExampleApplication
{
public:
// Basic constructor
SampleApp()
{}

protected:

// Just override the mandatory create scene method
void createScene(void)
{
// Create the SkyBox
mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");

// Create a light
Light* myLight = mSceneMgr->createLight("Light0");
myLight->setType(Light::LT_POINT);
myLight->setPosition(0, 40, 0);
myLight->setDiffuseColour(1, 1, 1);
myLight->setSpecularColour(1, 1, 1);

MyGUI::Gui * mGUI = new MyGUI::Gui();
mGUI->initialise(mWindow);


MyGUI::MessagePtr pGUIMsg = MyGUI::Message::createMessage(Ogre::String("aaaaa"),Ogre::String("Salir"), true,
MyGUI::Message::IconWarning | MyGUI::Message::Ok);
MyGUI::EditPtr pGUIEdit = MyGUI::Gui::getInstance().createWidget<MyGUI::Edit>("Edit", 0, 0, 100, 20, MyGUI::ALIGN_DEFAULT, "Info");

}
};


// ----------------------------------------------------------------------------
// Main function, just boots the application object
// ----------------------------------------------------------------------------
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
SampleApp app;

try
{
app.go();
}
catch( Exception& e )
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else

std::cerr << "An exception has occured: " << e.getFullDescription();
#endif
}

return 0;
}

my.name

31-10-2008 11:43:58

=)

Alessan

31-10-2008 12:07:20

Hi,

Well, I change all body code taking as reference baselayout code.

Now all works, but i don't know where was the error.

One comment, if in TestApp main.cpp you make a bucle creating an destroying all, the porogram crahses ¿memory leak?.


unsigned int index = 0;
while(index < 10)
{
demo::DemoKeeper * app = new demo::DemoKeeper();
app->prepare(argc, argv);
app->create();
app->run();
app->destroy();
delete app;
app = 0;

index++;
}

Altren

31-10-2008 12:10:54

Gotcha, this happens because you don't callmGUI->injectFrameEntered(evt.timeSinceLastFrame);every frame, so all effects related to time (as smooth Message showing) doesn't work.
You also will have troubles with RenderBox, Progress, Edit caret and Tab widget sheets selecting as described here.

Alessan

31-10-2008 13:59:34

:oops:

Thanks, all solved :D