Переглянути джерело

Merge branch 'next' of https://github.com/blackberry/GamePlay into next

Conflicts:
	gameplay/gameplay.vcxproj
	gameplay/src/lua/lua_Container.cpp
	gameplay/src/lua/lua_Form.cpp
	gameplay/src/lua/lua_Global.cpp
	gameplay/src/lua/lua_Global.h
sgrenier 11 роки тому
батько
коміт
87fa6fb4ce

+ 2 - 0
gameplay/CMakeLists.txt

@@ -292,6 +292,8 @@ set(GAMEPLAY_LUA
     src/lua/lua_CheckBox.h
     src/lua/lua_CheckBox.h
     src/lua/lua_Container.cpp
     src/lua/lua_Container.cpp
     src/lua/lua_Container.h
     src/lua/lua_Container.h
+    src/lua/lua_ContainerDirection.cpp
+    src/lua/lua_ContainerDirection.h
     src/lua/lua_ContainerScroll.cpp
     src/lua/lua_ContainerScroll.cpp
     src/lua/lua_ContainerScroll.h
     src/lua/lua_ContainerScroll.h
     src/lua/lua_Control.cpp
     src/lua/lua_Control.cpp

+ 1 - 0
gameplay/android/jni/Android.mk

@@ -138,6 +138,7 @@ LOCAL_SRC_FILES := \
     lua/lua_CameraType.cpp \
     lua/lua_CameraType.cpp \
     lua/lua_CheckBox.cpp \
     lua/lua_CheckBox.cpp \
     lua/lua_Container.cpp \
     lua/lua_Container.cpp \
+    lua/lua_ContainerDirection.cpp \
     lua/lua_ContainerScroll.cpp \
     lua/lua_ContainerScroll.cpp \
     lua/lua_Control.cpp \
     lua/lua_Control.cpp \
     lua/lua_ControlAlignment.cpp \
     lua/lua_ControlAlignment.cpp \

+ 6 - 0
gameplay/gameplay.vcxproj.filters

@@ -726,6 +726,9 @@
     <ClCompile Include="src\lua\lua_JoystickControl.cpp">
     <ClCompile Include="src\lua\lua_JoystickControl.cpp">
       <Filter>src\lua</Filter>
       <Filter>src\lua</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="src\lua\lua_ContainerDirection.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\Plane.h">
     <ClInclude Include="src\Plane.h">
@@ -1439,6 +1442,9 @@
     <ClInclude Include="src\lua\lua_JoystickControl.h">
     <ClInclude Include="src\lua\lua_JoystickControl.h">
       <Filter>src\lua</Filter>
       <Filter>src\lua</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="src\lua\lua_ContainerDirection.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="src\ScriptController.inl">
     <None Include="src\ScriptController.inl">

+ 8 - 0
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -586,6 +586,8 @@
 		5B2BC7621512514D00D176CD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC7611512514D00D176CD /* QuartzCore.framework */; };
 		5B2BC7621512514D00D176CD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC7611512514D00D176CD /* QuartzCore.framework */; };
 		6290E04A18223DCC00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04918223DCC00A28FB9 /* GameKit.framework */; };
 		6290E04A18223DCC00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04918223DCC00A28FB9 /* GameKit.framework */; };
 		6290E04C18223DDD00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04B18223DDD00A28FB9 /* GameKit.framework */; };
 		6290E04C18223DDD00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04B18223DDD00A28FB9 /* GameKit.framework */; };
+		8BA1B8BF197C3212009FF517 /* lua_ContainerDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8BA1B8BD197C3212009FF517 /* lua_ContainerDirection.cpp */; };
+		8BA1B8C0197C3212009FF517 /* lua_ContainerDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8BA1B8BD197C3212009FF517 /* lua_ContainerDirection.cpp */; };
 		BD2636E516CF5B7400CFE15F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */; };
 		BD2636E516CF5B7400CFE15F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */; };
 		BD2636E616CF5B7400CFE15F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E016CF5B7400CFE15F /* Foundation.framework */; };
 		BD2636E616CF5B7400CFE15F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E016CF5B7400CFE15F /* Foundation.framework */; };
 		BD2636E716CF5B7400CFE15F /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E116CF5B7400CFE15F /* OpenAL.framework */; };
 		BD2636E716CF5B7400CFE15F /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E116CF5B7400CFE15F /* OpenAL.framework */; };
@@ -1215,6 +1217,8 @@
 		5BC4E7D4150F8C3C00CBE1C0 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; path = res; sourceTree = "<group>"; };
 		5BC4E7D4150F8C3C00CBE1C0 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; path = res; sourceTree = "<group>"; };
 		6290E04918223DCC00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
 		6290E04918223DCC00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
 		6290E04B18223DDD00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
 		6290E04B18223DDD00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
