def delChar(self, event): item = self.lcCharacters.GetFirstSelected() if item > -1: charID = self.lcCharacters.GetItemData(item) sCrest = Crest.getInstance() sCrest.delCrestCharacter(charID) self.popCharList()
def exportFitting(self, event): sPort = Port.getInstance() fitID = self.mainFrame.getActiveFit() self.statusbar.SetStatusText("", 0) if fitID is None: self.statusbar.SetStatusText( "Please select an active fitting in the main window", 1) return self.statusbar.SetStatusText("Sending request and awaiting response", 1) sCrest = Crest.getInstance() try: sFit = Fit.getInstance() data = sPort.exportCrest(sFit.getFit(fitID)) res = sCrest.postFitting(self.getActiveCharacter(), data) self.statusbar.SetStatusText( "%d: %s" % (res.status_code, res.reason), 0) try: text = json.loads(res.text) self.statusbar.SetStatusText(text['message'], 1) except ValueError: pyfalog.warning("Value error on loading JSON.") self.statusbar.SetStatusText("", 1) except requests.exceptions.ConnectionError: msg = "Connection error, please check your internet connection" pyfalog.error(msg) self.statusbar.SetStatusText(msg)
def exportFitting(self, event): sPort = Port.getInstance() fitID = self.mainFrame.getActiveFit() self.statusbar.SetStatusText("", 0) if fitID is None: self.statusbar.SetStatusText("Please select an active fitting in the main window", 1) return self.statusbar.SetStatusText("Sending request and awaiting response", 1) sCrest = Crest.getInstance() try: sFit = Fit.getInstance() data = sPort.exportCrest(sFit.getFit(fitID)) res = sCrest.postFitting(self.getActiveCharacter(), data) self.statusbar.SetStatusText("%d: %s" % (res.status_code, res.reason), 0) try: text = json.loads(res.text) self.statusbar.SetStatusText(text['message'], 1) except ValueError: self.statusbar.SetStatusText("", 1) except requests.exceptions.ConnectionError: self.statusbar.SetStatusText("Connection error, please check your internet connection", 1)
def getActiveCharacter(self): sCrest = Crest.getInstance() if sCrest.settings.get('mode') == CrestModes.IMPLICIT: return sCrest.implicitCharacter.ID selection = self.charChoice.GetCurrentSelection() return self.charChoice.GetClientData(selection) if selection is not None else None
def updateTitle(self, event): sCrest = Crest.getInstance() char = sCrest.implicitCharacter if char: t = time.gmtime(char.eve.expires - time.time()) sTime = time.strftime("%H:%M:%S", t if t >= 0 else 0) newTitle = "%s | %s - %s" % (self.title, char.name, sTime) self.SetTitle(newTitle)
def getActiveCharacter(self): sCrest = Crest.getInstance() if sCrest.settings.get('mode') == CrestModes.IMPLICIT: return sCrest.implicitCharacter.ID selection = self.charChoice.GetCurrentSelection() return self.charChoice.GetClientData( selection) if selection is not None else None
def ssoHandler(self, event): sCrest = Crest.getInstance() if sCrest.settings.get('mode') == CrestModes.IMPLICIT: if sCrest.implicitCharacter is not None: sCrest.logout() else: uri = sCrest.startServer() webbrowser.open(uri) else: dlg = CrestMgmt(self) dlg.Show()
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition, size=(wx.Size(350, 100)), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.mainFrame = parent self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) sCrest = Crest.getInstance() mainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) if sCrest.settings.get('mode') == CrestModes.IMPLICIT: self.stLogged = wx.StaticText( self, wx.ID_ANY, "Currently logged in as %s" % sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize) self.stLogged.Wrap(-1) hSizer.Add(self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) else: self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []) hSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.updateCharList() self.charChoice.SetSelection(0) self.exportBtn = wx.Button(self, wx.ID_ANY, u"Export Fit", wx.DefaultPosition, wx.DefaultSize, 5) hSizer.Add(self.exportBtn, 0, wx.ALL, 5) mainSizer.Add(hSizer, 0, wx.EXPAND, 5) self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting) self.statusbar = wx.StatusBar(self) self.statusbar.SetFieldsCount(2) self.statusbar.SetStatusWidths([100, -1]) self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout) self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetSizer(hSizer) self.SetStatusBar(self.statusbar) self.Layout() self.Centre(wx.BOTH)
def updateCharList(self): sCrest = Crest.getInstance() chars = sCrest.getCrestCharacters() if len(chars) == 0: self.Close() self.charChoice.Clear() for char in chars: self.charChoice.Append(char.name, char.ID) self.charChoice.SetSelection(0)
def fetchFittings(self, event): sCrest = Crest.getInstance() try: waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self) fittings = sCrest.getFittings(self.getActiveCharacter()) self.cacheTime = fittings.get('cached_until') self.updateCacheStatus(None) self.cacheTimer.Start(1000) self.fitTree.populateSkillTree(fittings) except requests.exceptions.ConnectionError: self.statusbar.SetStatusText("Connection error, please check your internet connection") finally: del waitDialog
def popCharList(self): sCrest = Crest.getInstance() chars = sCrest.getCrestCharacters() self.lcCharacters.DeleteAllItems() for index, char in enumerate(chars): self.lcCharacters.InsertStringItem(index, char.name) self.lcCharacters.SetStringItem(index, 1, char.refresh_token) self.lcCharacters.SetItemData(index, char.ID) self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE)
def fetchFittings(self, event): sCrest = Crest.getInstance() try: waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self) fittings = sCrest.getFittings(self.getActiveCharacter()) self.cacheTime = fittings.get('cached_until') self.updateCacheStatus(None) self.cacheTimer.Start(1000) self.fitTree.populateSkillTree(fittings) del waitDialog except requests.exceptions.ConnectionError: msg = "Connection error, please check your internet connection" pyfalog.error(msg) self.statusbar.SetStatusText(msg)
def deleteFitting(self, event): sCrest = Crest.getInstance() selection = self.fitView.fitSelection if not selection: return data = json.loads(self.fitTree.fittingsTreeCtrl.GetPyData(selection)) dlg = wx.MessageDialog(self, "Do you really want to delete %s (%s) from EVE?" % (data['name'], data['ship']['name']), "Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: try: sCrest.delFitting(self.getActiveCharacter(), data['fittingID']) except requests.exceptions.ConnectionError: self.statusbar.SetStatusText("Connection error, please check your internet connection")
def updateCrestMenus(self, type): # in case we are logged in when switching, change title back self.titleTimer.Stop() self.SetTitle(self.title) menu = self.GetMenuBar() sCrest = Crest.getInstance() if type == CrestModes.IMPLICIT: menu.SetLabel(menu.ssoLoginId, "Login to EVE") menu.Enable(menu.eveFittingsId, False) menu.Enable(menu.exportToEveId, False) else: menu.SetLabel(menu.ssoLoginId, "Manage Characters") enable = len(sCrest.getCrestCharacters()) == 0 menu.Enable(menu.eveFittingsId, not enable) menu.Enable(menu.exportToEveId, not enable)
def deleteFitting(self, event): sCrest = Crest.getInstance() selection = self.fitView.fitSelection if not selection: return data = json.loads(self.fitTree.fittingsTreeCtrl.GetPyData(selection)) dlg = wx.MessageDialog( self, "Do you really want to delete %s (%s) from EVE?" % (data['name'], data['ship']['name']), "Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: try: sCrest.delFitting(self.getActiveCharacter(), data['fittingID']) except requests.exceptions.ConnectionError: msg = "Connection error, please check your internet connection" pyfalog.error(msg) self.statusbar.SetStatusText(msg)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition, size=(wx.Size(350, 100)), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.mainFrame = parent self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) sCrest = Crest.getInstance() mainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) if sCrest.settings.get('mode') == CrestModes.IMPLICIT: self.stLogged = wx.StaticText(self, wx.ID_ANY, "Currently logged in as %s" % sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize) self.stLogged.Wrap(-1) hSizer.Add(self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) else: self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []) hSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.updateCharList() self.charChoice.SetSelection(0) self.exportBtn = wx.Button(self, wx.ID_ANY, u"Export Fit", wx.DefaultPosition, wx.DefaultSize, 5) hSizer.Add(self.exportBtn, 0, wx.ALL, 5) mainSizer.Add(hSizer, 0, wx.EXPAND, 5) self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting) self.statusbar = wx.StatusBar(self) self.statusbar.SetFieldsCount(2) self.statusbar.SetStatusWidths([100, -1]) self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout) self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetSizer(hSizer) self.SetStatusBar(self.statusbar) self.Layout() self.Centre(wx.BOTH)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Browse EVE Fittings", pos=wx.DefaultPosition, size=wx.Size(550, 450), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) self.mainFrame = parent mainSizer = wx.BoxSizer(wx.VERTICAL) sCrest = Crest.getInstance() characterSelectSizer = wx.BoxSizer(wx.HORIZONTAL) if sCrest.settings.get('mode') == CrestModes.IMPLICIT: self.stLogged = wx.StaticText( self, wx.ID_ANY, "Currently logged in as %s" % sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize) self.stLogged.Wrap(-1) characterSelectSizer.Add(self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) else: self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []) characterSelectSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.updateCharList() self.fetchBtn = wx.Button(self, wx.ID_ANY, u"Fetch Fits", wx.DefaultPosition, wx.DefaultSize, 5) characterSelectSizer.Add(self.fetchBtn, 0, wx.ALL, 5) mainSizer.Add(characterSelectSizer, 0, wx.EXPAND, 5) self.sl = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.sl, 0, wx.EXPAND | wx.ALL, 5) contentSizer = wx.BoxSizer(wx.HORIZONTAL) browserSizer = wx.BoxSizer(wx.VERTICAL) self.fitTree = FittingsTreeView(self) browserSizer.Add(self.fitTree, 1, wx.ALL | wx.EXPAND, 5) contentSizer.Add(browserSizer, 1, wx.EXPAND, 0) fitSizer = wx.BoxSizer(wx.VERTICAL) self.fitView = FitView(self) fitSizer.Add(self.fitView, 1, wx.ALL | wx.EXPAND, 5) btnSizer = wx.BoxSizer(wx.HORIZONTAL) self.importBtn = wx.Button(self, wx.ID_ANY, u"Import to pyfa", wx.DefaultPosition, wx.DefaultSize, 5) self.deleteBtn = wx.Button(self, wx.ID_ANY, u"Delete from EVE", wx.DefaultPosition, wx.DefaultSize, 5) btnSizer.Add(self.importBtn, 1, wx.ALL, 5) btnSizer.Add(self.deleteBtn, 1, wx.ALL, 5) fitSizer.Add(btnSizer, 0, wx.EXPAND) contentSizer.Add(fitSizer, 1, wx.EXPAND, 0) mainSizer.Add(contentSizer, 1, wx.EXPAND, 5) self.fetchBtn.Bind(wx.EVT_BUTTON, self.fetchFittings) self.importBtn.Bind(wx.EVT_BUTTON, self.importFitting) self.deleteBtn.Bind(wx.EVT_BUTTON, self.deleteFitting) self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout) self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin) self.Bind(wx.EVT_CLOSE, self.OnClose) self.statusbar = wx.StatusBar(self) self.statusbar.SetFieldsCount() self.SetStatusBar(self.statusbar) self.cacheTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.updateCacheStatus, self.cacheTimer) self.SetSizer(mainSizer) self.Layout() self.Centre(wx.BOTH)
def exportCrest(cls, ofit, callback=None): # A few notes: # max fit name length is 50 characters # Most keys are created simply because they are required, but bogus data is okay nested_dict = lambda: collections.defaultdict(nested_dict) fit = nested_dict() sCrest = Crest.getInstance() sFit = svcFit.getInstance() eve = sCrest.eve # max length is 50 characters name = ofit.name[:47] + '...' if len(ofit.name) > 50 else ofit.name fit['name'] = name fit['ship']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, ofit.ship.item.ID) fit['ship']['id'] = ofit.ship.item.ID fit['ship']['name'] = '' fit['description'] = "<pyfa:%d />" % ofit.ID fit['items'] = [] slotNum = {} charges = {} for module in ofit.modules: if module.isEmpty: continue item = nested_dict() slot = module.slot if slot == Slot.SUBSYSTEM: # Order of subsystem matters based on this attr. See GH issue #130 slot = int(module.getModifiedItemAttr("subSystemSlot")) item['flag'] = slot else: if slot not in slotNum: slotNum[slot] = INV_FLAGS[slot] item['flag'] = slotNum[slot] slotNum[slot] += 1 item['quantity'] = 1 item['type']['href'] = "%sinventory/types/%d/" % ( eve._authed_endpoint, module.item.ID) item['type']['id'] = module.item.ID item['type']['name'] = '' fit['items'].append(item) if module.charge and sFit.serviceFittingOptions["exportCharges"]: if module.chargeID not in charges: charges[module.chargeID] = 0 # `or 1` because some charges (ie scripts) are without qty charges[module.chargeID] += module.numCharges or 1 for cargo in ofit.cargo: item = nested_dict() item['flag'] = INV_FLAG_CARGOBAY item['quantity'] = cargo.amount item['type']['href'] = "%sinventory/types/%d/" % ( eve._authed_endpoint, cargo.item.ID) item['type']['id'] = cargo.item.ID item['type']['name'] = '' fit['items'].append(item) for chargeID, amount in charges.items(): item = nested_dict() item['flag'] = INV_FLAG_CARGOBAY item['quantity'] = amount item['type']['href'] = "%sinventory/types/%d/" % ( eve._authed_endpoint, chargeID) item['type']['id'] = chargeID item['type']['name'] = '' fit['items'].append(item) for drone in ofit.drones: item = nested_dict() item['flag'] = INV_FLAG_DRONEBAY item['quantity'] = drone.amount item['type']['href'] = "%sinventory/types/%d/" % ( eve._authed_endpoint, drone.item.ID) item['type']['id'] = drone.item.ID item['type']['name'] = '' fit['items'].append(item) for fighter in ofit.fighters: item = nested_dict() item['flag'] = INV_FLAG_FIGHTER item['quantity'] = fighter.amountActive item['type']['href'] = "%sinventory/types/%d/" % ( eve._authed_endpoint, fighter.item.ID) item['type']['id'] = fighter.item.ID item['type']['name'] = fighter.item.name fit['items'].append(item) return json.dumps(fit)
def OnBtnApply(self, event): self.settings.set('clientID', self.inputClientID.GetValue().strip()) self.settings.set('clientSecret', self.inputClientSecret.GetValue().strip()) sCrest = Crest.getInstance() sCrest.delAllCharacters()
def addChar(self, event): sCrest = Crest.getInstance() uri = sCrest.startServer() webbrowser.open(uri)
def __init__(self, mainFrame): pyfalog.debug("Initialize MainMenuBar") self.characterEditorId = wx.NewId() self.damagePatternEditorId = wx.NewId() self.targetResistsEditorId = wx.NewId() self.implantSetEditorId = wx.NewId() self.graphFrameId = wx.NewId() self.backupFitsId = wx.NewId() self.exportSkillsNeededId = wx.NewId() self.importCharacterId = wx.NewId() self.exportHtmlId = wx.NewId() self.wikiId = wx.NewId() self.forumId = wx.NewId() self.saveCharId = wx.NewId() self.saveCharAsId = wx.NewId() self.revertCharId = wx.NewId() self.eveFittingsId = wx.NewId() self.exportToEveId = wx.NewId() self.ssoLoginId = wx.NewId() self.attrEditorId = wx.NewId() self.toggleOverridesId = wx.NewId() self.importDatabaseDefaultsId = wx.NewId() self.toggleIgnoreRestrictionID = wx.NewId() if 'wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0): wx.ID_COPY = wx.NewId() wx.ID_PASTE = wx.NewId() self.mainFrame = mainFrame wx.MenuBar.__init__(self) # File menu fileMenu = wx.Menu() self.Append(fileMenu, "&File") fileMenu.Append(self.mainFrame.addPageId, "&New Tab\tCTRL+T", "Open a new fitting tab") fileMenu.Append(self.mainFrame.closePageId, "&Close Tab\tCTRL+W", "Close the current fit") fileMenu.AppendSeparator() fileMenu.Append(self.backupFitsId, "&Backup All Fittings", "Backup all fittings to a XML file") fileMenu.Append(wx.ID_OPEN, "&Import Fittings\tCTRL+O", "Import fittings into pyfa") fileMenu.Append(wx.ID_SAVEAS, "&Export Fitting\tCTRL+S", "Export fitting to another format") fileMenu.AppendSeparator() fileMenu.Append(self.exportHtmlId, "Export HTML", "Export fits to HTML file (set in Preferences)") fileMenu.Append(self.exportSkillsNeededId, "Export &Skills Needed", "Export skills needed for this fitting") fileMenu.Append(self.importCharacterId, "Import C&haracter File", "Import characters into pyfa from file") fileMenu.AppendSeparator() fileMenu.Append(wx.ID_EXIT) # Edit menu editMenu = wx.Menu() self.Append(editMenu, "&Edit") # editMenu.Append(wx.ID_UNDO) # editMenu.Append(wx.ID_REDO) editMenu.Append(wx.ID_COPY, "To Clipboard\tCTRL+C", "Export a fit to the clipboard") editMenu.Append(wx.ID_PASTE, "From Clipboard\tCTRL+V", "Import a fit from the clipboard") editMenu.AppendSeparator() editMenu.Append(self.saveCharId, "Save Character") editMenu.Append(self.saveCharAsId, "Save Character As...") editMenu.Append(self.revertCharId, "Revert Character") editMenu.AppendSeparator() self.ignoreRestrictionItem = editMenu.Append( self.toggleIgnoreRestrictionID, "Ignore Fitting Restrictions") # Character menu windowMenu = wx.Menu() self.Append(windowMenu, "&Window") charEditItem = wx.MenuItem(windowMenu, self.characterEditorId, "&Character Editor\tCTRL+E") charEditItem.SetBitmap(BitmapLoader.getBitmap("character_small", "gui")) windowMenu.AppendItem(charEditItem) damagePatternEditItem = wx.MenuItem(windowMenu, self.damagePatternEditorId, "Damage Pattern Editor\tCTRL+D") damagePatternEditItem.SetBitmap( BitmapLoader.getBitmap("damagePattern_small", "gui")) windowMenu.AppendItem(damagePatternEditItem) targetResistsEditItem = wx.MenuItem(windowMenu, self.targetResistsEditorId, "Target Profile Editor\tCTRL+R") targetResistsEditItem.SetBitmap( BitmapLoader.getBitmap("explosive_small", "gui")) windowMenu.AppendItem(targetResistsEditItem) implantSetEditItem = wx.MenuItem(windowMenu, self.implantSetEditorId, "Implant Set Editor\tCTRL+I") implantSetEditItem.SetBitmap( BitmapLoader.getBitmap("hardwire_small", "gui")) windowMenu.AppendItem(implantSetEditItem) graphFrameItem = wx.MenuItem(windowMenu, self.graphFrameId, "Graphs\tCTRL+G") graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui")) windowMenu.AppendItem(graphFrameItem) if not gui.graphFrame.graphFrame_enabled: self.Enable(self.graphFrameId, False) preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P" preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t" + preferencesShortCut) preferencesItem.SetBitmap( BitmapLoader.getBitmap("preferences_small", "gui")) windowMenu.AppendItem(preferencesItem) if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): self.sCrest = Crest.getInstance() # CREST Menu crestMenu = wx.Menu() self.Append(crestMenu, "&CREST") if self.sCrest.settings.get('mode') != CrestModes.IMPLICIT: crestMenu.Append(self.ssoLoginId, "Manage Characters") else: crestMenu.Append(self.ssoLoginId, "Login to EVE") crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings") crestMenu.Append(self.exportToEveId, "Export To EVE") if self.sCrest.settings.get('mode') == CrestModes.IMPLICIT or len( self.sCrest.getCrestCharacters()) == 0: self.Enable(self.eveFittingsId, False) self.Enable(self.exportToEveId, False) if not self.mainFrame.disableOverrideEditor: windowMenu.AppendSeparator() attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B") attrItem.SetBitmap( BitmapLoader.getBitmap("fit_rename_small", "gui")) windowMenu.AppendItem(attrItem) windowMenu.Append(self.toggleOverridesId, "Turn Overrides On") # Help menu helpMenu = wx.Menu() self.Append(helpMenu, "&Help") helpMenu.Append(self.wikiId, "Wiki", "Go to wiki on GitHub") helpMenu.Append(self.forumId, "Forums", "Go to EVE Online Forum thread") helpMenu.AppendSeparator() helpMenu.Append(self.importDatabaseDefaultsId, "Import D&atabase Defaults", "Imports missing database defaults") helpMenu.AppendSeparator() helpMenu.Append(wx.ID_ABOUT) if config.debug: helpMenu.Append(self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool", "Open Widgets Inspect tool") self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Browse EVE Fittings", pos=wx.DefaultPosition, size=wx.Size(550, 450), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) self.mainFrame = parent mainSizer = wx.BoxSizer(wx.VERTICAL) sCrest = Crest.getInstance() characterSelectSizer = wx.BoxSizer(wx.HORIZONTAL) if sCrest.settings.get('mode') == CrestModes.IMPLICIT: self.stLogged = wx.StaticText(self, wx.ID_ANY, "Currently logged in as %s" % sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize) self.stLogged.Wrap(-1) characterSelectSizer.Add(self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) else: self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []) characterSelectSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.updateCharList() self.fetchBtn = wx.Button(self, wx.ID_ANY, u"Fetch Fits", wx.DefaultPosition, wx.DefaultSize, 5) characterSelectSizer.Add(self.fetchBtn, 0, wx.ALL, 5) mainSizer.Add(characterSelectSizer, 0, wx.EXPAND, 5) self.sl = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.sl, 0, wx.EXPAND | wx.ALL, 5) contentSizer = wx.BoxSizer(wx.HORIZONTAL) browserSizer = wx.BoxSizer(wx.VERTICAL) self.fitTree = FittingsTreeView(self) browserSizer.Add(self.fitTree, 1, wx.ALL | wx.EXPAND, 5) contentSizer.Add(browserSizer, 1, wx.EXPAND, 0) fitSizer = wx.BoxSizer(wx.VERTICAL) self.fitView = FitView(self) fitSizer.Add(self.fitView, 1, wx.ALL | wx.EXPAND, 5) btnSizer = wx.BoxSizer(wx.HORIZONTAL) self.importBtn = wx.Button(self, wx.ID_ANY, u"Import to pyfa", wx.DefaultPosition, wx.DefaultSize, 5) self.deleteBtn = wx.Button(self, wx.ID_ANY, u"Delete from EVE", wx.DefaultPosition, wx.DefaultSize, 5) btnSizer.Add(self.importBtn, 1, wx.ALL, 5) btnSizer.Add(self.deleteBtn, 1, wx.ALL, 5) fitSizer.Add(btnSizer, 0, wx.EXPAND) contentSizer.Add(fitSizer, 1, wx.EXPAND, 0) mainSizer.Add(contentSizer, 1, wx.EXPAND, 5) self.fetchBtn.Bind(wx.EVT_BUTTON, self.fetchFittings) self.importBtn.Bind(wx.EVT_BUTTON, self.importFitting) self.deleteBtn.Bind(wx.EVT_BUTTON, self.deleteFitting) self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout) self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin) self.Bind(wx.EVT_CLOSE, self.OnClose) self.statusbar = wx.StatusBar(self) self.statusbar.SetFieldsCount() self.SetStatusBar(self.statusbar) self.cacheTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.updateCacheStatus, self.cacheTimer) self.SetSizer(mainSizer) self.Layout() self.Centre(wx.BOTH)
def __init__(self, mainFrame): pyfalog.debug("Initialize MainMenuBar") self.characterEditorId = wx.NewId() self.damagePatternEditorId = wx.NewId() self.targetResistsEditorId = wx.NewId() self.implantSetEditorId = wx.NewId() self.graphFrameId = wx.NewId() self.backupFitsId = wx.NewId() self.exportSkillsNeededId = wx.NewId() self.importCharacterId = wx.NewId() self.exportHtmlId = wx.NewId() self.wikiId = wx.NewId() self.forumId = wx.NewId() self.saveCharId = wx.NewId() self.saveCharAsId = wx.NewId() self.revertCharId = wx.NewId() self.eveFittingsId = wx.NewId() self.exportToEveId = wx.NewId() self.ssoLoginId = wx.NewId() self.attrEditorId = wx.NewId() self.toggleOverridesId = wx.NewId() self.importDatabaseDefaultsId = wx.NewId() self.toggleIgnoreRestrictionID = wx.NewId() if 'wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0): wx.ID_COPY = wx.NewId() wx.ID_PASTE = wx.NewId() self.mainFrame = mainFrame wx.MenuBar.__init__(self) # File menu fileMenu = wx.Menu() self.Append(fileMenu, "&File") fileMenu.Append(self.mainFrame.addPageId, "&New Tab\tCTRL+T", "Open a new fitting tab") fileMenu.Append(self.mainFrame.closePageId, "&Close Tab\tCTRL+W", "Close the current fit") fileMenu.AppendSeparator() fileMenu.Append(self.backupFitsId, "&Backup All Fittings", "Backup all fittings to a XML file") fileMenu.Append(wx.ID_OPEN, "&Import Fittings\tCTRL+O", "Import fittings into pyfa") fileMenu.Append(wx.ID_SAVEAS, "&Export Fitting\tCTRL+S", "Export fitting to another format") fileMenu.AppendSeparator() fileMenu.Append(self.exportHtmlId, "Export HTML", "Export fits to HTML file (set in Preferences)") fileMenu.Append(self.exportSkillsNeededId, "Export &Skills Needed", "Export skills needed for this fitting") fileMenu.Append(self.importCharacterId, "Import C&haracter File", "Import characters into pyfa from file") fileMenu.AppendSeparator() fileMenu.Append(wx.ID_EXIT) # Edit menu editMenu = wx.Menu() self.Append(editMenu, "&Edit") # editMenu.Append(wx.ID_UNDO) # editMenu.Append(wx.ID_REDO) editMenu.Append(wx.ID_COPY, "To Clipboard\tCTRL+C", "Export a fit to the clipboard") editMenu.Append(wx.ID_PASTE, "From Clipboard\tCTRL+V", "Import a fit from the clipboard") editMenu.AppendSeparator() editMenu.Append(self.saveCharId, "Save Character") editMenu.Append(self.saveCharAsId, "Save Character As...") editMenu.Append(self.revertCharId, "Revert Character") editMenu.AppendSeparator() self.ignoreRestrictionItem = editMenu.Append(self.toggleIgnoreRestrictionID, "Ignore Fitting Restrictions") # Character menu windowMenu = wx.Menu() self.Append(windowMenu, "&Window") charEditItem = wx.MenuItem(windowMenu, self.characterEditorId, "&Character Editor\tCTRL+E") charEditItem.SetBitmap(BitmapLoader.getBitmap("character_small", "gui")) windowMenu.AppendItem(charEditItem) damagePatternEditItem = wx.MenuItem(windowMenu, self.damagePatternEditorId, "Damage Pattern Editor\tCTRL+D") damagePatternEditItem.SetBitmap(BitmapLoader.getBitmap("damagePattern_small", "gui")) windowMenu.AppendItem(damagePatternEditItem) targetResistsEditItem = wx.MenuItem(windowMenu, self.targetResistsEditorId, "Target Resists Editor\tCTRL+R") targetResistsEditItem.SetBitmap(BitmapLoader.getBitmap("explosive_small", "gui")) windowMenu.AppendItem(targetResistsEditItem) implantSetEditItem = wx.MenuItem(windowMenu, self.implantSetEditorId, "Implant Set Editor\tCTRL+I") implantSetEditItem.SetBitmap(BitmapLoader.getBitmap("hardwire_small", "gui")) windowMenu.AppendItem(implantSetEditItem) graphFrameItem = wx.MenuItem(windowMenu, self.graphFrameId, "Graphs\tCTRL+G") graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui")) windowMenu.AppendItem(graphFrameItem) if not gui.graphFrame.graphFrame_enabled: self.Enable(self.graphFrameId, False) preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P" preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t" + preferencesShortCut) preferencesItem.SetBitmap(BitmapLoader.getBitmap("preferences_small", "gui")) windowMenu.AppendItem(preferencesItem) if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): self.sCrest = Crest.getInstance() # CREST Menu crestMenu = wx.Menu() self.Append(crestMenu, "&CREST") if self.sCrest.settings.get('mode') != CrestModes.IMPLICIT: crestMenu.Append(self.ssoLoginId, "Manage Characters") else: crestMenu.Append(self.ssoLoginId, "Login to EVE") crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings") crestMenu.Append(self.exportToEveId, "Export To EVE") if self.sCrest.settings.get('mode') == CrestModes.IMPLICIT or len(self.sCrest.getCrestCharacters()) == 0: self.Enable(self.eveFittingsId, False) self.Enable(self.exportToEveId, False) if not self.mainFrame.disableOverrideEditor: windowMenu.AppendSeparator() attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B") attrItem.SetBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui")) windowMenu.AppendItem(attrItem) windowMenu.Append(self.toggleOverridesId, "Turn Overrides On") # Help menu helpMenu = wx.Menu() self.Append(helpMenu, "&Help") helpMenu.Append(self.wikiId, "Wiki", "Go to wiki on GitHub") helpMenu.Append(self.forumId, "Forums", "Go to EVE Online Forum thread") helpMenu.AppendSeparator() helpMenu.Append(self.importDatabaseDefaultsId, "Import D&atabase Defaults", "Imports missing database defaults") helpMenu.AppendSeparator() helpMenu.Append(wx.ID_ABOUT) if config.debug: helpMenu.Append(self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool", "Open Widgets Inspect tool") self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
def addChar(event): sCrest = Crest.getInstance() uri = sCrest.startServer() webbrowser.open(uri)
def exportCrest(cls, ofit, callback=None): # A few notes: # max fit name length is 50 characters # Most keys are created simply because they are required, but bogus data is okay nested_dict = lambda: collections.defaultdict(nested_dict) fit = nested_dict() sCrest = Crest.getInstance() sFit = svcFit.getInstance() eve = sCrest.eve # max length is 50 characters name = ofit.name[:47] + '...' if len(ofit.name) > 50 else ofit.name fit['name'] = name fit['ship']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, ofit.ship.item.ID) fit['ship']['id'] = ofit.ship.item.ID fit['ship']['name'] = '' fit['description'] = "<pyfa:%d />" % ofit.ID fit['items'] = [] slotNum = {} charges = {} for module in ofit.modules: if module.isEmpty: continue item = nested_dict() slot = module.slot if slot == Slot.SUBSYSTEM: # Order of subsystem matters based on this attr. See GH issue #130 slot = int(module.getModifiedItemAttr("subSystemSlot")) item['flag'] = slot else: if slot not in slotNum: slotNum[slot] = INV_FLAGS[slot] item['flag'] = slotNum[slot] slotNum[slot] += 1 item['quantity'] = 1 item['type']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, module.item.ID) item['type']['id'] = module.item.ID item['type']['name'] = '' fit['items'].append(item) if module.charge and sFit.serviceFittingOptions["exportCharges"]: if module.chargeID not in charges: charges[module.chargeID] = 0 # `or 1` because some charges (ie scripts) are without qty charges[module.chargeID] += module.numCharges or 1 for cargo in ofit.cargo: item = nested_dict() item['flag'] = INV_FLAG_CARGOBAY item['quantity'] = cargo.amount item['type']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, cargo.item.ID) item['type']['id'] = cargo.item.ID item['type']['name'] = '' fit['items'].append(item) for chargeID, amount in charges.items(): item = nested_dict() item['flag'] = INV_FLAG_CARGOBAY item['quantity'] = amount item['type']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, chargeID) item['type']['id'] = chargeID item['type']['name'] = '' fit['items'].append(item) for drone in ofit.drones: item = nested_dict() item['flag'] = INV_FLAG_DRONEBAY item['quantity'] = drone.amount item['type']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, drone.item.ID) item['type']['id'] = drone.item.ID item['type']['name'] = '' fit['items'].append(item) for fighter in ofit.fighters: item = nested_dict() item['flag'] = INV_FLAG_FIGHTER item['quantity'] = fighter.amountActive item['type']['href'] = "%sinventory/types/%d/" % (eve._authed_endpoint, fighter.item.ID) item['type']['id'] = fighter.item.ID item['type']['name'] = fighter.item.name fit['items'].append(item) return json.dumps(fit)