Export fitting to EVE, fix json bugs, and include forgotten CREST service.
This commit is contained in:
@@ -3,6 +3,7 @@ import service
|
||||
import gui.display as d
|
||||
from eos.types import Cargo
|
||||
from eos.db import getItem
|
||||
import json
|
||||
|
||||
class CrestFittings(wx.Frame):
|
||||
|
||||
@@ -64,6 +65,61 @@ class CrestFittings(wx.Frame):
|
||||
self.fitTree.populateSkillTree(fittings)
|
||||
|
||||
|
||||
class ExportToEve(wx.Frame):
|
||||
|
||||
def __init__(self, parent):
|
||||
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=(wx.Size(500,100)), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
|
||||
|
||||
self.mainFrame = parent
|
||||
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
|
||||
|
||||
sCrest = service.Crest.getInstance()
|
||||
|
||||
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
|
||||
chars = sCrest.getCrestCharacters()
|
||||
for char in chars:
|
||||
self.charChoice.Append(char.name, char.ID)
|
||||
|
||||
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
|
||||
self.charChoice.SetSelection(0)
|
||||
|
||||
mainSizer.Add( self.charChoice, 1, wx.ALL, 5 )
|
||||
self.exportBtn = wx.Button( self, wx.ID_ANY, u"Export Fit", wx.DefaultPosition, wx.DefaultSize, 5 )
|
||||
mainSizer.Add( self.exportBtn, 0, wx.ALL, 5 )
|
||||
|
||||
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
||||
|
||||
self.statusbar = wx.StatusBar(self)
|
||||
self.statusbar.SetFieldsCount(2)
|
||||
self.statusbar.SetStatusWidths([100, -1])
|
||||
|
||||
|
||||
self.SetSizer(mainSizer)
|
||||
self.SetStatusBar(self.statusbar)
|
||||
self.Layout()
|
||||
|
||||
self.Centre(wx.BOTH)
|
||||
|
||||
def getActiveCharacter(self):
|
||||
selection = self.charChoice.GetCurrentSelection()
|
||||
return self.charChoice.GetClientData(selection) if selection is not None else None
|
||||
|
||||
def exportFitting(self, event):
|
||||
self.statusbar.SetStatusText("", 0)
|
||||
self.statusbar.SetStatusText("Sending request and awaiting response", 1)
|
||||
sCrest = service.Crest.getInstance()
|
||||
|
||||
sFit = service.Fit.getInstance()
|
||||
data = sFit.exportCrest(self.mainFrame.getActiveFit())
|
||||
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)
|
||||
|
||||
class FittingsTreeView(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)
|
||||
|
||||
@@ -44,7 +44,7 @@ from gui.multiSwitch import MultiSwitch
|
||||
from gui.statsPane import StatsPane
|
||||
from gui.shipBrowser import ShipBrowser, FitSelected, ImportSelected, Stage3Selected
|
||||
from gui.characterEditor import CharacterEditor, SaveCharacterAs
|
||||
from gui.crestFittings import CrestFittings
|
||||
from gui.crestFittings import CrestFittings, ExportToEve
|
||||
from gui.characterSelection import CharacterSelection
|
||||
from gui.patternEditor import DmgPatternEditorDlg
|
||||
from gui.resistsEditor import ResistsEditorDlg
|
||||
@@ -418,6 +418,8 @@ class MainFrame(wx.Frame):
|
||||
self.Bind(wx.EVT_MENU, self.revertChar, id = menuBar.revertCharId)
|
||||
# Browse fittings
|
||||
self.Bind(wx.EVT_MENU, self.eveFittings, id = menuBar.eveFittingsId)
|
||||
# Export to EVE
|
||||
self.Bind(wx.EVT_MENU, self.exportToEve, id = menuBar.exportToEveId)
|
||||
|
||||
#Clipboard exports
|
||||
self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY)
|
||||
@@ -486,6 +488,10 @@ class MainFrame(wx.Frame):
|
||||
dlg=CrestFittings(self)
|
||||
dlg.Show()
|
||||
|
||||
def exportToEve(self, event):
|
||||
dlg=ExportToEve(self)
|
||||
dlg.Show()
|
||||
|
||||
def saveChar(self, event):
|
||||
sChr = service.Character.getInstance()
|
||||
charID = self.charSelection.getActiveCharacter()
|
||||
|
||||
@@ -41,6 +41,7 @@ class MainMenuBar(wx.MenuBar):
|
||||
self.saveCharAsId = wx.NewId()
|
||||
self.revertCharId = wx.NewId()
|
||||
self.eveFittingsId = wx.NewId()
|
||||
self.exportToEveId = wx.NewId()
|
||||
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -106,8 +107,8 @@ class MainMenuBar(wx.MenuBar):
|
||||
# CREST Menu
|
||||
crestMenu = wx.Menu()
|
||||
self.Append(crestMenu, "&CREST")
|
||||
eveFittings = wx.MenuItem(crestMenu, self.eveFittingsId, "Browse EVE Fittings")
|
||||
crestMenu.AppendItem(eveFittings)
|
||||
crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings")
|
||||
crestMenu.Append(self.exportToEveId, "Export To EVE")
|
||||
|
||||
# Help menu
|
||||
helpMenu = wx.Menu()
|
||||
|
||||
Reference in New Issue
Block a user