From 6442c99038dacb2cf082cc8b291ebae10a2f78d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Aug 2010 14:42:41 +0300 Subject: [PATCH] small getStaticBitmap and getBitmap mod to accept a path --- gui/bitmapLoader.py | 8 ++++---- gui/mainMenuBar.py | 4 ++-- gui/mainToolBar.py | 4 ++-- gui/statsPane.py | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gui/bitmapLoader.py b/gui/bitmapLoader.py index 1ac3c25c5..7362313e5 100644 --- a/gui/bitmapLoader.py +++ b/gui/bitmapLoader.py @@ -21,11 +21,11 @@ import os.path import config import wx -def getStaticBitmap(name, parent): +def getStaticBitmap(name, parent, location): static = wx.StaticBitmap(parent) - static.SetBitmap(getBitmap(name)) + static.SetBitmap(getBitmap(name,location)) return static -def getBitmap(name): - path = os.path.join(config.path, "icons", name + ".png") +def getBitmap(name,location): + path = os.path.join(config.path, location, name + ".png") return wx.Image(path).ConvertToBitmap() diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index bc4b91859..761f9659f 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -41,7 +41,7 @@ class MainMenuBar(wx.MenuBar): fitMenu = wx.Menu() self.Append(fitMenu, "F&it") shipBrowserItem = wx.MenuItem(fitMenu, wx.ID_ANY, "Ship &Browser") - shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small")) + shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small", "icons")) fitMenu.AppendItem(shipBrowserItem) fitMenu.AppendSeparator() fitMenu.Append(wx.ID_EDIT, "&Rename", "Rename this fit.") @@ -57,7 +57,7 @@ class MainMenuBar(wx.MenuBar): self.Append(charMenu, "&Character") charEditItem = wx.MenuItem(charMenu, wx.ID_ANY, "Character &Editor") - charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small")) + charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small", "icons")) charMenu.AppendItem(charEditItem) # Help menu diff --git a/gui/mainToolBar.py b/gui/mainToolBar.py index 3d22db424..9182a91e7 100644 --- a/gui/mainToolBar.py +++ b/gui/mainToolBar.py @@ -24,7 +24,7 @@ class MainToolBar(wx.ToolBar): def __init__(self, parent): wx.ToolBar.__init__(self, parent, wx.ID_ANY) - self.AddCheckLabelTool(wx.ID_ANY, "Ship Browser", bitmapLoader.getBitmap("ship_big")) - self.AddLabelTool(wx.ID_ANY, "Character Editor", bitmapLoader.getBitmap("character_big")) + self.AddCheckLabelTool(wx.ID_ANY, "Ship Browser", bitmapLoader.getBitmap("ship_big", "icons")) + self.AddLabelTool(wx.ID_ANY, "Character Editor", bitmapLoader.getBitmap("character_big", "icons")) self.Realize() diff --git a/gui/statsPane.py b/gui/statsPane.py index 7ebc5c06d..9800c8e60 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -54,7 +54,7 @@ class StatsPane(wx.Panel): sizerResources.Add(sizerHardResources, 1, wx.ALIGN_CENTER) for type in ("turret", "launcher"): - sizerHardResources.Add(bitmapLoader.getStaticBitmap("%s_big" % type, self), 0, wx.ALIGN_CENTER) + sizerHardResources.Add(bitmapLoader.getStaticBitmap("%s_big" % type, self, "icons"), 0, wx.ALIGN_CENTER) box = wx.BoxSizer(wx.HORIZONTAL) sizerHardResources.Add(box, 0, wx.ALIGN_CENTER) @@ -71,7 +71,7 @@ class StatsPane(wx.Panel): # Calibration points - sizerHardResources.Add(bitmapLoader.getStaticBitmap("calibration_big", self)) + sizerHardResources.Add(bitmapLoader.getStaticBitmap("calibration_big", self, "icons")) box = wx.BoxSizer(wx.HORIZONTAL) sizerHardResources.Add(box, 0, wx.ALIGN_CENTER) @@ -96,7 +96,7 @@ class StatsPane(wx.Panel): base = wx.BoxSizer(wx.HORIZONTAL) main.Add(base, 0, wx.EXPAND) - base.Add(bitmapLoader.getStaticBitmap(type + "_big", self), 0, wx.ALIGN_CENTER) + base.Add(bitmapLoader.getStaticBitmap(type + "_big", self, "icons"), 0, wx.ALIGN_CENTER) stats = wx.BoxSizer(wx.VERTICAL) base.Add(stats, 0, wx.EXPAND) @@ -149,12 +149,12 @@ class StatsPane(wx.Panel): sizerResistances.Add(wx.StaticText(self, wx.ID_ANY)) for damageType in ("em", "thermal", "kinetic", "explosive"): - sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % damageType, self), 0, wx.ALIGN_CENTER) + sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % damageType, self, "icons"), 0, wx.ALIGN_CENTER) sizerResistances.Add(wx.StaticText(self, wx.ID_ANY, "EHP"), 0, wx.ALIGN_CENTER) for tankType in ("damagePattern", "shield", "armor", "hull"): - sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self), 0, wx.ALIGN_CENTER) + sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self, "icons"), 0, wx.ALIGN_CENTER) for damageType in ("em", "thermal", "kinetic", "explosive"): box = wx.BoxSizer(wx.HORIZONTAL) @@ -192,10 +192,10 @@ class StatsPane(wx.Panel): #Add an empty label first for correct alignment. sizerTankStats.Add(wx.StaticText(self, wx.ID_ANY, ""), 0) for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"): - sizerTankStats.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self), 1, wx.ALIGN_CENTER) + sizerTankStats.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self, "icons"), 1, wx.ALIGN_CENTER) for stability in ("reinforced", "sustained"): - sizerTankStats.Add(bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), self), 0, wx.ALIGN_CENTER) + sizerTankStats.Add(bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), self, "icons"), 0, wx.ALIGN_CENTER) for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"): tankTypeCap = tankType[0].capitalize() + tankType[1:] lbl = wx.StaticText(self, wx.ID_ANY, "0.0") @@ -228,7 +228,7 @@ class StatsPane(wx.Panel): sizerFirepower.Add(baseBox, 0, wx.ALIGN_CENTER) image = "droneBay" if damageType == "drone" else damageType - baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, self), 0, wx.ALIGN_CENTER) + baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, self, "icons"), 0, wx.ALIGN_CENTER) box = wx.BoxSizer(wx.VERTICAL) baseBox.Add(box, 0, wx.ALIGN_CENTER) @@ -247,7 +247,7 @@ class StatsPane(wx.Panel): baseBox = wx.BoxSizer(wx.HORIZONTAL) sizerFirepower.Add(baseBox, 0, wx.ALIGN_CENTER) - baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", self), 0, wx.ALIGN_CENTER) + baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", self, "icons"), 0, wx.ALIGN_CENTER) box = wx.BoxSizer(wx.VERTICAL) baseBox.Add(box, 1, wx.ALIGN_CENTER) @@ -283,7 +283,7 @@ class StatsPane(wx.Panel): baseBox = wx.BoxSizer(wx.HORIZONTAL) sizerCapacitor.Add(baseBox, 1, wx.ALIGN_CENTER) - baseBox.Add(bitmapLoader.getStaticBitmap("capacitorInfo_big", self), 0, wx.ALIGN_CENTER) + baseBox.Add(bitmapLoader.getStaticBitmap("capacitorInfo_big", self, "icons"), 0, wx.ALIGN_CENTER) box = wx.BoxSizer(wx.VERTICAL) baseBox.Add(box, 0, wx.ALIGN_CENTER) @@ -307,7 +307,7 @@ class StatsPane(wx.Panel): baseBox = wx.BoxSizer(wx.HORIZONTAL) sizerCapacitor.Add(baseBox, 1, wx.ALIGN_CENTER) - baseBox.Add(bitmapLoader.getStaticBitmap("capacitorRecharge_big", self), 0, wx.ALIGN_CENTER) + baseBox.Add(bitmapLoader.getStaticBitmap("capacitorRecharge_big", self, "icons"), 0, wx.ALIGN_CENTER) box = wx.BoxSizer(wx.VERTICAL) baseBox.Add(box, 0, wx.ALIGN_CENTER) @@ -423,7 +423,7 @@ class StatsPane(wx.Panel): box = wx.BoxSizer(wx.HORIZONTAL) gridPrice.Add(box) - box.Add(bitmapLoader.getStaticBitmap(image, self), 0, wx.ALIGN_CENTER) + box.Add(bitmapLoader.getStaticBitmap(image, self, "icons"), 0, wx.ALIGN_CENTER) vbox = wx.BoxSizer(wx.VERTICAL) box.Add(vbox, 1, wx.EXPAND)