[email protected] 8 ani în urmă
părinte
comite
41ab36da51
2 a modificat fișierele cu 21 adăugiri și 101 ștergeri
  1. 17 24
      oxygine/src/InputText.cpp
  2. 4 77
      oxygine/src/core/oxygine.cpp

+ 17 - 24
oxygine/src/InputText.cpp

@@ -32,18 +32,10 @@ namespace oxygine
 
 
     void InputText::start(spTextField ta)
     void InputText::start(spTextField ta)
     {
     {
-#ifdef __S3E__
-        log::error("InputText isn't implemented for MARMALADE");
-#endif
-
         addRef();
         addRef();
 
 
-        //if (_active == this)
-        //  return;
         if (_active)
         if (_active)
-        {
             _active->stop();
             _active->stop();
-        }
 
 
         _active = this;
         _active = this;
 
 
@@ -51,14 +43,28 @@ namespace oxygine
 
 
         core::getDispatcher()->addEventListener(core::EVENT_SYSTEM, CLOSURE(this, &InputText::_onSysEvent));
         core::getDispatcher()->addEventListener(core::EVENT_SYSTEM, CLOSURE(this, &InputText::_onSysEvent));
 
 
-#ifndef __S3E__
         SDL_StartTextInput();
         SDL_StartTextInput();
-#endif
-        //log::messageln("InputText::start  %x", this);
+
         _txt = "";
         _txt = "";
         updateText();
         updateText();
     }
     }
 
 
+
+
+    void InputText::stop()
+    {
+        if (!_textActor)
+            return;
+
+        SDL_StopTextInput();
+        core::getDispatcher()->removeEventListeners(this);
+
+        _active = 0;
+        _textActor = 0;
+        //log::messageln("InputText::stop  %x", this);
+        releaseRef();
+    }
+
     void InputText::setAllowedSymbols(const std::string& utf8str)
     void InputText::setAllowedSymbols(const std::string& utf8str)
     {
     {
         _allowed = utf8str;
         _allowed = utf8str;
@@ -84,19 +90,6 @@ namespace oxygine
         _maxLength = v;
         _maxLength = v;
     }
     }
 
 
-    void InputText::stop()
-    {
-#ifndef __S3E__
-        SDL_StopTextInput();
-#endif
-        core::getDispatcher()->removeEventListeners(this);
-
-        _active = 0;
-        _textActor = 0;
-        //log::messageln("InputText::stop  %x", this);
-        releaseRef();
-    }
-
     void InputText::_onSysEvent(Event* event)
     void InputText::_onSysEvent(Event* event)
     {
     {
 #ifndef __S3E__
 #ifndef __S3E__

+ 4 - 77
oxygine/src/core/oxygine.cpp

@@ -27,6 +27,7 @@
 #include "ThreadDispatcher.h"
 #include "ThreadDispatcher.h"
 #include "PostProcess.h"
 #include "PostProcess.h"
 #include "TextField.h"
 #include "TextField.h"
+#include "InputText.h"
 
 
 #ifdef __S3E__
 #ifdef __S3E__
 #include "s3e.h"
 #include "s3e.h"
@@ -103,83 +104,6 @@ namespace oxygine
 
 
     static pthread_t _mainThread;
     static pthread_t _mainThread;
 
 
-#ifdef __S3E__
-
-    int32 pointerEvent(void* sysData, void* u)
-    {
-        s3ePointerEvent* ev = (s3ePointerEvent*)sysData;
-        int type = 0;
-        switch (ev->m_Button)
-        {
-            case S3E_POINTER_BUTTON_SELECT:
-                type = ev->m_Pressed ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP;
-                break;
-            case S3E_POINTER_BUTTON_MOUSEWHEELUP:
-                type = TouchEvent::WHEEL_UP;
-                break;
-            case S3E_POINTER_BUTTON_MOUSEWHEELDOWN:
-                type = TouchEvent::WHEEL_DOWN;
-                break;
-        }
-
-        MouseButton b = MouseButton_Left;
-        switch (ev->m_Button)
-        {
-            case S3E_POINTER_BUTTON_LEFTMOUSE: b = MouseButton_Left; break;
-            case S3E_POINTER_BUTTON_RIGHTMOUSE: b = MouseButton_Right; break;
-            case S3E_POINTER_BUTTON_MIDDLEMOUSE: b = MouseButton_Middle; break;
-        }
-
-        Input::instance.sendPointerButtonEvent(getStage(), b, (float)ev->m_x, (float)ev->m_y, 1.0f, type, &Input::instance._pointerMouse);
-
-        return 0;
-    }
-
-    int32 pointerMotionEvent(void* sysData, void* u)
-    {
-        s3ePointerMotionEvent* ev = (s3ePointerMotionEvent*)sysData;
-
-        Input::instance.sendPointerMotionEvent(getStage(), (float)ev->m_x, (float)ev->m_y, 1.0f, &Input::instance._pointerMouse);
-        return 0;
-    }
-
-    int32 pointerTouchEvent(void* sysData, void* u)
-    {
-        Input* This = (Input*)u;
-        s3ePointerTouchEvent* ev = (s3ePointerTouchEvent*)sysData;
-        int id = ev->m_TouchID + 1;
-
-        Input::instance.sendPointerButtonEvent(getStage(), MouseButton_Touch, (float)ev->m_x, (float)ev->m_y, 1.0f, ev->m_Pressed ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP, Input::instance.getTouchByIndex(id));
-
-        return 0;
-    }
-
-    int32 pointerTouchMotionEvent(void* sysData, void* u)
-    {
-        Input* This = (Input*)u;
-        s3ePointerTouchMotionEvent* ev = (s3ePointerTouchMotionEvent*)sysData;
-        int id = ev->m_TouchID + 1;
-
-        Input::instance.sendPointerMotionEvent(getStage(), (float)ev->m_x, (float)ev->m_y, 1.0f, Input::instance.getTouchByIndex(id));
-
-        return 0;
-    }
-
-    int32 applicationPause(void* systemData, void* userData)
-    {
-        Event ev(Stage::DEACTIVATE);
-        getStage()->dispatchEvent(&ev);
-        return 0;
-    }
-
-    int32 applicationUnPause(void* systemData, void* userData)
-    {
-        Event ev(Stage::ACTIVATE);
-        getStage()->dispatchEvent(&ev);
-        return 0;
-    }
-#endif
-
     namespace key
     namespace key
     {
     {
         void update();
         void update();
@@ -848,6 +772,8 @@ namespace oxygine
         {
         {
             log::messageln("core::release");
             log::messageln("core::release");
 
 
+            InputText::stopAnyInput();
+
             _threadMessages.clear();
             _threadMessages.clear();
             _uiMessages.clear();
             _uiMessages.clear();
 
 
@@ -875,6 +801,7 @@ namespace oxygine
             Stage::instance = 0;
             Stage::instance = 0;
             file::free();
             file::free();
 
 
+
             Resources::unregisterResourceType("atlas");
             Resources::unregisterResourceType("atlas");
             Resources::unregisterResourceType("buffer");
             Resources::unregisterResourceType("buffer");
             Resources::unregisterResourceType("font");
             Resources::unregisterResourceType("font");