mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 15:28:29 +08:00
Added a "Clear animation" button to the viewer.
This commit is contained in:
parent
1c44ce4620
commit
610a2bb64a
@ -23,6 +23,7 @@ class ViewerToolbarController(private val store: ViewerStore) : Controller() {
|
|||||||
private val _result = mutableVal<PwResult<*>?>(null)
|
private val _result = mutableVal<PwResult<*>?>(null)
|
||||||
|
|
||||||
val showSkeleton: Val<Boolean> = store.showSkeleton
|
val showSkeleton: Val<Boolean> = store.showSkeleton
|
||||||
|
val clearCurrentAnimationButtonEnabled = store.currentNinjaMotion.isNotNull()
|
||||||
val resultDialogVisible: Val<Boolean> = _resultDialogVisible
|
val resultDialogVisible: Val<Boolean> = _resultDialogVisible
|
||||||
val result: Val<PwResult<*>?> = _result
|
val result: Val<PwResult<*>?> = _result
|
||||||
val resultMessage: Val<String> = result.map {
|
val resultMessage: Val<String> = result.map {
|
||||||
@ -36,6 +37,10 @@ class ViewerToolbarController(private val store: ViewerStore) : Controller() {
|
|||||||
store.setShowSkeleton(show)
|
store.setShowSkeleton(show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun clearCurrentAnimation() {
|
||||||
|
store.setCurrentAnimation(null)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun openFiles(files: List<File>) {
|
suspend fun openFiles(files: List<File>) {
|
||||||
val result = PwResult.build<Unit>(logger)
|
val result = PwResult.build<Unit>(logger)
|
||||||
var success = false
|
var success = false
|
||||||
|
@ -177,10 +177,15 @@ class ViewerStore(
|
|||||||
_currentNinjaMotion.value = njm
|
_currentNinjaMotion.value = njm
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setCurrentAnimation(animation: AnimationModel) {
|
suspend fun setCurrentAnimation(animation: AnimationModel?) {
|
||||||
_currentAnimation.value = animation
|
_currentAnimation.value = animation
|
||||||
|
|
||||||
|
if (animation == null) {
|
||||||
|
_currentNinjaMotion.value = null
|
||||||
|
} else {
|
||||||
loadAnimation(animation)
|
loadAnimation(animation)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setShowSkeleton(show: Boolean) {
|
fun setShowSkeleton(show: Boolean) {
|
||||||
_showSkeleton.value = show
|
_showSkeleton.value = show
|
||||||
|
@ -26,6 +26,11 @@ class ViewerToolbar(private val ctrl: ViewerToolbarController) : Widget() {
|
|||||||
checked = ctrl.showSkeleton,
|
checked = ctrl.showSkeleton,
|
||||||
onChange = ctrl::setShowSkeleton,
|
onChange = ctrl::setShowSkeleton,
|
||||||
),
|
),
|
||||||
|
Button(
|
||||||
|
text = "Clear animation",
|
||||||
|
enabled = ctrl.clearCurrentAnimationButtonEnabled,
|
||||||
|
onClick = { scope.launch { ctrl.clearCurrentAnimation() } },
|
||||||
|
),
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
addDisposable(ResultDialog(
|
addDisposable(ResultDialog(
|
||||||
|
Loading…
Reference in New Issue
Block a user