|
@@ -7,11 +7,13 @@ import android.content.Context
|
|
import android.content.DialogInterface
|
|
import android.content.DialogInterface
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
|
|
+import android.graphics.BitmapFactory
|
|
import android.graphics.Canvas
|
|
import android.graphics.Canvas
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.support.v7.app.AppCompatActivity
|
|
import android.support.v7.app.AppCompatActivity
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
import android.support.v7.widget.RecyclerView
|
|
import android.support.v7.widget.RecyclerView
|
|
|
|
+import android.support.v7.widget.helper.ItemTouchHelper
|
|
import android.util.DisplayMetrics
|
|
import android.util.DisplayMetrics
|
|
import android.view.*
|
|
import android.view.*
|
|
import android.widget.PopupWindow
|
|
import android.widget.PopupWindow
|
|
@@ -41,6 +43,7 @@ import kotlinx.android.synthetic.main.view_control_dialogue_dialog.view.*
|
|
import com.bomostory.sceneeditmodule.DialogueColorData
|
|
import com.bomostory.sceneeditmodule.DialogueColorData
|
|
import com.bomostory.sceneeditmodule.SceneDrawer
|
|
import com.bomostory.sceneeditmodule.SceneDrawer
|
|
import com.bomostory.sceneeditmodule.cover.CoverEditorDialog
|
|
import com.bomostory.sceneeditmodule.cover.CoverEditorDialog
|
|
|
|
+import com.bomostory.sceneeditmodule.layermanagement.ItemTouchHelpCallback
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.ObjectView
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.ObjectView
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.NonInterceptTouchRecycleView
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.NonInterceptTouchRecycleView
|
|
import com.bomostory.sceneeditmodule.screen.draw.DrawActivity
|
|
import com.bomostory.sceneeditmodule.screen.draw.DrawActivity
|
|
@@ -50,6 +53,7 @@ import io.reactivex.schedulers.Schedulers
|
|
import kotlinx.android.synthetic.main.actor_select_view.view.*
|
|
import kotlinx.android.synthetic.main.actor_select_view.view.*
|
|
import kotlinx.android.synthetic.main.add_scene_view.view.*
|
|
import kotlinx.android.synthetic.main.add_scene_view.view.*
|
|
import kotlinx.android.synthetic.main.layer_management_fragment.*
|
|
import kotlinx.android.synthetic.main.layer_management_fragment.*
|
|
|
|
+import kotlinx.android.synthetic.main.layer_management_fragment.view.*
|
|
import kotlinx.android.synthetic.main.navigation_bar_view.view.*
|
|
import kotlinx.android.synthetic.main.navigation_bar_view.view.*
|
|
import kotlinx.android.synthetic.main.popupview_adjustment_dialog.view.*
|
|
import kotlinx.android.synthetic.main.popupview_adjustment_dialog.view.*
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
@@ -66,7 +70,7 @@ import kotlin.collections.ArrayList
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange, EditTextDialog.OnSetDialogFinish,
|
|
OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange, EditTextDialog.OnSetDialogFinish,
|
|
- BrushView.OnSelectBrush, FileUtils.OnSaveCover {
|
|
|
|
|
|
+ BrushView.OnSelectBrush, FileUtils.OnSaveCover, SceneAdapter.ItemMoveListener {
|
|
|
|
|
|
private lateinit var project: Project
|
|
private lateinit var project: Project
|
|
private var currentSceneIndex = 0
|
|
private var currentSceneIndex = 0
|
|
@@ -429,6 +433,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
switchLayer(0)
|
|
switchLayer(0)
|
|
initBrushView()
|
|
initBrushView()
|
|
} else {
|
|
} else {
|
|
|
|
+ unSelectActor()
|
|
var intent = Intent(this, DrawActivity::class.java).apply {
|
|
var intent = Intent(this, DrawActivity::class.java).apply {
|
|
putExtra("project", Gson().toJson(project))
|
|
putExtra("project", Gson().toJson(project))
|
|
}
|
|
}
|
|
@@ -512,6 +517,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sceneAdapter = SceneAdapter(this, projectBitmaps, onSceneSelectedArrayList, currentSceneIndex, recordTimeArrayList)
|
|
sceneAdapter = SceneAdapter(this, projectBitmaps, onSceneSelectedArrayList, currentSceneIndex, recordTimeArrayList)
|
|
|
|
+ sceneAdapter.listener = this@SceneEditActivity
|
|
var controlSceneView = ControlSceneView(this)
|
|
var controlSceneView = ControlSceneView(this)
|
|
controlSceneView.setonClickAddBtn(View.OnClickListener {
|
|
controlSceneView.setonClickAddBtn(View.OnClickListener {
|
|
viewContainer.removeAllViews()
|
|
viewContainer.removeAllViews()
|
|
@@ -650,6 +656,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
viewContainer.removeAllViews()
|
|
viewContainer.removeAllViews()
|
|
viewContainer.addView(controlSceneView)
|
|
viewContainer.addView(controlSceneView)
|
|
startRecord.visibility = View.VISIBLE
|
|
startRecord.visibility = View.VISIBLE
|
|
|
|
+ var itemTouchHelperCallBack = ItemTouchHelpCallback(sceneAdapter)
|
|
|
|
+ var itemTouchHelper = ItemTouchHelper(itemTouchHelperCallBack)
|
|
|
|
+ itemTouchHelper.attachToRecyclerView(sceneRecyclerView)
|
|
}
|
|
}
|
|
|
|
|
|
override fun onPause() {
|
|
override fun onPause() {
|
|
@@ -1095,6 +1104,33 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
sceneEditView.setLayerVisible(currentLayerIndex)
|
|
sceneEditView.setLayerVisible(currentLayerIndex)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun addBrushView(positionX: Int, positionY: Int, resourcePath: String) {
|
|
|
|
+ val metrics = DisplayMetrics()
|
|
|
|
+ val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
|
|
|
+ windowManager.defaultDisplay.getMetrics(metrics);
|
|
|
|
+ val screenWidth = metrics.widthPixels;
|
|
|
|
+ val screenHeight = screenWidth / 2
|
|
|
|
+
|
|
|
|
+ project.story?.let {
|
|
|
|
+ it.scenes?.let{
|
|
|
|
+ val actorData = Actor()
|
|
|
|
+ actorData.sideLength = BitmapFactory.decodeFile(resourcePath).width + (resources.getDimension(R.dimen.actor_padding_for_edit).toInt() * 2)
|
|
|
|
+ actorData.sideHeight = BitmapFactory.decodeFile(resourcePath).height + (resources.getDimension(R.dimen.actor_padding_for_edit).toInt() * 2)
|
|
|
|
+ actorData.positionX = positionX - resources.getDimension(R.dimen.actor_padding_for_edit).toInt()
|
|
|
|
+ actorData.positionY = positionY - resources.getDimension(R.dimen.actor_padding_for_edit).toInt()
|
|
|
|
+ actorData.positionZ = it[currentSceneIndex].layers[currentLayerIndex].actors.size
|
|
|
|
+ actorData.resourcePath = resourcePath
|
|
|
|
+ actorData.parentLayerIndex = currentLayerIndex
|
|
|
|
+ actorData.isMovable = true
|
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors.add(actorData)
|
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ viewContainer.removeAllViews()
|
|
|
|
+ startRecord.visibility = View.VISIBLE
|
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun addObject(positionX: Int, positionY: Int, resourcePath: String) {
|
|
private fun addObject(positionX: Int, positionY: Int, resourcePath: String) {
|
|
val metrics = DisplayMetrics()
|
|
val metrics = DisplayMetrics()
|
|
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
|
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
|
@@ -1631,7 +1667,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
ACTOR_FROM_BRUSH -> {
|
|
ACTOR_FROM_BRUSH -> {
|
|
when (resultCode) {
|
|
when (resultCode) {
|
|
Activity.RESULT_OK -> if (data != null) {
|
|
Activity.RESULT_OK -> if (data != null) {
|
|
- addActor(ACTOR_INIT_POSITION_X, ACTOR_INIT_POSITION_Y, data.getStringExtra("brush_bitmap"))
|
|
|
|
|
|
+ addBrushView(data.getIntExtra("brush_bitmap_positionX",0), data.getIntExtra("brush_bitmap_positionY",0), data.getStringExtra("brush_bitmap"))
|
|
}
|
|
}
|
|
Activity.RESULT_CANCELED -> {
|
|
Activity.RESULT_CANCELED -> {
|
|
}
|
|
}
|
|
@@ -1944,4 +1980,26 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
dialog.show(supportFragmentManager)
|
|
dialog.show(supportFragmentManager)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ override fun clearView() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onItemMove(fromPosition: Int, toPosition: Int) {
|
|
|
|
+ project.story?.let {
|
|
|
|
+ val scene = it.scenes[fromPosition]
|
|
|
|
+ it.scenes.removeAt(fromPosition)
|
|
|
|
+ it.scenes.add(toPosition, scene)
|
|
|
|
+ when(currentSceneIndex){
|
|
|
|
+ fromPosition -> {
|
|
|
|
+ currentSceneIndex = toPosition
|
|
|
|
+ sceneEditView.scene = it.scenes[toPosition]
|
|
|
|
+ }
|
|
|
|
+ toPosition -> {
|
|
|
|
+ currentSceneIndex = fromPosition
|
|
|
|
+ sceneEditView.scene = it.scenes[fromPosition]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|