faterhenry vor 6 Jahren
Ursprung
Commit
1d8fe12118

+ 47 - 4
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -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
@@ -206,7 +207,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()
@@ -214,7 +219,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 {
@@ -475,7 +480,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
@@ -486,10 +525,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
@@ -752,6 +792,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     initActorRecyclerView()
                 }
             }
+            selectActorView.btn_choose_theme.setOnClickListener {
+                /////TFTA
+            }
             viewContainer.addView(selectActorView)
         }
     }

+ 4 - 2
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/SceneAdapter.kt

@@ -7,6 +7,7 @@ import android.support.v7.widget.RecyclerView
 import android.view.*
 import android.widget.ImageView
 import android.widget.TextView
+import com.bomostory.sceneeditmodule.utils.Utils
 import com.example.tfat.myapplication.R
 import kotlinx.android.synthetic.main.item_scene.view.*
 import kotlin.collections.ArrayList
@@ -33,7 +34,7 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
         fun bind(bitmap: Bitmap?, position : Int, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex: Int, recordTime: Long?) {
             itemView.findViewById<ImageView>(R.id.scene_image).setImageBitmap(bitmap)
             itemView.findViewById<ImageView>(R.id.scene_image).setOnClickListener(onClickListenerList[position])
-            itemView.findViewById<TextView>(R.id.scene_number).text = position.toString()
+            itemView.findViewById<TextView>(R.id.scene_number).text = Utils.generateSceneName(position)
             when (recordTime != null) {
                 true -> {itemView.scene_record_time.text = recordTime?.div(1000)?.div(60).toString() + ":" +
                         recordTime?.div(1000)?.rem(60)?.div(10) + recordTime?.div(1000)?.rem(60)?.rem(10).toString()}
@@ -47,9 +48,10 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
         }
     }
 
-    fun update(data : ArrayList<Bitmap?>, onClickListenerList: ArrayList<View.OnClickListener>) {
+    fun update(data : ArrayList<Bitmap?>, onClickListenerList: ArrayList<View.OnClickListener>, recordTimeArrayList: ArrayList<Long?>) {
         this.data = data
         this.onClickListenerList = onClickListenerList
+        this.recordTimeArrayList = recordTimeArrayList
         this.notifyDataSetChanged()
     }
 }

+ 2 - 2
src/main/java/com/bomostory/sceneeditmodule/utils/Utils.kt

@@ -11,8 +11,8 @@ import java.io.File
 object Utils {
 
     fun generateSceneName(index: Int): String {
-        val book = ('A'.toInt() + ((index + 1) / 22)).toChar()
-        val num = (index + 1) % 22
+        val book = ('A'.toInt() + ((index) / 12)).toChar()
+        val num = (index) % 12 + 1
         return "$book$num"
     }
 

+ 1 - 1
src/main/res/layout/item_actor.xml

@@ -16,7 +16,7 @@
         <android.support.v7.widget.RecyclerView
             android:id="@+id/actor_rotate"
             android:nestedScrollingEnabled="false"
-            android:layout_width="200dp"
+            android:layout_width="wrap_content"
             android:layout_height="159dp"
             android:orientation="horizontal">
         </android.support.v7.widget.RecyclerView>