Compare commits

..

No commits in common. "3f18760a74d8aed254a9f10c18f72af176e4ca6e" and "3e1c46db81c56b3a1556a3dbbd61cf9b6640e94f" have entirely different histories.

View File

@ -49,7 +49,7 @@ class RootController : Controller() {
* @param tags all tags for the file * @param tags all tags for the file
*/ */
fun importTexture(path: String, name: String, tags: ObservableList<String>) { fun importTexture(path: String, name: String, tags: ObservableList<String>) {
var data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
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
@ -58,33 +58,15 @@ class RootController : Controller() {
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)
//Todo free image
val alertImportHash = JFXInfoAlert(
"Upload fehlgeschlagen",
"Die Textur wurde nicht fehlerfrei übertragen",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
val alertImport = JFXInfoAlert(
"Upload fehlgeschlagen",
"Mögliche Ursachen:" +
"\n- Textur existiert bereits" +
"\n- Server nicht bereit",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
data = null //Free image
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash) val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
try { try {
con.uploadTexture(newTexture, data) con.uploadTexture(newTexture, data)
println("Texture upload successful") println("Texture upload successful")
} catch (e: IllegalArgumentException) {
println(e)
alertImportHash.showAndWait()
} catch (e: Exception) { } catch (e: Exception) {
alertImport.showAndWait() println(e)
} }
} }
@ -196,8 +178,8 @@ class RootController : Controller() {
val alertExport = JFXInfoAlert( val alertExport = JFXInfoAlert(
"Exporterien fehlgeschlagen", "Exporterien fehlgeschlagen",
"Mögliche Ursachen:" + "Mögliche Ursachen:" +
"\n- Datei existiert bereits" + "\n-Datei existiert bereits" +
"\n- Ordner nicht beschreibbar", "\n-Ordner nicht beschreibbar",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;" "-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
) )