Esempio n. 1
0
def GetPaperDollResource(typeID, gender=None):
    assets = filter(lambda a: a.typeID == typeID, cfg.paperdollResources)
    if len(assets) == 0:
        log.LogWarn(
            'PreviewWnd::PreviewType - No asset matched the typeID {}'.format(
                typeID))
        return None
    default_asset = first(assets)
    unisex_asset = first_or_default(assets, lambda a: a.resGender is None,
                                    default_asset)
    return first_or_default(assets, lambda a: a.resGender == gender,
                            unisex_asset)
 def __init__(self, keyName):
     if isinstance(keyName, int):
         index = keyName
         namesToIndices = soundNotifications.get('NameToIndices')
         keyName = itertoolsext.first([ k for k, v in namesToIndices.items() if v == index ])
     notification = soundNotifications.get(keyName)
     self.activeFlagSettingsName = keyName + 'NotificationEnabled'
     self.healthThresholdSettingsName = keyName + 'Threshold'
     self.defaultThreshold = notification.get('defaultThreshold')
     self.notificationEventName = notification.get('soundEventName')
     self.localizationLabel = notification.get('localizationLabel')
     self.defaultStatus = notification.get('defaultStatus')
     self.hasBeenNotified = False
     self.name = keyName
Esempio n. 3
0
 def __init__(self, keyName):
     if isinstance(keyName, int):
         index = keyName
         namesToIndices = soundNotifications.get('NameToIndices')
         keyName = itertoolsext.first([ k for k, v in namesToIndices.items() if v == index ])
     notification = soundNotifications.get(keyName)
     self.activeFlagSettingsName = keyName + 'NotificationEnabled'
     self.healthThresholdSettingsName = keyName + 'Threshold'
     self.defaultThreshold = notification.get('defaultThreshold')
     self.notificationEventName = notification.get('soundEventName')
     self.localizationLabel = notification.get('localizationLabel')
     self.defaultStatus = notification.get('defaultStatus')
     self.hasBeenNotified = False
     self.name = keyName
Esempio n. 4
0
 def OnDropData(self, dragObj, nodes):
     super(PreviewWnd, self).OnDropData(dragObj, nodes)
     node = first(nodes)
     typeID = None
     if hasattr(node, 'item') and hasattr(node.item, 'typeID'):
         typeID = node.item.typeID
     elif hasattr(node, 'typeID'):
         typeID = node.typeID
     itemID = None
     if hasattr(node, 'item') and hasattr(node.item, 'itemID'):
         itemID = node.item.itemID
     elif hasattr(node, 'itemID'):
         itemID = node.itemID
     if typeID:
         self.PreviewType(typeID, itemID=itemID)
Esempio n. 5
0
def GetPaperDollResource(typeID, gender=None):
    """
    Returns the paper doll resource for the given typeID and gender.
    
    If there's at least one resource available for this type then a resource
    will always be returned with the following priority order:
     - Resource with the requested gender
     - Resource marked as unisex (gender == None)
     - The first resource in the list of resources
    
    Returns None if no resource could be found for this type.
    """
    assets = filter(lambda a: a.typeID == typeID, cfg.paperdollResources)
    if len(assets) == 0:
        log.LogWarn(
            'PreviewWnd::PreviewType - No asset matched the typeID {}'.format(
                typeID))
        return None
    default_asset = first(assets)
    unisex_asset = first_or_default(assets, lambda a: a.resGender is None,
                                    default_asset)
    return first_or_default(assets, lambda a: a.resGender == gender,
                            unisex_asset)
Esempio n. 6
0
 def testAll(self):
     self.assertEqual(1, it.first([1, 2, 3]))
     self.assertEqual(3, it.first((1, 2, 3), lambda x: x > 2))
     self.assertRaises(StopIteration, it.first, [])