From e676f58a80d24f742c1a0aa82eda885509365ff2 Mon Sep 17 00:00:00 2001 From: Rizlim Date: Tue, 4 Jun 2019 00:45:26 +0200 Subject: [PATCH] 1.11.3 --- .../kotlin/PAL2/Database/DataBaseHandler.kt | 17 ++++++++++++ src/main/kotlin/PAL2/GUI/CoreController.kt | 25 ++++++++++++++++++ src/main/kotlin/PAL2/GlobalData.kt | 1 + .../PAL2/SystemHandling/AddonUpdater.kt | 26 ++++++++++--------- src/main/resources/CoreUI.fxml | 5 ++++ src/main/resources/update_notes.html | 1 + 6 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/PAL2/Database/DataBaseHandler.kt b/src/main/kotlin/PAL2/Database/DataBaseHandler.kt index 7cf38e5..b1f848a 100644 --- a/src/main/kotlin/PAL2/Database/DataBaseHandler.kt +++ b/src/main/kotlin/PAL2/Database/DataBaseHandler.kt @@ -539,6 +539,23 @@ fun putSetting(name: String, value: String) connection.close() } +fun insSetting(name: String, value: String) +{ + val connection = connectToDB() + val sql = "INSERT into Settings values (\'$name\', \'$value\')" + connection.createStatement().execute(sql) + connection.close() +} + +fun checkSettingExist(name: String): Boolean +{ + val connection = connectToDB() + var rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM Settings WHERE name = \'$name\'") + val c = rs.getInt(1) + connection.close() + return (c != 0) +} + fun filterSettingsCheck(): FilterSettings { val connection = connectToDB() diff --git a/src/main/kotlin/PAL2/GUI/CoreController.kt b/src/main/kotlin/PAL2/GUI/CoreController.kt index b042c2a..cf18817 100644 --- a/src/main/kotlin/PAL2/GUI/CoreController.kt +++ b/src/main/kotlin/PAL2/GUI/CoreController.kt @@ -79,6 +79,17 @@ class CoreController : Initializable populateFiltersList() } + GlobalScope.launch { + if (GlobalData.db_file.exists()) + if(doesTableExist("Settings")) + if (checkSettingExist("tkOnClose")) + { + val setting = getSetting("tkOnClose") + GlobalData.allowTaskKill = setting == "1" + Platform.runLater { closeAddonsWhenPALCloses.isSelected = GlobalData.allowTaskKill } + } + } + GlobalScope.launch { init() setSettings() @@ -2041,6 +2052,20 @@ class CoreController : Initializable } } + @FXML + private lateinit var closeAddonsWhenPALCloses: CheckBox + + fun dbSyncOnCloseKill(actionEvent: ActionEvent) + { + if (!checkSettingExist("tkOnClose")) + insSetting("tkOnClose", "0") + + val state = closeAddonsWhenPALCloses.isSelected + GlobalData.allowTaskKill = state + val db_state = if (state) "1" else "0" + putSetting("tkOnClose", db_state) + } + @FXML private lateinit var listViewFilters: ListView diff --git a/src/main/kotlin/PAL2/GlobalData.kt b/src/main/kotlin/PAL2/GlobalData.kt index 6828d65..c51b848 100644 --- a/src/main/kotlin/PAL2/GlobalData.kt +++ b/src/main/kotlin/PAL2/GlobalData.kt @@ -49,6 +49,7 @@ class GlobalData var launchList = ArrayList() var steam_poe = false var launch_externals = true + var allowTaskKill = true fun addToListOfAddons(arr: Array) { diff --git a/src/main/kotlin/PAL2/SystemHandling/AddonUpdater.kt b/src/main/kotlin/PAL2/SystemHandling/AddonUpdater.kt index 64e93c2..e3c5cb7 100644 --- a/src/main/kotlin/PAL2/SystemHandling/AddonUpdater.kt +++ b/src/main/kotlin/PAL2/SystemHandling/AddonUpdater.kt @@ -27,18 +27,20 @@ fun updateAddon(aid: Int, image: Image) fun closeAllAddons() { - taskKill("autohotkey.exe /F") - taskKill("Path of Maps Client.exe") - taskKill("TraderForPoe.exe") - taskKill("javaw.exe") - taskKill("java.exe") - taskKill("POE-Trades-Companion.exe") - taskKill("XenonTrade.exe") - taskKill("LabCompass.exe") - taskKill("Exilence.exe") - taskKill("CurrencyCop.exe") - taskKill("PoE Custom Soundtrack.exe") - + if (GlobalData.allowTaskKill) + { + taskKill("autohotkey.exe /F") + taskKill("Path of Maps Client.exe") + taskKill("TraderForPoe.exe") + taskKill("javaw.exe") + taskKill("java.exe") + taskKill("POE-Trades-Companion.exe") + taskKill("XenonTrade.exe") + taskKill("LabCompass.exe") + taskKill("Exilence.exe") + taskKill("CurrencyCop.exe") + taskKill("PoE Custom Soundtrack.exe") + } } fun taskKill(name: String): Process diff --git a/src/main/resources/CoreUI.fxml b/src/main/resources/CoreUI.fxml index 6372118..813520c 100644 --- a/src/main/resources/CoreUI.fxml +++ b/src/main/resources/CoreUI.fxml @@ -635,6 +635,11 @@ + + + + + diff --git a/src/main/resources/update_notes.html b/src/main/resources/update_notes.html index 4f85159..caa42d7 100644 --- a/src/main/resources/update_notes.html +++ b/src/main/resources/update_notes.html @@ -66,6 +66,7 @@
  • FilterBlast Loot Filters support
  • Generally Code enhancements
  • Taskkill properly kills AHKs now
  • +
  • Added checkbox for closing addons on close ON BY DEFAULT
  • Hotfix: SQL sux ok
  • Hotfix-2: File extension checking
  • Hotfix-3: More SQL issues