|
@@ -6,6 +6,7 @@ import android.content.Context
|
|
|
import android.content.DialogInterface
|
|
|
import android.content.Intent
|
|
|
import android.graphics.Bitmap
|
|
|
+import android.graphics.Paint
|
|
|
import android.os.Bundle
|
|
|
import android.support.v7.app.AppCompatActivity
|
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
@@ -63,6 +64,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
BrushView.OnSelectBrush {
|
|
|
|
|
|
private lateinit var project: Project
|
|
|
+ private lateinit var otherThemes: OtherThemes
|
|
|
private var currentSceneIndex = 0
|
|
|
private var currentLayerIndex = 6
|
|
|
private var startRecordTime = 0L
|
|
@@ -91,7 +93,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
const val ACTOR_INIT_POSITION_Y = 200
|
|
|
const val BACKGROUND_MOVE_RATE = 32
|
|
|
const val BRUSH_SIZE = 16
|
|
|
- const val INIT_SCENE_NUMBER = 11
|
|
|
const val TIME_STEP_FOR_FPS = 33L
|
|
|
val listeners = CopyOnWriteArrayList<Runnable>()
|
|
|
}
|
|
@@ -104,13 +105,26 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
actionBar?.hide()
|
|
|
supportActionBar?.hide()
|
|
|
project = Gson().fromJson<Project>(intent.getStringExtra("project"), Project::class.java)
|
|
|
+ otherThemes = when(intent.getStringExtra("other_theme")){
|
|
|
+ null -> OtherThemes()
|
|
|
+ else -> Gson().fromJson<OtherThemes>(intent.getStringExtra("other_theme"), OtherThemes::class.java)
|
|
|
+ }
|
|
|
resourceThemeBitmap = project.sceneResource as ArrayList<String>
|
|
|
- resourceActorBitmap = project.actorResource as ArrayList<ArrayList<String>>
|
|
|
- resourceObjectPath = ArrayList<String>().apply {
|
|
|
- project.themeAssetIndex.contains.obj.values.forEach {
|
|
|
- val path = "${project.assetFolder.path}/${it.smallFile}"
|
|
|
- add(path)
|
|
|
+ resourceThemeBitmap.add(File(Config.ASSETS_FOLDER, Config.PROJECT_WHITE_FILE_NAME).path)
|
|
|
+ resourceActorBitmap = when(intent.getStringExtra("resource_actor")) {
|
|
|
+ null -> { project.actorResource as ArrayList<ArrayList<String>>}
|
|
|
+ else -> { Gson().fromJson<ThemeActorResource>(intent.getStringExtra("resource_actor"), ThemeActorResource::class.java).actorPath}
|
|
|
+ }
|
|
|
+ resourceObjectPath = when(intent.getStringArrayListExtra("resource_object")) {
|
|
|
+ null -> {
|
|
|
+ ArrayList<String>().apply {
|
|
|
+ project.themeAssetIndex.contains.obj.values.forEach {
|
|
|
+ val path = "${project.assetFolder.path}/${it.smallFile}"
|
|
|
+ add(path)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ else -> {intent.getStringArrayListExtra("resource_object")}
|
|
|
}
|
|
|
windowManager.defaultDisplay.getMetrics(monitorSize)
|
|
|
var layoutPrams = sceneEditView.layoutParams
|
|
@@ -205,7 +219,11 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
private fun initNavigationBarView(position: Int) {
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
|
- if (position != currentSceneIndex) {
|
|
|
+ var isSceneRecorded = when(it[currentSceneIndex].record){
|
|
|
+ null -> false
|
|
|
+ else -> true
|
|
|
+ }
|
|
|
+ if (position != currentSceneIndex && !isSceneRecorded) {
|
|
|
initNavigationFunction()
|
|
|
} else {
|
|
|
navigationBar.removeAllViews()
|
|
@@ -213,7 +231,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
navigationBar.addView(editSceneView)
|
|
|
setControlSceneView()
|
|
|
editSceneView.setOnClickDoneListener(View.OnClickListener {
|
|
|
- initNavigationFunction()
|
|
|
+ if (!isSceneRecorded) initNavigationFunction()
|
|
|
})
|
|
|
editSceneView.setOnClickStartOverListener(View.OnClickListener {
|
|
|
project.story?.let {
|
|
@@ -411,6 +429,15 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
initActorRecyclerView()
|
|
|
}
|
|
|
}
|
|
|
+ selectActorView.btn_choose_theme.setOnClickListener {
|
|
|
+ if (!otherThemes.themes.isEmpty()) {
|
|
|
+ var intent = Intent(this, ChooseThemeActivity::class.java)
|
|
|
+ intent.putExtra("project", Gson().toJson(project))
|
|
|
+ intent.putExtra("other_theme", Gson().toJson(otherThemes))
|
|
|
+ startActivity(intent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
private fun initDialogueView(){
|
|
|
if (viewContainer.getChildAt(0) is DialogueView) {
|
|
@@ -474,7 +501,41 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
controlSceneView.setonClickDuplicateBtn(View.OnClickListener {
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
|
- it.add(currentSceneIndex + 1, it[currentSceneIndex])
|
|
|
+ var scene = Scene().apply {
|
|
|
+ backgroundName = it[currentSceneIndex].backgroundName
|
|
|
+ backgroundPath = it[currentSceneIndex].backgroundPath
|
|
|
+ record = it[currentSceneIndex].record
|
|
|
+ sceneWidth = it[currentSceneIndex].sceneWidth
|
|
|
+ recordPath = it[currentSceneIndex].recordPath
|
|
|
+ for (layer in it[currentSceneIndex].layers) {
|
|
|
+ var newLayer = Layer()
|
|
|
+ newLayer.id = layer.id
|
|
|
+ newLayer.name = layer.name
|
|
|
+ for(actor in layer.actors) {
|
|
|
+ var newActor = Actor()
|
|
|
+ newActor.resourcePath = actor.resourcePath
|
|
|
+ newActor.positionX = actor.positionX
|
|
|
+ newActor.positionY = actor.positionY
|
|
|
+ newActor.positionZ = actor.positionZ
|
|
|
+ newActor.sideLength = actor.sideLength
|
|
|
+ newActor.sideHeight = actor.sideHeight
|
|
|
+ newActor.isSelect = actor.isSelect
|
|
|
+ newActor.parentLayerIndex = actor.parentLayerIndex
|
|
|
+ newActor.isMovable = actor.isMovable
|
|
|
+ newActor.text = actor.text
|
|
|
+ newActor.textColor = actor.textColor
|
|
|
+ newActor.textAlign = actor.textAlign
|
|
|
+ newActor.isDialogue = actor.isDialogue
|
|
|
+ newActor.isMirror = actor.isMirror
|
|
|
+ newActor.opacity = actor.opacity
|
|
|
+ newActor.dialogColor = actor.dialogColor
|
|
|
+ newActor.dialogType = actor.dialogType
|
|
|
+ newLayer.actors.add(newActor)
|
|
|
+ }
|
|
|
+ layers.add(newLayer)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ it.add(currentSceneIndex + 1, scene)
|
|
|
}
|
|
|
}
|
|
|
var sceneAdapter = controlSceneView.findViewById<RecyclerView>(R.id.scene_recycler_view).adapter as SceneAdapter
|
|
@@ -485,10 +546,11 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
for (i in 0 until it.size) {
|
|
|
onSceneSelectedArrayList.add(switchScene(i))
|
|
|
projectBitmaps.add(SceneDrawer.drawScene(this,it[i],0,200,100))
|
|
|
+ recordTimeArrayList.add(it[i].record?.period)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sceneAdapter.update(projectBitmaps, onSceneSelectedArrayList)
|
|
|
+ sceneAdapter.update(projectBitmaps, onSceneSelectedArrayList,recordTimeArrayList)
|
|
|
})
|
|
|
val layoutManager = LinearLayoutManager(this)
|
|
|
layoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
@@ -827,6 +889,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
viewContainer.removeAllViews()
|
|
|
+ startRecord.visibility = View.VISIBLE
|
|
|
sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
}
|
|
|
|
|
@@ -853,6 +916,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ startRecord.visibility = View.VISIBLE
|
|
|
viewContainer.removeAllViews()
|
|
|
}
|
|
|
private fun addDialogue(positionX: Int, positionY: Int, resource: Int) {
|