diff --git a/requirements.txt b/requirements.txt index a79dd44b2..a802b0603 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ wxpython pyinstaller packaging py_sip_xnu -py-applescript \ No newline at end of file +py-applescript +markdown2 \ No newline at end of file diff --git a/resources/sys_patch/sys_patch_auto.py b/resources/sys_patch/sys_patch_auto.py index 0c275919a..d6276de29 100644 --- a/resources/sys_patch/sys_patch_auto.py +++ b/resources/sys_patch/sys_patch_auto.py @@ -1,6 +1,10 @@ # Copyright (C) 2022, Mykola Grymalyuk +# Copyright (c) 2023 Jazzzny import wx +import wx.html2 +import requests +import markdown2 import logging import plistlib import subprocess @@ -51,19 +55,85 @@ class AutomaticSysPatch: logging.info(f"- Found new version: {version}") app = wx.App() - frame = wx.Frame(None, -1, "OpenCore Legacy Patcher") - dialog = wx.MessageDialog( - parent=frame, - message=f"Current Version: {self.constants.patcher_version}{' (Nightly)' if not self.constants.commit_info[0].startswith('refs/tags') else ''}\nNew version: {version}\nWould you like to update?", - caption="Update Available for OpenCore Legacy Patcher!", - style=wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION - ) - dialog.SetYesNoCancelLabels("Download and install", "View on Github", "Ignore") - response = dialog.ShowModal() - if response == wx.ID_YES: - gui_entry.EntryPoint(self.constants).start(entry=gui_entry.SupportedEntryPoints.UPDATE_APP) - elif response == wx.ID_NO: + mainframe = wx.Frame(None, -1, "OpenCore Legacy Patcher") + + ID_GITHUB = wx.NewId() + ID_UPDATE = wx.NewId() + + url = "https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest" + response = requests.get(url).json() + changelog = response["body"].split("## Asset Information")[0] + + html_markdown = markdown2.markdown(changelog) + html_css = """ + + """ + frame = wx.Dialog(None, -1, title="", size=(600, 500)) + frame.SetMinSize((600, 500)) + frame.SetWindowStyle(wx.STAY_ON_TOP) + panel = wx.Panel(frame) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.AddSpacer(10) + self.title_text = wx.StaticText(panel, label="A new version of OpenCore Legacy Patcher is available!") + self.description = wx.StaticText(panel, label=f"OpenCore Legacy Patcher {version} is now available - You have {self.constants.patcher_version}. Would you like to update?") + self.title_text.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + self.description.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + self.web_view = wx.html2.WebView.New(panel, style=wx.BORDER_SUNKEN) + html_code = html_css+html_markdown.replace(" + body { + font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif; + line-height: 1.5; + font-size: 13px; + margin-top: 20px; + background-color: rgb(238,238,238); + } + h2 { + line-height: 0.5; + } + a { + color: -apple-system-control-accent; + } + @media (prefers-color-scheme: dark) { + body { + color: #fff; + background-color: rgb(47,47,47); + } + + } + +""" + frame = wx.Dialog(None, -1, title="", size=(600, 500)) + frame.SetMinSize((600, 500)) + frame.SetWindowStyle(wx.STAY_ON_TOP) + panel = wx.Panel(frame) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.AddSpacer(10) + self.title_text = wx.StaticText(panel, label="A new version of OpenCore Legacy Patcher is available!") + self.description = wx.StaticText(panel, label=f"OpenCore Legacy Patcher {oclp_version} is now available - You have {self.constants.patcher_version}. Would you like to update?") + self.title_text.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + self.description.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + self.web_view = wx.html2.WebView.New(panel, style=wx.BORDER_SUNKEN) + html_code = html_css+html_markdown.replace("