diff --git a/gui/gui_help.py b/gui/gui_help.py new file mode 100644 index 000000000..5f3aac07f --- /dev/null +++ b/gui/gui_help.py @@ -0,0 +1,103 @@ +import wx +import webbrowser +from resources import constants + +class gui_help_menu: + def __init__(self, versions, frame, frame_modal): + self.constants: constants.Constants = versions + self.frame = frame + self.frame_modal = frame_modal + + # Define Window Size + self.WINDOW_WIDTH_MAIN = 300 + + + def reset_frame_modal(self): + if not self.frame_modal: + self.frame_modal = wx.Dialog(self.frame) + else: + self.frame_modal.DestroyChildren() + self.frame_modal.Close() + self.frame_modal.ShowWithoutActivating() + + def help_menu(self, event=None): + # Define Menu + # Header: Get help with OpenCore Legacy Patcher + # Subheader: Following resources are available: + # Button: Official Guide + # Button: Official Discord Server + + self.reset_frame_modal() + self.frame_modal.SetSize((self.WINDOW_WIDTH_MAIN, -1)) + + # Header + self.header = wx.StaticText(self.frame_modal, label="Patcher Resources", pos=(10,10)) + self.header.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) + self.header.Centre(wx.HORIZONTAL) + + # Subheader + self.subheader = wx.StaticText(self.frame_modal, label="Following resources are available:") + self.subheader.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) + self.subheader.SetPosition( + wx.Point( + self.header.GetPosition().x, + self.header.GetPosition().y + self.header.GetSize().height + 5 + ) + ) + self.subheader.Centre(wx.HORIZONTAL) + + + # Official Guide + self.guide = wx.Button(self.frame_modal, label="Official Guide", size=(200,30)) + self.guide.SetPosition( + wx.Point( + self.subheader.GetPosition().x, + self.subheader.GetPosition().y + self.subheader.GetSize().height + 5 + + ) + ) + self.guide.Bind(wx.EVT_BUTTON, lambda event: webbrowser.open(self.constants.guide_link)) + self.guide.Centre(wx.HORIZONTAL) + + # Official Discord Server + self.discord = wx.Button(self.frame_modal, label="Official Discord Server", size=(200,30)) + self.discord.SetPosition( + wx.Point( + self.guide.GetPosition().x, + self.guide.GetPosition().y + self.guide.GetSize().height + ) + ) + self.discord.Bind(wx.EVT_BUTTON, lambda event: webbrowser.open(self.constants.discord_link)) + self.discord.Centre(wx.HORIZONTAL) + + # Overclock Button + self.overclock = wx.Button(self.frame_modal, label="Official Support Phone", size=(200,30)) + self.overclock.SetPosition( + wx.Point( + self.discord.GetPosition().x, + self.discord.GetPosition().y + self.discord.GetSize().height + ) + ) + self.overclock.Bind(wx.EVT_BUTTON, lambda event: webbrowser.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ")) + self.overclock.Centre(wx.HORIZONTAL) + + + self.return_to_main = wx.Button(self.frame_modal, label="Return to Main Menu", size=(150,30)) + self.return_to_main.SetPosition( + wx.Point( + self.overclock.GetPosition().x, + self.overclock.GetPosition().y + self.overclock.GetSize().height + 5 + ) + ) + self.return_to_main.Bind(wx.EVT_BUTTON, lambda event: self.frame_modal.Close()) + self.return_to_main.Centre(wx.HORIZONTAL) + + # Set Window Size to below Copyright Label + self.frame_modal.SetSize( + ( + -1, + self.return_to_main.GetPosition().y + self.return_to_main.GetSize().height + 40 + ) + ) + self.frame_modal.ShowWindowModal() + \ No newline at end of file diff --git a/gui/gui_main.py b/gui/gui_main.py index 59c830728..05a4ba716 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -18,11 +18,11 @@ import hashlib from resources import constants, defaults, build, install, installer, sys_patch_download, utilities, sys_patch_detect, sys_patch, run, generate_smbios, updates, integrity_verification from data import model_array, os_data, smbios_data, sip_data -from gui import menu_redirect +from gui import menu_redirect, gui_help class wx_python_gui: - def __init__(self, versions): + def __init__(self, versions, frame=None, frame_modal=None): self.constants: constants.Constants = versions self.computer = self.constants.computer self.constants.gui_mode = True @@ -49,34 +49,33 @@ class wx_python_gui: # Create Application self.app = wx.App() - self.frame = wx.Frame( - None, title="OpenCore Legacy Patcher", - size=(self.WINDOW_WIDTH_MAIN, self.WINDOW_HEIGHT_MAIN), - style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX) - ) - self.frame.Centre(~wx.MAXIMIZE_BOX) - self.frame.Show() - self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame) - - # Create Menubar (allows Cmd+Q usage) - self.menubar = wx.MenuBar() - self.file_menu = wx.Menu() - self.file_menu.Append(wx.ID_EXIT, "Quit", "Quit Application" ) - self.file_menu.Append(wx.ID_REDO, f"Relaunch as Root (UID: {int(current_uid)})", "Relaunch OpenCore Legacy Patcher as Root") - self.menubar.Append(self.file_menu, "File") - self.frame.Bind(wx.EVT_MENU, self.OnCloseFrame, id=wx.ID_EXIT) - self.frame.Bind(wx.EVT_MENU, self.relaunch_as_root, id=wx.ID_REDO) - self.frame.SetMenuBar(self.menubar) + if frame is None: + self.frame = wx.Frame( + None, title="OpenCore Legacy Patcher", + size=(self.WINDOW_WIDTH_MAIN, self.WINDOW_HEIGHT_MAIN), + style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX) + ) + self.frame.Centre(~wx.MAXIMIZE_BOX) + self.frame.Show() + self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame) + # Create Menubar (allows Cmd+Q usage) + self.menubar = wx.MenuBar() + self.file_menu = wx.Menu() + self.file_menu.Append(wx.ID_EXIT, "Quit", "Quit Application" ) + self.file_menu.Append(wx.ID_REDO, f"Relaunch as Root (UID: {int(current_uid)})", "Relaunch OpenCore Legacy Patcher as Root") + self.menubar.Append(self.file_menu, "File") + self.frame.Bind(wx.EVT_MENU, self.OnCloseFrame, id=wx.ID_EXIT) + self.frame.Bind(wx.EVT_MENU, self.relaunch_as_root, id=wx.ID_REDO) + self.frame.SetMenuBar(self.menubar) + else: + self.frame = frame # Modal Frames - self.frame_modal = None + self.frame_modal = frame_modal if current_uid == 0: self.file_menu.Enable(wx.ID_REDO, False) - self.main_menu(None) - - wx.CallAfter(self.frame.Close) def OnCloseFrame(self, event=None): self.frame.SetTransparent(0) @@ -416,7 +415,7 @@ class wx_python_gui: self.settings.GetPosition().y + self.settings.GetSize().height ) ) - self.help_button.Bind(wx.EVT_BUTTON, self.help_menu) + self.help_button.Bind(wx.EVT_BUTTON, gui_help.gui_help_menu(self.constants, self.frame, self.frame_modal).help_menu) self.help_button.Centre(wx.HORIZONTAL) diff --git a/resources/main.py b/resources/main.py index 45ae16778..226ab88ce 100644 --- a/resources/main.py +++ b/resources/main.py @@ -21,7 +21,7 @@ class OpenCoreLegacyPatcher: if launch_gui is True: utilities.disable_cls() from gui import gui_main - gui_main.wx_python_gui(self.constants) + gui_main.wx_python_gui(self.constants).main_menu(None) else: self.main_menu() diff --git a/resources/sys_patch_auto.py b/resources/sys_patch_auto.py index 5069ef21c..07ba6f9cf 100644 --- a/resources/sys_patch_auto.py +++ b/resources/sys_patch_auto.py @@ -156,7 +156,7 @@ class AutomaticSysPatch: if output.returncode == 0: print("- Launching GUI's Build/Install menu") settings.start_build_install = True - gui_main.wx_python_gui(settings) + gui_main.wx_python_gui(settings).main_menu(None) else: print("- Boot Disk is not removable, skipping prompt") except KeyError: