Prechádzať zdrojové kódy

fix actor multiselected problem

faterhenry 6 rokov pred
rodič
commit
2649ad3dad

+ 35 - 2
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -30,6 +30,7 @@ import com.bomostory.sceneeditmodule.utils.FileUtils
 import com.bomostory.sceneeditmodule.view.LayerView
 import android.util.DisplayMetrics
 import com.bomostory.sceneeditmodule.MovieEditActivity
+import com.bomostory.sceneeditmodule.view.OnTouchSceneListener
 import com.example.tfat.myapplication.navigationbar.EditSceneView
 import com.example.tfat.myapplication.navigationbar.RecordFinishView
 import io.reactivex.android.schedulers.AndroidSchedulers
@@ -38,7 +39,7 @@ import java.util.concurrent.CopyOnWriteArrayList
 
 class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
         OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
-        LayerManagementDialog.OnLayerChange {
+        OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange {
 
     private lateinit var project: Project
     private var currentSceneIndex = 0
@@ -407,6 +408,15 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
 
     private fun switchLayer(layerIndex: Int){
         viewContainer.removeAllViews()
+        if(currentLayerIndex != 6) {
+            project.story?.let {
+                it.scenes?.let {
+                    for (i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size) {
+                        it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
+                    }
+                }
+            }
+        }
         currentLayerIndex = layerIndex
         controlBarView.setBtnSelected(4 - layerIndex)
         project.story?.let {
@@ -423,10 +433,13 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                             }
                     }
                 }
+
                 sceneEditView.scene = it[currentSceneIndex]
             }
         }
-        sceneEditView.setOnTouchListener(null)
+        val sceneListener = OnTouchSceneListener()
+        sceneListener.setCallBack(this)
+        sceneEditView.setOnTouchListener(sceneListener)
         sceneEditView.x = 0
         setActorDropLayer()
         sceneEditView.setLayerVisible(layerIndex)
@@ -532,6 +545,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             }
         }
         setActorDropLayer()
+        sceneEditView.setLayerVisible(currentLayerIndex)
     }
 
     private fun addDialogue(positionX: Int, positionY: Int, resource: Int) {
@@ -563,6 +577,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 sceneEditView.scene = it[currentSceneIndex]
             }
         }
+        sceneEditView.setLayerVisible(currentLayerIndex)
     }
 
     override fun onActorSelected(actor: Actor) {
@@ -579,6 +594,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 sceneEditView.scene = it[currentSceneIndex]
             }
         }
+        sceneEditView.setLayerVisible(currentLayerIndex)
     }
 
     override fun onActorLongClick(actor: Actor) {
@@ -595,6 +611,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 sceneEditView.scene = it[currentSceneIndex]
             }
         }
+        sceneEditView.setLayerVisible(currentLayerIndex)
         var popupWindow = PopupWindow(this)
         val popupView = LayoutInflater.from(this).inflate(R.layout.control_actor_dialog, null)
         popupView.duplicate.setOnClickListener{
@@ -742,4 +759,20 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             return@OnDragListener true
         }
     }
+
+    override fun onSceneTouch(){
+        unSelectActor()
+        sceneEditView.setLayerVisible(currentLayerIndex)
+    }
+
+    private fun unSelectActor(){
+        project.story?.let {
+            it.scenes?.let {
+                for(i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size){
+                    it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
+                }
+                sceneEditView.scene = it[currentSceneIndex]
+            }
+        }
+    }
 }

+ 34 - 0
src/main/java/com/bomostory/sceneeditmodule/sceneview/OnTouchSceneListener.kt

@@ -0,0 +1,34 @@
+package com.bomostory.sceneeditmodule.view
+
+import android.view.MotionEvent
+import android.view.View
+
+class OnTouchSceneListener : View.OnTouchListener{
+    var positionX = 0f
+    var onSceneTouchCallBack: OnSceneTouchListener? = null
+
+    override fun onTouch(v: View?, event: MotionEvent?): Boolean {
+            when (event?.action) {
+                MotionEvent.ACTION_DOWN -> {
+                    positionX = event.x
+                    onSceneTouchCallBack?.onSceneTouch()
+                }
+                MotionEvent.ACTION_MOVE -> {
+
+                }
+                MotionEvent.ACTION_UP -> {
+                }
+            }
+        return true
+    }
+
+    fun setCallBack(onSceneMoveCallBack: OnSceneTouchListener){
+        this.onSceneTouchCallBack = onSceneMoveCallBack
+    }
+    interface OnSceneTouchListener{
+        fun onSceneTouch()
+    }
+
+}
+
+