How to create loading screen using QuickGUI ?

kingdranix

08-11-2007 09:01:03

I modified the ExampleLoadingBar.h to use QuickGUI.

I'm not really sure how to create a loading screen using QuickGUI. It seems that the font is become small or another font type is used when I did a load screen using QuickGUI.

If I use the default overlay to render the loading screen, the font looks normal.

Here is the code when I'm using QuickGUI to render the loading screen.
void CGameManager::InitResources()
{
QuickGUI::registerScriptParser();
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("quickgui");
m_GUIManager = new QuickGUI::GUIManager(m_Camera->getViewport());
QuickGUI::SkinSetManager::getSingleton().loadSkin("qgui","quickgui");
m_GUIManager->setSceneManager(m_SceneManager);
m_Sheet = m_GUIManager->getDefaultSheet();
m_GUIManager->setActiveSheet(m_Sheet);
m_LoadBar = new CLoadingBar(m_GUIManager);
m_LoadBar->start(CGameApp::GetSingleton()->GetRenderWindow(), 1, 1, 0.5);
}

void CGameManager::InitGame()
{
SAFE_CREATE(m_StateManager, CStateManager);
m_StateManager->AddState(new CMenuTest(m_GUIManager, m_StateManager));
m_StateManager->AddState(new CGameOne(m_StateManager));
m_StateManager->SetState("MenuTest");
m_LoadBar->finish();
SAFE_DELETE(m_LoadBar);
}


Here's the modified code in the ExampleLoadingBar.h
void CLoadingBar::start(Ogre::RenderWindow* window, unsigned short numGroupsInit,
unsigned short numGroupsLoad, Ogre::Real initProportion)
{
mWindow = window;
mNumGroupsInit = numGroupsInit;
mNumGroupsLoad = numGroupsLoad;
mInitProportion = initProportion;
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");

if(m_GUIManager)
{
QuickGUI::Sheet *mSheet = m_GUIManager->getActiveSheet();
m_LoadBar = mSheet->createProgressBar();
m_LoadBar->setDimensions(QuickGUI::Rect(mWindow->getWidth()*0.5,mWindow->getHeight()*0.5,160,18));
m_LoadBar->setInitialPixelOffset(0);
m_LoadBarDescription = mSheet->createLabel();
m_LoadBarDescription->setPosition(440,315);
m_LoadBarDescription->setTexture("");
m_LoadBarDescription->setText("");
m_LoadBarDescription->appearOverWidget(m_LoadBar);
m_LoadBarComment = mSheet->createLabel();
m_LoadBarComment->setPosition(440,415);
m_LoadBarComment->setTexture("");
m_LoadBarComment->setText("");
m_LoadBarComment->appearOverWidget(m_LoadBar);
mProgressBarMaxSize = 160;
}
else
{
Ogre::OverlayManager& omgr = Ogre::OverlayManager::getSingleton();
mLoadOverlay = (Ogre::Overlay*)omgr.getByName("Core/LoadOverlay");
mLoadOverlay->show();
mLoadingBarElement = omgr.getOverlayElement("Core/LoadPanel/Bar/Progress");
mLoadingCommentElement = omgr.getOverlayElement("Core/LoadPanel/Comment");
mLoadingDescriptionElement = omgr.getOverlayElement("Core/LoadPanel/Description");

Ogre::OverlayElement* barContainer = omgr.getOverlayElement("Core/LoadPanel/Bar");
mProgressBarMaxSize = barContainer->getWidth();
mLoadingBarElement->setWidth(0);
}
Ogre::ResourceGroupManager::getSingleton().addResourceGroupListener(this);
}


Is there anything that I missed or shouldn't be doing? The problem here is the fonts changed other than that, everything works normally.

kungfoomasta

08-11-2007 17:25:12

I don't see anything wrong from the initial read..

I don't have the definitions for "Core/LoadPanel/Comment" off hand, but my guess is that the font being used is stretched to fit a certain height. Ogre::TextAreaOverlayElement allows the user to set the character height, which will scale the used font. QuickGUI doesn't do any scaling, so you will need to use a font with glyph dimensions appropriate for your use.

I believe Ogre has a default font using the BlueHighway.ttf file. You can modify the *.fontdef and add a bigger font size, or you can create a separate *.fontdef and declare/use the font from that.

kingdranix

09-11-2007 12:55:22

Thanks for helping me again kungfoomasta. I just realized that I was using the Ogre's BlueHighway font.

However, I find it strange that the font would change to QuickGUI's acmesa font if I call initialiseResourceGroup("quickgui"); before initialiseAllResourceGroups(); . Is there a way to set the default font for all the sheets? Right now I need to set the fonts for each individual sheet I created. I tried mSheet->setDefaultFont("BlueHighway"); and it don't work or compile.

kungfoomasta

09-11-2007 17:27:22

There isn't any current way to set the font of all widgets. If you're using the latest version, you'll want to call Sheet::setFont(...). setDefaultFont has been removed, and all widgets have the setFont function. All widgets will use the same font as their parent on creation. Additionally, you can make the call recursive, to set all existing child fonts.

The reason for the behavior of using acmesa font is that Sheets do not have a parent, but need a default font on creation. What I do is grab the first available font. The "quickgui" resource group must contain some fonts, which are loaded as ogre resources for use.