Преглед изворни кода

Always delete CMakeLists directory also in the Windows CMake batch files to prevent using wrong toolchain.
Added IsTouchEnabled() function to Input.

Lasse Öörni пре 12 година
родитељ
комит
4c46fe72df

+ 1 - 1
Bin/Data/Scripts/NinjaSnowWar.as

@@ -261,7 +261,7 @@ void CreateOverlays()
     healthBar.SetSize(116, 16);
     healthBorder.AddChild(healthBar);
 
-    if (GetPlatform() == "Android" || GetPlatform() == "iOS")
+    if (input.touchEnabled)
     {
         touchEnabled = true;
 

+ 1 - 0
Docs/ScriptAPI.dox

@@ -3148,6 +3148,7 @@ Properties:<br>
 - int mouseMoveX (readonly)
 - int mouseMoveY (readonly)
 - int mouseMoveWheel (readonly)
+- bool touchEnabled (readonly)
 - uint numTouches (readonly)
 - TouchState@[] touches (readonly)
 - uint numJoysticks (readonly)

+ 5 - 0
Engine/Input/Input.cpp

@@ -332,6 +332,11 @@ IntVector2 Input::GetMousePosition() const
     return ret;
 }
 
+bool Input::IsTouchEnabled() const
+{
+    return SDL_GetNumTouchDevices() > 0;
+}
+
 TouchState* Input::GetTouch(unsigned index) const
 {
     if (index >= touches_.Size())

+ 2 - 0
Engine/Input/Input.h

@@ -161,6 +161,8 @@ public:
     int GetMouseMoveY() const { return mouseMove_.y_; }
     /// Return mouse wheel movement since last frame.
     int GetMouseMoveWheel() const { return mouseMoveWheel_; }
+    /// Return if has touch input.
+    bool IsTouchEnabled() const;
     /// Return number of active finger touches.
     unsigned GetNumTouches() const { return touches_.Size(); }
     /// Return active finger touch by index.

+ 1 - 0
Engine/Script/InputAPI.cpp

@@ -162,6 +162,7 @@ static void RegisterInput(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Input", "int get_mouseMoveX() const", asMETHOD(Input, GetMouseMoveX), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveY() const", asMETHOD(Input, GetMouseMoveY), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveWheel() const", asMETHOD(Input, GetMouseMoveWheel), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Input", "bool get_touchEnabled() const", asMETHOD(Input, IsTouchEnabled), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numTouches() const", asMETHOD(Input, GetNumTouches), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "TouchState@+ get_touches(uint) const", asMETHOD(Input, GetTouch), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numJoysticks() const", asMETHOD(Input, GetNumJoysticks), asCALL_THISCALL);

+ 2 - 0
Extras/LuaScript/pkgs/Input/Input.pkg

@@ -99,6 +99,8 @@ public:
     int GetMouseMoveY() const { return mouseMove_.y_; }
     /// Return mouse wheel movement since last frame.
     int GetMouseMoveWheel() const { return mouseMoveWheel_; }
+    /// Return if has touch input.
+    bool IsTouchEnabled() const;
     /// Return number of active finger touches.
     unsigned GetNumTouches() const { return touches_.Size(); }
     /// Return active finger touch by index.

+ 1 - 0
cmake_android.bat

@@ -1,2 +1,3 @@
 @del /F CMakeCache.txt
+@rd /S /Q CMakeFiles
 cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=Android/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=Android -DCMAKE_BUILD_TYPE=Release %*

+ 1 - 0
cmake_vs2008.bat

@@ -1,4 +1,5 @@
 @del /F CMakeCache.txt
+@rd /S /Q CMakeFiles
 @set "arch="
 @for %%n in (%*) do @if "%%n" == "-DENABLE_64BIT" (set "arch= Win64")
 cmake -G "Visual Studio 9 2008%arch%" %*

+ 1 - 0
cmake_vs2010.bat

@@ -1,4 +1,5 @@
 @del /F CMakeCache.txt
+@rd /S /Q CMakeFiles
 @set "arch="
 @for %%n in (%*) do @if "%%n" == "-DENABLE_64BIT" (set "arch= Win64")
 cmake -G "Visual Studio 10%arch%" %*

+ 1 - 0
cmake_vs2012.bat

@@ -1,4 +1,5 @@
 @del /F CMakeCache.txt
+@rd /S /Q CMakeFiles
 @set "arch="
 @for %%n in (%*) do @if "%%n" == "-DENABLE_64BIT" (set "arch= Win64")
 cmake -G "Visual Studio 11%arch%" %*