Hi All,
In my Android Device the initialize stage shows black screen that's not very nice to see.
So I want to create a overlay page before locateResources() and initialiseAllResourceGroups() in Android System.
But how to show a loading page before initialiseAllResourceGroups(), and what specific ResourceGroup I need to initialize in Android system?
My setup: Ogre 1.10.2 on Android 4.4.2
Thanks in advance.
Create Loading Page before initialiseAllResourceGroups
-
- Halfling
- Posts: 77
- Joined: Wed Feb 01, 2017 4:02 pm
- x 1
-
- OGRE Team Member
- Posts: 1995
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1075
- Contact:
-
- Halfling
- Posts: 77
- Joined: Wed Feb 01, 2017 4:02 pm
- x 1
Re: Create Loading Page before initialiseAllResourceGroups
Thank you for advance.
This way it can shows a loadingbar with mouse, it's nice.
But I want to get a picture to mask the black screen in the beginning when OGRE system start.
Is that anything to just show a picture layer?
This way it can shows a loadingbar with mouse, it's nice.
But I want to get a picture to mask the black screen in the beginning when OGRE system start.
Is that anything to just show a picture layer?
-
- OGRE Team Member
- Posts: 1995
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1075
- Contact:
Re: Create Loading Page before initialiseAllResourceGroups
there is no predefined component for that. However you can take a look how the trays system sets its background here:
https://github.com/OGRECave/ogre/blob/m ... .cpp#L1160
https://github.com/OGRECave/ogre/blob/m ... .cpp#L1160
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: Create Loading Page before initialiseAllResourceGroups
Hi,
you can derive from Ogre::ResourceGroupListener and override the corresponding methods. I rotated e.g. a picture and printed text while loading the resources.
Code.h:
Code.cpp
Regards
Lax
you can derive from Ogre::ResourceGroupListener and override the corresponding methods. I rotated e.g. a picture and printed text while loading the resources.
Code.h:
Code: Select all
class EXPORTED EngineResourceListener : public Ogre::ResourceGroupListener
{
public:
EngineResourceListener(Ogre::RenderWindow* renderWindow);
~EngineResourceListener();
void showLoadingBar(unsigned int numGroupsInit = 1, unsigned int numGroupsLoad = 1, Ogre::Real initProportion = 0.7);
void hideLoadingBar(void);
virtual void resourceGroupScriptingStarted(const Ogre::String& groupName, size_t scriptCount) override;
virtual void scriptParseStarted(const Ogre::String& scriptName, bool& skipThisScript) override;
virtual void scriptParseEnded(const Ogre::String& scriptName, bool skipped) override;
virtual void resourceGroupScriptingEnded(const Ogre::String& groupName) override;
virtual void resourceGroupLoadStarted(const Ogre::String& groupName, size_t resourceCount) override;
virtual void resourceLoadStarted(const Ogre::ResourcePtr& resource) override;
virtual void resourceLoadEnded() override;
virtual void worldGeometryStageStarted(const Ogre::String& description) override;
virtual void worldGeometryStageEnded() override;
virtual void resourceGroupLoadEnded(const Ogre::String& groupName) override;
private:
Ogre::RenderWindow* renderWindow;
Ogre::Real groupInitProportion;
Ogre::Real groupLoadProportion;
Ogre::Real loadInc;
MyGUI::ImageBox* backgroundImage;
MyGUI::ImageBox* rotatingImage;
MyGUI::RotatingSkin* rotatingSkin;
};
Code: Select all
EngineResourceListener::EngineResourceListener(Ogre::RenderWindow* renderWindow)
: renderWindow(renderWindow),
groupInitProportion(0.0f),
groupLoadProportion(0.0f),
loadInc(0.0f)
{
this->backgroundImage = MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("RotatingSkin", MyGUI::IntCoord(0, 0, renderWindow->getWidth(), renderWindow->getHeight()),
MyGUI::Align::Default, "Overlapped");
this->backgroundImage->setImageTexture("BackgroundShadeBlue.png");
this->backgroundImage->setVisible(false);
MyGUI::EditPtr actionLabel = MyGUI::Gui::getInstancePtr()->createWidgetReal<MyGUI::EditBox>("EditBoxEmpty", 0.4f, 0.4f, 0.3f, 0.05f, MyGUI::Align::Default, "Main", "ActionLabel");
actionLabel->setVisible(false);
// actionLabel->setColour(MyGUI::Colour::White);
actionLabel->setEditStatic(true);
actionLabel->setFontHeight(20);
// actionLabel->setTextShadow(true);
MyGUI::EditPtr progressLabel = MyGUI::Gui::getInstancePtr()->createWidgetReal<MyGUI::EditBox>("EditBoxEmpty", 0.05f, 0.95f, 0.3f, 0.05f, MyGUI::Align::Default, "Main", "ProgressLabel");
progressLabel->setVisible(false);
// progressLabel->setColour(MyGUI::Colour::White);
progressLabel->setEditStatic(true);
progressLabel->setFontHeight(20);
// actionLabel->setTextShadow(true);
int logoWidth = static_cast<int>(260.0f * 0.5f);
int logoHeight = static_cast<int>(160.0f * 0.5);
this->rotatingImage = MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("RotatingSkin",
MyGUI::IntCoord(renderWindow->getWidth() - logoWidth - 20, renderWindow->getHeight() - logoHeight - 20, logoWidth, logoHeight), MyGUI::Align::Default, "Overlapped");
this->rotatingImage->setImageTexture("NOWA_Logo3.png");
this->rotatingImage->setVisible(false);
// this->rotatingImage->setAlpha(1.0f);
MyGUI::ISubWidget* main = this->rotatingImage->getSubWidgetMain();
if (nullptr == main)
{
Ogre::LogManager::getSingleton().logMessage(Ogre::LML_CRITICAL, "[EngineResourceListener] Error: Could not get MyGUI object. Check the resources.cfg, whether 'FileSystem=../../media/MyGUI_Media' is missing!");
throw Ogre::Exception(Ogre::Exception::ERR_ITEM_NOT_FOUND, "[EngineResourceListener] Error: Could not get MyGUI object. Check the resources.cfg, whether 'FileSystem=../../media/MyGUI_Media' is missing!\n", "NOWA");
}
this->rotatingSkin = main->castType<MyGUI::RotatingSkin>();
}
EngineResourceListener::~EngineResourceListener()
{
MyGUI::Gui::getInstancePtr()->destroyWidget(this->backgroundImage);
MyGUI::Gui::getInstancePtr()->destroyWidget(this->rotatingImage);
MyGUI::Gui::getInstancePtr()->destroyWidget(MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel"));
MyGUI::Gui::getInstancePtr()->destroyWidget(MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ProgressLabel"));
}
void EngineResourceListener::showLoadingBar(unsigned int numGroupsInit, unsigned int numGroupsLoad, Ogre::Real initProportion)
{
this->backgroundImage->setVisible(true);
this->rotatingImage->setVisible(true);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setVisible(true);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ProgressLabel")->setVisible(true);
Ogre::ResourceGroupManager::getSingleton().addResourceGroupListener(this);
MyGUI::PointerManager::getInstancePtr()->setVisible(false);
// calculate the proportion of job required to init/load one group
if (numGroupsInit == 0 && numGroupsLoad != 0)
{
this->groupInitProportion = 0;
this->groupLoadProportion = 1;
}
else if (numGroupsLoad == 0 && numGroupsInit != 0)
{
this->groupLoadProportion = 0;
if (numGroupsInit != 0)
{
this->groupInitProportion = 1;
}
}
else if (numGroupsInit == 0 && numGroupsLoad == 0)
{
this->groupInitProportion = 0;
this->groupLoadProportion = 0;
}
else
{
this->groupInitProportion = initProportion / numGroupsInit;
this->groupLoadProportion = (1 - initProportion) / numGroupsLoad;
}
}
void EngineResourceListener::hideLoadingBar(void)
{
MyGUI::PointerManager::getInstancePtr()->setVisible(true);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setVisible(false);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ProgressLabel")->setVisible(false);
this->backgroundImage->setVisible(false);
this->rotatingImage->setVisible(false);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setVisible(false);
Ogre::ResourceGroupManager::getSingleton().removeResourceGroupListener(this);
// here delete everything
}
void EngineResourceListener::resourceGroupScriptingStarted(const Ogre::String& groupName, size_t scriptCount)
{
this->loadInc = this->groupInitProportion / scriptCount;
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setCaptionWithReplacing("#00ff00#{Finished}!");
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::scriptParseStarted(const Ogre::String& scriptName, bool& skipThisScript)
{
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setCaptionWithReplacing("#00ff00#{Parsing}: " + scriptName);
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::scriptParseEnded(const Ogre::String& scriptName, bool skipped)
{
this->rotatingSkin->setAngle(this->rotatingSkin->getAngle() + this->loadInc * Ogre::Math::TWO_PI);
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ProgressLabel")->setCaptionWithReplacing("#00ff00" +
Ogre::StringConverter::toString(static_cast<int>(this->rotatingSkin->getAngle() / Ogre::Math::TWO_PI * 100.0f)) + " %");
// this->rotatingImage->setAlpha(0.2f);
this->rotatingSkin->setCenter(MyGUI::IntPoint(this->rotatingSkin->getWidth() / 2, this->rotatingSkin->getHeight() / 2));
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::resourceGroupScriptingEnded(const Ogre::String& groupName)
{
}
void EngineResourceListener::resourceGroupLoadStarted(const Ogre::String& groupName, size_t resourceCount)
{
this->loadInc = this->groupLoadProportion / resourceCount;
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setCaptionWithReplacing("#00ff00#{Loading}...");
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::resourceLoadStarted(const Ogre::ResourcePtr& resource)
{
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setCaptionWithReplacing("#00ff00#{Loading}: " + resource->getName());
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::resourceLoadEnded()
{
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::worldGeometryStageStarted(const Ogre::String& description)
{
MyGUI::Gui::getInstancePtr()->findWidget<MyGUI::EditBox>("ActionLabel")->setCaptionWithReplacing("#00ff00" + description);
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::worldGeometryStageEnded()
{
// Attention: No more available, will that work without??
// renderWindow->update();
}
void EngineResourceListener::resourceGroupLoadEnded(const Ogre::String& groupName)
{
}
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62