|
@@ -1,11 +1,15 @@
|
|
|
package com.bomostory.sceneeditmodule.screen.view
|
|
|
|
|
|
import android.content.Context
|
|
|
+import android.graphics.Paint
|
|
|
import android.graphics.drawable.Drawable
|
|
|
import android.support.constraint.ConstraintLayout
|
|
|
import android.util.AttributeSet
|
|
|
+import android.util.DisplayMetrics
|
|
|
import android.view.ViewGroup
|
|
|
+import android.view.WindowManager
|
|
|
import android.widget.RelativeLayout
|
|
|
+import com.bomostory.sceneeditmodule.basicdata.Actor
|
|
|
import com.bomostory.sceneeditmodule.basicdata.Scene
|
|
|
import kotlin.math.pow
|
|
|
|
|
@@ -19,19 +23,60 @@ class MovieView : ConstraintLayout {
|
|
|
value?.let {
|
|
|
removeAllViews()
|
|
|
|
|
|
+ val screenWidth = it.sceneWidth
|
|
|
+ val screenHeight = it.sceneWidth / 2
|
|
|
+ val widthScaleFactor: Float = layoutParams.width / screenWidth.toFloat()
|
|
|
+ val heightScaleFactor: Float = layoutParams.height / screenHeight.toFloat()
|
|
|
+
|
|
|
backgroundView.apply {
|
|
|
- var lParams = RelativeLayout.LayoutParams(it.sceneWidth + it.sceneWidth.div(32),it.sceneWidth.div(2))
|
|
|
+ val width = (it.sceneWidth * 33 / 32f * widthScaleFactor).toInt()
|
|
|
+ val height = (it.sceneWidth / 2 * heightScaleFactor).toInt()
|
|
|
+ var lParams = RelativeLayout.LayoutParams(width, height)
|
|
|
layoutParams = lParams
|
|
|
background = Drawable.createFromPath(it.backgroundPath)
|
|
|
- x = -(it.sceneWidth.div(64)).toFloat()
|
|
|
+ x = -width / 64f
|
|
|
}
|
|
|
addView(backgroundView)
|
|
|
|
|
|
+ val CONTROLLER_RADIUS = 25
|
|
|
for (layer in it.layers) {
|
|
|
val layerView = LayerView(context)
|
|
|
+
|
|
|
+ val actorsFix = ArrayList<Actor>()
|
|
|
+ for (actor in layer.actors) {
|
|
|
+ val actorFix = Actor().apply {
|
|
|
+ resourcePath = actor.resourcePath
|
|
|
+ if (!actor.isDialogue) {
|
|
|
+ positionX = ((actor.positionX + CONTROLLER_RADIUS * 2) * widthScaleFactor).toInt()
|
|
|
+ positionY = ((actor.positionY + CONTROLLER_RADIUS * 2) * heightScaleFactor).toInt()
|
|
|
+ sideLength = ((actor.sideLength - CONTROLLER_RADIUS * 4) * widthScaleFactor).toInt()
|
|
|
+ sideHeight = ((actor.sideHeight - CONTROLLER_RADIUS * 4) * heightScaleFactor).toInt()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ positionX = actor.positionX
|
|
|
+ positionY = actor.positionY
|
|
|
+ sideLength = actor.sideLength
|
|
|
+ sideHeight = actor.sideHeight
|
|
|
+ }
|
|
|
+ positionZ = actor.positionZ
|
|
|
+ isSelect = actor.isSelect
|
|
|
+ parentLayerIndex = actor.parentLayerIndex
|
|
|
+ isMovable = actor.isMovable
|
|
|
+ text = actor.text
|
|
|
+ textColor = actor.textColor
|
|
|
+ textAlign = actor.textAlign
|
|
|
+ isDialogue = actor.isDialogue
|
|
|
+ isMirror = actor.isMirror
|
|
|
+ opacity = actor.opacity
|
|
|
+ dialogColor = actor.dialogColor
|
|
|
+ dialogType = actor.dialogType
|
|
|
+ }
|
|
|
+ actorsFix.add(actorFix)
|
|
|
+ }
|
|
|
+
|
|
|
layerView.apply {
|
|
|
id = layer.id
|
|
|
- actors = layer.actors
|
|
|
+ actors = actorsFix
|
|
|
}
|
|
|
addView(layerView)
|
|
|
}
|
|
@@ -43,25 +88,14 @@ class MovieView : ConstraintLayout {
|
|
|
field = value
|
|
|
scene?.let {
|
|
|
|
|
|
- backgroundView.apply {
|
|
|
- layout(
|
|
|
- (value / 2f.pow(5)).toInt(),
|
|
|
- y.toInt(),
|
|
|
- (value / 2f.pow(5)).toInt() + width,
|
|
|
- y.toInt() + height
|
|
|
- )
|
|
|
- }
|
|
|
+ val screenWidth = it.sceneWidth
|
|
|
+ val widthScaleFactor: Float = layoutParams.width / screenWidth.toFloat()
|
|
|
+
|
|
|
+ backgroundView.x = value * widthScaleFactor / 32f - backgroundView.width / 64f
|
|
|
|
|
|
for (layer in it.layers) {
|
|
|
val layerView = findViewById<LayerView>(layer.id)
|
|
|
- layerView.apply {
|
|
|
- layout(
|
|
|
- value / ((2f.pow(it.layers.indexOf(layer))).toInt()),
|
|
|
- y.toInt(),
|
|
|
- value / ((2f.pow(it.layers.indexOf(layer))).toInt()) + width,
|
|
|
- y.toInt() + height
|
|
|
- )
|
|
|
- }
|
|
|
+ layerView.x = value * widthScaleFactor / (2f.pow(it.layers.indexOf(layer)))
|
|
|
}
|
|
|
}
|
|
|
}
|