mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 13:06:30 +02:00
Ask the user if they want to continue launching, if update/install fails
This commit is contained in:
parent
81a60cc759
commit
2c02703101
@ -60,7 +60,7 @@ class Main(args: Array<String>) {
|
||||
|
||||
val title = cmd.getOptionValue("title")
|
||||
if (title != null) {
|
||||
ui.setTitle(title)
|
||||
ui.title = title
|
||||
}
|
||||
|
||||
ui.show()
|
||||
|
@ -118,6 +118,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
|
||||
gson.fromJson(FileReader(Paths.get(opts.packFolder, opts.manifestFile).toString()),
|
||||
ManifestFile::class.java)
|
||||
} catch (e: FileNotFoundException) {
|
||||
ui.firstInstall = true
|
||||
ManifestFile()
|
||||
} catch (e: JsonSyntaxException) {
|
||||
ui.showErrorAndExit("Invalid local manifest file, try deleting ${opts.manifestFile}", e)
|
||||
|
@ -13,7 +13,7 @@ interface IUserInterface {
|
||||
}
|
||||
fun showErrorAndExit(message: String, e: Exception?): Nothing
|
||||
|
||||
fun setTitle(title: String) {}
|
||||
var title: String
|
||||
fun submitProgress(progress: InstallProgress)
|
||||
// Return true if the installation was cancelled!
|
||||
fun showOptions(options: List<IOptionDetails>): Boolean
|
||||
@ -33,4 +33,6 @@ interface IUserInterface {
|
||||
|
||||
var optionsButtonPressed: Boolean
|
||||
var cancelButtonPressed: Boolean
|
||||
|
||||
var firstInstall: Boolean
|
||||
}
|
@ -13,6 +13,10 @@ class CLIHandler : IUserInterface {
|
||||
override var optionsButtonPressed = false
|
||||
@Volatile
|
||||
override var cancelButtonPressed = false
|
||||
@Volatile
|
||||
override var firstInstall = false
|
||||
|
||||
override var title: String = ""
|
||||
|
||||
override fun showErrorAndExit(message: String, e: Exception?): Nothing {
|
||||
if (e != null) {
|
||||
|
@ -20,8 +20,14 @@ class GUIHandler : IUserInterface {
|
||||
override var optionsButtonPressed = false
|
||||
@Volatile
|
||||
override var cancelButtonPressed = false
|
||||
@Volatile
|
||||
override var firstInstall = false
|
||||
|
||||
private var title = "Updating modpack..."
|
||||
override var title = "packwiz-installer"
|
||||
set(value) {
|
||||
field = value
|
||||
EventQueue.invokeLater { frmPackwizlauncher.title = value }
|
||||
}
|
||||
|
||||
init {
|
||||
EventQueue.invokeAndWait {
|
||||
@ -45,29 +51,41 @@ class GUIHandler : IUserInterface {
|
||||
}
|
||||
|
||||
override fun showErrorAndExit(message: String, e: Exception?): Nothing {
|
||||
val buttons = arrayOf("Quit", if (firstInstall) "Continue without installing" else "Continue without updating")
|
||||
if (e != null) {
|
||||
Log.fatal(message, e)
|
||||
EventQueue.invokeAndWait {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
val result = JOptionPane.showOptionDialog(frmPackwizlauncher,
|
||||
"$message: $e",
|
||||
title, JOptionPane.ERROR_MESSAGE)
|
||||
title,
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, buttons, buttons[0])
|
||||
if (result == 1) {
|
||||
Log.info("User selected to continue without installing/updating, exiting with code 0...")
|
||||
exitProcess(0)
|
||||
} else {
|
||||
Log.info("User selected to quit, exiting with code 1...")
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.fatal(message)
|
||||
EventQueue.invokeAndWait {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
val result = JOptionPane.showOptionDialog(frmPackwizlauncher,
|
||||
message,
|
||||
title, JOptionPane.ERROR_MESSAGE)
|
||||
title,
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, buttons, buttons[0])
|
||||
if (result == 1) {
|
||||
Log.info("User selected to continue without installing/updating, exiting with code 0...")
|
||||
exitProcess(0)
|
||||
} else {
|
||||
Log.info("User selected to quit, exiting with code 1...")
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
exitProcess(1)
|
||||
}
|
||||
|
||||
override fun setTitle(title: String) {
|
||||
this.title = title
|
||||
EventQueue.invokeLater { frmPackwizlauncher.title = title }
|
||||
}
|
||||
|
||||
override fun submitProgress(progress: InstallProgress) {
|
||||
val sb = StringBuilder()
|
||||
if (progress.hasProgress) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user