all set images except base; simplify offset code for heights in tabs
141
dominion_tabs.py
@ -27,6 +27,9 @@ class Card:
|
|||||||
self.description = description
|
self.description = description
|
||||||
self.extra = ""
|
self.extra = ""
|
||||||
|
|
||||||
|
def getType(self):
|
||||||
|
return DominionTabs.cardTypes[self.types]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '"' + self.name + '"'
|
return '"' + self.name + '"'
|
||||||
|
|
||||||
@ -34,10 +37,11 @@ class Card:
|
|||||||
return self.name + ' ' + self.cardset + ' ' + '-'.join(self.types) + ' ' + `self.cost` + ' ' + self.description + ' ' + self.extra
|
return self.name + ' ' + self.cardset + ' ' + '-'.join(self.types) + ' ' + `self.cost` + ' ' + self.description + ' ' + self.extra
|
||||||
|
|
||||||
class CardType:
|
class CardType:
|
||||||
def __init__(self, typeNames, tabImageFile, contentHeightOffset):
|
def __init__(self, typeNames, tabImageFile, tabTextHeightOffset=0, tabCostHeightOffset=-1):
|
||||||
self.typeNames = typeNames
|
self.typeNames = typeNames
|
||||||
self.tabImageFile = tabImageFile
|
self.tabImageFile = tabImageFile
|
||||||
self.contentHeightOffset = contentHeightOffset
|
self.tabTextHeightOffset = tabTextHeightOffset
|
||||||
|
self.tabCostHeightOffset = tabCostHeightOffset
|
||||||
|
|
||||||
def getTypeNames(self):
|
def getTypeNames(self):
|
||||||
return self.typeNames
|
return self.typeNames
|
||||||
@ -48,68 +52,56 @@ class CardType:
|
|||||||
def getNoCoinTabImageFile(self):
|
def getNoCoinTabImageFile(self):
|
||||||
return ''.join(os.path.splitext(self.tabImageFile)[0] + '_nc' + os.path.splitext(self.tabImageFile)[1])
|
return ''.join(os.path.splitext(self.tabImageFile)[0] + '_nc' + os.path.splitext(self.tabImageFile)[1])
|
||||||
|
|
||||||
def getTabContentHeightOffset(self):
|
def getTabTextHeightOffset(self):
|
||||||
return self.contentHeightOffset
|
return self.tabTextHeightOffset
|
||||||
|
|
||||||
|
def getTabCostHeightOffset(self):
|
||||||
|
return self.tabCostHeightOffset
|
||||||
|
|
||||||
class DominionTabs:
|
class DominionTabs:
|
||||||
cardTypes = [
|
cardTypes = [
|
||||||
CardType(('Action',), 'action.png', 0),
|
CardType(('Action',), 'action.png'),
|
||||||
CardType(('Action','Attack'), 'action.png', 0),
|
CardType(('Action','Attack'), 'action.png'),
|
||||||
CardType(('Action','Attack','Prize'), 'action.png', 0),
|
CardType(('Action','Attack','Prize'), 'action.png'),
|
||||||
CardType(('Action','Reaction'), 'reaction.png', 0),
|
CardType(('Action','Reaction'), 'reaction.png'),
|
||||||
CardType(('Action','Victory'), 'action-victory.png', 0),
|
CardType(('Action','Victory'), 'action-victory.png'),
|
||||||
CardType(('Action','Duration'), 'duration.png', 0),
|
CardType(('Action','Duration'), 'duration.png'),
|
||||||
CardType(('Action','Looter'), 'action.png', 0),
|
CardType(('Action','Looter'), 'action.png'),
|
||||||
CardType(('Action','Prize'), 'action.png', 0),
|
CardType(('Action','Prize'), 'action.png'),
|
||||||
CardType(('Action','Ruins'), 'ruins.png', 0),
|
CardType(('Action','Ruins'), 'ruins.png', 0, 1),
|
||||||
CardType(('Action','Shelter'), 'shelter.png', 0),
|
CardType(('Action','Shelter'), 'shelter.png', 0, 1),
|
||||||
CardType(('Action','Attack','Looter'), 'action.png', 0),
|
CardType(('Action','Attack','Looter'), 'action.png'),
|
||||||
CardType(('Reaction',), 'reaction.png', 0),
|
CardType(('Reaction',), 'reaction.png'),
|
||||||
CardType(('Reaction','Shelter'), 'Shelter.png', 0),
|
CardType(('Reaction','Shelter'), 'Shelter.png', 0, 1),
|
||||||
CardType(('Treasure',), 'treasure.png', 0),
|
CardType(('Treasure',), 'treasure.png',3,0),
|
||||||
CardType(('Treasure','Victory'), 'treasure-victory.png', 0),
|
CardType(('Treasure','Victory'), 'treasure-victory.png'),
|
||||||
CardType(('Treasure','Prize'), 'treasure.png', 0),
|
CardType(('Treasure','Prize'), 'treasure.png',3,0),
|
||||||
CardType(('Treasure','Reaction'), 'treasure-reaction.png', 0),
|
CardType(('Treasure','Reaction'), 'treasure-reaction.png', 0, 1),
|
||||||
CardType(('Victory',), 'victory.png', 0),
|
CardType(('Victory',), 'victory.png'),
|
||||||
CardType(('Victory','Reaction'), 'victory-reaction.png', 0),
|
CardType(('Victory','Reaction'), 'victory-reaction.png', 0, 1),
|
||||||
CardType(('Victory','Shelter'), 'shelter.png', 0),
|
CardType(('Victory','Shelter'), 'shelter.png', 0, 1),
|
||||||
CardType(('Curse',), 'curse.png', 0),
|
CardType(('Curse',), 'curse.png',3),
|
||||||
]
|
]
|
||||||
|
|
||||||
cardTypes = dict(((c.getTypeNames(),c) for c in cardTypes))
|
cardTypes = dict(((c.getTypeNames(),c) for c in cardTypes))
|
||||||
|
|
||||||
labelImages = {
|
|
||||||
('Action',) : 'action.png',
|
|
||||||
('Action','Attack') : 'action.png',
|
|
||||||
('Action','Attack','Prize') : 'action.png',
|
|
||||||
('Action','Reaction') : 'reaction.png',
|
|
||||||
('Action','Victory') : 'action-victory.png',
|
|
||||||
('Action','Duration') : 'duration.png',
|
|
||||||
('Action','Looter') : 'action.png',
|
|
||||||
('Action','Prize') : 'action.png',
|
|
||||||
('Action','Ruins') : 'ruins.png',
|
|
||||||
('Action','Shelter') : 'shelter.png',
|
|
||||||
('Action','Attack','Looter') : 'action.png',
|
|
||||||
('Reaction',) : 'reaction.png',
|
|
||||||
('Reaction','Shelter') : 'Shelter.png',
|
|
||||||
('Treasure',) : 'treasure.png',
|
|
||||||
('Treasure','Victory') : 'treasure-victory.png',
|
|
||||||
('Treasure','Prize') : 'treasure.png',
|
|
||||||
('Treasure','Reaction') : 'treasure-reaction.png',
|
|
||||||
('Victory',) : 'victory.png',
|
|
||||||
('Victory','Reaction') : 'victory-reaction.png',
|
|
||||||
('Victory','Shelter') : 'shelter.png',
|
|
||||||
('Curse',) : 'curse.png'
|
|
||||||
}
|
|
||||||
|
|
||||||
noCoinLabelImages = dict(((name,''.join((os.path.splitext(fname)[0]+'_nc',os.path.splitext(fname)[1]))) for name,fname in labelImages.iteritems()))
|
|
||||||
|
|
||||||
setImages = {
|
setImages = {
|
||||||
'base' : 'base_set.png',
|
'base' : 'base_set.png',
|
||||||
'intrigue' : 'intrigue_set.png',
|
'intrigue' : 'intrigue_set.png',
|
||||||
'seaside' : 'seaside_set.png',
|
'seaside' : 'seaside_set.png',
|
||||||
'prosperity' : 'prosperity_set.png',
|
'prosperity' : 'prosperity_set.png',
|
||||||
'alchemy' : 'alchemy_set.png',
|
'alchemy' : 'alchemy_set.png',
|
||||||
|
'cornucopia' : 'cornucopia_set.png',
|
||||||
|
'hinterlands' : 'hinterlands_set.png',
|
||||||
|
'dark ages' : 'dark_ages_set.png',
|
||||||
|
'dark ages extras' : 'dark_ages_set.png',
|
||||||
|
}
|
||||||
|
promoImages = {
|
||||||
|
'walled village' : 'walled_village_set.png',
|
||||||
|
'stash' : 'stash_set.png',
|
||||||
|
'governor' : 'governor_set.png',
|
||||||
|
'black market' : 'black_market_set.png',
|
||||||
|
'envoy' : 'envoy_set.png'
|
||||||
}
|
}
|
||||||
|
|
||||||
def add_inline_images(self, text, fontsize):
|
def add_inline_images(self, text, fontsize):
|
||||||
@ -181,26 +173,33 @@ class DominionTabs:
|
|||||||
self.tabTotalHeight-self.tabLabelHeight)
|
self.tabTotalHeight-self.tabLabelHeight)
|
||||||
else:
|
else:
|
||||||
self.canvas.translate(0,self.tabTotalHeight-self.tabLabelHeight)
|
self.canvas.translate(0,self.tabTotalHeight-self.tabLabelHeight)
|
||||||
self.canvas.drawImage(os.path.join('images',DominionTabs.noCoinLabelImages[card.types]),1,0,
|
self.canvas.drawImage(os.path.join('images',card.getType().getNoCoinTabImageFile()),1,0,
|
||||||
self.tabLabelWidth-2,self.tabLabelHeight-1,
|
self.tabLabelWidth-2,self.tabLabelHeight-1,
|
||||||
preserveAspectRatio=False,anchor='n',mask='auto')
|
preserveAspectRatio=False,anchor='n',mask='auto')
|
||||||
if card.types[0] == 'Treasure' and (len(card.types) == 1 or card.types[1] != 'Reaction'
|
|
||||||
and card.types[1] != 'Victory')\
|
|
||||||
or card.types == ('Curse',):
|
textHeight = self.tabLabelHeight/2-7+card.getType().getTabTextHeightOffset()
|
||||||
textHeight = self.tabLabelHeight/2-4
|
costHeight = textHeight + card.getType().getTabCostHeightOffset()
|
||||||
costHeight = textHeight
|
potHeight = 3 + card.getType().getTabTextHeightOffset()
|
||||||
potSize = 12
|
|
||||||
potHeight = 5
|
|
||||||
else:
|
|
||||||
textHeight = self.tabLabelHeight/2-7
|
|
||||||
costHeight = textHeight-1
|
|
||||||
if card.types == ('Victory','Reaction') or\
|
|
||||||
card.types == ('Treasure','Reaction') or\
|
|
||||||
card.types == ('Action','Ruins') or\
|
|
||||||
len(card.types) > 1 and card.types[1].lower() == 'shelter':
|
|
||||||
costHeight = textHeight+1
|
|
||||||
potSize = 11
|
potSize = 11
|
||||||
potHeight = 2
|
|
||||||
|
# if card.types[0] == 'Treasure' and (len(card.types) == 1 or card.types[1] != 'Reaction'
|
||||||
|
# and card.types[1] != 'Victory')\
|
||||||
|
# or card.types == ('Curse',):
|
||||||
|
# textHeight = self.tabLabelHeight/2-4
|
||||||
|
# costHeight = textHeight
|
||||||
|
# potSize = 12
|
||||||
|
# potHeight = 5
|
||||||
|
# else:
|
||||||
|
# textHeight = self.tabLabelHeight/2-7
|
||||||
|
# costHeight = textHeight-1
|
||||||
|
# if card.types == ('Victory','Reaction') or\
|
||||||
|
# card.types == ('Treasure','Reaction') or\
|
||||||
|
# card.types == ('Action','Ruins') or\
|
||||||
|
# len(card.types) > 1 and card.types[1].lower() == 'shelter':
|
||||||
|
# costHeight = textHeight+1
|
||||||
|
# potSize = 11
|
||||||
|
# potHeight = 2
|
||||||
|
|
||||||
self.canvas.drawImage("images/coin_small.png",4,costHeight-5,16,16,preserveAspectRatio=True,mask='auto')
|
self.canvas.drawImage("images/coin_small.png",4,costHeight-5,16,16,preserveAspectRatio=True,mask='auto')
|
||||||
textInset = 22
|
textInset = 22
|
||||||
@ -213,11 +212,15 @@ class DominionTabs:
|
|||||||
|
|
||||||
#set image
|
#set image
|
||||||
setImage = DominionTabs.setImages.get(card.cardset, None)
|
setImage = DominionTabs.setImages.get(card.cardset, None)
|
||||||
|
if not setImage:
|
||||||
|
setImage = DominionTabs.promoImages.get(card.name.lower(), None)
|
||||||
|
|
||||||
if setImage:
|
if setImage:
|
||||||
self.canvas.drawImage(os.path.join('images',setImage), self.tabLabelWidth-20, potHeight, 14, 12, mask='auto')
|
self.canvas.drawImage(os.path.join('images',setImage), self.tabLabelWidth-20, potHeight, 14, 12, mask='auto')
|
||||||
elif setImage == None:
|
elif setImage == None:
|
||||||
print 'warning, no image for set',card.cardset
|
print 'warning, no set image for set "%s" card "%s"' % (card.cardset, card.name)
|
||||||
DominionTabs.setImages[card.cardset] = 0
|
DominionTabs.setImages[card.cardset] = 0
|
||||||
|
DominionTabs.promoImages[card.name.lower()] = 0
|
||||||
|
|
||||||
self.canvas.setFont('MinionPro-Bold',12)
|
self.canvas.setFont('MinionPro-Bold',12)
|
||||||
cost = str(card.cost)
|
cost = str(card.cost)
|
||||||
|
|||||||
BIN
images/black_market_set.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
images/cornucopia_set.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
images/dark_ages_set.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
images/envoy_set.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
images/governor_set.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
images/hinterlands_set.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
images/stash_set.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
images/walled_village_set.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |