Merge branch 'master' into attrGroup

# Conflicts:
#	eve.db
#	gui/bitmap_loader.py
This commit is contained in:
blitzmann
2018-10-27 15:13:54 -04:00
17 changed files with 79 additions and 14 deletions

View File

@@ -85,14 +85,12 @@ class BitmapLoader(object):
cls.scaling_factor = int(wx.GetApp().GetTopWindow().GetContentScaleFactor())
scale = cls.scaling_factor
filenameScaled = "{0}@{1}x.png".format(name, scale)
img = cls.loadImage(filenameScaled, location)
filename, img = cls.loadScaledBitmap(name, location, scale)
if img is None:
# can't find the scaled image, fallback to no scaling
filename = "{0}.png".format(name)
img = cls.loadImage(filename, location)
scale = 1
while img is None and scale > 0:
# can't find the correctly scaled image, fallback to smaller scales
scale -= 1
filename, img = cls.loadScaledBitmap(name, location, scale)
if img is None:
print(("Missing icon file: {0}/{1}".format(location, filename)))
@@ -100,9 +98,26 @@ class BitmapLoader(object):
bmp: wx.Bitmap = img.ConvertToBitmap()
if scale > 1:
bmp.SetSize((int(bmp.GetWidth()/scale), int(bmp.GetHeight()/scale)))
bmp.SetSize((bmp.GetWidth() // scale, bmp.GetHeight() // scale))
return bmp
@classmethod
def loadScaledBitmap(cls, name, location, scale=0):
"""Attempts to load a scaled bitmap.
Args:
name (str): TypeID or basename of the image being requested.
location (str): Path to a location that may contain the image.
scale (int): Scale factor of the image variant to load. If ``0``, attempts to load the unscaled variant.
Returns:
(str, wx.Image): Tuple of the filename that may have been loaded and the image at that location. The
filename will always be present, but the image may be ``None``.
"""
filename = "{0}@{1}x.png".format(name, scale) if scale > 0 else "{0}.png".format(name)
img = cls.loadImage(filename, location)
return filename, img
@classmethod
def loadImage(cls, filename, location):
if cls.archive: