personalDonateEMPanel.py (7302B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\panels\personal\personalDonateEMPanel.py 2 import blue 3 from featuremanagement.client.flag import flag_int 4 from appConst import corpHeraldry 5 from carbon.common.script.util.format import FmtAmt 6 from carbonui import uiconst, TextAlign 7 from carbonui.control.combo import Combo 8 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger 9 from carbonui.primitives.container import Container 10 from corporation.common import FLAG_MIN_ALLIANCE_MEMBERSHIP_DURATION_FOR_EM_DONATION_DEFAULT, FLAG_MIN_ALLIANCE_MEMBERSHIP_DURATION_FOR_EM_DONATION, FLAG_EM_DONATION_KILLSWITCH, FLAG_EM_DONATION_KILLSWITCH_DEFAULT 11 from eve.client.script.ui import eveColor 12 from eve.client.script.ui.control.eveLabel import EveLabelLarge, EveCaptionMedium 13 from eve.client.script.ui.control.infoNotice import InfoNotice 14 from eve.client.script.ui.shared.neocom.wallet.panels.personal.personalDonateLPPanel import PersonalDonateLPPanel 15 from eve.common.lib import appConst 16 from eve.common.script.sys import idCheckers 17 from localization import GetByLabel 18 19 class PersonalDonateEMPanel(PersonalDonateLPPanel): 20 default_name = 'personalDonateEMPanel' 21 killSwitchKey = FLAG_EM_DONATION_KILLSWITCH 22 killSwitchDefault = FLAG_EM_DONATION_KILLSWITCH_DEFAULT 23 killSwitchLabel = 'UI/Wallet/WalletWindow/TransferFailedEMDonationsDisabled' 24 25 def __init__(self, **kw): 26 self._available_corps = [] 27 self._min_membership_days = FLAG_MIN_ALLIANCE_MEMBERSHIP_DURATION_FOR_EM_DONATION_DEFAULT 28 flag_int(key=FLAG_MIN_ALLIANCE_MEMBERSHIP_DURATION_FOR_EM_DONATION, default_value=FLAG_MIN_ALLIANCE_MEMBERSHIP_DURATION_FOR_EM_DONATION_DEFAULT, callback=self._on_min_membership_days_changed) 29 super(PersonalDonateEMPanel, self).__init__(**kw) 30 31 def _on_min_membership_days_changed(self, evaluate_flag): 32 self._min_membership_days = evaluate_flag() 33 34 def _get_selected_issuer_corp_id_setting(self): 35 return corpHeraldry 36 37 def _set_selected_issuer_corp_id_setting(self, value): 38 pass 39 40 def _initialize_selected_corp_id(self): 41 pass 42 43 def _evaluate_can_make_donations(self): 44 self._selected_corp_id = None 45 self._can_make_donations = False 46 if self._is_corp_membership_valid(): 47 self._can_make_donations = True 48 self._available_corps = [session.corpid] 49 if session.allianceid is not None: 50 num_days_in_alliance = sm.RemoteSvc('allianceRegistry').GetDaysInAlliance(session.allianceid, session.corpid) 51 if num_days_in_alliance >= self._min_membership_days: 52 alliance_info = sm.GetService('alliance').GetAlliance(session.allianceid) 53 exec_corp = alliance_info.executorCorpID 54 if exec_corp != session.corpid: 55 num_days_in_alliance_exec = sm.RemoteSvc('allianceRegistry').GetDaysInAlliance(session.allianceid, exec_corp) 56 if num_days_in_alliance_exec >= self._min_membership_days: 57 self._available_corps.append(exec_corp) 58 if len(self._available_corps) == 1: 59 self._selected_corp_id = self._available_corps[0] 60 61 def _is_corp_membership_valid(self): 62 char_info = sm.RemoteSvc('charMgr').GetPrivateInfoOnCorpChange(session.charid) 63 if char_info is None: 64 return False 65 char_start_date = char_info.corporationDateTime 66 num_days_in_corp = (blue.os.GetWallclockTime() - char_start_date) / appConst.DAY 67 return num_days_in_corp >= self._min_membership_days and idCheckers.IsPlayerCorporation(session.corpid) 68 69 def is_panel_available(self): 70 return self._is_corp_membership_valid() 71 72 def _construct_main_cont_restricted(self): 73 super(PersonalDonateEMPanel, self)._construct_main_cont_restricted() 74 label_cont = Container(name='labelCont', parent=self._main_cont, align=uiconst.TOTOP_PROP, textAlign=TextAlign.CENTER, height=0.5) 75 EveLabelLarge(parent=label_cont, align=uiconst.TOBOTTOM, textAlign=TextAlign.CENTER, text=GetByLabel('UI/Wallet/WalletWindow/PersonalEMTabRestricted', numDays=self._min_membership_days), color=eveColor.GUNMETAL_GREY) 76 EveCaptionMedium(parent=label_cont, align=uiconst.TOBOTTOM, textAlign=TextAlign.CENTER, padBottom=4, text=GetByLabel('UI/Wallet/WalletWindow/AccessRestricted')) 77 78 def _construct_main_cont_full(self): 79 super(PersonalDonateEMPanel, self)._construct_main_cont_full() 80 info_cont = Container(parent=self, name='infoCont', align=uiconst.TORIGHT_PROP, width=0.5, padLeft=16) 81 info_notice = InfoNotice(name='infoNotice', parent=info_cont, align=uiconst.TOTOP, labelText=GetByLabel('UI/Wallet/WalletWindow/TransferPersonalEMNotice', numDaysCorp=self._min_membership_days, numDaysAlliance=self._min_membership_days)) 82 info_notice.noticeLabel.maxLines = None 83 84 def _construct_search_input(self): 85 if not self._can_make_donations or len(self._available_corps) == 1: 86 return 87 self._search_input_cont = Container(parent=self._main_cont, name='searchInputCont', height=32, padTop=14, align=uiconst.TOTOP) 88 options = [ (cfg.eveowners.Get(x).name, x) for x in self._available_corps ] 89 self._search_combo = Combo(label=GetByLabel('UI/Wallet/WalletWindow/TransferTo'), parent=self._search_input_cont, options=options, name='searchCombo', width=0.6, align=uiconst.TOLEFT_PROP, callback=self._on_corp_selected, nothingSelectedText=GetByLabel('UI/Wallet/WalletWindow/EMDonationSelectCorp')) 90 91 def _on_corp_selected(self, _combo, _key, value): 92 self._selected_corp_id = value 93 self._show_search_result() 94 95 def _filter_valid_corps(self, corps): 96 if not self._can_make_donations: 97 return 98 valid_corps = [ x for x in corps if x.charID in self._available_corps ] 99 return valid_corps 100 101 def _construct_reset_search_button(self): 102 if not self._can_make_donations or len(self._available_corps) == 1: 103 return 104 super(PersonalDonateEMPanel, self)._construct_reset_search_button() 105 106 def _reset_search_result(self): 107 if not self._can_make_donations or len(self._available_corps) == 1: 108 return 109 super(PersonalDonateEMPanel, self)._reset_search_result() 110 self._search_combo.SetNothingSelected() 111 112 def _construct_amount(self): 113 amount_cont = Container(parent=self._main_cont, name='amountCont', align=uiconst.TOTOP, height=32, padTop=48) 114 self._amount_input = SingleLineEditInteger(name='lpAmountInput', parent=amount_cont, align=uiconst.TOLEFT_PROP, width=0.6, hintText=GetByLabel('UI/Wallet/WalletWindow/EM'), label=GetByLabel('UI/Wallet/WalletWindow/GiveAmount')) 115 self._amount_input.OnChange = self._on_amount_changed 116 117 def _get_raw_issuer_corp_list(self): 118 return [corpHeraldry] 119 120 def _set_transfer_button_func(self): 121 self._transfer_button.SetFunc(self._transfer_lp) 122 123 def _get_confirmation_message(self, amount): 124 return GetByLabel('UI/Wallet/WalletWindow/CorpEMTransactionConfirmation', amount=FmtAmt(amount), corpName=cfg.eveowners.Get(self._selected_corp_id).name)