def __init__(self): # initialize the window super().__init__() self.wm_title(f'BEE Manipulator v{config.version()}') self.geometry("600x500") self.lift() # set window icon self.wm_iconbitmap(default="assets/icon.ico") set_window_icon(self) # check updates logWindow.init(self) self.LOGGER = get_logger("mainLoop") try: if (config.load("logWinodowVisible")): logWindow.toggleVisibility() except: logWindow.toggleVisibility() self.LOGGER.debug( "starting background update check for BEE Manipulator") self.checkUpdates(window=False) r""" there are the functions to make the main window, every # comment indicates what part is build there, to make it more clear and readable ttb = top tool bar TODO: make every dropdown menu a class """ # top tool bar self.toolBarFrame = tk.Menu(self, bg="lightgrey", fg="black") # file ttb menu self.fileMenu = tk.Menu(self.toolBarFrame, tearoff=0, bg="white", fg="black") self.fileMenu.add_command(label="Open Portal 2 Directory", command=self.openp2dir) self.fileMenu.add_command(label="Open BEEmod Directory", command=self.openBEEdir) self.fileMenu.add_command(label="Sync Games", command=self.syncGames) self.fileMenu.add_command(label="Quit", command=self.quit) # options ttb menu self.optionMenu = tk.Menu(self.toolBarFrame, tearoff=0, bg="white", fg="black") self.optionMenu.add_command(label="Settings", command=self.openSettingsWindow) self.optionMenu.add_command(label="Toggle Log Window", command=logWindow.toggleVisibility) self.optionMenu.add_command(label="Reload Configs", command=self.reloadConfig) self.optionMenu.add_command(label="Reload Packages", command=self.reloadPackages) self.optionMenu.add_command(label="Manage Games", command=self.openGameManager) self.optionMenu.add_command(label="Manage Packages", command=self.openPackageManager) self.optionMenu.add_command(label="Manage Plugins", command=self.openPackageManager) # options ttb menu self.portal2 = tk.Menu(self.toolBarFrame, tearoff=0, bg="white", fg="black") self.portal2.add_command(label="Verify Game Cache", command=self.verifyGameCache) self.portal2.add_command(label="Uninstall BEE2.4", command=self.uninstallBee) self.portal2.add_command(label="Install BEE2.4", command=self.installBee) # help ttb menu self.helpMenu = tk.Menu(self.toolBarFrame, tearoff=0, bg="white", fg="black") self.helpMenu.add_command(label="About..", command=self.openAboutWindow) self.helpMenu.add_command(label="Check Updates", command=self.checkUpdates) self.helpMenu.add_command(label="Open Wiki", command=self.openWiki) self.helpMenu.add_command(label="Github", command=self.openGithub) self.helpMenu.add_command(label="Discord", command=self.openDiscord) # put all the ttb together self.toolBarFrame.add_cascade(label="File", menu=self.fileMenu) self.toolBarFrame.add_cascade(label="Options", menu=self.optionMenu) self.toolBarFrame.add_cascade(label="Portal 2", menu=self.portal2) self.toolBarFrame.add_cascade(label="Help", menu=self.helpMenu) self.configure(menu=self.toolBarFrame) # pack the browser self.browser = browser(self) self.browser.pack() self.bind("<Control-l>", logWindow.toggleVisibility)
'window_log_level': 'INFO', }, } GEN_OPTS.load() GEN_OPTS.set_defaults(DEFAULT_SETTINGS) loadScreen.main_loader.set_length('UI', 14) loadScreen.show_main_loader(GEN_OPTS.get_bool('General', 'compact_splash')) # OS X starts behind other windows, fix that. if utils.MAC: TK_ROOT.lift() logWindow.init( GEN_OPTS.get_bool('Debug', 'show_log_win'), GEN_OPTS['Debug']['window_log_level'] ) UI.load_settings() gameMan.load() gameMan.set_game_by_name( GEN_OPTS.get_val('Last_Selected', 'Game', ''), ) gameMan.scan_music_locs() LOGGER.info('Loading Packages...') pack_data, package_sys = packageLoader.load_packages( GEN_OPTS['Directories']['package'], loader=loadScreen.main_loader, log_item_fallbacks=GEN_OPTS.get_bool(
# The lowest level which will be shown. 'window_log_level': 'INFO', }, } GEN_OPTS.load() GEN_OPTS.set_defaults(DEFAULT_SETTINGS) loadScreen.main_loader.set_length('UI', 14) loadScreen.show_main_loader(GEN_OPTS.get_bool('General', 'compact_splash')) # OS X starts behind other windows, fix that. if utils.MAC: TK_ROOT.lift() logWindow.init(GEN_OPTS.get_bool('Debug', 'show_log_win'), GEN_OPTS['Debug']['window_log_level']) UI.load_settings() gameMan.load() gameMan.set_game_by_name(GEN_OPTS.get_val('Last_Selected', 'Game', ''), ) gameMan.scan_music_locs() LOGGER.info('Loading Packages...') pack_data, package_sys = packageLoader.load_packages( GEN_OPTS['Directories']['package'], loader=loadScreen.main_loader, log_item_fallbacks=GEN_OPTS.get_bool('Debug', 'log_item_fallbacks'), log_missing_styles=GEN_OPTS.get_bool('Debug', 'log_missing_styles'), log_missing_ent_count=GEN_OPTS.get_bool('Debug', 'log_missing_ent_count'), log_incorrect_packfile=GEN_OPTS.get_bool('Debug',
def __init__(self): # load plugins super().__init__( None, title=f'BEE Manipulator {str(config.version)}' ) # sets the app icon self.SetIcon(utilities.icon) # init the logging window asyncio.run( logWindow.init() ) asyncio.run( appDateCheck() ) # set the utilities.root pointer to the object of this class root.instance = self try: self.SetPosition(wx.Point(config.load('mainWindowPos'))) except config.ConfigError: self.CenterOnScreen() self.SetSize(width=600, height=500) self.SetMinSize( wx.Size(width=600, height=500) ) LOGGER.info(f'internet connected: {utilities.isonline()}') pluginSystem.systemObj.startSync() """ A menu bar is composed of menus, which are composed of menu items. This section builds the menu bar and binds actions to them """ # file menu bar self.fileMenu = wx.Menu() openPortalDirItem = self.fileMenu.Append(0, loc('menu.file.openportaldir.name')+'\tCtrl-P', loc('menu.file.openportaldir.description') ) openBeeDirItem = self.fileMenu.Append(1, loc('menu.file.openbeedir.name')+"\tCtrl-B", loc('menu.file.openbeedir.description') ) syncGamesItem = self.fileMenu.Append(2, loc('menu.file.syncgames.name'), loc('menu.file.syncgames.description') ) exitItem = self.fileMenu.Append(3, loc('menu.file.exit.name'), loc('menu.file.exit.description') ) # options menu bar self.optionsMenu = wx.Menu() settingsItem = self.optionsMenu.Append(4, loc('menu.options.settings.name')+'\tCtrl-S', loc('menu.options.settings.description') ) toggleLogWindowItem = self.optionsMenu.Append(5, loc('menu.options.logtoggle.name')+'\tCtrl-L', loc('menu.options.logtoggle.description') ) reloadPluginsItem = self.optionsMenu.Append(6, loc('menu.options.reloadplugins.name'), loc('menu.options.reloadplugins.description') ) reloadPackagesItem = self.optionsMenu.Append(7, loc('menu.options.reloadpackages.name'), loc('menu.options.reloadpackages.description') ) # portal 2 menu bar self.portalMenu = wx.Menu() verifyGameFilesItem = self.portalMenu.Append(8, loc('menu.portal.vgf.name'), loc('menu.portal.vgf.description') ) uninstallBeeItem = self.portalMenu.Append(9, loc('menu.portal.uninstallbee.name'), loc('menu.portal.uninstallbee.description') ) installBeeItem = self.portalMenu.Append(10, loc('menu.portal.installbee.name'), loc('menu.portal.installbee.description') ) openP2Item = self.portalMenu.Append( 11, loc( 'menu.portal.openp2.name' ), loc( 'menu.portal.openp2.description' ) ) openBeeItem = self.portalMenu.Append( 12, loc( 'menu.portal.openbee.name' ), loc( 'menu.portal.openbee.description' ) ) # help menu bar self.helpMenu = wx.Menu() aboutItem = self.helpMenu.Append(13, loc('menu.help.about.name'), loc('menu.help.about.description') ) checkUpdatesItem = self.helpMenu.Append(14, loc('menu.help.cupdates.name'), loc('menu.help.cupdates.description') ) wikiItem = self.helpMenu.Append(15, loc('menu.help.wiki.name'), loc('menu.help.wiki.description') ) githubItem = self.helpMenu.Append(16, loc('menu.help.github.name'), loc('menu.help.github.description') ) discordItem = self.helpMenu.Append(17, loc('menu.help.discord.name'), loc('menu.help.discord.description') ) # set menu item icons self.helpMenu.FindItemById(13).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_bm.png') ) self.helpMenu.FindItemById(14).SetBitmap( wx.Bitmap( f'{config.assetsPath}icons/materialdesign/menu_update_black.png' ) ) self.helpMenu.FindItemById(15).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_github.png') ) self.helpMenu.FindItemById(16).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_github.png') ) self.helpMenu.FindItemById(17).SetBitmap( wx.Bitmap(f'{config.assetsPath}icons/menu_discord.png') ) # makes the menu bar self.menuBar = wx.MenuBar() self.menuBar.Append(self.fileMenu, loc('menu.file.name') ) self.menuBar.Append(self.optionsMenu, loc('menu.options.name') ) self.menuBar.Append(self.portalMenu, loc('menu.portal.name') ) self.menuBar.Append(self.helpMenu, loc('menu.help.name') ) # Give the menu bar to the frame self.SetMenuBar(self.menuBar) self.CreateStatusBar() self.SetStatusText( loc('statusbar.text').replace('{username}', config.steamUsername() ) ) # file menu self.Bind( wx.EVT_MENU, self.openp2dir, openPortalDirItem ) self.Bind( wx.EVT_MENU, self.openBEEdir, openBeeDirItem ) self.Bind( wx.EVT_MENU, self.syncGames, syncGamesItem ) self.Bind( wx.EVT_MENU, self.exit, exitItem ) # options menu self.Bind( wx.EVT_MENU, self.openSettingsWindow, settingsItem ) self.Bind( wx.EVT_MENU, logWindow.toggleVisibility, toggleLogWindowItem ) self.Bind( wx.EVT_MENU, self.reloadPlugins, reloadPluginsItem ) self.Bind( wx.EVT_MENU, self.reloadPackages, reloadPackagesItem ) # portal 2 menu self.Bind( wx.EVT_MENU, self.verifyGameFiles, verifyGameFilesItem ) self.Bind( wx.EVT_MENU, self.uninstallBee, uninstallBeeItem ) self.Bind( wx.EVT_MENU, self.installBee, installBeeItem ) self.Bind( wx.EVT_MENU, self.openP2, openP2Item ) self.Bind( wx.EVT_MENU, self.openBee, openBeeItem ) # help menu self.Bind( wx.EVT_MENU, self.openAboutWindow, aboutItem ) self.Bind( wx.EVT_MENU, self.checkUpdates, checkUpdatesItem ) self.Bind( wx.EVT_MENU, self.openWiki, wikiItem ) self.Bind( wx.EVT_MENU, self.openGithub, githubItem ) self.Bind( wx.EVT_MENU, self.openDiscord, discordItem ) # other events self.Bind( wx.EVT_CLOSE, self.OnClose, self ) self.Bind( wx.EVT_SIZING, self.OnResize, self ) self.Bind( wx.EVT_MAXIMIZE, self.OnMaximize, self ) if config.load('beePath') is None: self.portalMenu.Enable(9, False) self.fileMenu.Enable(1, False) else: self.portalMenu.Enable(10, False) # register event handlers dispatcher.connect( receiver=self.RemoveMenu, signal=Events.UnregisterMenu ) # trigger the registerMenu event dispatcher.send( Events.RegisterEvent, RegisterHandler=pluginSystem.RegisterHandler() ) """ A notebook is a controller which manages multiple windows with associated tabs. This section makes the notebook """ self.book = wx.Notebook( self, name="Main Menu", size=wx.Size( self.GetSize().GetWidth(), self.GetSize().GetHeight() ) ) self.browserTab = PackageBrowserPage(self.book) self.book.AddPage(self.browserTab, "Package Browser")