Exemplo n.º 1
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)

        self.mask = wx.LIST_MASK_IMAGE

        Attribute.getInstance().getAttributeInfo("capacitorNeed")
        self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui")
        self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui")
Exemplo n.º 2
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)
        if params is None:
            params = {"showIcon": True, "displayName": False}

        self.mask = wx.LIST_MASK_IMAGE

        Attribute.getInstance().getAttributeInfo("capacitorNeed")
        if params["showIcon"]:
            self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui")
            self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui")
        else:
            self.imageId = -1
        self.columnText = "Cap"
Exemplo n.º 3
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)
        sAttr = Attribute.getInstance()
        attributeSlave = params["attributeSlave"] or params["property"]
        # This function can throw an exception if the database isn't sane
        # We need to do a sanity check before this runs
        info = sAttr.getAttributeInfo(attributeSlave)

        self.mask = 0
        self.propertyName = params["property"]
        self.info = info
        if params["showIcon"]:
            if info.name == "power":
                iconFile = "pg_small"
                iconType = "gui"
            else:
                iconFile = info.icon.iconFile if info.icon else None
                iconType = "icons"
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
            else:
                self.imageId = -1

            self.mask = wx.LIST_MASK_IMAGE
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
Exemplo n.º 4
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)
        sAttr = Attribute.getInstance()
        attributeSlave = params["attributeSlave"] or params["property"]
        # This function can throw an exception if the database isn't sane
        # We need to do a sanity check before this runs
        info = sAttr.getAttributeInfo(attributeSlave)

        self.mask = 0
        self.propertyName = params["property"]
        self.info = info
        if params["showIcon"]:
            if info.name == "power":
                iconFile = "pg_small"
                iconType = "gui"
            else:
                iconFile = info.icon.iconFile if info.icon else None
                iconType = "icons"
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
            else:
                self.imageId = -1
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
Exemplo n.º 5
0
    def getIcons(self):
        icons = {}
        sAttr = Attribute.getInstance()
        for key, attrName in self.propertyAttributeMap.iteritems():
            iconFile = sAttr.getAttributeInfo(attrName).icon.iconFile
            bitmap = BitmapLoader.getBitmap(iconFile, "icons")
            if bitmap:
                icons[key] = bitmap

        return icons
Exemplo n.º 6
0
    def getIcons(self):
        icons = {}
        sAttr = Attribute.getInstance()
        for key, attrName in self.propertyAttributeMap.items():
            iconFile = sAttr.getAttributeInfo(attrName).iconID
            bitmap = BitmapLoader.getBitmap(iconFile, "icons")
            if bitmap:
                icons[key] = bitmap

        return icons
Exemplo n.º 7
0
    def refresh(self, items):
        if len(items) > 1:
            # Get dictionary with meta level attribute
            sAttr = Attribute.getInstance()
            attrs = sAttr.getAttributeInfo("metaLevel")
            sMkt = self.sMkt
            self.metalvls = sMkt.directAttrRequest(items, attrs)
            # Re-sort stuff
            items.sort(key=self.itemSort)

        for i, item in enumerate(items[:9]):
            # set shortcut info for first 9 modules
            item.marketShortcut = i + 1

        Display.refresh(self, items)
Exemplo n.º 8
0
    def refresh(self, items):
        if len(items) > 1:
            # Get dictionary with meta level attribute
            sAttr = Attribute.getInstance()
            attrs = sAttr.getAttributeInfo("metaLevel")
            sMkt = self.sMkt
            self.metalvls = sMkt.directAttrRequest(items, attrs)
            # Re-sort stuff
            items.sort(key=self.itemSort)

        for i, item in enumerate(items[:9]):
            # set shortcut info for first 9 modules
            item.marketShortcut = i + 1

        Display.refresh(self, items)
Exemplo n.º 9
0
 def populate(self, items):
     if len(items) > 0:
         # Get dictionary with meta level attribute
         sAttr = Attribute.getInstance()
         attrs = sAttr.getAttributeInfo("metaLevel")
         sMkt = self.sMkt
         self.metalvls = sMkt.directAttrRequest(items, attrs)
         # Clear selection
         self.unselectAll()
         # Perform sorting, using item's meta levels besides other stuff
         items.sort(key=self.itemSort)
     # Mark current item list as active
     self.active = items
     # Show them
     Display.populate(self, items)
Exemplo n.º 10
0
 def populate(self, items):
     if len(items) > 0:
         # Get dictionary with meta level attribute
         sAttr = Attribute.getInstance()
         attrs = sAttr.getAttributeInfo("metaLevel")
         sMkt = self.sMkt
         self.metalvls = sMkt.directAttrRequest(items, attrs)
         # Clear selection
         self.deselectItems()
         # Perform sorting, using item's meta levels besides other stuff
         items.sort(key=self.itemSort)
     # Mark current item list as active
     self.active = items
     # Show them
     Display.populate(self, items)
