Revision: 1431
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1431&view=rev
Author:   aperion
Date:     2010-07-11 08:22:46 +0000 (Sun, 11 Jul 2010)

Log Message:
-----------
Restore previous time advancement functionality, added a display to show what 
the tiem was changed to.

Modified Paths:
--------------
    trunk/source/main/RoRFrameListener.cpp
    trunk/source/main/SkyManager.cpp
    trunk/source/main/SkyManager.h

Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp      2010-07-08 15:40:58 UTC (rev 
1430)
+++ trunk/source/main/RoRFrameListener.cpp      2010-07-11 08:22:46 UTC (rev 
1431)
@@ -3946,22 +3946,43 @@
                        camDist=20;
                }
 #ifdef USE_CAELUM
-               if (INPUTENGINE.getEventBoolValue(EV_CAELUM_INCREASE_TIME) && 
SkyManager::getSingletonPtr())
+               if (SETTINGS.getSetting("Sky effects")=="Caelum (best looking, 
slower)")
                {
-                       SkyManager::getSingleton().setTimeFactor(2.0f);
+                       Ogre::Real time_factor = 1000.0f;
+                       Ogre::Real multiplier = 10;
+                       bool update_time = false;
+                                       
+                       if 
(INPUTENGINE.getEventBoolValue(EV_CAELUM_INCREASE_TIME) && 
SkyManager::getSingletonPtr())
+                       {
+                               update_time = true;
+                       }
+                       else if 
(INPUTENGINE.getEventBoolValue(EV_CAELUM_INCREASE_TIME_FAST) && 
SkyManager::getSingletonPtr())
+                       {
+                               time_factor *= multiplier;
+                               update_time = true;
+                       }
+                       else if 
(INPUTENGINE.getEventBoolValue(EV_CAELUM_DECREASE_TIME) && 
SkyManager::getSingletonPtr())
+                       {
+                               time_factor = -time_factor;
+                               update_time = true;
+                       }
+                       else if 
(INPUTENGINE.getEventBoolValue(EV_CAELUM_DECREASE_TIME_FAST) && 
SkyManager::getSingletonPtr())
+                       {
+                               time_factor *= -multiplier;
+                               update_time = true;
+                       }
+                       else
+                       {
+                               time_factor = 1.0f;
+                               update_time = 
SkyManager::getSingleton().getTimeFactor() != 1.0f;                       
+                       }
+                       
+                       if( update_time )
+                       {
+                               
SkyManager::getSingleton().setTimeFactor(time_factor);
+                               if(ow) ow->flashMessage(Ogre::String("Time set 
to ") + SkyManager::getSingleton().getPrettyTime(), 2.0);
+                       }
                }
-               if (INPUTENGINE.getEventBoolValue(EV_CAELUM_INCREASE_TIME_FAST) 
&& SkyManager::getSingletonPtr())
-               {
-                       SkyManager::getSingleton().setTimeFactor(20.0f);
-               }
-               if (INPUTENGINE.getEventBoolValue(EV_CAELUM_DECREASE_TIME) && 
SkyManager::getSingletonPtr())
-               {
-                       SkyManager::getSingleton().setTimeFactor(-2.0f);
-               }
-               if (INPUTENGINE.getEventBoolValue(EV_CAELUM_DECREASE_TIME_FAST) 
&& SkyManager::getSingletonPtr())
-               {
-                       SkyManager::getSingleton().setTimeFactor(-20.0f);
-               }
 #endif //CAELUM
                if 
(INPUTENGINE.getEventBoolValueBounce(EV_COMMON_TOGGLE_RENDER_MODE, 0.5f))
                {
@@ -4109,8 +4130,9 @@
                        NETCHAT.toggleMode(this);
                }
 
-               if 
(INPUTENGINE.getEventBoolValueBounce(EV_COMMON_ENTER_OR_EXIT_TRUCK, 0.5f) && 
!chatting)
+               if 
(INPUTENGINE.getEventBoolValue(EV_COMMON_ENTER_OR_EXIT_TRUCK) && !chatting && 
mTimeUntilNextToggle <= 0)
                {
+                       mTimeUntilNextToggle = 0.5; //Some delay before trying 
to re-enter(exit) truck
                        //perso in/out
                        if (current_truck==-1)
                        {
@@ -4144,6 +4166,7 @@
                        } else
                        {
                                
trucks[current_truck]->brake=trucks[current_truck]->brakeforce*0.66;
+                               mTimeUntilNextToggle = 0.0; //No delay in this 
case: the truck must brake like braking normally
                        }
                }
 

Modified: trunk/source/main/SkyManager.cpp
===================================================================
--- trunk/source/main/SkyManager.cpp    2010-07-08 15:40:58 UTC (rev 1430)
+++ trunk/source/main/SkyManager.cpp    2010-07-11 08:22:46 UTC (rev 1431)
@@ -65,10 +65,28 @@
        CaelumPlugin::getSingleton().loadCaelumSystemFromScript (mCaelumSystem, 
script);
 }
 
-void SkyManager::setTimeFactor(double factor)
+void SkyManager::setTimeFactor(LongReal factor)
 {
-    mCaelumSpeedFactor += factor;
-    mCaelumSystem->getUniversalClock()->setTimeScale (mCaelumSpeedFactor);
+    mCaelumSystem->getUniversalClock()->setTimeScale (factor);
 }
 
-#endif //USE_CAELUM
\ No newline at end of file
+LongReal SkyManager::getTimeFactor()
+{
+    return mCaelumSystem->getUniversalClock()->getTimeScale();
+}
+
+Ogre::String SkyManager::getPrettyTime()
+{
+       int ignore;
+       int hour;
+       int minute;
+       Caelum::LongReal second;
+       
Caelum::Astronomy::getGregorianDateTimeFromJulianDay(mCaelumSystem->getJulianDay()
+       , ignore, ignore, ignore, hour, minute, second);
+       
+       return Ogre::StringConverter::toString( hour, 2, '0' )
+       + ":" + Ogre::StringConverter::toString( minute, 2, '0' )
+       + ":" + Ogre::StringConverter::toString( (int)second, 2, '0' );
+}
+
+#endif //USE_CAELUM

Modified: trunk/source/main/SkyManager.h
===================================================================
--- trunk/source/main/SkyManager.h      2010-07-08 15:40:58 UTC (rev 1430)
+++ trunk/source/main/SkyManager.h      2010-07-11 08:22:46 UTC (rev 1431)
@@ -39,14 +39,22 @@
        void init(Ogre::SceneManager *mScene, Ogre::RenderWindow *mWindow, 
Ogre::Camera *mCamera);
 
        void loadScript(Ogre::String script);
+       
+       /// change the time scale
        void setTimeFactor(double f);
+       
+       /// gets the current time scale
+       double getTimeFactor();
+       
+       /// prints the current time of the simulation inthe format of HH:MM:SS
+       Ogre::String getPrettyTime();
+       
 
 protected:
     Caelum::CaelumSystem *mCaelumSystem;
        Caelum::CaelumSystem *getCaelumSystem() { return mCaelumSystem; };
-       double mCaelumSpeedFactor;
 };
 
 #endif //SKYMANAGER_H__
 
-#endif //USE_CAELUM
\ No newline at end of file
+#endif //USE_CAELUM


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to