don't open export if nothing is selected & clean up
This commit is contained in:
parent
225316abb9
commit
391dfe4282
@ -32,16 +32,11 @@ import javax.imageio.ImageIO
|
|||||||
class RootController : Controller() {
|
class RootController : Controller() {
|
||||||
|
|
||||||
private val mvc: MainViewController by inject()
|
private val mvc: MainViewController by inject()
|
||||||
|
|
||||||
private val svc: StartupViewController by inject()
|
private val svc: StartupViewController by inject()
|
||||||
|
|
||||||
private lateinit var con: Connection
|
private lateinit var con: Connection
|
||||||
|
|
||||||
private lateinit var selectedTextureModel: GUIModel
|
private lateinit var selectedTextureModel: GUIModel
|
||||||
|
|
||||||
private var lastExportDir: String = System.getProperty("user.home")
|
private var lastExportDir: String = System.getProperty("user.home")
|
||||||
lateinit var selectedTexture: Texture
|
|
||||||
fun isSelectedTextureInitialized() = ::selectedTexture.isInitialized
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calculate the resolution, get today's date -> upload to server
|
* calculate the resolution, get today's date -> upload to server
|
||||||
@ -54,7 +49,7 @@ class RootController : Controller() {
|
|||||||
|
|
||||||
val uuid = UUID.randomUUID()
|
val uuid = UUID.randomUUID()
|
||||||
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
|
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
|
||||||
var bimg = ImageIO.read(File(path)) //image for obtaining resolution
|
val bimg = ImageIO.read(File(path)) //image for obtaining resolution
|
||||||
val resolution = Pair(bimg.height, bimg.width)
|
val resolution = Pair(bimg.height, bimg.width)
|
||||||
val cal = Calendar.getInstance() //calendar obj with current time
|
val cal = Calendar.getInstance() //calendar obj with current time
|
||||||
val hash = Sha256(data)
|
val hash = Sha256(data)
|
||||||
@ -228,9 +223,8 @@ class RootController : Controller() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* remove a texture from the FolderView and the server
|
* remove a texture from the FolderView and the server
|
||||||
* @param data the texture as meta element
|
|
||||||
*/
|
*/
|
||||||
fun deleteTexture(data: Texture) {
|
fun deleteTexture() {
|
||||||
val dialogDelete = JFXOkayCancelAlert(
|
val dialogDelete = JFXOkayCancelAlert(
|
||||||
"Löschen",
|
"Löschen",
|
||||||
"Textur ${selectedTextureModel.data.name} wirklich löschen?",
|
"Textur ${selectedTextureModel.data.name} wirklich löschen?",
|
||||||
@ -257,7 +251,6 @@ class RootController : Controller() {
|
|||||||
newTexture,
|
newTexture,
|
||||||
con.getTextureFile(selectedTextureModel.data.textureHash)
|
con.getTextureFile(selectedTextureModel.data.textureHash)
|
||||||
)
|
)
|
||||||
selectedTextureModel.setTexture(newTexture)
|
|
||||||
selectedTextureModel.data = newTexture
|
selectedTextureModel.data = newTexture
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println(e)
|
println(e)
|
||||||
@ -278,9 +271,13 @@ class RootController : Controller() {
|
|||||||
*/
|
*/
|
||||||
fun setSelectedTexture(model: GUIModel) {
|
fun setSelectedTexture(model: GUIModel) {
|
||||||
selectedTextureModel = model
|
selectedTextureModel = model
|
||||||
|
selectedTexture = model.data
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
var selectedTexture: Texture? = null
|
||||||
|
|
||||||
fun switchStartupToMain() {
|
fun switchStartupToMain() {
|
||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
|
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
|
||||||
|
@ -12,6 +12,7 @@ import javafx.scene.layout.BackgroundFill
|
|||||||
import javafx.scene.layout.CornerRadii
|
import javafx.scene.layout.CornerRadii
|
||||||
import javafx.scene.layout.VBox
|
import javafx.scene.layout.VBox
|
||||||
import javafx.scene.paint.Paint
|
import javafx.scene.paint.Paint
|
||||||
|
import org.hso.texturesyncclient.controller.RootController
|
||||||
import tornadofx.addClass
|
import tornadofx.addClass
|
||||||
import tornadofx.find
|
import tornadofx.find
|
||||||
import tornadofx.paddingTop
|
import tornadofx.paddingTop
|
||||||
@ -24,12 +25,9 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox() {
|
|||||||
private var exportItem = MenuItem("exportiern")
|
private var exportItem = MenuItem("exportiern")
|
||||||
private var deleteItem = MenuItem("löschen")
|
private var deleteItem = MenuItem("löschen")
|
||||||
|
|
||||||
private lateinit var texture: Texture
|
|
||||||
|
|
||||||
private val gmc = find(GUIModelController::class)
|
private val gmc = find(GUIModelController::class)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
texture = data
|
|
||||||
super.setPadding(Insets(5.0, 5.0, 5.0, 5.0))
|
super.setPadding(Insets(5.0, 5.0, 5.0, 5.0))
|
||||||
super.getChildren().addAll(image, label)
|
super.getChildren().addAll(image, label)
|
||||||
super.setOnContextMenuRequested { p0 -> contextMenu.show(this@GUIModel, p0.screenX, p0.screenY) }
|
super.setOnContextMenuRequested { p0 -> contextMenu.show(this@GUIModel, p0.screenX, p0.screenY) }
|
||||||
@ -69,15 +67,11 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteItem.setOnAction {
|
deleteItem.setOnAction {
|
||||||
gmc.delete(data)
|
gmc.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMenu.items.add(exportItem)
|
contextMenu.items.add(exportItem)
|
||||||
contextMenu.items.add(deleteItem)
|
contextMenu.items.add(deleteItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTexture(data: Texture) {
|
|
||||||
texture = data
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -14,8 +14,8 @@ class GUIModelController : Controller() {
|
|||||||
rootc.exportTexture(data)
|
rootc.exportTexture(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun delete(data: Texture) {
|
fun delete() {
|
||||||
rootc.deleteTexture(data)
|
rootc.deleteTexture()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun previewSelectedAction(data: Texture) {
|
fun previewSelectedAction(data: Texture) {
|
||||||
|
@ -67,7 +67,7 @@ class MainViewController : Controller() {
|
|||||||
folderView.children.clear()
|
folderView.children.clear()
|
||||||
mv.cvSearch.isDisable = true
|
mv.cvSearch.isDisable = true
|
||||||
setPreview3DTexture(Image("icons/TextureSync_Icon_256x256.jpeg")) // reset the 3DPreview to the logo
|
setPreview3DTexture(Image("icons/TextureSync_Icon_256x256.jpeg")) // reset the 3DPreview to the logo
|
||||||
// TODO should we clear the selectedTexture?
|
RootController.selectedTexture = null
|
||||||
|
|
||||||
runAsync {
|
runAsync {
|
||||||
rootc.queryElements(tags)
|
rootc.queryElements(tags)
|
||||||
@ -100,9 +100,7 @@ class MainViewController : Controller() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun scExport() {
|
fun scExport() {
|
||||||
if (rootc.isSelectedTextureInitialized()) {
|
RootController.selectedTexture?.let { rootc.exportTexture(RootController.selectedTexture!!) }
|
||||||
rootc.exportTexture(rootc.selectedTexture)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user