Exemplo n.º 11
0
def getFighterAbilityMult(fighter, ability, src, tgt, distance, tgtSpeed, tgtSigRadius):
    fighterSpeed = fighter.getModifiedItemAttr('maxVelocity')
    attrPrefix = ability.attrPrefix
    # It's bomb attack
    if attrPrefix == 'fighterAbilityLaunchBomb':
        # Just assume we can land bomb anywhere
        return _calcBombFactor(
            atkEr=fighter.getModifiedChargeAttr('aoeCloudSize'),
            tgtSigRadius=tgtSigRadius)
    droneOpt = GraphSettings.getInstance().get('mobileDroneMode')
    # It's regular missile-based attack
    if (droneOpt == GraphDpsDroneMode.auto and fighterSpeed >= tgtSpeed) or droneOpt == GraphDpsDroneMode.followTarget:
        rangeFactor = 1
    # Same as with drones, if fighters are slower - put them to center of
    # the ship and see how they apply
    else:
        if distance is None:
            rangeFactorDistance = None
        else:
            rangeFactorDistance = distance + src.getRadius() - fighter.getModifiedItemAttr('radius')
        rangeFactor = calculateRangeFactor(
            srcOptimalRange=fighter.getModifiedItemAttr('{}RangeOptimal'.format(attrPrefix)) or fighter.getModifiedItemAttr('{}Range'.format(attrPrefix)),
            srcFalloffRange=fighter.getModifiedItemAttr('{}RangeFalloff'.format(attrPrefix)),
            distance=rangeFactorDistance)
    drf = fighter.getModifiedItemAttr('{}ReductionFactor'.format(attrPrefix), None)
    if drf is None:
        drf = fighter.getModifiedItemAttr('{}DamageReductionFactor'.format(attrPrefix))
    drs = fighter.getModifiedItemAttr('{}ReductionSensitivity'.format(attrPrefix), None)
    if drs is None:
        drs = fighter.getModifiedItemAttr('{}DamageReductionSensitivity'.format(attrPrefix))
    missileFactor = _calcMissileFactor(
        atkEr=fighter.getModifiedItemAttr('{}ExplosionRadius'.format(attrPrefix)),
        atkEv=fighter.getModifiedItemAttr('{}ExplosionVelocity'.format(attrPrefix)),
        atkDrf=_calcAggregatedDrf(reductionFactor=drf, reductionSensitivity=drs),
        tgtSpeed=tgtSpeed,
        tgtSigRadius=tgtSigRadius)
    resistMult = 1
    if tgt.isFit:
        resistAttrID = fighter.getModifiedItemAttr('{}ResistanceID'.format(attrPrefix))
        if resistAttrID:
            resistAttrInfo = Attribute.getInstance().getAttributeInfo(resistAttrID)
            if resistAttrInfo is not None:
                resistMult = tgt.item.ship.getModifiedItemAttr(resistAttrInfo.name, 1)
    mult = rangeFactor * missileFactor * resistMult
    return mult
Exemplo n.º 12
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)
        sAttr = Attribute.getInstance()
        info = sAttr.getAttributeInfo(params["attribute"])
        self.info = info
        self.direct = False
        if params["showIcon"]:
            if info.name == "power":
                iconFile = "pg_small"
                iconType = "gui"
            else:
                iconFile = info.icon.iconFile if info.icon else None
                iconType = "icons"
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(
                    iconFile, iconType)
                self.bitmap = BitmapLoader.getBitmap(iconFile, iconType)
            else:
                self.imageId = -1

            self.mask = wx.LIST_MASK_IMAGE
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
            self.mask |= wx.LIST_MASK_IMAGE

        if params["direct"]:
            self.direct = True
            self.view = fittingView
            originalRefresh = fittingView.refresh
            sMkt = Market.getInstance()

            def refresh(stuff):
                # Hack into our master view and add a callback for ourselves to know when to query
                self.directInfo = sMkt.directAttrRequest(
                    stuff, info) if stuff else None
                originalRefresh(stuff)

            fittingView.refresh = refresh
