Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene name validation #113

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.mbrlabs.mundus.editor.ui.modules.menu
import com.badlogic.gdx.scenes.scene2d.InputEvent
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
import com.badlogic.gdx.utils.Array
import com.kotcrab.vis.ui.util.InputValidator
import com.kotcrab.vis.ui.util.dialog.Dialogs
import com.kotcrab.vis.ui.util.dialog.InputDialogAdapter
import com.kotcrab.vis.ui.widget.Menu
Expand Down Expand Up @@ -52,10 +53,11 @@ class SceneMenu : Menu("Scenes"),

addScene.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
Dialogs.showInputDialog(UI, "Add Scene", "Name:", object : InputDialogAdapter() {
override fun finished(input: String?) {
Dialogs.showInputDialog(UI, "Add Scene", "Name:", SceneNameValidator(), object : InputDialogAdapter() {
override fun finished(input: String) {
val newSceneName = input.trim()
val project = projectManager.current()
val scene = projectManager.createScene(project, input)
val scene = projectManager.createScene(project, newSceneName)
projectManager.changeScene(project, scene.name)
Mundus.postEvent(SceneAddedEvent(scene))
}
Expand Down Expand Up @@ -103,4 +105,11 @@ class SceneMenu : Menu("Scenes"),
Log.trace(TAG, "SceneMenu", "New scene [{}] added.", sceneName)
}

inner class SceneNameValidator : InputValidator {
override fun validateInput(input: String): Boolean {
return input.isNotBlank()
}

}

}