ive been trying to implement the framewindow as an informational thing and as a backgound of a checkbox for graphics settings, but somehow a couple of commands such as destroy() function is not working..ok i kind of cant think in english today so ill try so summarize it by posting parts of the code and the entire .cpp file for better analyzes...alright here s the deal, i created a couple of TaharezLook/Button s and i am trying to give them functionalities ..so one of the buttons i wanted to trigger a framewindow and then inside the framewindow show the options for the user to choose between opengl or directx and some other graphics options for the future but the thing is i can trigger to open the frame window but i want to also be able to close the window by clicking again in the 3d graphics button and i cant seem to find a way out of this..when i call the function destroy it seems to be destrying but the framewindow remains there,i tried to use the removeChildWindow() function but its not working..can anyone help me out with this?
heres the entire .cpp file:
Code: Select all
/*
-----------------------------------------------------------------------------
Filename: BasicTutorial7.cpp
-----------------------------------------------------------------------------
This source file is generated by the
___ _ __ __ _ _
/___\__ _ _ __ ___ /_\ _ __ _ __/ / /\ \ (_)______ _ _ __ __| |
// // _` | '__/ _ \ //_\\| '_ \| '_ \ \/ \/ / |_ / _` | '__/ _` |
/ \_// (_| | | | __/ / _ \ |_) | |_) \ /\ /| |/ / (_| | | | (_| |
\___/ \__, |_| \___| \_/ \_/ .__/| .__/ \/ \/ |_/___\__,_|_| \__,_|
|___/ |_| |_|
Ogre 1.7.x Application Wizard for VC10 (July 2011)
http://code.google.com/p/ogreappwizards/
-----------------------------------------------------------------------------
*/
#include "BasicTutorial7.h"
CEGUI::MouseButton convertButton(OIS::MouseButtonID buttonID)
{
switch(buttonID)
{
case OIS::MB_Left:
return CEGUI::LeftButton;
case OIS::MB_Right:
return CEGUI::RightButton;
case OIS::MB_Middle:
return CEGUI::MiddleButton;
default:
return CEGUI::LeftButton;
}
}
//-------------------------------------------------------------------------------------
BasicTutorial7::BasicTutorial7(void)
{
}
//-------------------------------------------------------------------------------------
BasicTutorial7::~BasicTutorial7(void)
{
}
//-------------------------------------------------------------------------------------
void BasicTutorial7::createScene(void)
{
mRenderer = &CEGUI::OgreRenderer::bootstrapSystem();
CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
sheet = wmgr.createWindow("DefaultWindow", "CEGUIDemo/Sheet");
//CEGUI::ScrollablePane* scrollablePane = static_cast<CEGUI::ScrollablePane*>(wmgr.createWindow("TaharezLook/ScrollablePane"));
// CEGUI::ImagesetManager::getSingleton().createFromImageFile("ImageForScrollablePane", "GPN-2000-001437.tga");
// CEGUI::DefaultWindow* staticImageInScrollablePane = static_cast<CEGUI::DefaultWindow*>(wmgr.createWindow("TaharezLook/StaticImage", "StaticImageInScrollablePane"));
// staticImageInScrollablePane->setProperty("Image", "set:ImageForScrollablePane image:full_image"); // "full_image" is a default name from CEGUIImageset::Imageset()
// staticImageInScrollablePane->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f),CEGUI:: UDim(0.0f, 0.0f))); // Start in the upper left corner
// staticImageInScrollablePane->setWidth(CEGUI::UDim(2.0f, 0.0f)); // Twice the width of the parent, the ScrollablePane
// staticImageInScrollablePane->setHeight(CEGUI::UDim(2.0f, 0.0f)); // Twice the height of the parent, the ScrollablePane
// scrollablePane->addChildWindow(staticImageInScrollablePane); // Add the image to the // Twice the width of the parent, the ScrollablePane
// CEGUI::Editbox* editboxInScrollablePane = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "EditboxInScrollablePane"));
// editboxInScrollablePane->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(2.1f, 0.0f))); // Start below the image
// editboxInScrollablePane->setWidth(CEGUI::UDim(2.0f, 0.0f));
// editboxInScrollablePane->setHeight(CEGUI::UDim(0.3f, 0.0f));
// scrollablePane->addChildWindow(editboxInScrollablePane);
// sheet->addChildWindow(scrollablePane);
/* MultiLineEditbox */
//CEGUI::MultiLineEditbox* multiLineEditbox = static_cast<CEGUI::MultiLineEditbox*>(wmgr.createWindow("TaharezLook/MultiLineEditbox"));
//multiLineEditbox->setText("MultiLineEditbox value");
//multiLineEditbox->setReadOnly(false);
//multiLineEditbox->setWordWrapping(true);
//CEGUI::String valueMultiLineEditbox = multiLineEditbox->getText(); // Retrieve the text
RTT();
QuitButton();
GraphicsButton();
AudioButton();
MainMenuButton();
ComboBox(evt);
mSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1));
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
CEGUI::System::getSingleton().setGUISheet(sheet);
}
void BasicTutorial7::createFrameListener(void)
{
//BaseApplication::createFrameListener();
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem( pl );
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
//Set initial mouse clipping size
windowResized(mWindow);
//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mRoot->addFrameListener(this);
}
bool BasicTutorial7::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;
if(mShutDown)
return false;
//Need to capture/update each device
mKeyboard->capture();
mMouse->capture();
//need to inject timestamps to CEGUI System
CEGUI::System::getSingleton().injectTimePulse(evt.timeSinceLastFrame);
return true;
//return BaseApplication::frameRenderingQueued(evt);
}
bool BasicTutorial7::keyPressed(const OIS::KeyEvent& arg)
{
CEGUI::System &sys = CEGUI::System::getSingleton();
sys.injectKeyDown(arg.key);
sys.injectChar(arg.text);
return true;
//return BaseApplication::keyPressed(arg);
}
bool BasicTutorial7::keyReleased(const OIS::KeyEvent& arg)
{
CEGUI::System::getSingleton().injectKeyUp(arg.key);
return true;
//return BaseApplication::keyReleased(arg);
}
bool BasicTutorial7::mouseMoved(const OIS::MouseEvent& arg)
{
CEGUI::System &sys = CEGUI::System::getSingleton();
sys.injectMouseMove(arg.state.X.rel, arg.state.Y.rel);
//Scroll wheel
if(arg.state.Z.rel)
sys.injectMouseWheelChange(arg.state.Z.rel / 120.0f);
return true;
//return BaseApplication::mouseMoved(arg);
}
bool BasicTutorial7::mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
{
CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id));
return true;
//return BaseApplication::mousePressed(arg, id);
}
bool BasicTutorial7::mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
{
CEGUI::System::getSingleton().injectMouseButtonUp(convertButton(id));
return true;
//return BaseApplication::mouseReleased(arg, id);
}
bool BasicTutorial7::quitit(const CEGUI::EventArgs& e)
{
mShutDown = true;
return true;
}
bool BasicTutorial7::createRobot(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Robot"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Robot");
ent = mSceneMgr->createEntity(name, "robot.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Robot");
ent = mSceneMgr->createEntity(name, "robot.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -300));
node->attachObject(ent);
node->scale(3,3,3);
return true;
}
bool BasicTutorial7::createNinja(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Ninja"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Ninja");
ent = mSceneMgr->createEntity(name, "ninja.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Ninja");
ent = mSceneMgr->createEntity(name, "ninja.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -300));
node->attachObject(ent);
return true;
}
bool BasicTutorial7::createFighter(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Fighter"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Fighter");
ent = mSceneMgr->createEntity(name, "penguin.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Fighter");
ent = mSceneMgr->createEntity(name, "penguin.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, 010, -400));
node->attachObject(ent);
node->scale(4,4,4);
return true;
}
bool BasicTutorial7::createKnight(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Knight"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Knight");
ent = mSceneMgr->createEntity(name, "jaiqua.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "knight");
ent = mSceneMgr->createEntity(name, "jaiqua.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -030));
node->attachObject(ent);
node->scale(15,15,15);
return true;
}
bool BasicTutorial7::createMage(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Mage"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Mage");
ent = mSceneMgr->createEntity(name, "ogrehead.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Mage");
ent = mSceneMgr->createEntity(name, "ogrehead.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -300));
node->attachObject(ent);
node->scale(4,4,4);
return true;
}
bool BasicTutorial7::createPikeman(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Pike"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Pike");
ent = mSceneMgr->createEntity(name, "fish.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Pike");
ent = mSceneMgr->createEntity(name, "fish.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -300));
node->attachObject(ent);
node->scale(15,15,15);
return true;
}
bool BasicTutorial7::createPriest(const CEGUI::EventArgs& e)
{
if(mSceneMgr->hasEntity("Priest"))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Priest");
ent = mSceneMgr->createEntity(name, "Mech.mesh");
if(mSceneMgr->getEntity(name))
{
mSceneMgr->destroyAllEntities();
}
sprintf(name, "Priest");
ent = mSceneMgr->createEntity(name, "Mech.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, -100, -300));
node->attachObject(ent);
node->scale(6,6,6);
return true;
}
bool BasicTutorial7::ComboBox(const CEGUI::EventArgs& e)
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
objectComboBox = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/Combobox", (CEGUI::utf8*)"CEGUIDemo/Menu");
objectComboBox = static_cast<CEGUI::Combobox*>(wmgr.getWindow("CEGUIDemo/Menu"));
objectComboBox->setReadOnly(true);
CEGUI::ListboxTextItem* itemCombobox = new CEGUI::ListboxTextItem("Fighter", 1);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox = new CEGUI::ListboxTextItem("Knight", 2);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox->setSelected(true);// Select this item
objectComboBox->setText(itemCombobox->getText()); // Copy the item's text into the Editbox
itemCombobox = new CEGUI::ListboxTextItem("Pikeman", 3);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox = new CEGUI::ListboxTextItem("Mage", 4);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox = new CEGUI::ListboxTextItem("Priest", 5);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox = new CEGUI::ListboxTextItem("Mechanic", 6);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
itemCombobox = new CEGUI::ListboxTextItem("Ninja", 7);
itemCombobox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
objectComboBox->addItem(itemCombobox);
objectComboBox->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.5, 0)));
objectComboBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.1f, 0)));
objectComboBox->setText("SelectCharacter");
sheet->addChildWindow(objectComboBox);
//objectComboBox->setAlwaysOnTop(true);
CEGUI::String valueCombobox = objectComboBox->getText(); // Retrieve the displayed text
CEGUI::uint idCombobox = objectComboBox->getSelectedItem()->getID(); // Retrieve the ID of the selected combobox it
objectComboBox->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber(&BasicTutorial7::handleListSelectionChanged, this));
return true;
}
void BasicTutorial7::RTT(void)
{
Ogre::TexturePtr tex = mRoot->getTextureManager()->createManual(
"RTT",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
512,
512,
0,
Ogre::PF_R8G8B8,
Ogre::TU_RENDERTARGET);
Ogre::RenderTexture* rtex = tex->getBuffer()->getRenderTarget();
Ogre::Camera* cam = mSceneMgr->createCamera("RTTCam");
cam->setPosition(100, -100, -400);
cam->lookAt(0, 0, -300);
Ogre::Viewport *v = rtex->addViewport(cam);
v->setOverlaysEnabled(false);
v->setClearEveryFrame(true);
v->setBackgroundColour(Ogre::ColourValue::Black);
CEGUI::Texture &guiTex = mRenderer->createTexture(tex);
CEGUI::Imageset &imgSet =
CEGUI::ImagesetManager::getSingleton().create("RTTImageset", guiTex);
imgSet.defineImage("RTTImage",
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(guiTex.getSize().d_width,
guiTex.getSize().d_height),
CEGUI::Point(0.0f, 0.0f));
CEGUI::Window* si = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "RTTWindow");
si->setSize(CEGUI::UVector2(CEGUI::UDim(0.2f, 0),
CEGUI::UDim(0.2f, 0)));
si->setPosition(CEGUI::UVector2(CEGUI::UDim(0.8f, 0),
CEGUI::UDim(0.0f, 0)));
si->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imgSet.getImage("RTTImage")));
sheet->addChildWindow(si);
}
void BasicTutorial7::QuitButton(void)
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
quit = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/QuitButton");
quit->setText("Exit Game");
quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
sheet->addChildWindow(quit);
quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicTutorial7::quitit, this));
}
void BasicTutorial7::GraphicsButton(void)
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
graph = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/GraphicsBt");
graph->setText("3D Graphics");
graph->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
graph->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0, 0), CEGUI::UDim(0.05, 0)));
sheet->addChildWindow(graph);
graph->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicTutorial7::Graphics, this));
}
bool BasicTutorial7::Graphics(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd2))
{
/*fWnd2->destroy();
sheet->removeChildWindow(fWnd2);
sheet->update(0.1);
fWnd2->update(0.1);
fWnd2->~FrameWindow();*/
fWnd2->destroy();
/*fWnd2->show();
fWnd2->setVisible(false);*/
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
fWnd2 = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindowGraphics" );
fWnd2->setText("3D Graphics Settings");
fWnd2->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.2f, 0)));
fWnd2->setSizingEnabled(false);
fWnd2->setDragMovingEnabled(false);
/*CEGUI::Checkbox* checkbox = (CEGUI::Checkbox*)(wmgr.createWindow("TaharezLook/Checkbox", "CheckBoxSettings"));
checkbox->setSelected( true );
checkbox->setText("Direct3D");
bool valueCheckbox = checkbox->isSelected();
fWnd2->addChildWindow(checkbox);*/
sheet->addChildWindow(fWnd2);
return true;
}
void BasicTutorial7::AudioButton(void)
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
audio = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/AudioBt");
audio->setText("Audio Settings");
audio->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
audio->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0, 0), CEGUI::UDim(0.10, 0)));
sheet->addChildWindow(audio);
audio->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicTutorial7::Audio, this));
}
bool BasicTutorial7::Audio(const CEGUI::EventArgs& e)
{
// if(sheet->isChild(fWnd2) == true)
//{
// /*fWnd2->destroy();
// sheet->removeChildWindow(fWnd2);
// sheet->update(0.1);
// fWnd2->update(0.1);
// fWnd2->~FrameWindow();*/
// fWnd2->destroy();
// /*fWnd2->show();
// fWnd2->setVisible(false);*/
//
//
//}
return true;
}
void BasicTutorial7::MainMenuButton(void)
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
menu = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/MenuBt");
menu->setText("Main Menu");
menu->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
menu->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0, 0), CEGUI::UDim(0.15, 0)));
sheet->addChildWindow(menu);
//menu->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicTutorial7::Audio, this));
}
bool BasicTutorial7::CharacterInfo(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText", "Static");
staticText->setText("Fighters are the fastest and the most\n skillfull warriors of this world,however\n they are known as short range attackers.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
/*staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");*/
staticText->setProperty("TextColours", "tl:ffffffff tr:70000000 bl:ff000000 br:ff000000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo1(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText", "Static1");
staticText->setText("Knights are the agile and\n tankers warriors,however\n they are known as short range attackers.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow1" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo2(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText");
staticText->setText("Pikes are the fastest and the most\n skillfull warriors of this world,however\n they are known as short range attackers.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo3(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText");
staticText->setText("Mages are the most inteligent warriors and the most\n skillfull deadliest for magical\n power and they can attack from large range attackers.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo4(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText");
staticText->setText("Priests have one of the most\n Magical attack power of this world,however\n they can cast the spell from long range attackers.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo5(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText");
staticText->setText("Mechanics are the strongest Tankers\n they have the ability of absorbing\n The enemies power.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::CharacterInfo6(const CEGUI::EventArgs& e)
{
if(sheet->isChild(fWnd) == true && fWnd->isChild(staticText) == true )
{
staticText->destroy();
fWnd->destroy();
}
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
staticText = (CEGUI::DefaultWindow*)wmgr.createWindow("TaharezLook/StaticText");
staticText->setText("Ninjas are the Stealth Killers and the most\n silent and Powerful warriors of this world,however\n they can attack from short and long range.");
// Colours are specified as aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("TextColours", "tl:ffffffff tr:70200000 bl:ff500000 br:ff600000");
staticText->setProperty("VertFormatting", "TopAligned"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "LeftAligned"); // LeftAligned, RightAligned, HorzCentred
staticText->setProperty("FrameColours", "tl:00000000 tr:00000000 bl:00000000 br:00000000");
staticText->setProperty("BackgroundEnabled" ,"false");
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
//staticText->setTooltipText("This is a StaticText widget");
fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "FrameWindow" );
fWnd->setText("Character Information");
fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(0.39, 0), CEGUI::UDim(0.75, 0)));
fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
fWnd->setSizingEnabled(false);
fWnd->setDragMovingEnabled(false);
sheet->addChildWindow(fWnd);
fWnd->addChildWindow(staticText);
return true;
}
bool BasicTutorial7::handleListSelectionChanged(const CEGUI::EventArgs& e)
{
CEGUI::WindowEventArgs wea( static_cast<const CEGUI::WindowEventArgs& >(e));
CEGUI::Combobox* combobox = static_cast<CEGUI::Combobox*>(wea.window);
CEGUI::ListboxItem* selectedItem = combobox->getSelectedItem();
if (!selectedItem)
return false;
switch(selectedItem->getID())
{
case 1:
CharacterInfo(evt);
createFighter(evt);
break;
case 2:
CharacterInfo1(evt);
createKnight(evt);
break;
case 3:
CharacterInfo2(evt);
createPikeman(evt);
break;
case 4:
CharacterInfo3(evt);
createMage(evt);
break;
case 5:
CharacterInfo4(evt);
createPriest(evt);
break;
case 6:
CharacterInfo5(evt);
createRobot(evt);
break;
case 7:
CharacterInfo6(evt);
createNinja(evt);
break;
}
return true;
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
BasicTutorial7 app;
try {
app.go();
} catch( Ogre::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().c_str() << std::endl;
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif
this little part is the one im talking about :
Code: Select all
if(sheet->isChild(fWnd2))
{
/*fWnd2->destroy();
sheet->removeChildWindow(fWnd2);
sheet->update(0.1);
fWnd2->update(0.1);
fWnd2->~FrameWindow();*/
fWnd2->destroy();
/*fWnd2->show();
fWnd2->setVisible(false);*/
}
the header file :
Code: Select all
/*
-----------------------------------------------------------------------------
Filename: BasicTutorial7.h
-----------------------------------------------------------------------------
This source file is generated by the
___ _ __ __ _ _
/___\__ _ _ __ ___ /_\ _ __ _ __/ / /\ \ (_)______ _ _ __ __| |
// // _` | '__/ _ \ //_\\| '_ \| '_ \ \/ \/ / |_ / _` | '__/ _` |
/ \_// (_| | | | __/ / _ \ |_) | |_) \ /\ /| |/ / (_| | | | (_| |
\___/ \__, |_| \___| \_/ \_/ .__/| .__/ \/ \/ |_/___\__,_|_| \__,_|
|___/ |_| |_|
Ogre 1.7.x Application Wizard for VC10 (July 2011)
http://code.google.com/p/ogreappwizards/
-----------------------------------------------------------------------------
*/
#ifndef __BasicTutorial7_h_
#define __BasicTutorial7_h_
#include "BaseApplication.h"
#include <cegui.h>
#include <RendererModules/Ogre/CEGUIOgreRenderer.h>
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#include "../res/resource.h"
#endif
class BasicTutorial7 : public BaseApplication
{
public:
BasicTutorial7(void);
virtual ~BasicTutorial7(void);
protected:
CEGUI::OgreRenderer* mRenderer;
virtual void createScene(void);
virtual void createFrameListener(void);
//Ogre::FrameListener
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
//OIS::KeyListener
virtual bool keyPressed(const OIS::KeyEvent& arg);
virtual bool keyReleased(const OIS::KeyEvent& arg);
//OIS::MouseListener
virtual bool mouseMoved(const OIS::MouseEvent& arg);
virtual bool mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id);
virtual bool mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id);
bool createRobot(const CEGUI::EventArgs& e);
bool createNinja(const CEGUI::EventArgs& e);
bool createFighter(const CEGUI::EventArgs& e);
bool createKnight(const CEGUI::EventArgs& e);
bool createPikeman(const CEGUI::EventArgs& e);
bool createMage(const CEGUI::EventArgs& e);
bool createPriest(const CEGUI::EventArgs& e);
bool quitit(const CEGUI::EventArgs& e);
bool Graphics(const CEGUI::EventArgs& e);
bool Audio(const CEGUI::EventArgs& e);
bool ComboBox(const CEGUI::EventArgs& e);
bool handleListSelectionChanged(const CEGUI::EventArgs& e);
void RTT(void);
void QuitButton(void);
void GraphicsButton(void);
void AudioButton(void);
void MainMenuButton(void);
bool CharacterInfo(const CEGUI::EventArgs& e);
bool CharacterInfo1(const CEGUI::EventArgs& e);
bool CharacterInfo2(const CEGUI::EventArgs& e);
bool CharacterInfo3(const CEGUI::EventArgs& e);
bool CharacterInfo4(const CEGUI::EventArgs& e);
bool CharacterInfo5(const CEGUI::EventArgs& e);
bool CharacterInfo6(const CEGUI::EventArgs& e);
CEGUI::Combobox* objectComboBox;
CEGUI::Window* sheet;
CEGUI::Window* quit;
CEGUI::Window* graph;
CEGUI::Window* audio;
CEGUI::Window* menu;
/*CEGUI::Window* bg;*/
CEGUI::EventArgs evt;
Ogre::SceneNode* node;
CEGUI::DefaultWindow* staticText;
CEGUI::FrameWindow* fWnd;
CEGUI::FrameWindow* fWnd2;
char name[16];
Ogre::Entity* ent;
};
#endif // #ifndef __BasicTutorial7_h_
any help is greatly appreciated!
kind regards,
Romulo Romero