Note: The client architecture is broken beyond repair
This commit is contained in:
CodeSteak 2019-06-13 00:10:00 +02:00
parent 1ac13f80d5
commit bc43b33536
5 changed files with 65 additions and 32 deletions

View File

@ -246,20 +246,10 @@ class RootController : Controller() {
dialogDelete.showAndWait()
}
/**
* send a changed texture to the server
* @param chips the new tag list
*/
fun updateTexture(chips: ObservableList<String>) {
val uuid = UUID.randomUUID()
val newTexture = Texture(
uuid,
selectedTextureModel.data.name,
chips.toTypedArray(),
selectedTextureModel.data.format,
selectedTextureModel.data.resolution,
selectedTextureModel.data.addedOn,
selectedTextureModel.data.textureHash
fun updateTexture(name: String, tags: Array<String>) {
val newTexture = selectedTextureModel.data.copy(
tags = tags,
name = name
)
try {
con.updateTexture(
@ -274,6 +264,7 @@ class RootController : Controller() {
}
}
/**
* show all available textures at start
*/

View File

@ -1,6 +1,8 @@
package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView
import com.jfoenix.controls.JFXTextField
import javafx.geometry.Insets
import javafx.geometry.Orientation
import javafx.scene.image.Image
@ -15,15 +17,14 @@ class DetailView : View() {
val preview = Preview3D()
val cvTags = JFXChipView<String>()
val nameInfo = label().addClass("metadata")
val nameInfo = JFXTextField().addClass("metadata")
val resolutionInfo = label().addClass("metadata")
val formatInfo = label().addClass("metadata")
val dateInfo = label().addClass("metadata")
val submitButton = JFXButton("Ändern").addClass("btn-orange")
val metadataPanel = gridpane {
isVisible = false
row {
label("Name ").addClass("metadata")
add(nameInfo)
@ -42,11 +43,6 @@ class DetailView : View() {
}
}
init {
// set a default texture
preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg"))
}
override val root = form {
minWidth = 250.0
background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY))
@ -68,6 +64,17 @@ class DetailView : View() {
add(cvTags)
}
field {
add(submitButton)
}
}
}
init {
// set a default texture
preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg"))
submitButton.useMaxWidth = true
}
}

View File

@ -78,8 +78,19 @@ class MainView : View("TextureSync") {
mvc.btnImportAction()
}
// TODO: on chipview update on name update
detailView.cvTags.chips.onChange {
detailView.submitButton.isVisible = true
}
detailView.nameInfo.textProperty().onChange {
detailView.submitButton.isVisible = true
}
detailView.submitButton.setOnAction {
mvc.updateTags()
detailView.submitButton.isVisible = false
}
//keyboard actions

View File

@ -2,10 +2,10 @@ package org.hso.texturesyncclient.view.mainView
import javafx.collections.ObservableList
import javafx.scene.image.Image
import org.hso.texturesyncclient.model.GUIModel
import tornadofx.Controller
import org.hso.texturesyncclient.controller.RootController
import org.hso.texturesyncclient.model.GUIModel
import org.hso.texturesyncclient.model.Texture
import tornadofx.Controller
class MainViewController : Controller() {
@ -31,7 +31,7 @@ class MainViewController : Controller() {
}
fun setMeta(name: String, res: String, format: String, date: String) {
with( mv.detailView) {
with(mv.detailView) {
nameInfo.text = name
formatInfo.text = format
resolutionInfo.text = date
@ -46,14 +46,17 @@ class MainViewController : Controller() {
lockUpdate = true //allow update with onChange
}
fun getTags(): ObservableList<String>{
fun getTags(): ObservableList<String> {
return cvTags.chips
}
fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user
println("Tags changed")
rootc.updateTexture(cvTags.chips)
rootc.updateTexture(
tags = cvTags.chips.toTypedArray(),
name = mv.detailView.nameInfo.text
)
}
}
@ -84,12 +87,14 @@ class MainViewController : Controller() {
.ifPresent { x -> folderView.children.remove(x) }
}
fun setVisibleMetaTags(bool: Boolean){
if(bool){
fun setVisibleMetaTags(bool: Boolean) {
if (bool) {
mv.detailView.metadataPanel.isVisible = true
mv.detailView.submitButton.isVisible = false
cvTags.isVisible = true
}else{
} else {
mv.detailView.metadataPanel.isVisible = false
mv.detailView.submitButton.isVisible = false
cvTags.isVisible = false
}
}

View File

@ -114,7 +114,26 @@
/*******************************************************************************
* *
* DetailView *
* Buttons *
* *
******************************************************************************/
.btn-blue {
-fx-button-type: RAISED;
-fx-background-color: #3c3f41;
-fx-text-fill: #2b7bbb;
-fx-padding: 10;
}
.btn-orange {
-fx-button-type: RAISED;
-fx-background-color: #b15b2e;
-fx-text-fill: #3c3f41;
}
/*******************************************************************************
* *
* DetailView *
* *
******************************************************************************/