[Editor] Create Project Properties scaffolding
This commit is contained in:
@@ -15,6 +15,8 @@ import com.bartlomiejpluta.base.editor.map.view.editor.MapFragment
|
|||||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
||||||
import com.bartlomiejpluta.base.editor.process.view.ProcessLogsView
|
import com.bartlomiejpluta.base.editor.process.view.ProcessLogsView
|
||||||
import com.bartlomiejpluta.base.editor.project.context.ProjectContext
|
import com.bartlomiejpluta.base.editor.project.context.ProjectContext
|
||||||
|
import com.bartlomiejpluta.base.editor.project.view.ProjectParametersView
|
||||||
|
import javafx.beans.binding.Bindings.createStringBinding
|
||||||
import javafx.collections.MapChangeListener
|
import javafx.collections.MapChangeListener
|
||||||
import javafx.event.Event
|
import javafx.event.Event
|
||||||
import javafx.scene.control.Tab
|
import javafx.scene.control.Tab
|
||||||
@@ -31,6 +33,7 @@ class MainView : View("BASE Game Editor") {
|
|||||||
private val scriptFilesView = find<ScriptFilesView>()
|
private val scriptFilesView = find<ScriptFilesView>()
|
||||||
private val buildLogsView = find<BuildLogsView>()
|
private val buildLogsView = find<BuildLogsView>()
|
||||||
private val processLogsView = find<ProcessLogsView>()
|
private val processLogsView = find<ProcessLogsView>()
|
||||||
|
private val projectPropertiesView = find<ProjectParametersView>()
|
||||||
|
|
||||||
private val openTabs = mutableMapOf<Scope, Tab>()
|
private val openTabs = mutableMapOf<Scope, Tab>()
|
||||||
|
|
||||||
@@ -78,8 +81,13 @@ class MainView : View("BASE Game Editor") {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
projectContext.projectProperty.addListener { _, _, project ->
|
projectContext.projectProperty.addListener { _, _, project ->
|
||||||
val projectName = project?.let { " :: ${it.name} (${it.sourceDirectory.absolutePath})" } ?: ""
|
when (project) {
|
||||||
title = "BASE Game Editor$projectName"
|
null -> "BASE Game Editor".toProperty()
|
||||||
|
else -> createStringBinding(
|
||||||
|
{ "BASE Game Editor :: ${project.name} (${project.sourceDirectory.absolutePath})" },
|
||||||
|
project.nameProperty, project.sourceDirectoryProperty
|
||||||
|
)
|
||||||
|
}.let { titleProperty.bind(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe<AppendBuildLogsEvent> {
|
subscribe<AppendBuildLogsEvent> {
|
||||||
@@ -110,6 +118,10 @@ class MainView : View("BASE Game Editor") {
|
|||||||
item("Assets", expanded = false) {
|
item("Assets", expanded = false) {
|
||||||
this += assetsView
|
this += assetsView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item("Project Parameters") {
|
||||||
|
this += projectPropertiesView
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom = drawer {
|
bottom = drawer {
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.bartlomiejpluta.base.editor.project.view
|
||||||
|
|
||||||
|
import com.bartlomiejpluta.base.editor.common.parameter.model.StringParameter
|
||||||
|
import com.bartlomiejpluta.base.editor.common.parameter.view.ParametersTableFragment
|
||||||
|
import com.bartlomiejpluta.base.editor.project.context.ProjectContext
|
||||||
|
import javafx.beans.property.SimpleStringProperty
|
||||||
|
import tornadofx.View
|
||||||
|
import tornadofx.observableListOf
|
||||||
|
|
||||||
|
class ProjectParametersView : View() {
|
||||||
|
private val projectContext: ProjectContext by di()
|
||||||
|
private val name = SimpleStringProperty()
|
||||||
|
|
||||||
|
private val parameters = observableListOf(
|
||||||
|
StringParameter("name", "", onCommit = { _, _, submit ->
|
||||||
|
submit()
|
||||||
|
projectContext.save()
|
||||||
|
}).apply { bindBidirectional(name) }
|
||||||
|
)
|
||||||
|
|
||||||
|
init {
|
||||||
|
projectContext.projectProperty.addListener { _, _, project ->
|
||||||
|
project?.let {
|
||||||
|
name.bindBidirectional(it.nameProperty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val root = find<ParametersTableFragment>(ParametersTableFragment::parameters to parameters).root
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user