+		8BA1B8BD197C3212009FF517 /* lua_ContainerDirection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_ContainerDirection.cpp; sourceTree = "<group>"; };
+		8BA1B8BE197C3212009FF517 /* lua_ContainerDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_ContainerDirection.h; sourceTree = "<group>"; };
 		BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E016CF5B7400CFE15F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E016CF5B7400CFE15F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E116CF5B7400CFE15F /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E116CF5B7400CFE15F /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; };
@@ -1319,6 +1323,8 @@
 				420BBADF1817416D00C7B720 /* lua_CheckBox.h */,
 				420BBADF1817416D00C7B720 /* lua_CheckBox.h */,
 				420BBAE01817416D00C7B720 /* lua_Container.cpp */,
 				420BBAE01817416D00C7B720 /* lua_Container.cpp */,
 				420BBAE11817416D00C7B720 /* lua_Container.h */,
 				420BBAE11817416D00C7B720 /* lua_Container.h */,
+				8BA1B8BD197C3212009FF517 /* lua_ContainerDirection.cpp */,
+				8BA1B8BE197C3212009FF517 /* lua_ContainerDirection.h */,
 				420BBAE21817416D00C7B720 /* lua_ContainerScroll.cpp */,
 				420BBAE21817416D00C7B720 /* lua_ContainerScroll.cpp */,
 				420BBAE31817416D00C7B720 /* lua_ContainerScroll.h */,
 				420BBAE31817416D00C7B720 /* lua_ContainerScroll.h */,
 				420BBAE41817416D00C7B720 /* lua_Control.cpp */,
 				420BBAE41817416D00C7B720 /* lua_Control.cpp */,
@@ -2160,6 +2166,7 @@
 				42CC5A121809A4EF00AAD8AD /* Vector4.cpp in Sources */,
 				42CC5A121809A4EF00AAD8AD /* Vector4.cpp in Sources */,
 				420BBE661817416F00C7B720 /* lua_Technique.cpp in Sources */,
 				420BBE661817416F00C7B720 /* lua_Technique.cpp in Sources */,
 				420BBE5A1817416F00C7B720 /* lua_ScriptTarget.cpp in Sources */,
 				420BBE5A1817416F00C7B720 /* lua_ScriptTarget.cpp in Sources */,
+				8BA1B8BF197C3212009FF517 /* lua_ContainerDirection.cpp in Sources */,
 				420BBD361817416F00C7B720 /* lua_Light.cpp in Sources */,
 				420BBD361817416F00C7B720 /* lua_Light.cpp in Sources */,
 				42CC59BA1809A4EF00AAD8AD /* Slider.cpp in Sources */,
 				42CC59BA1809A4EF00AAD8AD /* Slider.cpp in Sources */,
 				420BBC5E1817416F00C7B720 /* lua_AudioListener.cpp in Sources */,
 				420BBC5E1817416F00C7B720 /* lua_AudioListener.cpp in Sources */,
@@ -2453,6 +2460,7 @@
 				42CC5A0B1809A4EF00AAD8AD /* Vector2.cpp in Sources */,
 				42CC5A0B1809A4EF00AAD8AD /* Vector2.cpp in Sources */,
 				420BBE671817416F00C7B720 /* lua_Technique.cpp in Sources */,
 				420BBE671817416F00C7B720 /* lua_Technique.cpp in Sources */,
 				420BBE5B1817416F00C7B720 /* lua_ScriptTarget.cpp in Sources */,
 				420BBE5B1817416F00C7B720 /* lua_ScriptTarget.cpp in Sources */,
+				8BA1B8C0197C3212009FF517 /* lua_ContainerDirection.cpp in Sources */,
 				420BBD371817416F00C7B720 /* lua_Light.cpp in Sources */,
 				420BBD371817416F00C7B720 /* lua_Light.cpp in Sources */,
 				42CC55A11809A4EF00AAD8AD /* AudioListener.cpp in Sources */,
 				42CC55A11809A4EF00AAD8AD /* AudioListener.cpp in Sources */,
 				42CC5A131809A4EF00AAD8AD /* Vector4.cpp in Sources */,
 				42CC5A131809A4EF00AAD8AD /* Vector4.cpp in Sources */,

+ 11 - 7
gameplay/src/AudioSource.cpp