Exemplo n.º 13
0
def test_attribute():
    """
    We don't really have much to test here, so throw a generic attribute at it and validate we get the expected results

    :return:
    """
    sAttr = Attribute.getInstance()
    info = sAttr.getAttributeInfo("maxRange")

    assert info.attributeID == 54
    assert type(info.attributeID) is int
    assert info.attributeName == 'maxRange'
    assert type(info.attributeName) is unicode
    assert info.defaultValue == 0.0
    assert type(info.defaultValue) is float
    assert info.description == 'Distance below which range does not affect the to-hit equation.'
    assert type(info.description) is unicode
    assert info.displayName == 'Optimal Range'
    assert type(info.displayName) is unicode
    assert info.highIsGood is True
    assert type(info.highIsGood) is bool
    assert info.iconID == 1391
    assert type(info.iconID) is int
    assert info.name == 'maxRange'
    assert type(info.name) is unicode
    assert info.published is True
    assert type(info.published) is bool
    assert info.unitID == 1
    assert type(info.unitID) is int
    assert info.unit.ID == 1
    assert type(info.unit.ID) is int
    assert info.unit.displayName == 'm'
    assert type(info.unit.displayName) is unicode
    assert info.unit.name == 'Length'
    assert type(info.unit.name) is unicode
    assert info.unit.unitID == 1
    assert type(info.unit.unitID) is int
    assert info.unit.unitName == 'Length'
    assert type(info.unit.unitName) is unicode
Exemplo n.º 14
0
    def __init__(self, fittingView, params):
        ViewColumn.__init__(self, fittingView)
        sAttr = Attribute.getInstance()
        info = sAttr.getAttributeInfo(params["attribute"])
        self.info = info
        if params["showIcon"]:
            if info.name == "power":
                iconFile = "pg_small"
                iconType = "gui"
            else:
                iconFile = info.icon.iconFile if info.icon else None
                iconType = "icons"
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
                self.bitmap = BitmapLoader.getBitmap(iconFile, iconType)
            else:
                self.imageId = -1

            self.mask = wx.LIST_MASK_IMAGE
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
            self.mask |= wx.LIST_MASK_IMAGE

        if params["direct"]:
            self.direct = True
            self.view = fittingView
            originalRefresh = fittingView.refresh
            sMkt = Market.getInstance()

            def refresh(stuff):
                # Hack into our master view and add a callback for ourselves to know when to query
                self.directInfo = sMkt.directAttrRequest(stuff, info) if stuff else None
                originalRefresh(stuff)

            fittingView.refresh = refresh
Exemplo n.º 15
0
    def __init__(self, fittingView, params=None):
        if params is None:
            params = {"showIcon": True, "displayName": False}

        ViewColumn.__init__(self, fittingView)

        sAttr = Attribute.getInstance()
        info = sAttr.getAttributeInfo("maxRange")
        self.info = info
        if params["showIcon"]:
            iconFile = info.icon.iconFile if info.icon else None
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(iconFile, "icons")
                self.bitmap = BitmapLoader.getBitmap(iconFile, "icons")
            else:
                self.imageId = -1
            self.mask = wx.LIST_MASK_IMAGE
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
            self.mask |= wx.LIST_MASK_TEXT
Exemplo n.º 16
0
    def __init__(self, fittingView, params=None):
        if params is None:
            params = {"showIcon": True, "displayName": False}

        ViewColumn.__init__(self, fittingView)

        sAttr = Attribute.getInstance()
        info = sAttr.getAttributeInfo("maxRange")
        self.info = info
        if params["showIcon"]:
            iconFile = info.icon.iconFile if info.icon else None
            if iconFile:
                self.imageId = fittingView.imageList.GetImageIndex(iconFile, "icons")
                self.bitmap = BitmapLoader.getBitmap(iconFile, "icons")
            else:
                self.imageId = -1
            self.mask = wx.LIST_MASK_IMAGE
        else:
            self.imageId = -1

        if params["displayName"] or self.imageId == -1:
            self.columnText = info.displayName if info.displayName != "" else info.name
            self.mask |= wx.LIST_MASK_TEXT
Exemplo n.º 17
0
 def attributeIDCallback():
     if not value:  # some attributes come through with a value of 0? See #1387
         return "%d" % (value)
     attribute = Attribute.getInstance().getAttributeInfo(value)
     return "%s (%d)" % (attribute.name.capitalize(), value)
Exemplo n.º 18
0
 def attributeIDCallback():
     attribute = Attribute.getInstance().getAttributeInfo(value)
     return "%s (%d)" % (attribute.name.capitalize(), value)
Exemplo n.º 19
0
 def attributeIDCallback():
     if not value:  # some attributes come through with a value of 0? See #1387
         return "%d" % (value)
     attribute = Attribute.getInstance().getAttributeInfo(value)
     return "%s (%d)" % (attribute.name.capitalize(), value)
Exemplo n.º 20
0
 def attributeIDCallback():
     attribute = Attribute.getInstance().getAttributeInfo(value)
     return "%s (%d)" % (attribute.name.capitalize(), value)