Преглед на файлове

Merge pull request #594 from dgough/next

Changed launchUrl to launchURL and added Control::removeListener
Sean Paul Taylor преди 13 години
родител
ревизия
b8ca631c0b

+ 23 - 0
gameplay/src/Control.cpp

@@ -694,6 +694,29 @@ void Control::addListener(Control::Listener* listener, int eventFlags)
     }
 }
 
+void Control::removeListener(Control::Listener* listener)
+{
+    if (_listeners == NULL || listener == NULL)
+        return;
+
+    for (std::map<Listener::EventType, std::list<Listener*>*>::iterator itr = _listeners->begin(); itr != _listeners->end();)
+    {
+        itr->second->remove(listener);
+
+        if(itr->second->empty())
+        {
+            std::list<Listener*>* list = itr->second;
+            _listeners->erase(itr++);
+            SAFE_DELETE(list);
+        }
+        else
+            ++itr;
+    }
+
+    if (_listeners->empty())
+        SAFE_DELETE(_listeners);
+}
+
 void Control::addSpecificListener(Control::Listener* listener, Listener::EventType eventType)
 {
     GP_ASSERT(listener);

+ 8 - 1
gameplay/src/Control.h

@@ -725,7 +725,7 @@ public:
     virtual const char* getType() const;
 
     /**
-     * Add a listener to be notified of specific events affecting
+     * Adds a listener to be notified of specific events affecting
      * this control.  Event types can be OR'ed together.
      * E.g. To listen to touch-press and touch-release events,
      * pass <code>Control::Listener::TOUCH | Control::Listener::RELEASE</code>
@@ -736,6 +736,13 @@ public:
      */
     virtual void addListener(Control::Listener* listener, int eventFlags);
 
+    /**
+     * Removes a listener from this control.
+     * 
+     * @param listener The listener to remove.
+     */
+    virtual void removeListener(Control::Listener* listener);
+
     /**
      * @see AnimationTarget::getAnimationPropertyComponentCount
      */

+ 1 - 1
gameplay/src/Game.h

@@ -524,7 +524,7 @@ public:
      *
      * @return True if URL was opened successfully, false otherwise.
      */
-    bool launchUrl(const char *url) const;
+    bool launchURL(const char *url) const;
 
 protected:
 

+ 2 - 2
gameplay/src/Game.inl

@@ -141,9 +141,9 @@ inline Gamepad* Game::getGamepad(unsigned int index) const
         return NULL;
 }
 
-inline bool Game::launchUrl(const char* url) const
+inline bool Game::launchURL(const char* url) const
 {
-    return Platform::launchUrl(url);
+    return Platform::launchURL(url);
 }
 
 }

+ 1 - 1
gameplay/src/Platform.h

@@ -369,7 +369,7 @@ public:
      *
      * @return True if URL was opened successfully, false otherwise.
      */
-    static bool launchUrl(const char* url);
+    static bool launchURL(const char* url);
     
 private:
 

+ 1 - 1
gameplay/src/PlatformAndroid.cpp

@@ -1358,7 +1358,7 @@ float Platform::getGamepadTriggerValue(unsigned int gamepadHandle, unsigned int
     return 0.0f;
 }
 
-bool Platform::launchUrl(const char *url)
+bool Platform::launchURL(const char *url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 1 - 1
gameplay/src/PlatformBlackBerry.cpp

@@ -1419,7 +1419,7 @@ float Platform::getGamepadTriggerValue(unsigned int gamepadHandle, unsigned int
     return 0.0f;
 }
 
-bool Platform::launchUrl(const char* url)
+bool Platform::launchURL(const char* url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 1 - 1
gameplay/src/PlatformLinux.cpp

@@ -1002,7 +1002,7 @@ float Platform::getGamepadTriggerValue(unsigned int gamepadHandle, unsigned int
     return 0.0f;
 }
 
-bool Platform::launchUrl(const char* url)
+bool Platform::launchURL(const char* url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 1 - 1
gameplay/src/PlatformMacOSX.mm

@@ -1882,7 +1882,7 @@ static void hidDeviceValueAvailableCallback(void* inContext, IOReturn inResult,
     } while (1);
 }
 
-bool Platform::launchUrl(const char *url)
+bool Platform::launchURL(const char *url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 1 - 1
gameplay/src/PlatformWindows.cpp

@@ -1455,7 +1455,7 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     }
 }
 
-bool Platform::launchUrl(const char* url)
+bool Platform::launchURL(const char* url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 1 - 1
gameplay/src/PlatformiOS.mm

@@ -1320,7 +1320,7 @@ float Platform::getGamepadTriggerValue(unsigned int gamepadHandle, unsigned int
     return 0.0f;
 }
 
-bool Platform::launchUrl(const char *url)
+bool Platform::launchURL(const char *url)
 {
     if (url == NULL || *url == '\0')
         return false;

+ 2 - 0
gameplay/src/Transform.h

@@ -757,6 +757,8 @@ public:
 
     /**
      * Removes a transform listener.
+     * 
+     * @param listener The listener to remove.
      */
     void removeListener(Transform::Listener* listener);