mirror of
https://github.com/Mestima/ZomboidModsCopier.git
synced 2025-05-06 16:20:23 +00:00
Compare commits
No commits in common. "main" and "v1.0" have entirely different histories.
@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'me.mestima'
|
group 'me.mestima'
|
||||||
version '2.0'
|
version '1.0'
|
||||||
mainClassName = 'me.mestima.zomboidmodscopier.ZomboidCopierKt'
|
mainClassName = 'me.mestima.zomboidmodscopier.ZomboidCopierKt'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
package me.mestima.zomboidmodscopier
|
package me.mestima.zomboidmodscopier
|
||||||
|
|
||||||
import javafx.application.Platform
|
|
||||||
import javafx.fxml.FXML
|
import javafx.fxml.FXML
|
||||||
import javafx.scene.control.Alert
|
|
||||||
import javafx.scene.control.Button
|
|
||||||
import javafx.scene.control.ProgressBar
|
import javafx.scene.control.ProgressBar
|
||||||
import javafx.scene.control.TextField
|
import javafx.scene.control.TextField
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.Semaphore
|
import java.util.concurrent.Semaphore
|
||||||
|
|
||||||
class CopierController {
|
class CopierController {
|
||||||
@FXML
|
|
||||||
private lateinit var copyBtn: Button
|
|
||||||
|
|
||||||
@FXML
|
//private val secondPerMod: Long = 2
|
||||||
private lateinit var userBtn: Button
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var pathName: TextField
|
private lateinit var pathName: TextField
|
||||||
@ -25,35 +19,17 @@ class CopierController {
|
|||||||
@FXML
|
@FXML
|
||||||
private lateinit var progress: ProgressBar
|
private lateinit var progress: ProgressBar
|
||||||
|
|
||||||
@FXML
|
|
||||||
private fun onChangeUsername() {
|
|
||||||
userBtn.isDisable = true
|
|
||||||
userName.isDisable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private fun onCopy() {
|
private fun onCopy() {
|
||||||
var isCopying: Boolean = true
|
|
||||||
copyBtn.isDisable = true
|
|
||||||
userBtn.isDisable = true
|
|
||||||
pathName.isDisable = true
|
|
||||||
userName.isDisable = true
|
|
||||||
|
|
||||||
val startAlert: Alert = Alert(Alert.AlertType.INFORMATION)
|
|
||||||
startAlert.title = "Копирование"
|
|
||||||
startAlert.headerText = null
|
|
||||||
startAlert.contentText = "Копирование началось! Не закрывайте программу до окончания копирования. Это может привести к невообразимым последствиям..."
|
|
||||||
startAlert.show()
|
|
||||||
|
|
||||||
|
|
||||||
val path = pathName.text
|
val path = pathName.text
|
||||||
val dest = File("C:\\Users\\${userName.text}\\Zomboid")
|
val dest = File("C:\\Users\\${userName.text}\\Zomboid")
|
||||||
|
|
||||||
val queue = Semaphore(2)
|
val queue = Semaphore(2)
|
||||||
val folder = File(path)
|
val folder = File(path)
|
||||||
val modsCount: Double = folder.list().size.toDouble()
|
//val modsCount: Double = folder.list().size.toDouble()
|
||||||
val progressPerMod: Double = 1.0 / modsCount
|
//val progressPerMod: Double = 100.0 / modsCount
|
||||||
|
|
||||||
|
//var i: Long = 0
|
||||||
val lst = folder.list()
|
val lst = folder.list()
|
||||||
lst.forEach {
|
lst.forEach {
|
||||||
Thread {
|
Thread {
|
||||||
@ -61,27 +37,10 @@ class CopierController {
|
|||||||
|
|
||||||
val subfolder = File("$path\\$it")
|
val subfolder = File("$path\\$it")
|
||||||
subfolder.copyRecursively(dest, true)
|
subfolder.copyRecursively(dest, true)
|
||||||
if (isCopying) {
|
|
||||||
progress.progress += progressPerMod
|
|
||||||
println(progress.progress)
|
|
||||||
}
|
|
||||||
queue.release()
|
|
||||||
|
|
||||||
if (progress.progress >= 1.0) {
|
queue.release()
|
||||||
Platform.runLater {
|
if (it == lst.last()) {
|
||||||
if (isCopying) {
|
progress.progress = 100.0
|
||||||
isCopying = false
|
|
||||||
copyBtn.isDisable = false
|
|
||||||
userBtn.isDisable = false
|
|
||||||
pathName.isDisable = false
|
|
||||||
progress.progress = 0.0
|
|
||||||
val doneAlert: Alert = Alert(Alert.AlertType.INFORMATION)
|
|
||||||
doneAlert.title = "Копирование"
|
|
||||||
doneAlert.headerText = null
|
|
||||||
doneAlert.contentText = "Копирование завершено! Программу можно закрыть."
|
|
||||||
doneAlert.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
@ -89,7 +48,6 @@ class CopierController {
|
|||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
progress.progress = 0.0
|
progress.progress = 0.0
|
||||||
userName.text = System.getProperty("user.name")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,16 +5,16 @@ import javafx.fxml.FXMLLoader
|
|||||||
import javafx.scene.Scene
|
import javafx.scene.Scene
|
||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
|
|
||||||
class ZomboidCopier : Application() {
|
class HelloApplication : Application() {
|
||||||
override fun start(stage: Stage) {
|
override fun start(stage: Stage) {
|
||||||
val fxmlLoader = FXMLLoader(ZomboidCopier::class.java.getResource("main.fxml"))
|
val fxmlLoader = FXMLLoader(HelloApplication::class.java.getResource("main.fxml"))
|
||||||
val scene = Scene(fxmlLoader.load(), 483.0, 281.0)
|
val scene = Scene(fxmlLoader.load(), 483.0, 281.0)
|
||||||
stage.title = "Zomboid mods copier v2.0"
|
stage.title = "Zomboid mods copier v1.0"
|
||||||
stage.scene = scene
|
stage.scene = scene
|
||||||
stage.show()
|
stage.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Application.launch(ZomboidCopier::class.java)
|
Application.launch(HelloApplication::class.java)
|
||||||
}
|
}
|
@ -5,25 +5,18 @@
|
|||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ProgressBar?>
|
<?import javafx.scene.control.ProgressBar?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<VBox alignment="CENTER" prefHeight="281.0" prefWidth="483.0" spacing="10.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="me.mestima.zomboidmodscopier.CopierController">
|
<VBox alignment="CENTER" prefHeight="281.0" prefWidth="483.0" spacing="20.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="me.mestima.zomboidmodscopier.CopierController">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<children>
|
<children>
|
||||||
<Label prefHeight="18.0" prefWidth="445.0" text="Путь до папки Steam\steamapps\workshop\content\108600" />
|
<Label prefHeight="18.0" prefWidth="376.0" text="Путь до папки Steam\steamapps\workshop\content\108600" />
|
||||||
<TextField id="pathName" fx:id="pathName" />
|
<TextField id="pathName" fx:id="pathName" />
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="30.0" prefWidth="200.0">
|
<Label prefHeight="18.0" prefWidth="125.0" text="Имя пользователя" />
|
||||||
<children>
|
<TextField id="userName" fx:id="userName" />
|
||||||
<Label prefHeight="18.0" prefWidth="125.0" text="Имя пользователя" />
|
|
||||||
<Button fx:id="userBtn" mnemonicParsing="false" onAction="#onChangeUsername" prefHeight="25.0" prefWidth="318.0" text="Изменить имя пользователя" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<TextField id="userName" fx:id="userName" disable="true" />
|
|
||||||
<ProgressBar id="progress" fx:id="progress" prefHeight="26.0" prefWidth="443.0" progress="0.0" />
|
<ProgressBar id="progress" fx:id="progress" prefHeight="26.0" prefWidth="443.0" progress="0.0" />
|
||||||
<Button id="copyBtn" fx:id="copyBtn" mnemonicParsing="false" onAction="#onCopy" prefHeight="33.0" prefWidth="443.0" text="Копировать" />
|
<Button id="copyBtn" fx:id="copyBtn" mnemonicParsing="false" onAction="#onCopy" prefHeight="33.0" prefWidth="443.0" text="Копировать" />
|
||||||
<TextField editable="false" text="https://github.com/Mestima/ZomboidModsCopier" />
|
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user