1.the content of the tooltip i create cann't work as i wished
I create two staticimages(one is Root/left/slot another is Root/righttop/weapon) in my layoutfile unnamed2.layout.Root/left/slot is the child window of Root/left(StaticImage) and Root/righttop/weapon is the childwindow of Root/righttop(StaticImage).
Code: Select all
CEGUI::Window* itemWidget = MyGUI::getSingletonPtr()->getWindow("Root/left/slot");//MyGUI is a class which i create some functions on UI
itemWidget->setUserString("type","Destroyer");//to set a flag "Destroyer"
formatInvTooltip(itemWidget,mItems[0]);//std::vector<Item*> mItems;
CEGUI::Window* skillWidget = MyGUI::getSingletonPtr()->getWindow("Root/righttop/slot");
formatSkillTooltip(skillWidget,mSkills[0]);//std::vector<Skill*> mSkills;
formatInvTooltip()
Code: Select all
void Demo::formatInvTooltip(CEGUI::Window* window,Item* item)
{
std::stringstream ssTooltip;
ssTooltip
<<"[font='SimHei-14'][colour='FF0000FF']"<<item->getName()<<std::endl
<<"[top-padding='5'][bottom-padding='10'][image-width='60'][image-height='90'][colour='FFFFFFFF'][image='"
<<item->getIconName()<<"']"<<std::endl
<<"------------------------"<<std::endl
<<"[top-padding='0'][bottom-padding='0'][font='SimHei-14'][colour='FF00FFFF']" << item->getDescription() << std::endl
<<"------------------------"<<std::endl
<<"Tech Level: " << item->getSkillLevel() << std::endl
<<"------------------------"<<std::endl
<<"Cost: "<<item->getCost()<<std::endl;
//
window->setTooltipText(ssTooltip.str());
}
formatInvSkillTooltip
Code: Select all
void Demo::formatSkillTooltip(CEGUI::Window* window, Skill* skill)
{
std::stringstream ssTooltip;
ssTooltip
<<"[font='SimHei-14'][colour='FFFFFF00']"<<skill->getName()<<std::endl
<<"[top-padding='5'][bottom-padding='10'][image-width='80'][image-height='80'][colour='FFFFFFFF'][image='"
<<skill->getIconName()<<"']"<<std::endl
<<"------------------------"<<std::endl
<<"[top-padding='0'][bottom-padding='0'][font='SimHei-14'][colour='FF00FF00']" << skill->getDescription() << std::endl
<<"------------------------"<<std::endl
<<(CEGUI::utf8*)Ogre::UTFString(L"Your skill level is : ").asUTF8_c_str()<< skill->getLevel() << std::endl
<<"------------------------"<<std::endl
<<(CEGUI::utf8*)Ogre::UTFString(L"Mana cost of XXX Skill: ").asUTF8_c_str()<<skill->getCost()<<std::endl
<<"------------------------"<<std::endl
<<(CEGUI::utf8*)Ogre::UTFString(L"Damage:").asUTF8_c_str()<<skill->getDamage()<<std::endl;
//
window->setTooltipText((CEGUI::utf8*)ssTooltip.str().c_str());
}
But when i call createGUIEvents()
Code: Select all
void Demo::createGUIEvents()
{
MyGUI::subscribeEvent("Root/left/slot",CEGUI::Window::EventMouseClick,CEGUI::Event::Subscriber(&Demo::onEquip,this));
}
bool Demo::onEquip(const CEGUI::EventArgs& args)
{
const CEGUI::WindowEventArgs& WindowArgs = static_cast<const CEGUI::WindowEventArgs&>(args);
if(WindowArgs.window->getUserString("type") == "Destroyer")
{
CEGUI::Window* invleft = MyGUI::getSingletonPtr()->getWindow("Root/left");
invleft->removeChildWindow(WindowArgs.window);
CEGUI::Window* invweapon = MyGUI::getSingletonPtr()->getWindow("Root/righttop/weapon");
invweapon->getChild(0)->addChildWindow(WindowArgs.window);
WindowArgs.window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
WindowArgs.window->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
}
return true;
}
formatInvTooltip() and formatSkillTooltip() ,they are created in order to create the tooltip which i can put the image and text in it and i find when my cursor was on the staticimage window ,nothing happend
While in the model of debug,i find that the EventMouseClick event was not fired.Oh what a mess!!.Maybe i made a stupid mistakes again,but i really want to know where are they set.