Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync

This commit is contained in:
CodeSteak 2019-06-08 22:17:24 +02:00
commit 4a213afdf5
2 changed files with 35 additions and 8 deletions

View File

@ -104,6 +104,7 @@ class RootController : Controller() {
con.ping() con.ping()
println("auto Connection to Server successful") println("auto Connection to Server successful")
switchStartupToMain() switchStartupToMain()
showAll()
} else { } else {
println("[auto] no server found") println("[auto] no server found")
} }
@ -119,6 +120,7 @@ class RootController : Controller() {
con.ping() con.ping()
println("[file] Connection to Server successful") println("[file] Connection to Server successful")
switchStartupToMain() switchStartupToMain()
showAll()
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
println("[file] Connection to Server NOT successful") println("[file] Connection to Server NOT successful")
@ -135,6 +137,7 @@ class RootController : Controller() {
println("Connection to Server successful") println("Connection to Server successful")
SettingsController.setServerAddress(name) //store address in settings file SettingsController.setServerAddress(name) //store address in settings file
switchStartupToMain() switchStartupToMain()
showAll()
println("swithing to MainView @ initCon") println("swithing to MainView @ initCon")
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
@ -144,6 +147,7 @@ class RootController : Controller() {
} }
fun queryElements(tags: ObservableList<String>): ArrayList<GUIModel> { fun queryElements(tags: ObservableList<String>): ArrayList<GUIModel> {
mvc.setVisibleMetaTags(false)
val previewList = arrayListOf<GUIModel>() val previewList = arrayListOf<GUIModel>()
try { try {
@ -230,9 +234,15 @@ class RootController : Controller() {
mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash)) mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash))
val sdf = SimpleDateFormat("dd.MM.yyyy") val sdf = SimpleDateFormat("dd.MM.yyyy")
mvc.setMeta(data.name, "${data.resolution.first}px x ${data.resolution.second}px", data.format.toString(), sdf.format(data.addedOn.time)) mvc.setMeta(
data.name,
"${data.resolution.first}px x ${data.resolution.second}px",
data.format.toString(),
sdf.format(data.addedOn.time)
)
mvc.setTags(data.tags.toList().observable()) mvc.setTags(data.tags.toList().observable())
selectedTexture = data selectedTexture = data
mvc.setVisibleMetaTags(true)
} }
/** /**
@ -255,7 +265,10 @@ class RootController : Controller() {
dialogDelete.showAndWait() dialogDelete.showAndWait()
} }
/**
* send a changed texture to the server
* @param chips the new tag list
*/
fun updateTexture(chips: ObservableList<String>) { fun updateTexture(chips: ObservableList<String>) {
val uuid = UUID.randomUUID() val uuid = UUID.randomUUID()
val newTexture = Texture( val newTexture = Texture(
@ -270,4 +283,10 @@ class RootController : Controller() {
con.updateTexture(selectedTexture, newTexture, con.getTextureFile(selectedTexture.textureHash)) con.updateTexture(selectedTexture, newTexture, con.getTextureFile(selectedTexture.textureHash))
} }
/**
* show all available textures at start
*/
fun showAll() {
queryElements(mvc.getTags())
}
} }

View File

@ -26,11 +26,6 @@ class MainViewController : Controller() {
folderView.children.add(element) folderView.children.add(element)
} }
fun addAllElements(elementList: ArrayList<GUIModel>) {
folderView.children.addAll(elementList)
}
// DetailView functions // DetailView functions
fun setPreview3DTexture(img: Image) { fun setPreview3DTexture(img: Image) {
preview.setTexture(img) preview.setTexture(img)
@ -47,6 +42,10 @@ class MainViewController : Controller() {
lockUpdate = true //allow update with onChange lockUpdate = true //allow update with onChange
} }
fun getTags(): ObservableList<String>{
return cvTags.chips
}
fun updateTags() { fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user if (lockUpdate) { //the chipView was changed by the user
println("Tags changed") println("Tags changed")
@ -74,11 +73,20 @@ class MainViewController : Controller() {
rootc.switchMainToImport() rootc.switchMainToImport()
} }
fun removeTextureFromView(data: Texture) { fun removeTextureFromView(data: Texture) {
// stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView // stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView
folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny() folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny()
.ifPresent { x -> folderView.children.remove(x) } .ifPresent { x -> folderView.children.remove(x) }
} }
fun setVisibleMetaTags(bool: Boolean){
if(bool){
metaLabel.isVisible = true
cvTags.isVisible = true
}else{
metaLabel.isVisible = false
cvTags.isVisible = false
}
}
} }