diff --git a/gui/builtinContextMenus/itemStats.py b/gui/builtinContextMenus/itemStats.py index c8ccfc9be..dec776289 100644 --- a/gui/builtinContextMenus/itemStats.py +++ b/gui/builtinContextMenus/itemStats.py @@ -9,7 +9,7 @@ class ItemStats(ContextMenu): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, srcContext, selection): - return srcContext in ("marketItemGroup", "marketItemMisc", "fittingModule", "fittingCharge", "fittingShip", + return srcContext in ("marketItemGroup", "marketItemMisc", "fittingModule", "fittingCharge", "fittingShip", "baseShip", "droneItem", "implantItem", "boosterItem", "skillItem", "projectedModule", "projectedDrone", "projectedCharge") def getText(self, itmContext, selection): diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 3d262f54a..7b641eaf4 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -13,9 +13,9 @@ import gui.utils.colorUtils as colorUtils import gui.utils.drawUtils as drawUtils import gui.utils.animUtils as animUtils import gui.utils.animEffects as animEffects -import gui.utils.textFormatting as textFormatting import gui.sfBrowserItem as SFItem +from gui.contextMenu import ContextMenu import service @@ -1017,19 +1017,10 @@ class ShipItem(SFItem.SFBrowserItem): self.animPeriod = 10 self.animDuration = 100 - self.popupMenu = wx.Menu() - self.popupMenuItems = ["Ship stats"] - - for item in self.popupMenuItems: - menuItem = self.popupMenu.Append(-1, item) - self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, menuItem) - self.Bind(wx.EVT_CONTEXT_MENU, self.OnShowPopup) self.marketInstance = service.Market.getInstance() self.baseItem = self.marketInstance.getItem(self.shipID) - self.shipDescription = textFormatting.wrap(self.baseItem.description, 80) - self.SetToolTip(wx.ToolTip(self.shipDescription)) #=======================================================================\ # DISABLED - it will be added as an option in PREFERENCES @@ -1043,16 +1034,14 @@ class ShipItem(SFItem.SFBrowserItem): # self.animCount = 0 #======================================================================= - def OnPopupItemSelected(self, event): - item = self.popupMenu.FindItemById(event.GetId()) - itemText = item.GetText() - if itemText == self.popupMenuItems [0]: - print "Menu:", itemText def OnShowPopup(self, event): pos = event.GetPosition() pos = self.ScreenToClient(pos) - self.PopupMenu(self.popupMenu, pos) + contexts = [] + contexts.append(("baseShip", "Ship Basic")) + menu = ContextMenu.getMenu(self.baseItem, *contexts) + self.PopupMenu(menu, pos) def OnTimer(self, event): step = self.OUT_QUAD(self.animStep, 0, 10, self.animDuration) diff --git a/gui/utils/textFormatting.py b/gui/utils/textFormatting.py deleted file mode 100644 index 91a14dfed..000000000 --- a/gui/utils/textFormatting.py +++ /dev/null @@ -1,14 +0,0 @@ -def wrap(text, width): - """ - A word-wrap function that preserves existing line breaks - and most spaces in the text. Expects that existing line - breaks are posix newlines (\n). - """ - return reduce(lambda line, word, width=width: '%s%s%s' % - (line, - ' \n'[(len(line)-line.rfind('\n')-1 - + len(word.split('\n',1)[0] - ) >= width)], - word), - text.split(' ') - ) \ No newline at end of file