The 3D view camera now resets when a different area variant is configured for the current area.

This commit is contained in:
Daan Vanden Bosch 2021-04-18 12:02:24 +02:00
parent 147c910209
commit de8aef4cca
6 changed files with 15 additions and 19 deletions

View File

@ -161,6 +161,8 @@ Features that are in ***bold italics*** are planned but not yet implemented.
- When a modal dialog is open, global keybindings should be disabled
- The ASM editor is slow with big scripts, e.g. Seat of the Heart (#27)
- Improve the default camera target for Crater Interior
- Creating a new quest discards changes to previously open quest without asking user
- Opening a new file discards changes to previously open quest without asking user
- Entities with rendering issues:
- Caves 4 Button door
- Pofuilly Slime

View File

@ -17,9 +17,6 @@ class AreaVariant(
fun getAreasForEpisode(episode: Episode): List<Area> =
AREAS.getValue(episode)
fun getAreaVariant(episode: Episode, areaId: Int, variantId: Int): AreaVariant? =
AREAS.getValue(episode).find { it.id == areaId }?.areaVariants?.getOrNull(variantId)
private val AREAS by lazy {
var order = 0

View File

@ -57,7 +57,7 @@ fun <T1, T2, T3, R> map(
/**
* Map a transformation function that returns a val over 2 vals. The resulting val will change when
* either val changes and when the val returned by [transform] changes.
* either val changes and also when the val returned by [transform] changes.
*
* @param transform called whenever this val changes
*/

View File

@ -14,16 +14,8 @@ class QuestEditorMeshManager(
init {
observe(
questEditorStore.currentQuest,
questEditorStore.currentQuest.flatMapNull { it?.areaVariants },
questEditorStore.currentArea,
) { quest, questAreaVariants, area ->
val areaVariant = questAreaVariants?.let {
area?.let {
questAreaVariants.find { it.area.id == area.id }
?: area.areaVariants.first()
}
}
questEditorStore.currentAreaVariant,
) { quest, areaVariant ->
loadAreaMeshes(quest?.episode, areaVariant)
}

View File

@ -40,6 +40,6 @@ class QuestRenderer(
)
observe(questEditorStore.currentQuest) { inputManager.resetCamera() }
observe(questEditorStore.currentArea) { inputManager.resetCamera() }
observe(questEditorStore.currentAreaVariant) { inputManager.resetCamera() }
}
}

View File

@ -3,11 +3,8 @@ package world.phantasmal.web.questEditor.stores
import kotlinx.coroutines.launch
import mu.KotlinLogging
import world.phantasmal.lib.Episode
import world.phantasmal.observable.value.Val
import world.phantasmal.observable.value.and
import world.phantasmal.observable.value.*
import world.phantasmal.observable.value.list.emptyListVal
import world.phantasmal.observable.value.mutableVal
import world.phantasmal.observable.value.not
import world.phantasmal.web.core.PwToolType
import world.phantasmal.web.core.actions.Action
import world.phantasmal.web.core.stores.UiStore
@ -40,6 +37,14 @@ class QuestEditorStore(
private val runner = QuestRunner()
val currentQuest: Val<QuestModel?> = _currentQuest
val currentArea: Val<AreaModel?> = _currentArea
val currentAreaVariant: Val<AreaVariantModel?> =
map(currentArea, currentQuest.flatMapNull { it?.areaVariants }) { area, variants ->
if (area != null && variants != null) {
variants.find { it.area.id == area.id } ?: area.areaVariants.first()
} else {
null
}
}
val selectedEvent: Val<QuestEventModel?> = _selectedEvent
/**