diff --git a/gui/builtinContextMenus/itemStats.py b/gui/builtinContextMenus/itemStats.py index 4b8c84de1..b56a07d1d 100644 --- a/gui/builtinContextMenus/itemStats.py +++ b/gui/builtinContextMenus/itemStats.py @@ -8,11 +8,16 @@ class ItemStats(ContextMenu): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, context, selection): - return context in ("item", "ship", "module", "ammo", "skill", "itemSearch", "drone", "implant", "booster") + return context in ("item", "ship", "module", "ammo", "skill", + "itemSearch", "drone", "implant", "booster", + "projectedModule", "projectedDrone") def getText(self, context, selection): - return "%s stats" % (context.capitalize() if context != "itemSearch" else "Item") + return "%s stats" % (context.capitalize() if context not in self.REPLACES else self.REPLACES[context]) + REPLACES = {"itemSearch": "Item", + "projectedModule": "Module", + "projectedDrone": "Drone"} def activate(self, context, selection, i): if context == "ship": fitID = self.mainFrame.getActiveFit() @@ -24,6 +29,6 @@ class ItemStats(ContextMenu): if context == "module" and stuff.isEmpty: return - dlg=ItemStatsDialog(stuff, context if context != "itemSearch" else "Item") + dlg=ItemStatsDialog(stuff, context.capitalize() if context not in self.REPLACES else self.REPLACES[context]) ItemStats.register() diff --git a/gui/builtinContextMenus/project.py b/gui/builtinContextMenus/project.py new file mode 100755 index 000000000..2f709e6c8 --- /dev/null +++ b/gui/builtinContextMenus/project.py @@ -0,0 +1,27 @@ +from gui.contextMenu import ContextMenu +import gui.mainFrame +import service +import gui.fittingView +import wx + +class Project(ContextMenu): + def __init__(self): + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def display(self, context, selection): + if context not in ("item", "itemSearch") or self.mainFrame.getActiveFit() is None: + return False + + item = selection[0] + return item.isType("projected") + + def getText(self, context, selection): + return "Project onto Fit" + + def activate(self, context, selection, i): + sFit = service.Fit.getInstance() + fitID = self.mainFrame.getActiveFit() + sFit.project(fitID, selection[0]) + wx.PostEvent(self.mainFrame, gui.fittingView.FitChanged(fitID=fitID)) + +Project.register() diff --git a/gui/builtinViewColumns/projectedName.py b/gui/builtinViewColumns/projectedName.py new file mode 100755 index 000000000..ab28cc6a8 --- /dev/null +++ b/gui/builtinViewColumns/projectedName.py @@ -0,0 +1,45 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# 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 . +#=============================================================================== + +from gui.viewColumn import ViewColumn +import gui.builtinViewColumns.name +import gui.builtinViewColumns.droneNameAmount +from eos.types import Drone + +class ProjectedName(ViewColumn): + name = "Projected Name" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.columnText = "Name" + self.slave = gui.builtinViewColumns.name.StuffName(fittingView, params) + self.droneSlave = gui.builtinViewColumns.droneNameAmount.DroneNameAmount(fittingView, params) + + def getText(self, stuff): + if isinstance(stuff, Drone): + return self.droneSlave.getText(stuff) + else: + return self.slave.getText(stuff) + + def getImageId(self, thing): + if isinstance(thing, Drone): + return self.droneSlave.getImageId(thing) + else: + return self.slave.getImageId(thing) + +ProjectedName.register() diff --git a/gui/builtinViewColumns/projectedState.py b/gui/builtinViewColumns/projectedState.py new file mode 100755 index 000000000..b3d1f4163 --- /dev/null +++ b/gui/builtinViewColumns/projectedState.py @@ -0,0 +1,55 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# 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 . +#=============================================================================== + +from gui import builtinViewColumns +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +from eos.types import Slot +import gui.builtinViewColumns.moduleState +import gui.builtinViewColumns.droneCheckbox +from eos.types import Module, Drone, Fit +import gui.bitmapLoader + +class ProjectedState(ViewColumn): + name = "Projected State" + def __init__(self, view, params): + ViewColumn.__init__(self, view) + self.columnText = "" + self.size = 20 + self.fitImageId = view.imageList.Add(gui.bitmapLoader.getBitmap("fit_small", "icons")) + self.moduleSlave = gui.builtinViewColumns.moduleState.ModuleState(view, params) + self.droneSlave = gui.builtinViewColumns.droneCheckbox.DroneCheckbox(view, params) + + def getText(self, stuff): + if isinstance(stuff, Module): + return self.moduleSlave.getText(stuff) + elif isinstance(stuff, Drone): + return self.droneSlave.getText(stuff) + else: + return "" + + def getImageId(self, stuff): + if isinstance(stuff, Module): + return self.moduleSlave.getImageId(stuff) + elif isinstance(stuff, Drone): + return self.droneSlave.getImageId(stuff) + else: + return self.fitImageId + +ProjectedState.register() diff --git a/gui/contextMenu.py b/gui/contextMenu.py index 34724f834..d7683818c 100644 --- a/gui/contextMenu.py +++ b/gui/contextMenu.py @@ -68,7 +68,7 @@ class ContextMenu(object): if amount > 0 and i != len(contexts) - 1: menu.AppendSeparator() - return menu if not empty else None + return menu @classmethod def handler(cls, event): diff --git a/gui/projectedView.py b/gui/projectedView.py index 8ce2bdf57..0e8693bc5 100644 --- a/gui/projectedView.py +++ b/gui/projectedView.py @@ -24,6 +24,7 @@ import service import gui.droneView from gui.builtinViewColumns.projectedState import ProjectedState from gui.contextMenu import ContextMenu +import eos.types class ProjectedView(d.Display): DEFAULT_COLS = ["Projected State", @@ -86,14 +87,23 @@ class ProjectedView(d.Display): event.Skip() row, _ = self.HitTest(event.Position) if row != -1: + item = self.get(row) col = self.getColumn(event.Position) if col == self.getColIndex(ProjectedState): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() - cFit.toggleProjected(fitID, self.get(row), "right" if event.Button == 3 else "left") + cFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left") wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) elif event.Button == 3: - menu = ContextMenu.getMenu((self.get(row),), "projectedDrone") + if isinstance(item, eos.types.Drone): + context = "projectedDrone" + elif isinstance(item, eos.types.Module): + context = "projectedModule" + else: + context = "projectedFit" + + print item, context + menu = ContextMenu.getMenu((item,), context) self.PopupMenu(menu) def remove(self, event):