buySkinDialogue.py (5122B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\store\buySkinDialogue.py 2 from carbonui import Align, uiconst 3 from carbonui.primitives.container import Container 4 from cosmetics.client.shipSkinTradingSvc import get_ship_skin_trading_svc 5 from cosmetics.client.ships.ship_skin_signals import on_skin_listing_expired 6 from cosmetics.client.ships.skins.errors import get_listing_error_text 7 from cosmetics.common.ships.skins.util import Currency 8 from player_messaging.client.ui_message import message_player 9 from eve.client.script.ui.cosmetics.ship.pages.cards.skinListingCard import SkinListingCard 10 from eve.client.script.ui.cosmetics.ship.pages.store import storeSignals 11 from eve.client.script.ui.cosmetics.ship.pages.store.buyComponentDialogue import BuyComponentDialogue 12 from eve.common.lib.appConst import corpHeraldry 13 from localization import GetByLabel 14 15 class BuySkinDialogue(BuyComponentDialogue): 16 __notifyevents__ = ['OnCharacterLPBalanceChange_Local'] 17 default_windowID = 'BuySkinDialogue' 18 default_caption = GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/BuySkin') 19 20 def __init__(self, listing, *args, **kwargs): 21 super(BuySkinDialogue, self).__init__(listing, *args, **kwargs) 22 on_skin_listing_expired.connect(self._on_skin_listing_expired) 23 24 def Close(self, setClosed = False, *args, **kwargs): 25 try: 26 super(BuySkinDialogue, self).Close(setClosed, *args, **kwargs) 27 finally: 28 on_skin_listing_expired.disconnect(self._on_skin_listing_expired) 29 30 def construct_card(self): 31 card_container = Container(name='card_container', parent=self.content, align=Align.TOTOP, height=SkinListingCard.default_height) 32 card = SkinListingCard(name='card', parent=card_container, align=Align.CENTER, listing=self.listing) 33 card._on_selected = lambda *args, **kwargs: None 34 card.is_selected = True 35 36 def construct_item_delivery_notice(self): 37 pass 38 39 def construct_activate_now_checkbox(self): 40 pass 41 42 def update_buyer_fee(self): 43 self.buyer_fee.amount = self.get_buyer_fee_amount() 44 45 def get_buyer_fee_amount(self): 46 if self.listing is None: 47 return 48 target_id = self.listing.target.target_id 49 if target_id is None: 50 return 51 buyer_fee, error = get_ship_skin_trading_svc().get_buyer_fee_for_listing(self.listing) 52 if error: 53 message_player(GetByLabel(get_listing_error_text(error))) 54 return 55 else: 56 return buyer_fee.lp_amount * self.purchase_quantity 57 58 def purchase_listing(self): 59 return get_ship_skin_trading_svc().purchase_listing(listing_id=self.listing.identifier, quantity=self.quantity) 60 61 def on_buy_success(self): 62 storeSignals.on_skin_listing_selected(None, None) 63 self.SetModalResult(uiconst.ID_OK) 64 65 def load_buy_button_tooltip_panel(self, tooltip_panel, *args): 66 if self.listing.is_targeted_at_another_character: 67 return GetByLabel('UI/Personalization/ShipSkins/SKINR/TargetedAtAnotherCharacter') 68 if self.listing.is_targeted_at_another_organization: 69 return GetByLabel('UI/Personalization/ShipSkins/SKINR/TargetedAtAnotherOrganization') 70 return super(BuySkinDialogue, self).load_buy_button_tooltip_panel(tooltip_panel, *args) 71 72 @property 73 def insufficient_funds_hint(self): 74 currencies = [] 75 if self.listing.currency == Currency.ISK and not self.has_enough_isk: 76 currencies.append(GetByLabel('UI/Common/ISK')) 77 if self.listing.currency == Currency.PLEX and not self.has_enough_plex: 78 currencies.append(GetByLabel('UI/Common/PLEX')) 79 if self.requires_evermarks and not self.has_enough_evermarks: 80 currencies.append(GetByLabel('UI/Wallet/WalletWindow/EM')) 81 return u'{base} ({currencies})'.format(base=GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/ListingErrors/InsufficientFunds'), currencies=u'/'.join(currencies)) 82 83 def has_sufficient_funds(self): 84 if self.requires_evermarks and not self.has_enough_evermarks: 85 return False 86 return super(BuySkinDialogue, self).has_sufficient_funds() 87 88 @property 89 def is_allowed_to_purchase(self): 90 if self.listing.is_targeted_at_another_character or self.listing.is_targeted_at_another_organization: 91 return False 92 return super(BuySkinDialogue, self).is_allowed_to_purchase 93 94 @property 95 def requires_evermarks(self): 96 return self.buyer_fee.amount is not None 97 98 @property 99 def has_enough_evermarks(self): 100 return sm.GetService('loyaltyPointsWalletSvc').GetCharacterEvermarkBalance() >= self.buyer_fee.amount 101 102 def _on_skin_listing_expired(self, listing_id): 103 if self.listing and self.listing.identifier == listing_id: 104 self.kill_threads() 105 self.buy_button.disable() 106 107 def OnCharacterLPBalanceChange_Local(self, issuerCorpID, lpBefore, lpAfter): 108 if issuerCorpID == corpHeraldry: 109 self.update()