@@ -30,13 +30,17 @@ AudioSource::~AudioSource()
 {
 {
     if (_alSource)
     if (_alSource)
     {
     {
-        if (getState() == PLAYING || getState() == STOPPED)
-        {
-            // Remove the source from the controller's set of currently playing sources.
-            AudioController* audioController = Game::getInstance()->getAudioController();
-            GP_ASSERT(audioController);
-            audioController->removePlayingSource(this);
-        }
+        // Remove the source from the controller's set of currently playing sources
+        // regardless of the source's state. E.g. when the AudioController::pause is called
+        // all sources are paused but still remain in controller's set of currently 
+        // playing sources. When the source is deleted afterwards, it should be removed
+        // from controller's set regardless of its playing state.
+        AudioController* audioController = Game::getInstance()->getAudioController();
+        GP_ASSERT(audioController);
+        audioController->removePlayingSource(this);
+
+        AL_CHECK(alDeleteSources(1, &_alSource));
+        _alSource = 0;
     }
     }
     SAFE_RELEASE(_buffer);
     SAFE_RELEASE(_buffer);
 }
 }

+ 9 - 9
gameplay/src/PlatformiOS.mm

@@ -770,7 +770,7 @@ int getUnicode(int key);
 - (void)handleTapGesture:(UITapGestureRecognizer*)sender
 - (void)handleTapGesture:(UITapGestureRecognizer*)sender
 {
 {
     CGPoint location = [sender locationInView:self];
     CGPoint location = [sender locationInView:self];
-    gameplay::Platform::gestureTapEventInternal(location.x, location.y);
+    gameplay::Platform::gestureTapEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE);
 }
 }
 
 
 - (void)handleLongTapGesture:(UILongPressGestureRecognizer*)sender
 - (void)handleLongTapGesture:(UILongPressGestureRecognizer*)sender
@@ -790,7 +790,7 @@ int getUnicode(int key);
         
         
         gettimeofday(&time, NULL);
         gettimeofday(&time, NULL);
         currentTimeStamp = (time.tv_sec * 1000) + (time.tv_usec / 1000);
         currentTimeStamp = (time.tv_sec * 1000) + (time.tv_usec / 1000);
-        gameplay::Platform::gestureLongTapEventInternal(location.x, location.y, currentTimeStamp - __gestureLongTapStartTimestamp);
+        gameplay::Platform::gestureLongTapEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE, currentTimeStamp - __gestureLongTapStartTimestamp);
     }
     }
 }
 }
 
 
@@ -798,7 +798,7 @@ int getUnicode(int key);
 {
 {
     CGFloat factor = [sender scale];
     CGFloat factor = [sender scale];
     CGPoint location = [sender locationInView:self];
     CGPoint location = [sender locationInView:self];
-    gameplay::Platform::gesturePinchEventInternal(location.x, location.y, factor);
+    gameplay::Platform::gesturePinchEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE, factor);
 }
 }
 
 
 - (void)handleSwipeGesture:(UISwipeGestureRecognizer*)sender
 - (void)handleSwipeGesture:(UISwipeGestureRecognizer*)sender
@@ -820,7 +820,7 @@ int getUnicode(int key);
             gameplayDirection = Gesture::SWIPE_DIRECTION_DOWN;
             gameplayDirection = Gesture::SWIPE_DIRECTION_DOWN;
             break;
             break;
     }
     }
-    gameplay::Platform::gestureSwipeEventInternal(location.x, location.y, gameplayDirection);
+    gameplay::Platform::gestureSwipeEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE, gameplayDirection);
 }
 }
 
 
 - (void)handleLongPressGestures:(UILongPressGestureRecognizer*)sender
 - (void)handleLongPressGestures:(UILongPressGestureRecognizer*)sender
@@ -838,7 +838,7 @@ int getUnicode(int key);
     if (sender.state == UIGestureRecognizerStateChanged)
     if (sender.state == UIGestureRecognizerStateChanged)
     {
     {
         if (__gestureDraging)
         if (__gestureDraging)
-            gameplay::Platform::gestureDragEventInternal(location.x, location.y);
+            gameplay::Platform::gestureDragEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE);
         else
         else
         {
         {
             float delta = sqrt(pow(__gestureLongPressStartPosition.x - location.x, 2) + pow(__gestureLongPressStartPosition.y - location.y, 2));
             float delta = sqrt(pow(__gestureLongPressStartPosition.x - location.x, 2) + pow(__gestureLongPressStartPosition.y - location.y, 2));
@@ -846,7 +846,7 @@ int getUnicode(int key);
             if (delta >= GESTURE_LONG_PRESS_DISTANCE_MIN)
             if (delta >= GESTURE_LONG_PRESS_DISTANCE_MIN)
             {
             {
                 __gestureDraging = true;
                 __gestureDraging = true;
-                gameplay::Platform::gestureDragEventInternal(__gestureLongPressStartPosition.x, __gestureLongPressStartPosition.y);
+                gameplay::Platform::gestureDragEventInternal(__gestureLongPressStartPosition.x * WINDOW_SCALE, __gestureLongPressStartPosition.y * WINDOW_SCALE);
             }
             }
         }
         }
     }
     }
