diff --git a/gui/builtinContextMenus/damagePatternMenu.py b/gui/builtinContextMenus/damagePatternMenu.py new file mode 100755 index 000000000..24c76cce6 --- /dev/null +++ b/gui/builtinContextMenus/damagePatternMenu.py @@ -0,0 +1,32 @@ +from gui.contextMenu import ContextMenu +from gui.itemStats import ItemStatsDialog +import gui.mainFrame +import service + +class DamagePattern(ContextMenu): + def __init__(self): + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def display(self, context, selection): + return context in ("resistancePane",) + + def getText(self, context, selection): + return "%s stats" % context.capitalize() + + def activate(self, context, selection): + if context == "ship": + fitID = self.mainFrame.getActiveFit() + cFit = service.Fit.getInstance() + stuff = cFit.getFit(fitID).ship + elif context == "ammo": + stuff = selection[0].charge + else: + stuff = selection[0] + + if context == "module" and stuff.isEmpty: + return + + dlg=ItemStatsDialog(stuff) + dlg.Show() + +ItemStats.register() \ No newline at end of file diff --git a/gui/builtinContextMenus/itemStats.py b/gui/builtinContextMenus/itemStats.py index 4d50b3640..b1671900e 100755 --- a/gui/builtinContextMenus/itemStats.py +++ b/gui/builtinContextMenus/itemStats.py @@ -13,7 +13,7 @@ class ItemStats(ContextMenu): def getText(self, context, selection): return "%s stats" % context.capitalize() - def activate(self, context, selection): + def activate(self, context, selection, i): if context == "ship": fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() diff --git a/gui/contextMenu.py b/gui/contextMenu.py index 6acee712f..2ea737bb9 100755 --- a/gui/contextMenu.py +++ b/gui/contextMenu.py @@ -35,9 +35,14 @@ class ContextMenu(object): m = menuHandler() if m.display(context, selection): amount += 1 - id = wx.NewId() - item = wx.MenuItem(menu, id, m.getText(context, selection)) - cls.activeMenu[id] = (m, context, selection) + texts = m.getText(context, selection) + if isinstance(texts, basestring): + texts = (texts,) + + for i, text in enumerate(texts): + id = wx.NewId() + item = wx.MenuItem(menu, id, text) + cls.activeMenu[id] = (m, context, selection, i) menu.Bind(wx.EVT_MENU, cls.handler) bitmap = m.getBitmap(context, selection) @@ -53,14 +58,14 @@ class ContextMenu(object): @classmethod def handler(cls, event): - m, context, selection = cls.activeMenu[event.Id] + m, context, selection, i = cls.activeMenu[event.Id] cls.activeMenu.clear() - m.activate(context, selection) + m.activate(context, selection, i) def display(self, context, selection): raise NotImplementedError() - def activate(self, context, selection): + def activate(self, context, selection, i): raise NotImplementedError() def getText(self, context, selection): diff --git a/gui/fittingView.py b/gui/fittingView.py index 7f3e48843..8b94811a6 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -122,9 +122,9 @@ class FittingView(d.Display): if sel != -1: mod = self.mods[self.GetItemData(sel)] if not mod.isEmpty: - contexts.add("module") + contexts.append("module") if mod.charge is not None and "ammo" not in contexts: - contexts.add("ammo") + contexts.append("ammo") selection.append(mod) diff --git a/gui/itemStats.py b/gui/itemStats.py index e6c7f4acd..b8688044b 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -125,7 +125,6 @@ class ItemParams (wx.Panel): index = self.paramList.InsertStringItem(sys.maxint, name) self.paramList.SetStringItem(index, 1, str(attrs[name]) if stuff is not None else str(attrs[name].value)) - self.Layout() ###########################################################################