|
@@ -22,15 +22,19 @@ import com.bomostory.sceneeditmodule.navigationbar.actor.SelectActorView
|
|
|
import com.google.gson.Gson
|
|
|
import kotlinx.android.synthetic.main.activity_scene_edit.*
|
|
|
import com.bomostory.sceneeditmodule.basicdata.*
|
|
|
+import com.bomostory.sceneeditmodule.navigationbar.dialogue.DialogueView
|
|
|
import com.bomostory.sceneeditmodule.view.EditActorView
|
|
|
import com.bomostory.sceneeditmodule.view.OnTouchBoMoSceneListener
|
|
|
-import com.bomostory.sceneeditmodule.view.SceneView1
|
|
|
import com.example.tfat.myapplication.navigationbar.RecordFinishView
|
|
|
import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
|
|
|
import kotlinx.android.synthetic.main.control_actor_dialog.view.*
|
|
|
import java.io.File
|
|
|
import java.io.FileWriter
|
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
|
+import com.bomostory.sceneeditmodule.view.LayerView
|
|
|
+import android.util.DisplayMetrics
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
@@ -41,12 +45,14 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
private var currentSceneIndex = 0
|
|
|
private var currentLayerIndex = 6
|
|
|
private var startRecordTime = 0L
|
|
|
+ private var swipeX = 0
|
|
|
private var record = Record()
|
|
|
private var resourceThemeBitmap = ArrayList<String>()
|
|
|
private var resourceActorBitmap = ArrayList<ArrayList<String>>()
|
|
|
private lateinit var sceneAdapter: SceneAdapter
|
|
|
private var isRecord = false
|
|
|
private var layerManagementDialog = LayerManagementDialog()
|
|
|
+ private val monitorSize = DisplayMetrics()
|
|
|
companion object {
|
|
|
const val PHOTO_FROM_GALLERY = 1
|
|
|
const val LAYER_MANAGEMENT = "layer_management"
|
|
@@ -54,6 +60,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
const val ACTOR_WIDTH = 200
|
|
|
const val ACTOR_INIT_POSITION_X = 200
|
|
|
const val ACTOR_INIT_POSITION_Y = 200
|
|
|
+ const val BACKGROUND_MOVE_RATE = 32
|
|
|
}
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -66,8 +73,10 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
project = Gson().fromJson<Project>(intent.getStringExtra("project"), Project::class.java)
|
|
|
resourceThemeBitmap = project.sceneResource as ArrayList<String>
|
|
|
resourceActorBitmap = project.actorResource as ArrayList<ArrayList<String>>
|
|
|
+ windowManager.defaultDisplay.getMetrics(monitorSize)
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
|
+ it[0].sceneWidth = monitorSize.widthPixels
|
|
|
sceneEditView.scene = it[0]
|
|
|
}
|
|
|
}
|
|
@@ -94,10 +103,12 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
private fun initControlBarView() {
|
|
|
controlBarView.setBtnSelected(6)
|
|
|
+ switchToPreViewLayer()
|
|
|
controlBarView.setonClickSwipeLayerBtn(View.OnClickListener {
|
|
|
switchToPreViewLayer()
|
|
|
})
|
|
|
controlBarView.setonClickLayerSceneBtn(View.OnClickListener {
|
|
|
+ controlBarView.setBtnSelected(5)
|
|
|
layerManagementDialog = LayerManagementDialog()
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
@@ -140,7 +151,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
})
|
|
|
navigationBarView.setonClickDialogueBtn(View.OnClickListener {
|
|
|
-
|
|
|
+ initDialogueView()
|
|
|
})
|
|
|
navigationBarView.setonClickImageBtn(View.OnClickListener {
|
|
|
pickFromGallery()
|
|
@@ -183,6 +194,17 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun initDialogueView(){
|
|
|
+ if (viewContainer.getChildAt(0) is DialogueView) {
|
|
|
+ viewContainer.removeAllViews()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var dialogueView = DialogueView(this)
|
|
|
+ switchLayer(0)
|
|
|
+ sceneEditView.findViewById<LayerView>(currentLayerIndex).setOnDragListener(dragListener())
|
|
|
+ viewContainer.addView(dialogueView)
|
|
|
+ }
|
|
|
+
|
|
|
private fun initActorRecyclerView() {
|
|
|
if (viewContainer.getChildAt(0) is SelectActorView) {
|
|
|
viewContainer.removeAllViews()
|
|
@@ -323,7 +345,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
sceneEditView.setOnTouchListener(null)
|
|
|
+ sceneEditView.x = 0
|
|
|
setActorDropLayer()
|
|
|
+ sceneEditView.setLayerVisible(layerIndex)
|
|
|
}
|
|
|
|
|
|
private fun switchToPreViewLayer(){
|
|
@@ -344,6 +368,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
val boMoSceneListener = OnTouchBoMoSceneListener()
|
|
|
boMoSceneListener.setCallBack(this)
|
|
|
sceneEditView.setOnTouchListener(boMoSceneListener)
|
|
|
+ sceneEditView.x = 0
|
|
|
if (viewContainer.getChildAt(0) is SelectActorView) {
|
|
|
viewContainer.removeAllViews()
|
|
|
}
|
|
@@ -414,6 +439,24 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
setActorDropLayer()
|
|
|
}
|
|
|
|
|
|
+ private fun addDialogue(positionX: Int, positionY: Int, resource: Int) {
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let{
|
|
|
+ val dialog = Dialogue()
|
|
|
+ dialog.resource = resource
|
|
|
+ dialog.positionX = positionX
|
|
|
+ dialog.positionY = positionY
|
|
|
+ dialog.positionZ = it[currentSceneIndex].layers[currentLayerIndex].actors.size
|
|
|
+ dialog.sideLength = ACTOR_WIDTH
|
|
|
+ dialog.sideHeight = ACTOR_HEIGHT
|
|
|
+ dialog.parentLayerIndex = currentLayerIndex
|
|
|
+ dialog.isMoveable = true
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors.add(dialog)
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sceneEditView.findViewById<LayerView>(currentLayerIndex).setOnDragListener(dragListener())
|
|
|
+ }
|
|
|
override fun onActorDropFinish(positionX: Int, positionY: Int, resourcePath: String) {
|
|
|
addActor(positionX, positionY, resourcePath)
|
|
|
}
|
|
@@ -432,7 +475,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
it.scenes?.let {
|
|
|
for(i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size){
|
|
|
if(actor.positionZ == i) {
|
|
|
- it[currentSceneIndex].layers[currentLayerIndex].actors[i] = actor
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect =
|
|
|
+ !it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect
|
|
|
} else {
|
|
|
it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
|
|
|
}
|
|
@@ -447,7 +491,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
it.scenes?.let {
|
|
|
for(i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size){
|
|
|
if(actor.positionZ == i) {
|
|
|
- it[currentSceneIndex].layers[currentLayerIndex].actors[i] = actor
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect =
|
|
|
+ !it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect
|
|
|
} else {
|
|
|
it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
|
|
|
}
|
|
@@ -517,17 +562,27 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
|
|
|
override fun onSceneMove(dX: Int) {
|
|
|
- sceneEditView.x = dX
|
|
|
- if (isRecord){
|
|
|
- record?.tracks.let {
|
|
|
- val track = Track()
|
|
|
- track.positionX = dX
|
|
|
- track.time = System.currentTimeMillis() - startRecordTime
|
|
|
- record.tracks.add(track)
|
|
|
+ if ( (BACKGROUND_MOVE_RATE * 69) >= (swipeX + dX) && (swipeX + dX) > (-(BACKGROUND_MOVE_RATE * 69))) {
|
|
|
+ sceneEditView.x = swipeX + dX
|
|
|
+ if (isRecord) {
|
|
|
+ record?.tracks.let {
|
|
|
+ val track = Track()
|
|
|
+ track.positionX = dX
|
|
|
+ track.time = System.currentTimeMillis() - startRecordTime
|
|
|
+ record.tracks.add(track)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ override fun onSceneReadyToMove() {
|
|
|
+ swipeX = sceneEditView.x
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onSceneFinishMove() {
|
|
|
+ swipeX = 0
|
|
|
+ }
|
|
|
+
|
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
@@ -577,4 +632,19 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private fun dragListener() : View.OnDragListener {
|
|
|
+ return View.OnDragListener {v, event ->
|
|
|
+ when (event.action) {
|
|
|
+ DragEvent.ACTION_DRAG_STARTED -> {
|
|
|
+ return@OnDragListener true
|
|
|
+ }
|
|
|
+ DragEvent.ACTION_DROP -> {
|
|
|
+ addDialogue(event.x.toInt() - 100, event.y.toInt() - 100, event.clipData.getItemAt(0).text.toString().toInt())
|
|
|
+ return@OnDragListener true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return@OnDragListener true
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|