Merge branch 'master' of git://github.com/splatteredbits/dominiontabs into splatteredbits-master

This commit is contained in:
Sumpfork 2015-06-08 10:19:57 -07:00
commit d9134b3227

85
dominion_tabs.py Normal file → Executable file
View File

@ -58,6 +58,14 @@ class Card:
DominionTabs.promoImages[self.name.lower()] = 0
return setImage
def setTextIcon(self):
setTextIcon = DominionTabs.getSetText(self.cardset, self.name)
if setTextIcon is None and self.cardset not in ['base', 'extra'] and not self.isExpansion():
print 'warning, no set text for set "%s" card "%s"' % (self.cardset, self.name)
DominionTabs.setTextIcons[self.cardset] = 0
DominionTabs.promoTextIcons[self.name.lower()] = 0
return setTextIcon
def isBlank(self):
return False
@ -171,6 +179,31 @@ class DominionTabs:
'prince': 'prince_set.png'
}
setTextIcons = {
'dominion': 'D',
'intrigue': 'I',
'seaside': 'S',
'prosperity': 'P',
'alchemy': 'A',
'cornucopia': 'C',
'cornucopia extras': 'C',
'hinterlands': 'H',
'dark ages': 'DA',
'dark ages extras': 'DA',
'guilds': 'G',
'adventures': 'Ad',
'adventures extras': 'Ad'
}
promoTextIcons = {
'walled village': '',
'stash': '',
'governor': '',
'black market': '',
'envoy': '',
'prince': ''
}
@classmethod
def getSetImage(cls, setName, cardName):
if setName in cls.setImages:
@ -187,6 +220,14 @@ class DominionTabs:
return cls.promoImages[trans.lower()]
return None
@classmethod
def getSetText(cls, setName, cardName):
if setName in cls.setTextIcons:
return cls.setTextIcons[setName]
if cardName.lower() in cls.promoTextIcons:
return cls.promoTextIcons[cardName.lower()]
return None
def __init__(self):
self.filedir = os.path.dirname(__file__)
self.odd = True
@ -325,12 +366,15 @@ class DominionTabs:
# allow for 3 pt border on each side
textWidth = self.tabLabelWidth - 6
textHeight = self.tabLabelHeight / 2 - 7 + \
textHeight = 7
if self.options.no_tab_artwork:
textHeight = 4
textHeight = self.tabLabelHeight / 2 - textHeight + \
card.getType().getTabTextHeightOffset()
# draw banner
img = card.getType().getNoCoinTabImageFile()
if img:
if not self.options.no_tab_artwork and img:
self.canvas.drawImage(os.path.join(self.filedir, 'images', img), 1, 0,
self.tabLabelWidth -
2, self.tabLabelHeight - 1,
@ -348,16 +392,28 @@ class DominionTabs:
textInset = 13
# draw set image
setImage = card.setImage()
if setImage and 'tab' in self.options.set_icon:
setImageHeight = 3 + card.getType().getTabTextHeightOffset()
self.drawSetIcon(setImage, self.tabLabelWidth - 20,
setImageHeight)
textInsetRight = 20
else:
# always need to offset from right edge, to make sure it stays on
# banner
textInsetRight = 6
if self.options.use_text_set_icon:
setImageHeight = card.getType().getTabTextHeightOffset()
#self.canvas.rect(self.tabLabelWidth - 20, setImageHeight, 20, 20, 1 )
setText = card.setTextIcon()
self.canvas.setFont('MinionPro-Oblique', 8)
if setText is None:
setText = ""
self.canvas.drawCentredString( self.tabLabelWidth - 10, textHeight + 2, setText)
textInsetRight = 15
else:
setImage = card.setImage()
if setImage and 'tab' in self.options.set_icon:
setImageHeight = 3 + card.getType().getTabTextHeightOffset()
self.drawSetIcon(setImage, self.tabLabelWidth - 20,
setImageHeight)
textInsetRight = 20
# draw name
fontSize = 12
@ -443,6 +499,9 @@ class DominionTabs:
if drewTopIcon:
usedHeight += 15
if self.options.no_card_rules:
return
# draw text
if useExtra and card.extra:
descriptions = (card.extra,)
@ -792,6 +851,12 @@ class DominionTabs:
default=False, help="exclude individual dividers for events")
parser.add_option("--cardlist", type="string", dest="cardlist", default=None,
help="Path to file that enumerates each card to be printed on its own line.")
parser.add_option("--no-tab-artwork", action="store_true", dest="no_tab_artwork",
help="don't show background artwork on tabs")
parser.add_option("--no-card-rules", action="store_true", dest="no_card_rules",
help="don't print the card's rules on the tab body")
parser.add_option("--use-text-set-icon", action="store_true", dest="use_text_set_icon",
help="use text/letters to represent a card's set instead of the set icon")
options, args = parser.parse_args(argstring)
if not options.cost:
@ -965,6 +1030,8 @@ class DominionTabs:
TTFont('MinionPro-Regular', os.path.join(dirn, 'MinionPro-Regular.ttf')))
pdfmetrics.registerFont(
TTFont('MinionPro-Bold', os.path.join(dirn, 'MinionPro-Bold.ttf')))
pdfmetrics.registerFont(
TTFont('MinionPro-Oblique', os.path.join(dirn, 'MinionPro-It.ttf')))
except:
raise
pdfmetrics.registerFont(