Beispiel #1
0
    def OnDonateLPBtn(self, *args):
        if not self.bottomBottomCont.pickState:
            return
        pointsToDonate = self.donateAmountEdit.GetValue()
        if not pointsToDonate:
            return
        donationTax = facwarCommon.GetDonationTax(session.warfactionid)
        pointsToIHub = int(pointsToDonate - pointsToDonate * donationTax)
        try:
            sm.GetService('facwar').DonateLPsToSolarSystem(
                pointsToDonate, pointsToIHub)
        except UserError as e:
            if e.msg == 'FacWarDonationTaxChanged':
                sm.GetService(
                    'facwar').objectCaching.InvalidateCachedMethodCalls([
                        ('map', 'GetFacWarZoneInfo', (session.warfactionid, ))
                    ])
                self.UpdateMyLPToIHubLabel(refreshTax=True)
                if uicore.Message('FacWarDonationTaxChanged', e.dict,
                                  uiconst.YESNO,
                                  uiconst.ID_YES) == uiconst.ID_YES:
                    newPointsToIhub = int(pointsToDonate *
                                          (1 - e.dict['taxNow'] / 100.0))
                    try:
                        sm.GetService('facwar').DonateLPsToSolarSystem(
                            pointsToDonate, newPointsToIhub)
                    except UserError as e:
                        if e.msg == 'FacWarDonationTaxChanged':
                            return
                        raise

                else:
                    return
            else:
                raise

        self.donateAmountEdit.SetValue('0')
        uicore.animations.FadeIn(self.bottomFlashEffect, duration=0.3)
        self.bottomBottomCont.Disable()
        uicore.animations.FadeOut(self.bottomBottomCont, duration=0.1)
        self.bottomTaxCont.Disable()
        uicore.animations.FadeOut(self.bottomTaxCont, duration=0.1)
        blue.synchro.Sleep(300)
        uicore.animations.MoveInFromBottom(self.donationReceivedLabel,
                                           amount=5,
                                           duration=0.15)
        uicore.animations.FadeIn(self.donationReceivedLabel,
                                 sleep=True,
                                 duration=0.5)
        blue.synchro.Sleep(5000)
        uicore.animations.FadeOut(self.bottomFlashEffect,
                                  duration=0.3,
                                  sleep=True)
        uicore.animations.FadeOut(self.donationReceivedLabel,
                                  sleep=True,
                                  duration=0.3)
        uicore.animations.FadeIn(self.bottomBottomCont, duration=0.3)
        self.bottomBottomCont.Enable()
        uicore.animations.FadeIn(self.bottomTaxCont, duration=0.3)
        self.bottomTaxCont.Enable()
Beispiel #2
0
 def UpdateMyLPToIHubLabel(self, refreshTax=False):
     lpAmount = self.donateAmountEdit.GetValue()
     donationTax = facwarCommon.GetDonationTax(session.warfactionid)
     tax = math.ceil(donationTax * lpAmount)
     if self.myLPToIhubLabel:
         self.myLPToIhubLabel.Close()
     self.myLPToIhubLabel = uicontrols.Label(
         name='myLPToIhubLabel',
         parent=self.bottomTaxCont,
         align=uiconst.TOLEFT,
         idx=0,
         text=localization.GetByLabel(
             'UI/FactionWarfare/IHub/TotalDonated',
             loyaltyPoints=localization.formatters.FormatNumeric(
                 int(lpAmount - tax), useGrouping=True)))
     if refreshTax:
         if self.myLPTaxLabel:
             self.myLPTaxLabel.Close()
         self.myLPTaxLabel = uicontrols.Label(
             name='myLPTaxLabel',
             parent=self.bottomTaxCont,
             text=localization.GetByLabel(
                 'UI/FactionWarfare/IHub/maintenanceTax',
                 tax=int(donationTax * 100)),
             align=uiconst.TOLEFT,
             state=uiconst.UI_NORMAL,
             left=5)
     self.myLPTaxLabel.hint = localization.GetByLabel(
         'UI/FactionWarfare/LPAmount', lps=tax)
Beispiel #3
0
    def ApplyAttributes(self, attributes):
        uicontrols.Window.ApplyAttributes(self, attributes)
        self.itemID = attributes.Get('itemID')
        lpPool = sm.GetService('facwar').GetSolarSystemLPs()
        topCont = uiprimitives.Container(name='topCont',
                                         parent=self.sr.main,
                                         align=uiconst.TOTOP,
                                         height=40,
                                         padding=(self.PADSIDE, self.PADTOP,
                                                  self.PADSIDE, self.PADSIDE))
        mainCont = uicontrols.ContainerAutoSize(name='mainCont',
                                                parent=self.sr.main,
                                                align=uiconst.TOTOP)
        bottomCont = uiprimitives.Container(name='bottomCont',
                                            parent=self.sr.main,
                                            align=uiconst.TOBOTTOM,
                                            height=100,
                                            padTop=self.PADTOP)
        uicontrols.EveLabelLarge(
            parent=topCont,
            text=localization.GetByLabel(
                'UI/FactionWarfare/IHub/SystemUpgradePanel',
                systemName=cfg.evelocations.Get(session.solarsystemid2).name),
            align=uiconst.TOPLEFT,
            top=5)
        uicontrols.EveLabelLarge(
            parent=topCont,
            text=localization.GetByLabel('UI/FactionWarfare/IHub/TotalLP'),
            align=uiconst.TOPRIGHT,
            top=5)
        self.lpPoolLabel = uicontrols.EveCaptionSmall(parent=topCont,
                                                      align=uiconst.TOPRIGHT,
                                                      top=25)
        limits = [0] + const.facwarSolarSystemUpgradeThresholds + [
            const.facwarSolarSystemMaxLPPool
        ]
        self.upgradeBars = []
        for i in xrange(1, 7):
            bar = uicls.FWUpgradeLevelCont(parent=mainCont,
                                           align=uiconst.TOTOP,
                                           padding=(self.PADSIDE, 0, 10, 10),
                                           lowerLimit=limits[i - 1],
                                           upperLimit=limits[i],
                                           lpAmount=lpPool,
                                           level=i,
                                           idx=0)
            self.upgradeBars.append(bar)

        self.bottomGradient = uicontrols.GradientSprite(bgParent=bottomCont,
                                                        rotation=-pi / 2,
                                                        rgbData=[(0, (0.3, 0.3,
                                                                      0.3))],
                                                        alphaData=[(0, 0.3),
                                                                   (0.9, 0.0)])
        self.bottomFlashEffect = uicontrols.GradientSprite(
            bgParent=bottomCont,
            rotation=-pi / 2,
            rgbData=[(0, (0.6, 0.6, 0.6))],
            alphaData=[(0, 0.3), (0.9, 0.0)],
            opacity=0.0)
        uiprimitives.Line(parent=bottomCont,
                          align=uiconst.TOTOP,
                          color=(0.3, 0.3, 0.3, 0.3))
        bottomMainCont = uiprimitives.Container(name='bottomMainCont',
                                                parent=bottomCont,
                                                align=uiconst.CENTER,
                                                width=450,
                                                height=100)
        self.myLPLabel = uicontrols.Label(parent=bottomMainCont,
                                          text=self.GetLPOwnedLabel(),
                                          align=uiconst.TOPLEFT,
                                          left=self.PADSIDE,
                                          top=self.PADTOP)
        self.bottomBottomCont = uiprimitives.Container(name='bottomBottom',
                                                       align=uiconst.TOPLEFT,
                                                       pos=(self.PADSIDE, 40,
                                                            450, 25),
                                                       parent=bottomMainCont)
        self.donateAmountEdit = uicontrols.SinglelineEdit(
            parent=self.bottomBottomCont,
            name='donateAmountEdit',
            align=uiconst.TOLEFT,
            setvalue=0,
            width=155,
            OnReturn=self.OnDonateLPBtn,
            OnChange=self.OnDonateValueChanged)
        self.donateBtn = uicontrols.Button(
            parent=self.bottomBottomCont,
            align=uiconst.TOLEFT,
            func=self.OnDonateLPBtn,
            label=localization.GetByLabel('UI/FactionWarfare/IHub/DonateLPs'),
            padLeft=4)
        self.donationReceivedLabel = uicontrols.EveCaptionMedium(
            name='donationReceivedLabel',
            parent=bottomMainCont,
            align=uiconst.TOPLEFT,
            text=localization.GetByLabel(
                'UI/FactionWarfare/IHub/DonationReceived'),
            left=self.PADSIDE,
            top=50,
            opacity=0.0)
        self.bottomTaxCont = uiprimitives.Container(name='bottomTax',
                                                    align=uiconst.TOPLEFT,
                                                    pos=(self.PADSIDE, 73, 400,
                                                         25),
                                                    parent=bottomMainCont)
        self.myLPToIhubLabel = None
        factionID = sm.GetService('facwar').GetSystemOccupier(
            session.solarsystemid)
        self.myLPTaxLabel = uicontrols.Label(
            name='myLPTaxLabel',
            parent=self.bottomTaxCont,
            text=localization.GetByLabel(
                'UI/FactionWarfare/IHub/maintenanceTax',
                tax=int(facwarCommon.GetDonationTax(factionID) * 100)),
            align=uiconst.TOLEFT,
            state=uiconst.UI_NORMAL,
            left=5)
        self.SetLPPoolAmount(lpPool)
        self.UpdateMyLPAmount()
        self.UpdateMyLPToIHubLabel()
        uthread.new(self.CheckOpenThread)