diff --git a/gui/builtinStatsViews/resourcesViewFull.py b/gui/builtinStatsViews/resourcesViewFull.py index d2051da99..2ad4061d7 100644 --- a/gui/builtinStatsViews/resourcesViewFull.py +++ b/gui/builtinStatsViews/resourcesViewFull.py @@ -60,8 +60,8 @@ class ResourcesViewFull(StatsView): base = sizerResources #Turrets & launcher hardslots display - tooltipText = {"turret":"Turret hardpoints", "drones":"Drones active", "launcher":"Launcher hardpoints", "calibration":"Calibration"} - for type in ("turret", "drones", "launcher", "calibration"): + tooltipText = {"turret":"Turret hardpoints", "launcher":"Launcher hardpoints", "drones":"Drones active", "calibration":"Calibration"} + for type in ("turret", "launcher", "drones", "calibration"): box = wx.BoxSizer(wx.HORIZONTAL) bitmap = bitmapLoader.getStaticBitmap("%s_big" % type, parent, "icons") @@ -72,7 +72,7 @@ class ResourcesViewFull(StatsView): sizer.Add(box, 0, wx.ALIGN_CENTER) - suffix = {'turret':'Hardpoints', 'drones':'Active', 'launcher':'Hardpoints', 'calibration':'Points'} + suffix = {'turret':'Hardpoints', 'launcher':'Hardpoints', 'drones':'Active', 'calibration':'Points'} lbl = wx.StaticText(parent, wx.ID_ANY, "0") setattr(self, "label%sUsed%s%s" % (panel.capitalize(), type.capitalize(), suffix[type].capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_CENTER) @@ -136,10 +136,10 @@ class ResourcesViewFull(StatsView): stats = (("label%sUsedTurretHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.TURRET), 0, 0, 0), ("label%sTotalTurretHardpoints", lambda: fit.ship.getModifiedItemAttr('turretSlotsLeft'), 0, 0, 0), - ("label%sUsedDronesActive", lambda: fit.activeDrones, 0, 0, 0), - ("label%sTotalDronesActive", lambda: fit.extraAttributes["maxActiveDrones"], 0, 0, 0), ("label%sUsedLauncherHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.MISSILE), 0, 0, 0), ("label%sTotalLauncherHardpoints", lambda: fit.ship.getModifiedItemAttr('launcherSlotsLeft'), 0, 0, 0), + ("label%sUsedDronesActive", lambda: fit.activeDrones, 0, 0, 0), + ("label%sTotalDronesActive", lambda: fit.extraAttributes["maxActiveDrones"], 0, 0, 0), ("label%sUsedCalibrationPoints", lambda: fit.calibrationUsed, 0, 0, 0), ("label%sTotalCalibrationPoints", lambda: fit.ship.getModifiedItemAttr('upgradeCapacity'), 0, 0, 0), ("label%sUsedPg", lambda: fit.pgUsed, 4, 0, 9), diff --git a/gui/builtinViewColumns/moduleAmmo.py b/gui/builtinViewColumns/moduleAmmo.py index 45584adcd..85b04df53 100644 --- a/gui/builtinViewColumns/moduleAmmo.py +++ b/gui/builtinViewColumns/moduleAmmo.py @@ -25,7 +25,7 @@ class ModuleAmmo(ViewColumn): name = "Module Ammo" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) - self.columnText = "Selected Ammo" + self.imageId = fittingView.imageList.Add(bitmapLoader.getBitmap("damagePattern_small", "icons")) def getText(self, mod): return "%s (%s)" % (mod.charge.name, mod.numCharges) if mod.charge is not None else "" diff --git a/gui/builtinViewColumns/projectedAmmo.py b/gui/builtinViewColumns/projectedAmmo.py index b36541d1f..dbcd285ea 100644 --- a/gui/builtinViewColumns/projectedAmmo.py +++ b/gui/builtinViewColumns/projectedAmmo.py @@ -25,9 +25,9 @@ class ProjectedAmmo(ViewColumn): name = "Projected Ammo" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) - self.columnText = "Ammo" + self.columnText = "" self.slave = gui.builtinViewColumns.moduleAmmo.ModuleAmmo(fittingView, params) - + self.imageId = self.slave.imageId def getText(self, stuff): if isinstance(stuff, Module): return self.slave.getText(stuff) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py new file mode 100644 index 000000000..45fb91d10 --- /dev/null +++ b/gui/copySelectDialog.py @@ -0,0 +1,61 @@ +#=============================================================================== +# Copyright (C) 2010 Lucas Thode +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +#=============================================================================== + + +import wx + +class CopySelectDialog(wx.Dialog): + copyFormatEft = 0 + copyFormatXml = 1 + copyFormatDna = 2 + + def __init__(self, parent): + wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = (-1,-1), style = wx.DEFAULT_DIALOG_STYLE) + mainSizer = wx.BoxSizer(wx.VERTICAL) + + copyFormats = [u"EFT", u"XML", u"DNA"] + copyFormatTooltips = {CopySelectDialog.copyFormatEft: u"Eve Fitting Tool text format", + CopySelectDialog.copyFormatXml: u"EvE native XML format", + CopySelectDialog.copyFormatDna: u"A one-line text format"} + selector = wx.RadioBox(self, wx.ID_ANY, label = u"Copy to the clipboard using:", choices = copyFormats, style = wx.RA_SPECIFY_ROWS) + selector.Bind(wx.EVT_RADIOBOX, self.Selected) + for format, tooltip in copyFormatTooltips.iteritems(): + selector.SetItemToolTip(format, tooltip) + + self.copyFormat = CopySelectDialog.copyFormatEft + selector.SetSelection(self.copyFormat) + + mainSizer.Add(selector,0,wx.EXPAND | wx.ALL, 5) + + buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) + if (buttonSizer): + mainSizer.Add(buttonSizer,0, wx.EXPAND | wx.ALL, 5) + + self.SetSizer(mainSizer) + self.Fit() + self.Center() + + + def Selected(self, event): + self.copyFormat = event.GetSelection() + + def GetSelected(self): + return self.copyFormat + + diff --git a/gui/fittingView.py b/gui/fittingView.py index ce4912bb8..71302d234 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -107,6 +107,7 @@ class FittingView(d.Display): wx.PostEvent(self.mainFrame, FitChanged(fitID=self.activeFitID)) event.Skip() + #Gets called from the fitMultiSwitch when it decides its time def changeFit(self, fitID): self.activeFitID = fitID @@ -247,3 +248,18 @@ class FittingView(d.Display): wx.PostEvent(self.mainFrame, FitChanged(fitID=self.mainFrame.getActiveFit())) else: event.Skip() + + def refresh(self, stuff): + d.Display.refresh(self, stuff) + sFit = service.Fit.getInstance() + fit = sFit.getFit(self.activeFitID) + slotMap = {} + for slotType in Slot.getTypes(): + slot = Slot.getValue(slotType) + slotMap[slot] = fit.getSlotsFree(slot) < 0 + + for i, mod in enumerate(self.mods): + if slotMap[mod.slot]: + self.SetItemBackgroundColour(i, wx.Colour(255, 51, 51)) + else: + self.SetItemBackgroundColour(i, self.GetBackgroundColour()) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index bcf336ad5..38ac58ac5 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -31,6 +31,7 @@ from gui.characterEditor import CharacterEditor from gui.characterSelection import CharacterSelection from gui.patternEditor import DmgPatternEditorDlg from gui.preferenceDialog import PreferenceDialog +from gui.copySelectDialog import CopySelectDialog import aboutData import gui.fittingView as fv from wx._core import PyDeadObjectError @@ -242,19 +243,17 @@ class MainFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES) #Clipboard exports - self.Bind(wx.EVT_MENU, self.clipboardEft, id=menuBar.idExportEft) - self.Bind(wx.EVT_MENU, self.clipboardDna, id=menuBar.idExportDna) - self.Bind(wx.EVT_MENU, self.clipboardXml, id=menuBar.idExportXml) + self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY) - def clipboardEft(self, event): + def clipboardEft(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportFit(self.getActiveFit())) - def clipboardDna(self, event): + def clipboardDna(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportDna(self.getActiveFit())) - def clipboardXml(self, event): + def clipboardXml(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportXml(self.getActiveFit())) @@ -266,6 +265,19 @@ class MainFrame(wx.Frame): self._openAfterImport(len(fits), IDs) except: pass + + def exportToClipboard(self, event): + CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft, + CopySelectDialog.copyFormatXml: self.clipboardXml, + CopySelectDialog.copyFormatDna: self.clipboardDna} + dlg = CopySelectDialog(self) + dlg.ShowModal() + selected = dlg.GetSelected() + try: + CopySelectDict[selected]() + except: + pass + dlg.Destroy() def toClipboard(self, text): clip = wx.TheClipboard diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index fe56fcfac..5bcd5e8a5 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -51,18 +51,12 @@ class MainMenuBar(wx.MenuBar): #editMenu.Append(wx.ID_UNDO) #editMenu.Append(wx.ID_REDO) - clipboardMenu = wx.Menu() - self.idExportDna, self.idExportEft, self.idExportXml = wx.NewId(), wx.NewId(), wx.NewId() - clipboardMenu.Append(self.idExportEft, "&EFT", "Copy the EFT export of this fit to the clipboard") - clipboardMenu.Append(self.idExportXml, "&XML", "Copy the XML export of this fit to the clipboard") - clipboardMenu.Append(self.idExportDna, "&DNA", "Copy the DNA export of this fit to the clipboard") - copyText = "Export &To Clipboard" + ("\tCTRL+C" if 'wxMSW' in wx.PlatformInfo else "") - pasteText = "Import &From Clipboard" + ("\tCTRL+V" if 'wxMSW' in wx.PlatformInfo else "") - editMenu.AppendMenu(wx.ID_COPY, copyText, clipboardMenu, "Export a fit to the clipboard") + copyText = "&To Clipboard" + ("\tCTRL+C" if 'wxMSW' in wx.PlatformInfo else "") + pasteText = "&From Clipboard" + ("\tCTRL+V" if 'wxMSW' in wx.PlatformInfo else "") + editMenu.Append(wx.ID_COPY, copyText, "Export a fit to the clipboard") editMenu.Append(wx.ID_PASTE, pasteText, "Import a fit from the clipboard") - # Character menu windowMenu = wx.Menu() self.Append(windowMenu, "&Window") diff --git a/gui/multiSwitch.py b/gui/multiSwitch.py index 54220d752..26aea48da 100644 --- a/gui/multiSwitch.py +++ b/gui/multiSwitch.py @@ -148,8 +148,10 @@ class MultiSwitch(wx.Notebook): page = self.GetPage(selection) if self.countEvt == 0: + fitID = page.view.activeFitID + sFit = service.Fit.getInstance() + sFit.switchFit(fitID) if hasattr(page, "type") and page.type == "fit": - fitID = page.view.activeFitID wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) else: wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=None)) @@ -168,6 +170,11 @@ class MultiSwitch(wx.Notebook): if page.type == "fit": fitID = event.fitID view = page.view + + #Notify service + sFit = service.Fit.getInstance() + sFit.switchFit(fitID) + #Change title of current tab to new fit self.setTabTitle(selected, fitID) view.changeFit(fitID) diff --git a/gui/statsPane.py b/gui/statsPane.py index ded4daedc..db8c96b69 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -39,7 +39,7 @@ class StatsPane(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - self.SetMinSize((310, -1)) + #self.SetMinSize((250, -1)) # Use 25% smaller fonts if MAC or force font size to 8 for msw/linux @@ -93,4 +93,4 @@ class StatsPane(wx.Panel): event.Skip() - return handler \ No newline at end of file + return handler diff --git a/service/character.py b/service/character.py index 846a6d7bf..56df2b0f8 100644 --- a/service/character.py +++ b/service/character.py @@ -30,10 +30,13 @@ class Character(): return cls.instance - def all0ID(self): + def all0(self): all0 = eos.types.Character.getAll0() eos.db.commit() - return all0.ID + return all0 + + def all0ID(self): + return self.all0().ID def getCharacterList(self): baseChars = [eos.types.Character.getAll0(), eos.types.Character.getAll5()] diff --git a/service/fit.py b/service/fit.py index 2e3f0d16c..b15bcc417 100644 --- a/service/fit.py +++ b/service/fit.py @@ -22,7 +22,7 @@ import eos.types from eos.types import State, Slot import copy from service.damagePattern import DamagePattern - +from service.character import Character class Fit(object): instance = None @@ -33,6 +33,10 @@ class Fit(object): return cls.instance + def __init__(self): + self.pattern = DamagePattern.getInstance().getDamagePattern("Uniform") + self.character = Character.getInstance().all0() + def getAllFits(self): fits = eos.db.getFitList() names = [] @@ -58,7 +62,8 @@ class Fit(object): fit = eos.types.Fit() fit.ship = eos.types.Ship(eos.db.getItem(shipID)) fit.name = name if name is not None else "New %s" % fit.ship.item.name - fit.damagePattern = DamagePattern.getInstance().getDamagePattern("Uniform") + fit.damagePattern = self.pattern + fit.character = self.character eos.db.save(fit) fit.calculateModifiedAttributes() return fit.ID @@ -96,6 +101,21 @@ class Fit(object): fit.clear() fit.calculateModifiedAttributes() + def switchFit(self, fitID): + if fitID is None: + return None + + fit = eos.db.getFit(fitID) + + if fit.character != self.character: + fit.character = self.character + if fit.damagePattern != self.pattern: + fit.damagePattern = self.pattern + + eos.db.commit() + fit.clear() + fit.calculateModifiedAttributes() + def getFit(self, fitID): if fitID is None: return None @@ -362,7 +382,7 @@ class Fit(object): return fit = eos.db.getFit(fitID) - fit.character = eos.db.getCharacter(charID) + fit.character = self.character = eos.db.getCharacter(charID) fit.clear() fit.calculateModifiedAttributes() @@ -395,7 +415,7 @@ class Fit(object): return fit = eos.db.getFit(fitID) - fit.damagePattern = pattern + fit.damagePattern = self.pattern = pattern eos.db.commit() fit.clear()