Revision: 2465 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2465&view=rev Author: rorthomas Date: 2012-03-15 17:10:21 +0000 (Thu, 15 Mar 2012) Log Message: ----------- refactored singleton method
Modified Paths: -------------- trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gfx/camera/CameraBehaviorFree.cpp trunk/source/main/gfx/camera/CameraManager.cpp trunk/source/main/gui/Console.h trunk/source/main/gui/gui_manager.cpp trunk/source/main/gui/gui_menu.cpp trunk/source/main/physics/BeamFactory.cpp trunk/source/main/physics/input_output/SerializedRig.cpp trunk/source/main/scripting/GameScript.cpp trunk/source/main/scripting/ScriptEngine.cpp trunk/source/main/utils/Singleton.h Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -1139,7 +1139,7 @@ netChat = ChatSystemFactory::getSingleton().createLocal(colourNum); #ifdef USE_MYGUI - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) { c->setVisible(true); @@ -1924,7 +1924,7 @@ #ifdef USE_MYGUI if (INPUTENGINE.getEventBoolValueBounce(EV_COMMON_ENTER_CHATMODE, 0.5f) && !hidegui) { - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) { INPUTENGINE.resetKeys(); @@ -5623,7 +5623,7 @@ Beam *curr_truck = BeamFactory::getSingleton().getCurrentTruck(); #ifdef USE_MYGUI - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) c->setVisible(!visible); #endif // USE_MYGUI Modified: trunk/source/main/gfx/camera/CameraBehaviorFree.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gfx/camera/CameraBehaviorFree.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -37,6 +37,10 @@ LOG("entering free camera mode"); CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("free camera"), "camera_go.png", 3000, false); + +#ifdef USE_MYGUI + MyGUI::PointerManager::getInstance().setVisible(false); +#endif // USE_MYGUI } void CameraBehaviorFree::deactivate() @@ -49,11 +53,13 @@ CONSOLE_PUTMESSAGE(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("normal camera"), "camera.png", 3000, false); +#ifdef USE_MYGUI + MyGUI::PointerManager::getInstance().setVisible(true); +#endif // USE_MYGUI } void CameraBehaviorFree::update(float dt) { - // this is a workaround for the free camera mode :) Real mMoveScale = 0.1; Ogre::Degree mRotScale(0.1f); Ogre::Degree mRotX(0); @@ -123,17 +129,10 @@ const OIS::MouseState ms = _arg.state; Camera *cam = CameraManager::getSingleton().getCamera(); - if(ms.buttonDown(OIS::MB_Right)) - { - cam->yaw(Degree(-(float)ms.X.rel * 0.13f)); - cam->pitch(Degree(-(float)ms.Y.rel * 0.13f)); -#ifdef USE_MYGUI - MyGUI::PointerManager::getInstance().setPointer("hand"); -#endif // USE_MYGUI - return true; - } + cam->yaw(Degree(-(float)ms.X.rel * 0.13f)); + cam->pitch(Degree(-(float)ms.Y.rel * 0.13f)); - return false; + return true; } bool CameraBehaviorFree::mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id) Modified: trunk/source/main/gfx/camera/CameraManager.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraManager.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -72,6 +72,7 @@ //createGlobalBehaviors(); currentBehavior = new CameraBehaviorFree(); //globalBehaviors[CAMBEHAVIOR_FREE]; + currentBehavior->activate(); } CameraManager::~CameraManager() @@ -118,7 +119,7 @@ } else { - OverlayWrapper *ow = OverlayWrapper::getInstancePtrNoCreation(); + OverlayWrapper *ow = OverlayWrapper::getSingletonPtrNoCreation(); if (cameramode==CAMERA_INT) { //end of internal cam Modified: trunk/source/main/gui/Console.h =================================================================== --- trunk/source/main/gui/Console.h 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gui/Console.h 2012-03-15 17:10:21 UTC (rev 2465) @@ -20,8 +20,8 @@ // this must be outside of the other macro #ifdef USE_MYGUI -# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) Console::getSingleton().putMessage(a,b,c,d,e,f) -# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) Console::getSingleton().putMessage(a,b,c) +# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c,d,e,f); } +# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c); } #else # define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) # define CONSOLE_PUTMESSAGE_SHORT(a,b,c) Modified: trunk/source/main/gui/gui_manager.cpp =================================================================== --- trunk/source/main/gui/gui_manager.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gui/gui_manager.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -118,7 +118,7 @@ //MyGUI::PluginManager::getInstance().loadPlugin("Plugin_BerkeliumWidget.dll"); MyGUI::PointerManager::getInstance().setVisible(true); - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) c->resized(); } @@ -169,7 +169,7 @@ BeamFactory *bf = BeamFactory::getSingletonPtr(); if(bf) bf->windowResized(); - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) c->resized(); } Modified: trunk/source/main/gui/gui_menu.cpp =================================================================== --- trunk/source/main/gui/gui_menu.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/gui/gui_menu.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -364,7 +364,7 @@ mefl->shutdown_final(); } else if(miname == _L("Show Console")) { - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) c->setVisible(!c->getVisible()); } // the debug menu Modified: trunk/source/main/physics/BeamFactory.cpp =================================================================== --- trunk/source/main/physics/BeamFactory.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/physics/BeamFactory.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -200,7 +200,7 @@ Ogre::UTFString username = ChatSystem::getColouredName(*c); Ogre::UTFString message = username + ChatSystem::commandColour + _L(" spawned a new vehicle: ") + ChatSystem::normalColour + treg->name; #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if (console) console->putMessage(Console::CONSOLE_MSGTYPE_NETWORK, Console::CONSOLE_VEHILCE_ADD, message, "car_add.png"); #endif // USE_MYGUI } Modified: trunk/source/main/physics/input_output/SerializedRig.cpp =================================================================== --- trunk/source/main/physics/input_output/SerializedRig.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/physics/input_output/SerializedRig.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -439,7 +439,7 @@ if(ds.isNull() || !ds->isReadable()) { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (unable to open file): " + filename + " : " + errorStr, "error.png", 30000, true); #endif // USE_MYGUI parser_warning(c, "Can't open truck file '"+filename+"'", PARSER_FATAL_ERROR); @@ -1383,7 +1383,7 @@ if (id != free_node) { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (lost sync in nodes numbers): " + filename, "error.png", 30000, true); #endif // USE_MYGUI @@ -2041,7 +2041,7 @@ if ( sin == -1.0f || din == -1.0f || psin == -1.0f || pdin == -1.0f || sout == -1.0f || dout == -1.0f || psout == -1.0f || pdout == -1.0f || sbound == -1.0f || lbound == -1.0f || precomp == -1.0f) { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (Wrong values in shocks2 section): " + filename, "error.png", 30000, true); #endif // USE_MYGUI @@ -2277,7 +2277,7 @@ if (id1>=free_node || id2>=free_node) { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (unknown node number in animators section): " + filename, "error.png", 30000, true); #endif // USE_MYGUI @@ -2640,7 +2640,7 @@ { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (Material not found! Try to ensure that tracks/transred exists and retry): " + filename, "error.png", 30000, true); #endif // USE_MYGUI @@ -5199,7 +5199,7 @@ { #ifdef USE_MYGUI - Console *console = Console::getInstancePtrNoCreation(); + Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, "unable to load vehicle (Material '"+String(texname)+"' missing!): " + filename, "error.png", 30000, true); #endif // USE_MYGUI Modified: trunk/source/main/scripting/GameScript.cpp =================================================================== --- trunk/source/main/scripting/GameScript.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/scripting/GameScript.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -687,7 +687,7 @@ LOG("online API result: " + result); #ifdef USE_MYGUI - Console *con = Console::getInstancePtrNoCreation(); + Console *con = Console::getSingletonPtrNoCreation(); if(con) con->putMessage(Console::CONSOLE_MSGTYPE_HIGHSCORE, Console::CONSOLE_SYSTEM_NOTICE, ANSI_TO_UTF(result)); #endif // USE_MYGUI @@ -717,7 +717,7 @@ result = "asynchronous"; #ifdef USE_MYGUI - Console *con = Console::getInstancePtrNoCreation(); + Console *con = Console::getSingletonPtrNoCreation(); if(con) con->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("using Online API..."), "information.png", 2000); #endif // USE_MYGUI Modified: trunk/source/main/scripting/ScriptEngine.cpp =================================================================== --- trunk/source/main/scripting/ScriptEngine.cpp 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/scripting/ScriptEngine.cpp 2012-03-15 17:10:21 UTC (rev 2465) @@ -121,7 +121,7 @@ #endif // OGRE_VERSION { #ifdef USE_MYGUI - Console *c = Console::getInstancePtrNoCreation(); + Console *c = Console::getSingletonPtrNoCreation(); if(c) c->putMessage(Console::CONSOLE_MSGTYPE_SCRIPT, Console::CONSOLE_LOGMESSAGE_SCRIPT, message, "page_white_code.png"); #endif // USE_MYGUI } Modified: trunk/source/main/utils/Singleton.h =================================================================== --- trunk/source/main/utils/Singleton.h 2012-03-15 16:27:33 UTC (rev 2464) +++ trunk/source/main/utils/Singleton.h 2012-03-15 17:10:21 UTC (rev 2465) @@ -48,7 +48,7 @@ if (!_instance) _instance = new T; return _instance; } - inline static T* getInstancePtrNoCreation() + inline static T* getSingletonPtrNoCreation() { return _instance; } @@ -83,7 +83,7 @@ MYASSERT(_instance); return _instance; } - inline static T* getInstancePtrNoCreation() + inline static T* getSingletonPtrNoCreation() { return _instance; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel