Browse Source

Explicitly mention that DirectX June 2010 SDK needs to be installed.
Moved the Log timestamp functionality to Time subsystem, so that it can also be called by the user.

Lasse Öörni 13 years ago
parent
commit
21811bc13f
7 changed files with 34 additions and 22 deletions
  1. 1 1
      Docs/GettingStarted.dox
  2. 1 0
      Docs/ScriptAPI.dox
  3. 20 10
      Engine/Core/Timer.cpp
  4. 3 1
      Engine/Core/Timer.h
  5. 2 1
      Engine/Engine/CoreAPI.cpp
  6. 4 6
      Engine/IO/Log.cpp
  7. 3 3
      Readme.txt

+ 1 - 1
Docs/GettingStarted.dox

@@ -8,7 +8,7 @@ namespace Urho3D
 
 
 Although all required third-party libraries are included as source code, there are system-level dependencies that must be satisfied before Urho3D can be built successfully:
 Although all required third-party libraries are included as source code, there are system-level dependencies that must be satisfied before Urho3D can be built successfully:
 
 
-- For Windows, the DirectX SDK needs to be installed and its include and library directories set as Visual Studio global directories (Tools -> Options -> Projects and Solutions -> VC++ Directories in VS2008.)
+- For Windows, the June 2010 DirectX SDK needs to be installed and its include and library directories set as Visual Studio global directories (Tools -> Options -> Projects and Solutions -> VC++ Directories in VS2008.)
 
 
 - For Linux, the following development packages need to be installed: libx11-dev, libxrandr-dev, libasound2-dev. Also install the package libgl1-mesa-dev if your GPU driver does not include OpenGL headers & libs.
 - For Linux, the following development packages need to be installed: libx11-dev, libxrandr-dev, libasound2-dev. Also install the package libgl1-mesa-dev if your GPU driver does not include OpenGL headers & libs.
 
 

+ 1 - 0
Docs/ScriptAPI.dox

@@ -799,6 +799,7 @@ Properties:<br>
 - float timeStep (readonly)
 - float timeStep (readonly)
 - float elapsedTime (readonly)
 - float elapsedTime (readonly)
 - uint systemTime (readonly)
 - uint systemTime (readonly)
+- String timeStamp (readonly)
 
 
 
 
 Log
 Log

+ 20 - 10
Engine/Core/Timer.cpp

@@ -26,6 +26,8 @@
 #include "Profiler.h"
 #include "Profiler.h"
 #include "Timer.h"
 #include "Timer.h"
 
 
+#include <ctime>
+
 #ifdef WIN32
 #ifdef WIN32
 #include <windows.h>
 #include <windows.h>
 #include <mmsystem.h>
 #include <mmsystem.h>
@@ -125,16 +127,7 @@ float Time::GetElapsedTime()
     return elapsedTime_.GetMSec(false) / 1000.0f;
     return elapsedTime_.GetMSec(false) / 1000.0f;
 }
 }
 
 
-void Time::Sleep(unsigned mSec)
-{
-    #ifdef WIN32
-    ::Sleep(mSec);
-    #else
-    usleep(mSec * 1000);
-    #endif
-}
-
-unsigned Time::GetSystemTime()
+unsigned Time::GetSystemTime() const
 {
 {
     #ifdef WIN32
     #ifdef WIN32
     unsigned currentTime = timeGetTime();
     unsigned currentTime = timeGetTime();
@@ -147,6 +140,23 @@ unsigned Time::GetSystemTime()
     return currentTime;
     return currentTime;
 }
 }
 
 
+String Time::GetTimeStamp() const
+{
+    time_t sysTime;
+    time(&sysTime);
+    const char* dateTime = ctime(&sysTime);
+    return String(dateTime).Replaced("\n", "");
+}
+
+void Time::Sleep(unsigned mSec)
+{
+    #ifdef WIN32
+    ::Sleep(mSec);
+    #else
+    usleep(mSec * 1000);
+    #endif
+}
+
 Timer::Timer()
 Timer::Timer()
 {
 {
     Reset();
     Reset();

+ 3 - 1
Engine/Core/Timer.h

@@ -101,7 +101,9 @@ public:
     /// Return elapsed time from program start as seconds.
     /// Return elapsed time from program start as seconds.
     float GetElapsedTime();
     float GetElapsedTime();
     /// Get system time as milliseconds.
     /// Get system time as milliseconds.
-    unsigned GetSystemTime();
+    unsigned GetSystemTime() const;
+    /// Get a date/time stamp as a string.
+    String GetTimeStamp() const;
     
     
     /// Sleep for a number of milliseconds.
     /// Sleep for a number of milliseconds.
     static void Sleep(unsigned mSec);
     static void Sleep(unsigned mSec);

+ 2 - 1
Engine/Engine/CoreAPI.cpp

@@ -581,7 +581,8 @@ static void RegisterTimer(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Time", "uint get_frameNumber() const", asMETHOD(Time, GetFrameNumber), asCALL_THISCALL);
     engine->RegisterObjectMethod("Time", "uint get_frameNumber() const", asMETHOD(Time, GetFrameNumber), asCALL_THISCALL);
     engine->RegisterObjectMethod("Time", "float get_timeStep() const", asMETHOD(Time, GetTimeStep), asCALL_THISCALL);
     engine->RegisterObjectMethod("Time", "float get_timeStep() const", asMETHOD(Time, GetTimeStep), asCALL_THISCALL);
     engine->RegisterObjectMethod("Time", "float get_elapsedTime()", asMETHOD(Time, GetElapsedTime), asCALL_THISCALL);
     engine->RegisterObjectMethod("Time", "float get_elapsedTime()", asMETHOD(Time, GetElapsedTime), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Time", "uint get_systemTime()", asMETHOD(Time, GetSystemTime), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Time", "uint get_systemTime() const", asMETHOD(Time, GetSystemTime), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Time", "String get_timeStamp() const", asMETHOD(Time, GetTimeStamp), asCALL_THISCALL);
     engine->RegisterGlobalFunction("Time@+ get_time()", asFUNCTION(GetTime), asCALL_CDECL);
     engine->RegisterGlobalFunction("Time@+ get_time()", asFUNCTION(GetTime), asCALL_CDECL);
 }
 }
 
 

+ 4 - 6
Engine/IO/Log.cpp

@@ -27,9 +27,9 @@
 #include "IOEvents.h"
 #include "IOEvents.h"
 #include "Log.h"
 #include "Log.h"
 #include "ProcessUtils.h"
 #include "ProcessUtils.h"
+#include "Timer.h"
 
 
 #include <cstdio>
 #include <cstdio>
-#include <ctime>
 
 
 #ifdef ANDROID
 #ifdef ANDROID
 #include <android/log.h>
 #include <android/log.h>
@@ -102,11 +102,9 @@ void Log::Write(int level, const String& message)
     
     
     if (timeStamp_)
     if (timeStamp_)
     {
     {
-        time_t sysTime;
-        time(&sysTime);
-        const char* dateTime = ctime(&sysTime);
-        String dateTimeString = String(dateTime).Replaced("\n", "");
-        formattedMessage = "[" + dateTimeString + "] " + formattedMessage;
+        Time* time = GetSubsystem<Time>();
+        if (time)
+            formattedMessage = "[" + time->GetTimeStamp() + "] " + formattedMessage;
     }
     }
     
     
     #if defined(ANDROID)
     #if defined(ANDROID)

+ 3 - 3
Readme.txt

@@ -94,9 +94,9 @@ Although all required third-party libraries are included as source code, there
 are system-level dependencies that must be satisfied before Urho3D can be built
 are system-level dependencies that must be satisfied before Urho3D can be built
 successfully:
 successfully:
 
 
-- For Windows, the DirectX SDK needs to be installed and its include and library
-  directories set as Visual Studio global directories (Tools -> Options ->
-  Projects and Solutions -> VC++ Directories in VS2008.)
+- For Windows, the June 2010 DirectX SDK needs to be installed and its include 
+  and library directories set as Visual Studio global directories (Tools -> 
+  Options -> Projects and Solutions -> VC++ Directories in VS2008.)
 
 
 - For Linux, the following development packages need to be installed:
 - For Linux, the following development packages need to be installed:
   libx11-dev, libxrandr-dev, libasound2-dev. Also install the package
   libx11-dev, libxrandr-dev, libasound2-dev. Also install the package