Skip to content
Browse files

Replaced all get_*_instance()-calls with macros

  • Loading branch information...
1 parent 884329a commit 11a238f3d74edab9e84b267e72f1a18d684984fa @Phosfor Phosfor committed
View
6 include/Engine.hpp
@@ -33,7 +33,7 @@ namespace Engine
{
GameApplication &Application() { return GameApplication::get_mutable_instance(); }
void setDimension(string &dimension) { Utils::get_mutable_instance().setDimension(dimension); }
- const float GetElapsed() { return GameApplication::get_const_instance().getElapsed(); }
+ const float GetElapsed() { return gameApplicationConst.getElapsed(); }
/*
Object *MakeObject(const string& entityName)
{
@@ -87,8 +87,8 @@ namespace Engine
return EntityManager::get_mutable_instance().GetCamera(cameraName);
}
*/
- unsigned int GetWidth() { return Systems::GetGraphic().getWindow()->getWidth(); }
- unsigned int GetHeight() { return Systems::GetGraphic().getWindow()->getHeight(); }
+ unsigned int GetWidth() { return graphicSystem.getWindow()->getWidth(); }
+ unsigned int GetHeight() { return graphicSystem.getWindow()->getHeight(); }
template<typename WidgetType>
WidgetType *findWidget(const string &name)
View
10 samples/pong-cpp/main.cpp
@@ -7,14 +7,14 @@ class MenuState : public State
{
public:
void init() {
- Systems::GetGui().loadLayout("Pseudoform.layout");
+ guiSystem.loadLayout("Pseudoform.layout");
World::findWidget<MyGUI::StaticImage>("ButtonPlay")->eventMouseButtonClick =
MyGUI::newDelegate(this, &MenuState::ButtoPlayClicked);
}
void shutdown() {
- Systems::GetGui().unloadLayout("Pseudoform.layout");
+ guiSystem.unloadLayout("Pseudoform.layout");
}
// MyGUI Handlers
@@ -59,10 +59,10 @@ class GameState : public State
int main()
{
- Managers::GetState().push(new(MenuState));
- Managers::GetState().push(new(GameState));
+ stateManager.push(new(MenuState));
+ stateManager.push(new(GameState));
- World::Application().Start();
+ gameApplication.Start();
return 0;
}
View
30 src/Core/GameApplication.cpp
@@ -29,7 +29,7 @@ const float GameApplication::getFPS() const { return floor(mFrameRate+0.5); }
void GameApplication::_init()
{
LOG_NOFORMAT("Systems initialization:\n=======================\n\n");
- Utils::get_mutable_instance().writeTimestamp();
+ utils.writeTimestamp();
BOOST_FOREACH(ISystem &curSystem, mSystemsList)
{
@@ -38,22 +38,22 @@ void GameApplication::_init()
LOG(FORMAT("--------------- Initialization of `%1%` is finished\n", curSystem.toString()));
}
- LOG_NOFORMAT("Finished in: [" + Utils::get_mutable_instance().getTimeDifference() + "]\n\n");
+ LOG_NOFORMAT("Finished in: [" + utils.getTimeDifference() + "]\n\n");
LOG_NOFORMAT("Game initialization:\n====================\n\n");
- Utils::get_mutable_instance().writeTimestamp();
+ utils.writeTimestamp();
}
void GameApplication::Start()
{
mRunning = true;
- Utils::get_mutable_instance().setMediaPath(CONFIG("resources.MediaFolder", string, "Media"));
+ utils.setMediaPath(CONFIG("resources.MediaFolder", string, "Media"));
SIGNAL(Engine::Events::GlobalInitEvent, "Inited", );
- LOG_NOFORMAT("\nFinished in: [" + Utils::get_mutable_instance().getTimeDifference() + "]\n");
+ LOG_NOFORMAT("\nFinished in: [" + utils.getTimeDifference() + "]\n");
LOG_NOFORMAT("\nGame Loop:\n==========\n\n");
- Utils::get_mutable_instance().writeTimestamp();
+ utils.writeTimestamp();
this->_loop();
}
@@ -77,7 +77,7 @@ void GameApplication::_loop()
curSystem.update(mElapsed);
}
SIGNAL(Engine::Events::GlobalUpdateEvent, "Updated", );
- StateManager::get_mutable_instance().update();
+ stateManager.update();
mAccumulator -= mDt;
mDrawn = false;
@@ -89,7 +89,7 @@ void GameApplication::_loop()
}
else
{
- if (!GraphicSystem::get_const_instance().getRoot()->renderOneFrame())
+ if (!graphicSystem.getRoot()->renderOneFrame())
LOG("Something bad happened in the render cycle!");
mDrawn = true;
@@ -101,7 +101,7 @@ void GameApplication::_loop()
void GameApplication::_shutdown()
{
- LOG_NOFORMAT("\nFinished in: [" + Utils::get_mutable_instance().getTimeDifference() + "]\n");
+ LOG_NOFORMAT("\nFinished in: [" + utils.getTimeDifference() + "]\n");
mSystemsList.clear();
}
@@ -119,19 +119,19 @@ void GameApplication::keyPressed(const OIS::KeyEvent &e)
if (e.key == OIS::KC_I)
{
- if (InputSystem::get_mutable_instance().getKeyboard()->isModifierDown(OIS::Keyboard::Ctrl))
+ if (inputSystem.getKeyboard()->isModifierDown(OIS::Keyboard::Ctrl))
{
mStatsVisible = !mStatsVisible;
if (mStatsVisible)
{
- GuiSystem::get_mutable_instance().loadLayout("Statistic.layout");
+ guiSystem.loadLayout("Statistic.layout");
mStatsUpdate = CONNECT0(Engine::Events::GlobalUpdateEvent, "Updated", &GameApplication::showStats);
}
else
{
if (mStatsUpdate.connected()) mStatsUpdate.disconnect();
- GuiSystem::get_mutable_instance().unloadLayout("Statistic.layout");
+ guiSystem.unloadLayout("Statistic.layout");
}
}
}
@@ -144,10 +144,10 @@ void GameApplication::showStats()
using namespace MyGUI;
string fps = boost::lexical_cast<string>(getFPS());
- string batches = boost::lexical_cast<string>(GraphicSystem::get_mutable_instance().getWindow()->getBatchCount());
- string triangles = boost::lexical_cast<string>(GraphicSystem::get_mutable_instance().getWindow()->getTriangleCount());
+ string batches = boost::lexical_cast<string>(graphicSystem.getWindow()->getBatchCount());
+ string triangles = boost::lexical_cast<string>(graphicSystem.getWindow()->getTriangleCount());
- Gui *handle = GuiSystem::get_mutable_instance().handle();
+ Gui *handle = guiSystem.handle();
handle->findWidget<Widget>("fps_statistic")->setCaption("#FFFFFF fps: #ffe1bd" + fps);
handle->findWidget<Widget>("batches_statistic")->setCaption("#FFFFFF batches: #ffe1bd" + batches);
View
16 src/Managers/Entities/Camera.cpp
@@ -2,7 +2,7 @@
Camera::Camera(const string entityName)
{
- Ogre::SceneManager *sceneMgr = GraphicSystem::get_const_instance().getSceneMgr();
+ Ogre::SceneManager *sceneMgr = graphicSystemConst.getSceneMgr();
mEntityName = entityName;
@@ -26,7 +26,7 @@ void Camera::loadFromFile(const string &filename, const string &res)
//Ogre::ResourceGroupManager::getSingleton().declareResource(entMesh, "Mesh", res);
ptree tree_handle;
- read_info(Utils::get_const_instance().getMediaPath() + "Entities/" + filename + "/init.info", tree_handle);
+ read_info(utilsConst.getMediaPath() + "Entities/" + filename + "/init.info", tree_handle);
float fov = tree_handle.get<float>("type_settings.fov", 90);
float nearClip = tree_handle.get<float>("type_settings.nearClip", 1);
@@ -35,7 +35,7 @@ void Camera::loadFromFile(const string &filename, const string &res)
configure(nearClip, farClip, autoAR, fov);
bool attachVP = tree_handle.get<bool>("type_settings.attachVP", true);
if(attachVP)
- GraphicSystem::get_mutable_instance().getViewport()->setCamera(mCamera);
+ graphicSystem.getViewport()->setCamera(mCamera);
string type = tree_handle.get<string>("type_settings.cam_type", "DONT_USE");
if(type == "DONT_USE")
setCameraType(Camera::DONT_USE);
@@ -74,8 +74,8 @@ string Camera::type() { return "camera"; }
void Camera::_loadData() { }
void Camera::update(float elapsed) { }
-#define WIDTH GraphicSystem::get_mutable_instance().getWindow()->getWidth()
-#define HEIGHT GraphicSystem::get_mutable_instance().getWindow()->getHeight()
+#define WIDTH graphicSystem.getWindow()->getWidth()
+#define HEIGHT graphicSystem.getWindow()->getHeight()
void Camera::setCameraType(CameraType type)
{
@@ -113,7 +113,7 @@ void Camera::onUpdated()
{
using namespace sf;
vec3 translation = vec3::ZERO;
- OIS::Keyboard *keyboard = InputSystem::get_mutable_instance().getKeyboard();
+ OIS::Keyboard *keyboard = inputSystem.getKeyboard();
switch(mCameraType)
{
case Camera::FREE:
@@ -130,7 +130,7 @@ void Camera::onUpdated()
else if (keyboard->isKeyDown(OIS::KC_E))
translation.y -= mMove;
- mNode->translate(mNode->getOrientation() * translation * GameApplication::get_const_instance().getElapsed());
+ mNode->translate(mNode->getOrientation() * translation * gameApplicationConst.getElapsed());
break;
case Camera::ATTACHED:
// ...
@@ -165,7 +165,7 @@ void Camera::onKeyPressed(const OIS::KeyEvent &e)
else if (e.key == OIS::KC_E)
translation -= mMove;
- mNode->translate(mNode->getOrientation() * translation * GameApplication::get_const_instance().getElapsed());
+ mNode->translate(mNode->getOrientation() * translation * gameApplicationConst.getElapsed());
break;
case Camera::ATTACHED:
View
4 src/Managers/Entities/Entity.cpp
@@ -101,7 +101,7 @@ void Entity::_declareEntityResources()
{
LOG(FORMAT("Loading new entity `%1%`", mEntityName));
- string entityData = Utils::get_const_instance().getMediaPath() + "Entities/" + mEntityName;
+ string entityData = utilsConst.getMediaPath() + "Entities/" + mEntityName;
if (!boost::filesystem::exists(entityData))
{
@@ -122,7 +122,7 @@ void Entity::_defaultLoader(const string &entityName)
LOG_NOFORMAT("\tDumping information, parsed from file:\n");
ptree tree_handle;
- read_info(Utils::get_const_instance().getMediaPath() + "Entities/" + mEntityName + "/init.info", tree_handle);
+ read_info(utilsConst.getMediaPath() + "Entities/" + mEntityName + "/init.info", tree_handle);
setDrawable( tree_handle.get<bool>("common_settigns.visible", true) );
setName( tree_handle.get<string>("common_settigns.name", mEntityName) );
View
2 src/Managers/Entities/Light.cpp
@@ -5,7 +5,7 @@ Light::Light(const string entityName)
mEntityName = entityName;
_declareEntityResources();
- Ogre::SceneManager *sceneMgr = GraphicSystem::get_const_instance().getSceneMgr();
+ Ogre::SceneManager *sceneMgr = graphicSystemConst.getSceneMgr();
mLight = sceneMgr->createLight("Light:" + entityName);
View
4 src/Managers/Entities/Object.cpp
@@ -15,7 +15,7 @@ Object::Object(const string entityName, const string &entityMesh, const string &
if (Ogre::ResourceGroupManager::getSingletonPtr()->resourceExists(res, entMesh))
{
Ogre::ResourceGroupManager::getSingleton().declareResource(entMesh, "Mesh", res);
- Ogre::SceneManager *sceneMgr = GraphicSystem::get_mutable_instance().getSceneMgr();
+ Ogre::SceneManager *sceneMgr = graphicSystem.getSceneMgr();
mEntity = sceneMgr->createEntity(entityName, entMesh);
mNode = sceneMgr->getRootSceneNode()->createChildSceneNode("Node:" + mEntityName);
@@ -34,7 +34,7 @@ void Object::setImage(const string& imgPath)
Ogre::MaterialPtr textureMat = Ogre::MaterialManager::getSingleton().create("Material:" + mEntityName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
textureMat->getTechnique(0)->getPass(0)->createTextureUnitState(imgPath);
- GraphicSystem::get_mutable_instance().getSceneMgr()->getEntity(mEntityName)->setMaterial(textureMat);
+ graphicSystem.getSceneMgr()->getEntity(mEntityName)->setMaterial(textureMat);
}
string Object::type() { return "object"; }
View
2 src/Managers/LogManager.cpp
@@ -47,7 +47,7 @@ void LogManager::write(const string& message, const string logFile, const string
this->_forceLog(workPath);
string comand = "";
- string time = boost::posix_time::to_simple_string(Utils::get_const_instance().getCurrentTime());
+ string time = boost::posix_time::to_simple_string(utilsConst.getCurrentTime());
if (formatString)
{
View
2 src/Managers/StateManager.cpp
@@ -52,6 +52,6 @@ State *StateManager::pop()
State *StateManager::getActiveState()
{
- if (mActiveState.get() == NULL) LOG_META("There aren't any active state. Maybe, you didn't push one.");
+ if (mActiveState.get() == NULL) LOG_META("There is no active state. Maybe, you didn't push one.");
return mActiveState.get();
}
View
6 src/Systems/GraphicSystem.cpp
@@ -39,7 +39,7 @@ void GraphicSystem::init()
LOG("\t- All plugins are loaded");
- std::vector<std::string> pluginsList = ConfigManager::get_mutable_instance().getListValue("ogre.plugins");
+ std::vector<std::string> pluginsList = configManager.getListValue("ogre.plugins");
BOOST_FOREACH(std::string &plugin, pluginsList)
{
mRoot->loadPlugin(pluginsDir + plugin);
@@ -86,7 +86,7 @@ void GraphicSystem::init()
try
{
- std::vector<std::string> resourcesList = ConfigManager::get_mutable_instance().getListValue("resources");
+ std::vector<std::string> resourcesList = configManager.getListValue("resources");
BOOST_FOREACH(std::string &location, resourcesList)
{
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(location, "FileSystem", "General", true);
@@ -100,7 +100,7 @@ void GraphicSystem::init()
std::cerr << msg << std::endl;
exit (-1);
}
-
+
LOG("\t- All resources are loaded");
}
View
2 src/Systems/GuiSystem.cpp
@@ -19,7 +19,7 @@ void GuiSystem::init()
{
mPlatform = new MyGUI::OgrePlatform();
LOG("\t- Platform object is created");
- mPlatform->initialise(GraphicSystem::get_const_instance().getWindow(), GraphicSystem::get_const_instance().getSceneMgr());
+ mPlatform->initialise(graphicSystemConst.getWindow(), graphicSystemConst.getSceneMgr());
LOG("\t- Platform is initialised");
mGUI = new MyGUI::Gui();
View
16 src/Systems/InputSystem.cpp
@@ -7,35 +7,35 @@ template<> InputSystem* ISingleton<InputSystem>::mInstance = 0;
bool InputSystem::keyPressed(const OIS::KeyEvent &e)
{
SIGNAL(Events::KeyEvent, "KeyPressed", e);
- GuiSystem::get_mutable_instance().handle()->injectKeyPress(MyGUI::KeyCode::Enum(e.key), e.text);
+ guiSystem.handle()->injectKeyPress(MyGUI::KeyCode::Enum(e.key), e.text);
return true;
}
bool InputSystem::keyReleased(const OIS::KeyEvent &e)
{
SIGNAL(Events::KeyEvent, "KeyReleased", e);
- GuiSystem::get_mutable_instance().handle()->injectKeyRelease(MyGUI::KeyCode::Enum(e.key));
+ guiSystem.handle()->injectKeyRelease(MyGUI::KeyCode::Enum(e.key));
return true;
}
bool InputSystem::mouseMoved(const OIS::MouseEvent &e)
{
SIGNAL(Events::MouseMoveEvent, "MouseMoved", e);
- GuiSystem::get_mutable_instance().handle()->injectMouseMove(e.state.X.abs, e.state.Y.abs, e.state.Z.abs);
+ guiSystem.handle()->injectMouseMove(e.state.X.abs, e.state.Y.abs, e.state.Z.abs);
return true;
}
bool InputSystem::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
{
SIGNAL(Events::MouseButtonEvent, "MouseButtonPressed", e, id);
- GuiSystem::get_mutable_instance().handle()->injectMousePress(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
+ guiSystem.handle()->injectMousePress(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
return true;
}
bool InputSystem::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
{
SIGNAL(Events::MouseButtonEvent, "MouseButtonReleased", e, id);
- GuiSystem::get_mutable_instance().handle()->injectMouseRelease(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
+ guiSystem.handle()->injectMouseRelease(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
return true;
}
@@ -91,10 +91,10 @@ InputSystem::~InputSystem()
void InputSystem::init()
{
- GraphicSystem::get_const_instance().getWindow()->getCustomAttribute("WINDOW", &mWindowHandle);
+ graphicSystemConst.getWindow()->getCustomAttribute("WINDOW", &mWindowHandle);
LOG("\t- Got window handle from Ogre");
- Ogre::WindowEventUtilities::addWindowEventListener(GraphicSystem::get_const_instance().getWindow(),this);
+ Ogre::WindowEventUtilities::addWindowEventListener(graphicSystemConst.getWindow(),this);
if( !mInputSystem )
{
@@ -138,7 +138,7 @@ void InputSystem::init()
// Get window size
unsigned int width, height, depth;
int left, top;
- GraphicSystem::get_const_instance().getWindow()->getMetrics(width, height, depth, left, top);
+ graphicSystemConst.getWindow()->getMetrics(width, height, depth, left, top);
this->setWindowExtents(width, height);
LOG("\t- Window size have been appeared for input region");

0 comments on commit 11a238f

Please sign in to comment.
Something went wrong with that request. Please try again.