Wire up the ship browser menu item so it works too.
This commit is contained in:
@@ -40,9 +40,6 @@ class MainFrame(wx.Frame):
|
||||
self.SetMinSize((1000, 700))
|
||||
self.SetSize((1000, 700))
|
||||
|
||||
#Register menubar events / only quit for now
|
||||
self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT)
|
||||
self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT)
|
||||
|
||||
self.splitter = wx.SplitterWindow(self, style = wx.SP_LIVE_UPDATE)
|
||||
|
||||
@@ -77,6 +74,8 @@ class MainFrame(wx.Frame):
|
||||
self.SetMenuBar(MainMenuBar())
|
||||
self.SetToolBar(MainToolBar(self))
|
||||
|
||||
self.registerMenu()
|
||||
|
||||
#Show ourselves
|
||||
self.Show()
|
||||
|
||||
@@ -84,10 +83,26 @@ class MainFrame(wx.Frame):
|
||||
self.Close()
|
||||
|
||||
def ShowAboutBox(self, evt):
|
||||
info = wx.AboutDialogInfo()
|
||||
info.Name = "pyfa"
|
||||
info.Version = aboutData.versionString
|
||||
info.Description = wordwrap(aboutData.description + "\n\n\nDevelopers: " + ", ".join(aboutData.developers) + "\nLicense: " + aboutData.license + " see included " + aboutData.licenseLocation,
|
||||
350, wx.ClientDC(self))
|
||||
info.WebSite = ("http://pyfa.sourceforge.net/", "pyfa home page")
|
||||
wx.AboutBox(info)
|
||||
info = wx.AboutDialogInfo()
|
||||
info.Name = "pyfa"
|
||||
info.Version = aboutData.versionString
|
||||
info.Description = wordwrap(aboutData.description + "\n\n\nDevelopers: " + ", ".join(aboutData.developers) + "\nLicense: " + aboutData.license + " see included " + aboutData.licenseLocation,
|
||||
350, wx.ClientDC(self))
|
||||
info.WebSite = ("http://pyfa.sourceforge.net/", "pyfa home page")
|
||||
wx.AboutBox(info)
|
||||
|
||||
def registerMenu(self):
|
||||
# Quit
|
||||
self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT)
|
||||
|
||||
# About
|
||||
self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT)
|
||||
|
||||
#Ship browser
|
||||
self.Bind(wx.EVT_MENU, self.toggleShipBrowser, id=10)
|
||||
|
||||
def toggleShipBrowser(self, event):
|
||||
toolbar = self.GetToolBar()
|
||||
toolbar.ToggleTool(10, not toolbar.GetToolState(10))
|
||||
toolbar.toggleShipBrowser(event)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class MainMenuBar(wx.MenuBar):
|
||||
# Fit menu
|
||||
fitMenu = wx.Menu()
|
||||
self.Append(fitMenu, "F&it")
|
||||
shipBrowserItem = wx.MenuItem(fitMenu, wx.ID_ANY, "Ship &Browser")
|
||||
shipBrowserItem = wx.MenuItem(fitMenu, 10, "Toggle Ship &Browser")
|
||||
shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small", "icons"))
|
||||
fitMenu.AppendItem(shipBrowserItem)
|
||||
fitMenu.AppendSeparator()
|
||||
@@ -56,7 +56,7 @@ class MainMenuBar(wx.MenuBar):
|
||||
charMenu = wx.Menu()
|
||||
self.Append(charMenu, "&Character")
|
||||
|
||||
charEditItem = wx.MenuItem(charMenu, wx.ID_ANY, "Character &Editor")
|
||||
charEditItem = wx.MenuItem(charMenu, 20, "Character &Editor")
|
||||
charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small", "icons"))
|
||||
charMenu.AppendItem(charEditItem)
|
||||
|
||||
|
||||
@@ -29,19 +29,22 @@ class MainToolBar(wx.ToolBar):
|
||||
self.AddCheckLabelTool(10, "Ship Browser", bitmapLoader.getBitmap("ship_big", "icons"), shortHelp="Ship browser")
|
||||
self.AddCheckLabelTool(20, "Character Editor", bitmapLoader.getBitmap("character_big", "icons"), shortHelp="Character editor")
|
||||
|
||||
self.Bind(wx.EVT_TOOL, self.shipBrowserToggle, id=10)
|
||||
self.Bind(wx.EVT_TOOL, self.characterEditor, id=20)
|
||||
self.Bind(wx.EVT_TOOL, self.toggleShipBrowser, id=10)
|
||||
self.Bind(wx.EVT_TOOL, self.toggleCharacterBrowser, id=20)
|
||||
self.Realize()
|
||||
|
||||
gui.mainFrame.MainFrame.getInstance().shipBrowser.Hide()
|
||||
|
||||
def shipBrowserToggle(self, event):
|
||||
def toggleShipBrowser(self, event):
|
||||
newState = self.GetToolState(10)
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
if newState:
|
||||
mainFrame.shipBrowser.build()
|
||||
|
||||
mainFrame.shipBrowser.Show(newState)
|
||||
mainFrame.marketBrowser.Show(not newState)
|
||||
mainFrame.marketShipBrowserSizer.Layout()
|
||||
|
||||
def characterEditor(self, event):
|
||||
def toggleCharacterBrowser(self, event):
|
||||
print event
|
||||
|
||||
@@ -4,6 +4,7 @@ import bitmapLoader
|
||||
|
||||
class ShipBrowser(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
self.built = False
|
||||
wx.Panel.__init__(self, parent)
|
||||
vbox = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetSizer(vbox)
|
||||
@@ -16,16 +17,6 @@ class ShipBrowser(wx.Panel):
|
||||
|
||||
self.shipRoot = self.shipView.AddRoot("Ships")
|
||||
|
||||
iconId = self.shipImageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
|
||||
|
||||
cMarket = controller.Market.getInstance()
|
||||
shipRoot = cMarket.getShipRoot()
|
||||
for id, name in shipRoot:
|
||||
childId = self.shipView.AppendItem(self.shipRoot, name, iconId, data=wx.TreeItemData(id))
|
||||
self.shipView.AppendItem(childId, "dummy")
|
||||
|
||||
self.shipView.SortChildren(self.shipRoot)
|
||||
|
||||
self.raceImageIds = {}
|
||||
self.races = ["amarr", "caldari", "gallente", "minmatar", "ore", "serpentis", "angel", "blood", "sansha", "guristas"]
|
||||
for race in self.races:
|
||||
@@ -39,6 +30,17 @@ class ShipBrowser(wx.Panel):
|
||||
self.shipView.races = self.races
|
||||
self.shipView.idRaceMap = self.idRaceMap
|
||||
|
||||
def build(self):
|
||||
if not self.built:
|
||||
self.built = True
|
||||
cMarket = controller.Market.getInstance()
|
||||
shipRoot = cMarket.getShipRoot()
|
||||
iconId = self.shipImageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
|
||||
for id, name in shipRoot:
|
||||
childId = self.shipView.AppendItem(self.shipRoot, name, iconId, data=wx.TreeItemData(id))
|
||||
self.shipView.AppendItem(childId, "dummy")
|
||||
|
||||
self.shipView.SortChildren(self.shipRoot)
|
||||
def expandLookup(self, event):
|
||||
root = event.Item
|
||||
child, cookie = self.shipView.GetFirstChild(root)
|
||||
|
||||
Reference in New Issue
Block a user