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()
println("auto Connection to Server successful")
switchStartupToMain()
showAll()
} else {
println("[auto] no server found")
}
@ -119,6 +120,7 @@ class RootController : Controller() {
con.ping()
println("[file] Connection to Server successful")
switchStartupToMain()
showAll()
} catch (e: Exception) {
println(e)
println("[file] Connection to Server NOT successful")
@ -135,6 +137,7 @@ class RootController : Controller() {
println("Connection to Server successful")
SettingsController.setServerAddress(name) //store address in settings file
switchStartupToMain()
showAll()
println("swithing to MainView @ initCon")
} catch (e: Exception) {
println(e)
@ -144,6 +147,7 @@ class RootController : Controller() {
}
fun queryElements(tags: ObservableList<String>): ArrayList<GUIModel> {
mvc.setVisibleMetaTags(false)
val previewList = arrayListOf<GUIModel>()
try {
@ -230,9 +234,15 @@ class RootController : Controller() {
mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash))
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())
selectedTexture = data
mvc.setVisibleMetaTags(true)
}
/**
@ -255,7 +265,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(
@ -270,4 +283,10 @@ class RootController : Controller() {
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)
}
fun addAllElements(elementList: ArrayList<GUIModel>) {
folderView.children.addAll(elementList)
}
// DetailView functions
fun setPreview3DTexture(img: Image) {
preview.setTexture(img)
@ -47,6 +42,10 @@ class MainViewController : Controller() {
lockUpdate = true //allow update with onChange
}
fun getTags(): ObservableList<String>{
return cvTags.chips
}
fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user
println("Tags changed")
@ -74,11 +73,20 @@ class MainViewController : Controller() {
rootc.switchMainToImport()
}
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
folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny()
.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
}
}
}