CProgress(IrrlichtDevice *pDevice) { m_pDevice=pDevice; m_pDriver=pDevice->getVideoDriver(); m_pGuienv=pDevice->getGUIEnvironment(); //let's add a "please stand by" image filling the complete window / screen core::dimension2du cScreenSize=m_pDevice->getVideoDriver()->getScreenSize(); m_pImg=m_pGuienv->addImage(core::rect<s32>(0,0,cScreenSize.Width,cScreenSize.Height)); m_pImg->setScaleImage(true); m_pImg->setImage(m_pDriver->getTexture(DATADIR "/textures/standby.png")); m_pBar=new CProgressBar(m_pGuienv,core::rect<s32>(core::position2di(cScreenSize.Width/2-150,cScreenSize.Height-60),core::dimension2di(300,30)),-1,NULL); m_pText=m_pGuienv->addStaticText(L"",core::rect<s32>(core::position2di(cScreenSize.Width/2-150,cScreenSize.Height-60),core::dimension2di(300,30)),true); m_pText->setBackgroundColor(video::SColor(192,192,192,192)); m_pText->setDrawBackground(true); m_pText->setTextAlignment(gui::EGUIA_CENTER,gui::EGUIA_CENTER); ode::CIrrOdeManager::getSharedInstance()->getIrrThread()->getInputQueue()->addEventListener(this); }
virtual bool onEvent(ode::IIrrOdeEvent *pEvent) { bool bRet=false; if (pEvent->getType()==ode::eIrrOdeEventProgress) { ode::CIrrOdeEventProgress *pEvt=reinterpret_cast<ode::CIrrOdeEventProgress *>(pEvent); wchar_t s[0xFF]; if (pEvt->getCount()==0) { swprintf(s,0xFF,L"Loading scene..."); m_pText->setText(s); } else { swprintf(s,0xFF,L"Physics Initialization: %i / %i",pEvt->getCurrent(),pEvt->getCount()); m_pText->setText(s); m_pBar->setProgress(100*pEvt->getCurrent()/pEvt->getCount()); } m_pDriver->beginScene(true, true, video::SColor(0,200,200,200)); m_pGuienv->drawAll(); m_pDriver->endScene(); } return bRet; }
/** Init the message text, do linebreak as required. */ void init() { const GUIEngine::BoxRenderParams &brp = GUIEngine::getSkin()->getBoxRenderParams(m_render_type); const unsigned width = irr_driver->getActualScreenSize().Width; const unsigned height = irr_driver->getActualScreenSize().Height; const unsigned max_width = width - (brp.m_left_border + brp.m_right_border); m_text = GUIEngine::getGUIEnv()->addStaticText(m_message.c_str(), core::recti(0, 0, max_width, height)); m_text->setRightToLeft(translations->isRTLText(m_message)); core::dimension2du dim(m_text->getTextWidth(), m_text->getTextHeight()); dim.Width += brp.m_left_border + brp.m_right_border; int x = (width - dim.Width) / 2; int y = height - int(1.5f * dim.Height); g_area = irr::core::recti(x, y, x + dim.Width, y + dim.Height); m_text->setRelativePosition(g_area); m_text->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER); m_text->grab(); m_text->remove(); }
// ------------------------------------------------------------------------ ~Message() { assert(m_text != NULL); m_text->drop(); }
/** Draw the message. */ void draw() { assert(m_text != NULL); m_text->draw(); }
virtual ~CProgress() { m_pImg->remove(); m_pText->remove(); m_pBar->remove(); ode::CIrrOdeManager::getSharedInstance()->getIrrThread()->getInputQueue()->removeEventListener(this); }