From 3356565593de279212f848c9d9c9051fa609f8ee Mon Sep 17 00:00:00 2001 From: frarol96 Date: Sat, 20 Jul 2024 05:21:15 +0000 Subject: [PATCH] Added changelog viewing Users can now see the latest changelog entry by hovering over the ERSCMU version text, or the 5 latest entries in the info section --- ERSCMU.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/ERSCMU.py b/ERSCMU.py index 9cb0337..438f132 100644 --- a/ERSCMU.py +++ b/ERSCMU.py @@ -1,5 +1,5 @@ # Define version number -PROGRAM_VERSION = "1.7.0.5" +PROGRAM_VERSION = "1.7.0.6" LAUNCHER_VERSION = "1.1.0.0" # Define a persistent path for the configuration files in the AppData folder @@ -53,6 +53,25 @@ def check_logo(): else: print(f"Logo discovered locally at {LOGO_PATH}") +def get_changelog(num_entries=1): + url = 'https://git.rolfsvaag.no/frarol96/ERSCMU/raw/branch/main/changelog.md' + response = requests.get(url) + if response.status_code != 200: + raise Exception(f"Failed to fetch changelog. HTTP status code: {response.status_code}") + + changelog = response.text.split('\n- ') + latest_entries = changelog[:num_entries] + + formatted_entries = [] + for entry in latest_entries: + if entry.strip(): + lines = entry.split('\n') + version = lines[0].strip() + changes = '\n'.join([f"- {line.strip()}" for line in lines[1:] if line.strip()]) + formatted_entries.append(f"version {version}:\n{changes}") + + return '\n\n'.join(formatted_entries) + def ensure_vocabulary(config): if "vocabulary" not in config: config["vocabulary"] = { @@ -789,7 +808,7 @@ def show_info(): last_updated = config.get('last_updated', 'Unknown') launcher_path = os.path.join(os.path.dirname(config["mod_path"]), config['launcher_name']) wdir = PERSISTENT_DIR - QMessageBox.information(None, "Info", f"Current Version: {installed_version}\nLast Updated: {last_updated}\nLauncher Path: {launcher_path}\nWorking Directory: {wdir}\nERSCMU Version: {PROGRAM_VERSION}\nLauncher Version: {LAUNCHER_VERSION}") + QMessageBox.information(None, "Info", f"Current Version: {installed_version}\nLast Updated: {last_updated}\nLauncher Path: {launcher_path}\nWorking Directory: {wdir}\nERSCMU Version: {PROGRAM_VERSION}\nLauncher Version: {LAUNCHER_VERSION}\n\nChangelog (last 5 versions):\n{get_changelog(5)}") def show_about(): about_text = f""" @@ -856,7 +875,7 @@ def create_gui(): version_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) version_label.setStyleSheet("padding-right: 10px;") # Optional: add some padding to the right menu_bar.setCornerWidget(version_label, Qt.TopRightCorner) - version_label_tooltip_text = f"ERSCMU version.\nThis is the version of this program you're currently running.\nLauncher Version: {LAUNCHER_VERSION}" + version_label_tooltip_text = f"ERSCMU version.\nThis is the version of this program you're currently running.\nLauncher Version: {LAUNCHER_VERSION}\n\nChangelog:\n{get_changelog()}" version_label.setToolTip(str(version_label_tooltip_text)) mod_path_label = QLabel("Mod Folder:") @@ -922,4 +941,4 @@ def create_gui(): if __name__ == "__main__": check_logo() - create_gui() + create_gui() \ No newline at end of file