From 92107793439a702f510376a6ca903e451e1529b0 Mon Sep 17 00:00:00 2001 From: Fabian Zi Date: Thu, 23 Jan 2025 05:20:10 +0100 Subject: [PATCH 1/4] - added: config option 'allowAutoUpdate'. Toggles auto update of VostokMods Launcher --- Injector/Main.gd | 9 ++++++--- Injector/Main.tscn | 11 ++++++++++- Injector/Settings.gd | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Injector/Main.gd b/Injector/Main.gd index dc8a7d0..a6d52d6 100644 --- a/Injector/Main.gd +++ b/Injector/Main.gd @@ -19,6 +19,7 @@ class ModLoaderConfig: var customModDir : String = "" var startOnConfigScreen : bool = false var autoUpdatePreRelease : bool = false + var allowAutoUpdate: bool = true var config : ModLoaderConfig = ModLoaderConfig.new() func loadConfig(): @@ -34,14 +35,16 @@ func loadConfig(): config.startOnConfigScreen = obj["startOnConfigScreen"] if "autoUpdatePreRelease" in obj: config.autoUpdatePreRelease = obj["autoUpdatePreRelease"] - + if "allowAutoUpdate" in obj: + config.allowAutoUpdate = obj["allowAutoUpdate"] SettingsPage.onLoaded() func saveConfig(): var jarr = { "customModDir": config.customModDir, "startOnConfigScreen": config.startOnConfigScreen, - "autoUpdatePreRelease": config.autoUpdatePreRelease + "autoUpdatePreRelease": config.autoUpdatePreRelease, + "allowAutoUpdate": config.allowAutoUpdate } var jstr = JSON.stringify(jarr) var f = FileAccess.open(configPath, FileAccess.WRITE) @@ -102,7 +105,7 @@ func _ready() -> void: Mods.loadMods() showLoadingScreen() - if !OS.has_feature("editor"): + if !OS.has_feature("editor") and config.allowAutoUpdate: await Updater.checkInjectorUpdate() else: await Updater.checkModUpdates() diff --git a/Injector/Main.tscn b/Injector/Main.tscn index d82e7f4..efdc665 100644 --- a/Injector/Main.tscn +++ b/Injector/Main.tscn @@ -61,13 +61,14 @@ layout_mode = 2 size_flags_horizontal = 3 current_tab = 0 -[node name="Settings" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "CustomModDirLine", "StartOnConfigCheckBox")] +[node name="Settings" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "CustomModDirLine", "StartOnConfigCheckBox", "AllowAutoUpdateCheckBox")] layout_mode = 2 size_flags_horizontal = 3 script = ExtResource("2_b0jil") Main = NodePath("../../..") CustomModDirLine = NodePath("VBoxContainer/GridContainer/HBoxContainer/CustomModDirLine") StartOnConfigCheckBox = NodePath("VBoxContainer/GridContainer/CheckBox") +AllowAutoUpdateCheckBox = NodePath("VBoxContainer/GridContainer/CheckBox2") metadata/_tab_index = 0 [node name="VBoxContainer" type="VBoxContainer" parent="ConfigScreen/TabContainer/Settings"] @@ -105,6 +106,14 @@ text = "Start on config screen" layout_mode = 2 size_flags_horizontal = 0 +[node name="Label3" type="Label" parent="ConfigScreen/TabContainer/Settings/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "Enable VostokMods auto update" + +[node name="CheckBox2" type="CheckBox" parent="ConfigScreen/TabContainer/Settings/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 0 + [node name="Mods" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "List")] visible = false layout_mode = 2 diff --git a/Injector/Settings.gd b/Injector/Settings.gd index 9aab479..5ebbf20 100644 --- a/Injector/Settings.gd +++ b/Injector/Settings.gd @@ -3,10 +3,12 @@ extends Control @export var Main: Control @export var CustomModDirLine: LineEdit @export var StartOnConfigCheckBox: CheckBox +@export var AllowAutoUpdateCheckBox: CheckBox func _ready() -> void: CustomModDirLine.text_changed.connect(func(val): Main.config.customModDir = val; Main.Mods.loadMods()) StartOnConfigCheckBox.toggled.connect(func(val): Main.config.startOnConfigScreen = val) + AllowAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowAutoUpdate = val) func openModDirDialog(): var fd = FileDialog.new() @@ -20,3 +22,4 @@ func openModDirDialog(): func onLoaded(): CustomModDirLine.text = Main.config.customModDir StartOnConfigCheckBox.button_pressed = Main.config.startOnConfigScreen + AllowAutoUpdateCheckBox.button_pressed = Main.config.allowAutoUpdate From be06305519591c4f5a97358753115c345f11c432 Mon Sep 17 00:00:00 2001 From: Fabian Zi Date: Thu, 23 Jan 2025 05:42:08 +0100 Subject: [PATCH 2/4] - added: config option 'allowModsAutoUpdate'. Toggles auto update of mods in general --- Injector/AutoUpdater.gd | 50 +++++++++++++++++++++++++++++++++-------- Injector/Main.gd | 15 ++++++++++--- Injector/Main.tscn | 11 ++++++++- Injector/Settings.gd | 3 +++ 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/Injector/AutoUpdater.gd b/Injector/AutoUpdater.gd index aa4beb9..f72173a 100644 --- a/Injector/AutoUpdater.gd +++ b/Injector/AutoUpdater.gd @@ -16,7 +16,11 @@ func checkInjectorUpdate(): var err = httpReq.request(Main.githubAPIBaseURL + "repos/Ryhon0/VostokMods/releases", ["accept: application/vnd.github+json"]) if err != OK: push_error("Failed to create mod loader releases request ", err) - await checkModUpdates() + if Main.config.allowModsAutoUpdate: + await checkModUpdates() + else: + Main.Mods.loadMods() + Main.launchOrShowConfig() return Main.StatusLabel.text = "Checking for updates" @@ -27,11 +31,19 @@ func checkInjectorUpdate(): func injectorReleasesRequestCompleted(result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray): if result != HTTPRequest.RESULT_SUCCESS: push_error("Failed to get mod loader releases") - await checkModUpdates() + if Main.config.allowModsAutoUpdate: + await checkModUpdates() + else: + Main.Mods.loadMods() + Main.launchOrShowConfig() return if response_code < 200 || response_code >= 300: push_error("Failed to get mod loader releases (HTTP code " + str(response_code) + ")") - await checkModUpdates() + if Main.config.allowModsAutoUpdate: + await checkModUpdates() + else: + Main.Mods.loadMods() + Main.launchOrShowConfig() return var json = JSON.parse_string(body.get_string_from_utf8()) @@ -52,7 +64,12 @@ func injectorReleasesRequestCompleted(result: int, response_code: int, _headers: print("Latest version: " + tag) if Main.version != tag: downloadLoaderUpdate(tag, injectorAsset) - else: await checkModUpdates() + else: + if Main.config.allowModsAutoUpdate: + await checkModUpdates() + else: + Main.Mods.loadMods() + Main.launchOrShowConfig() return func downloadLoaderUpdate(tag, asset): @@ -61,7 +78,10 @@ func downloadLoaderUpdate(tag, asset): var err = httpReq.request(asset["browser_download_url"]) if err != OK: Main.StatusLabel.text = "Failed to download mod loader update.\nCode " + str(err) - get_tree().create_timer(2).timeout.connect(checkModUpdates) + if Main.config.allowModsAutoUpdate: + get_tree().create_timer(2).timeout.connect(checkModUpdates) + else: + get_tree().create_timer(2).timeout.connect(func(): Main.Mods.loadMods(); Main.launchOrShowConfig()) return Main.StatusLabel.text = "Downloading mod loader version " + tag @@ -73,12 +93,18 @@ func injectorFileDownloaded(result: int, response_code: int, _headers: PackedStr if result != HTTPRequest.RESULT_SUCCESS: push_error("Failed to download mod loader") Main.StatusLabel.text = "Failed to save mod loader, error " + str(FileAccess.get_open_error()) - get_tree().create_timer(2).timeout.connect(checkModUpdates) + if Main.config.allowModsAutoUpdate: + get_tree().create_timer(2).timeout.connect(checkModUpdates) + else: + get_tree().create_timer(2).timeout.connect(func(): Main.Mods.loadMods(); Main.launchOrShowConfig()) return if response_code < 200 || response_code >= 300: push_error("Failed to get mod loader releases (HTTP code " + str(response_code) + ")") Main.StatusLabel.text = "Failed to save mod loader, error " + str(FileAccess.get_open_error()) - get_tree().create_timer(2).timeout.connect(checkModUpdates) + if Main.config.allowModsAutoUpdate: + get_tree().create_timer(2).timeout.connect(checkModUpdates) + else: + get_tree().create_timer(2).timeout.connect(func(): Main.Mods.loadMods(); Main.launchOrShowConfig()) return var dir = ProjectSettings.globalize_path(".") @@ -88,14 +114,20 @@ func injectorFileDownloaded(result: int, response_code: int, _headers: PackedStr var err = DirAccess.rename_absolute(injectorPath, deletemePath) if err != OK: Main.StatusLabel.text = "Failed to move moad loader, error " + str(err) - get_tree().create_timer(2).timeout.connect(checkModUpdates) + if Main.config.allowModsAutoUpdate: + get_tree().create_timer(2).timeout.connect(checkModUpdates) + else: + get_tree().create_timer(2).timeout.connect(func(): Main.Mods.loadMods(); Main.launchOrShowConfig()) return var f = FileAccess.open(injectorPath, FileAccess.WRITE) if !f: DirAccess.rename_absolute(deletemePath, injectorPath) Main.StatusLabel.text = "Failed to save mod loader, error " + str(FileAccess.get_open_error()) - get_tree().create_timer(2).timeout.connect(checkModUpdates) + if Main.config.allowModsAutoUpdate: + get_tree().create_timer(2).timeout.connect(checkModUpdates) + else: + get_tree().create_timer(2).timeout.connect(func(): Main.Mods.loadMods(); Main.launchOrShowConfig()) return f.store_buffer(body) f.close() diff --git a/Injector/Main.gd b/Injector/Main.gd index a6d52d6..289109e 100644 --- a/Injector/Main.gd +++ b/Injector/Main.gd @@ -20,6 +20,7 @@ class ModLoaderConfig: var startOnConfigScreen : bool = false var autoUpdatePreRelease : bool = false var allowAutoUpdate: bool = true + var allowModsAutoUpdate: bool = true var config : ModLoaderConfig = ModLoaderConfig.new() func loadConfig(): @@ -37,6 +38,8 @@ func loadConfig(): config.autoUpdatePreRelease = obj["autoUpdatePreRelease"] if "allowAutoUpdate" in obj: config.allowAutoUpdate = obj["allowAutoUpdate"] + if "allowModsAutoUpdate" in obj: + config.allowModsAutoUpdate = obj["allowModsAutoUpdate"] SettingsPage.onLoaded() func saveConfig(): @@ -44,7 +47,8 @@ func saveConfig(): "customModDir": config.customModDir, "startOnConfigScreen": config.startOnConfigScreen, "autoUpdatePreRelease": config.autoUpdatePreRelease, - "allowAutoUpdate": config.allowAutoUpdate + "allowAutoUpdate": config.allowAutoUpdate, + "allowModsAutoUpdate": config.allowModsAutoUpdate } var jstr = JSON.stringify(jarr) var f = FileAccess.open(configPath, FileAccess.WRITE) @@ -107,7 +111,12 @@ func _ready() -> void: showLoadingScreen() if !OS.has_feature("editor") and config.allowAutoUpdate: await Updater.checkInjectorUpdate() - else: await Updater.checkModUpdates() + else: + if config.allowModsAutoUpdate: + await Updater.checkModUpdates() + else: + Mods.loadMods() + launchOrShowConfig() func launchOrShowConfig(): if config.startOnConfigScreen: @@ -334,4 +343,4 @@ func hashPCK(path): return res.hex_encode() func openDonatePage(): - OS.shell_open("https://github.com/sponsors/Ryhon0") \ No newline at end of file + OS.shell_open("https://github.com/sponsors/Ryhon0") diff --git a/Injector/Main.tscn b/Injector/Main.tscn index efdc665..ac8e16d 100644 --- a/Injector/Main.tscn +++ b/Injector/Main.tscn @@ -61,7 +61,7 @@ layout_mode = 2 size_flags_horizontal = 3 current_tab = 0 -[node name="Settings" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "CustomModDirLine", "StartOnConfigCheckBox", "AllowAutoUpdateCheckBox")] +[node name="Settings" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "CustomModDirLine", "StartOnConfigCheckBox", "AllowAutoUpdateCheckBox", "AllowModsAutoUpdateCheckBox")] layout_mode = 2 size_flags_horizontal = 3 script = ExtResource("2_b0jil") @@ -69,6 +69,7 @@ Main = NodePath("../../..") CustomModDirLine = NodePath("VBoxContainer/GridContainer/HBoxContainer/CustomModDirLine") StartOnConfigCheckBox = NodePath("VBoxContainer/GridContainer/CheckBox") AllowAutoUpdateCheckBox = NodePath("VBoxContainer/GridContainer/CheckBox2") +AllowModsAutoUpdateCheckBox = NodePath("VBoxContainer/GridContainer/CheckBox3") metadata/_tab_index = 0 [node name="VBoxContainer" type="VBoxContainer" parent="ConfigScreen/TabContainer/Settings"] @@ -114,6 +115,14 @@ text = "Enable VostokMods auto update" layout_mode = 2 size_flags_horizontal = 0 +[node name="Label4" type="Label" parent="ConfigScreen/TabContainer/Settings/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "Enable auto update of Mods" + +[node name="CheckBox3" type="CheckBox" parent="ConfigScreen/TabContainer/Settings/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 0 + [node name="Mods" type="ScrollContainer" parent="ConfigScreen/TabContainer" node_paths=PackedStringArray("Main", "List")] visible = false layout_mode = 2 diff --git a/Injector/Settings.gd b/Injector/Settings.gd index 5ebbf20..742996f 100644 --- a/Injector/Settings.gd +++ b/Injector/Settings.gd @@ -4,11 +4,13 @@ extends Control @export var CustomModDirLine: LineEdit @export var StartOnConfigCheckBox: CheckBox @export var AllowAutoUpdateCheckBox: CheckBox +@export var AllowModsAutoUpdateCheckBox: CheckBox func _ready() -> void: CustomModDirLine.text_changed.connect(func(val): Main.config.customModDir = val; Main.Mods.loadMods()) StartOnConfigCheckBox.toggled.connect(func(val): Main.config.startOnConfigScreen = val) AllowAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowAutoUpdate = val) + AllowModsAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowModsAutoUpdate = val) func openModDirDialog(): var fd = FileDialog.new() @@ -23,3 +25,4 @@ func onLoaded(): CustomModDirLine.text = Main.config.customModDir StartOnConfigCheckBox.button_pressed = Main.config.startOnConfigScreen AllowAutoUpdateCheckBox.button_pressed = Main.config.allowAutoUpdate + AllowModsAutoUpdateCheckBox.button_pressed = Main.config.allowModsAutoUpdate From 9e96a4a5d9b11288d8ecd673ee7fb4bf297fa411 Mon Sep 17 00:00:00 2001 From: Fabian Zi Date: Thu, 23 Jan 2025 05:45:23 +0100 Subject: [PATCH 3/4] - changed: changing settings saves them to config immediately (no more lose of changes after closing the window) --- Injector/Settings.gd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Injector/Settings.gd b/Injector/Settings.gd index 742996f..7fee491 100644 --- a/Injector/Settings.gd +++ b/Injector/Settings.gd @@ -7,10 +7,10 @@ extends Control @export var AllowModsAutoUpdateCheckBox: CheckBox func _ready() -> void: - CustomModDirLine.text_changed.connect(func(val): Main.config.customModDir = val; Main.Mods.loadMods()) - StartOnConfigCheckBox.toggled.connect(func(val): Main.config.startOnConfigScreen = val) - AllowAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowAutoUpdate = val) - AllowModsAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowModsAutoUpdate = val) + CustomModDirLine.text_changed.connect(func(val): Main.config.customModDir = val; Main.saveConfig(); Main.Mods.loadMods()) + StartOnConfigCheckBox.toggled.connect(func(val): Main.config.startOnConfigScreen = val; Main.saveConfig()) + AllowAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowAutoUpdate = val; Main.saveConfig()) + AllowModsAutoUpdateCheckBox.toggled.connect(func(val): Main.config.allowModsAutoUpdate = val; Main.saveConfig()) func openModDirDialog(): var fd = FileDialog.new() From 0fb77d3398e1dbd991ecdf09dfec6001bc33da42 Mon Sep 17 00:00:00 2001 From: Fabian Zi Date: Thu, 23 Jan 2025 06:23:28 +0100 Subject: [PATCH 4/4] - changed: disabled mods won't be checked for updates on launch --- Injector/AutoUpdater.gd | 2 ++ Injector/ModList.gd | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Injector/AutoUpdater.gd b/Injector/AutoUpdater.gd index f72173a..3f890bf 100644 --- a/Injector/AutoUpdater.gd +++ b/Injector/AutoUpdater.gd @@ -145,6 +145,8 @@ func checkModUpdates(): var updatableMods = [] var mwsIds = [] for mod in Main.Mods.mods: + if mod.disabled: + continue if mod.config.has_section_key("updates", "modworkshop"): updatableMods.append(mod) mwsIds.append(mod.config.get_value("updates", "modworkshop")) diff --git a/Injector/ModList.gd b/Injector/ModList.gd index cf0c60c..28fb763 100644 --- a/Injector/ModList.gd +++ b/Injector/ModList.gd @@ -8,6 +8,7 @@ var mods : Array[ModInfo] = [] class ModInfo: var zipPath : String var config : ConfigFile + var disabled : bool func _ready(): List.set_column_title(0, "Name") @@ -66,6 +67,7 @@ func loadMods(): var modi = ModInfo.new() modi.config = cfg modi.zipPath = modsdir.path_join(zipname) + modi.disabled = disabled mods.append(modi) var li = List.create_item()