@@ -854,7 +854,7 @@ int getUnicode(int key);
     {
     {
         if (__gestureDraging)
         if (__gestureDraging)
         {
         {
-            gameplay::Platform::gestureDropEventInternal(location.x, location.y);
+            gameplay::Platform::gestureDropEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE);
             __gestureDraging = false;
             __gestureDraging = false;
         }
         }
         else
         else
@@ -864,12 +864,12 @@ int getUnicode(int key);
         
         
             gettimeofday(&time, NULL);
             gettimeofday(&time, NULL);
             currentTimeStamp = (time.tv_sec * 1000) + (time.tv_usec / 1000);
             currentTimeStamp = (time.tv_sec * 1000) + (time.tv_usec / 1000);
-            gameplay::Platform::gestureLongTapEventInternal(location.x, location.y, currentTimeStamp - __gestureLongTapStartTimestamp);
+            gameplay::Platform::gestureLongTapEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE, currentTimeStamp - __gestureLongTapStartTimestamp);
         }
         }
     }
     }
     if ((sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed) && __gestureDraging)
     if ((sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed) && __gestureDraging)
     {
     {
-        gameplay::Platform::gestureDropEventInternal(location.x, location.y);
+        gameplay::Platform::gestureDropEventInternal(location.x * WINDOW_SCALE, location.y * WINDOW_SCALE);
         __gestureDraging = false;
         __gestureDraging = false;
     }
     }
 }
 }

+ 51 - 0
gameplay/src/lua/lua_ContainerDirection.cpp

@@ -0,0 +1,51 @@
+#include "Base.h"
+#include "lua_ContainerDirection.h"
+
+namespace gameplay
+{
+
+static const char* enumStringEmpty = "";
+
+static const char* luaEnumString_ContainerDirection_UP = "UP";
+static const char* luaEnumString_ContainerDirection_DOWN = "DOWN";
+static const char* luaEnumString_ContainerDirection_LEFT = "LEFT";
+static const char* luaEnumString_ContainerDirection_RIGHT = "RIGHT";
+static const char* luaEnumString_ContainerDirection_NEXT = "NEXT";
+static const char* luaEnumString_ContainerDirection_PREVIOUS = "PREVIOUS";
+
+Container::Direction lua_enumFromString_ContainerDirection(const char* s)
+{
+    if (strcmp(s, luaEnumString_ContainerDirection_UP) == 0)
+        return Container::UP;
+    if (strcmp(s, luaEnumString_ContainerDirection_DOWN) == 0)
+        return Container::DOWN;
+    if (strcmp(s, luaEnumString_ContainerDirection_LEFT) == 0)
+        return Container::LEFT;
+    if (strcmp(s, luaEnumString_ContainerDirection_RIGHT) == 0)
+        return Container::RIGHT;
+    if (strcmp(s, luaEnumString_ContainerDirection_NEXT) == 0)
+        return Container::NEXT;
+    if (strcmp(s, luaEnumString_ContainerDirection_PREVIOUS) == 0)
+        return Container::PREVIOUS;
+    return Container::UP;
+}
+
+const char* lua_stringFromEnum_ContainerDirection(Container::Direction e)
+{
+    if (e == Container::UP)
+        return luaEnumString_ContainerDirection_UP;
+    if (e == Container::DOWN)
+        return luaEnumString_ContainerDirection_DOWN;
+    if (e == Container::LEFT)
+        return luaEnumString_ContainerDirection_LEFT;
+    if (e == Container::RIGHT)
+        return luaEnumString_ContainerDirection_RIGHT;
+    if (e == Container::NEXT)
+        return luaEnumString_ContainerDirection_NEXT;
+    if (e == Container::PREVIOUS)
+        return luaEnumString_ContainerDirection_PREVIOUS;
+    return enumStringEmpty;
+}
+
+}
+

+ 15 - 0
gameplay/src/lua/lua_ContainerDirection.h

@@ -0,0 +1,15 @@
+#ifndef LUA_CONTAINERDIRECTION_H_
+#define LUA_CONTAINERDIRECTION_H_
+
+#include "Container.h"
+
+namespace gameplay
+{
+
+// Lua bindings for enum conversion functions for Container::Direction.
+Container::Direction lua_enumFromString_ContainerDirection(const char* s);
+const char* lua_stringFromEnum_ContainerDirection(Container::Direction e);
+
+}
+
+#endif