A default new quest is now loaded when the quest editor starts up.

This commit is contained in:
Daan Vanden Bosch 2021-04-13 17:52:20 +02:00
parent b856a22851
commit 85df1015f8
3 changed files with 14 additions and 4 deletions

View File

@ -46,6 +46,7 @@ class QuestEditor(
// Stores
val areaStore = addDisposable(AreaStore(areaAssetLoader))
val questEditorStore = addDisposable(QuestEditorStore(
questLoader,
uiStore,
areaStore,
undoManager,
@ -56,7 +57,6 @@ class QuestEditor(
val questEditorController = addDisposable(QuestEditorController(questEditorUiPersister))
val toolbarController = addDisposable(QuestEditorToolbarController(
uiStore,
questLoader,
areaStore,
questEditorStore,
))

View File

@ -17,7 +17,6 @@ import world.phantasmal.observable.value.mutableVal
import world.phantasmal.observable.value.value
import world.phantasmal.web.core.PwToolType
import world.phantasmal.web.core.stores.UiStore
import world.phantasmal.web.questEditor.loading.QuestLoader
import world.phantasmal.web.questEditor.models.AreaModel
import world.phantasmal.web.questEditor.stores.AreaStore
import world.phantasmal.web.questEditor.stores.QuestEditorStore
@ -34,7 +33,6 @@ class AreaAndLabel(val area: AreaModel, val label: String)
class QuestEditorToolbarController(
uiStore: UiStore,
private val questLoader: QuestLoader,
private val areaStore: AreaStore,
private val questEditorStore: QuestEditorStore,
) : Controller() {
@ -127,7 +125,7 @@ class QuestEditorToolbarController(
suspend fun createNewQuest(episode: Episode) {
setFilename("")
setVersion(Version.BB)
setCurrentQuest(questLoader.loadDefaultQuest(episode))
questEditorStore.setDefaultQuest(episode)
}
suspend fun openFiles(files: List<File>) {

View File

@ -1,6 +1,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.list.emptyListVal
@ -12,12 +14,14 @@ import world.phantasmal.web.core.stores.UiStore
import world.phantasmal.web.core.undo.UndoManager
import world.phantasmal.web.core.undo.UndoStack
import world.phantasmal.web.questEditor.QuestRunner
import world.phantasmal.web.questEditor.loading.QuestLoader
import world.phantasmal.web.questEditor.models.*
import world.phantasmal.webui.stores.Store
private val logger = KotlinLogging.logger {}
class QuestEditorStore(
private val questLoader: QuestLoader,
uiStore: UiStore,
private val areaStore: AreaStore,
private val undoManager: UndoManager,
@ -87,6 +91,8 @@ class QuestEditorStore(
_selectedEntity.value = null
}
}
scope.launch { setDefaultQuest(Episode.I) }
}
override fun dispose() {
@ -136,6 +142,12 @@ class QuestEditorStore(
}
}
suspend fun setDefaultQuest(episode: Episode) {
setCurrentQuest(
convertQuestToModel(questLoader.loadDefaultQuest(episode), areaStore::getVariant)
)
}
private fun setSectionOnQuestEntities(
entities: List<QuestEntityModel<*, *>>,
variant: AreaVariantModel,