lpIncursionsPanel.py (13861B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\panels\personal\lpIncursionsPanel.py 2 import blue 3 from carbon.common.script.util.format import FmtDate, FmtSimpleDateUTC, ParseDate, ParseSmallDate 4 import carbonui.const as uiconst 5 from carbonui.control.button import Button 6 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText 7 from carbonui.control.combo import Combo 8 from carbonui.primitives.container import Container 9 from eve.client.script.ui.control.entries.generic import Generic 10 from eve.client.script.ui.control.entries.util import GetFromClass 11 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel 12 from eve.client.script.ui.control.eveScroll import Scroll 13 from eve.client.script.ui.shared.neocom.wallet import walletConst 14 from eve.common.lib import appConst 15 from eve.common.script.mgt import appLogConst 16 import evetypes 17 import localization 18 19 class LPIncursionsPanel(Container): 20 panelID = walletConst.PANEL_LP_INCURSIONS 21 22 def ApplyAttributes(self, attributes): 23 self.incursionLPLogData = None 24 Container.ApplyAttributes(self, attributes) 25 self.ConstructLayout() 26 27 def OnTabSelect(self): 28 if self.incursionLPLogData is None: 29 self.scroll.Clear() 30 self.scroll.ShowHint(localization.GetByLabel('UI/Incursion/Journal/LoadData')) 31 else: 32 self.UpdateIncursionLPLog(self.incursionLPLogData) 33 34 def ConstructLayout(self): 35 self.incursionLPLogFilters = Container(name='incursionLPLogFilters', parent=self, height=Button.default_height, align=uiconst.TOTOP, padTop=16) 36 self.incursionLPLoadbutton = Button(parent=self.incursionLPLogFilters, label=localization.GetByLabel('UI/Generic/Load'), align=uiconst.BOTTOMRIGHT, func=self.LoadIncursionLPLog) 37 now = FmtDate(blue.os.GetWallclockTime(), 'sn') 38 self.incursionLPDate = SingleLineEditText(name='incursionFromdate', parent=self.incursionLPLogFilters, setvalue=now, align=uiconst.TOLEFT, maxLength=16, label=localization.GetByLabel('UI/Common/Date'), padding=(4, 0, 0, 0), width=110) 39 options = [(localization.GetByLabel('UI/Incursion/Journal/AllIncursionsFilter'), None)] 40 self.incursionTaleIDFilter = Combo(label=localization.GetByLabel('UI/Incursion/Journal/Incursion'), parent=self.incursionLPLogFilters, options=options, name='incursionTaleIDFilter', width=110, align=uiconst.TOLEFT, padding=(4, 0, 0, 0)) 41 options = [(localization.GetByLabel('UI/Incursion/Journal/AllTypesFilter'), None)] 42 self.incursionTypeFilter = Combo(label=localization.GetByLabel('UI/Incursion/Journal/Types'), parent=self.incursionLPLogFilters, options=options, name='incursionTypeFilter', width=110, align=uiconst.TOLEFT, padding=(4, 0, 0, 0)) 43 self.loadingWheel = LoadingWheel(parent=self, align=uiconst.CENTER, state=uiconst.UI_HIDDEN) 44 self.scroll = Scroll(parent=self) 45 self.scroll.multiSelect = 0 46 self.scroll.sr.id = 'walletLoyaltyPointIncursionScroll' 47 48 def LoadIncursionLPLog(self, *args): 49 self.incursionLPLoadbutton.disabled = True 50 self.incursionTaleIDFilter.Disable() 51 self.incursionTypeFilter.Disable() 52 self.incursionLPDate.Disable() 53 self.loadingWheel.Show() 54 self.scroll.Clear() 55 self.incursionLPLogData = sm.RemoteSvc('rewardMgr').GetRewardLPLogs() 56 self.UpdateIncursionLPLog(self.incursionLPLogData) 57 self.loadingWheel.Hide() 58 self.incursionLPLoadbutton.disabled = False 59 self.incursionTaleIDFilter.Enable() 60 self.incursionTypeFilter.Enable() 61 self.incursionLPDate.Enable() 62 63 def UpdateIncursionLPLog(self, data, selectedTaleID = None, selectedConstellationID = None): 64 mapsvc = sm.GetService('map') 65 taleIDFilter = self.incursionTaleIDFilter.selectedValue 66 incursionTypeFilter = self.incursionTypeFilter.selectedValue 67 try: 68 fromDate = ParseSmallDate(self.incursionLPDate.GetValue()) 69 except (Exception, TypeError): 70 dateString = localization.formatters.FormatDateTime(blue.os.GetWallclockTime(), dateFormat='short', timeFormat='none') 71 fromDate = ParseDate(dateString) 72 self.incursionLPDate.SetValue(dateString) 73 74 fromDate += appConst.DAY 75 dungeonTypes = set() 76 taleIDs = {} 77 filteredData = [] 78 for d in data: 79 dungeonTypes.add(d.rewardMessageKey) 80 constellationID = mapsvc.GetParent(d.solarSystemID) 81 if constellationID is not None: 82 constellation = mapsvc.GetItem(constellationID) 83 if constellation is not None: 84 taleIDs[d.taleID] = constellation.itemName 85 if selectedTaleID is not None: 86 if selectedTaleID != d.taleID: 87 continue 88 if taleIDFilter is not None and selectedTaleID is None: 89 if taleIDFilter != d.taleID: 90 continue 91 if incursionTypeFilter is not None: 92 shouldAdd = False 93 if incursionTypeFilter == LPTypeFilter.LPPayedOut: 94 if d.eventTypeID == appLogConst.eventRewardLPPoolPayedOut: 95 shouldAdd = True 96 elif incursionTypeFilter == LPTypeFilter.LPLost: 97 if d.eventTypeID == appLogConst.eventRewardLPPoolLost: 98 shouldAdd = True 99 elif incursionTypeFilter == d.rewardMessageKey: 100 shouldAdd = True 101 if not shouldAdd: 102 continue 103 if fromDate < d.date: 104 continue 105 filteredData.append(d) 106 107 if selectedTaleID is not None: 108 if selectedTaleID not in taleIDs: 109 constellation = mapsvc.GetItem(selectedConstellationID) 110 if constellation is not None: 111 taleIDs[selectedTaleID] = constellation.itemName 112 scrolllist = [] 113 for d in filteredData: 114 solarSystemType = '' 115 if d.eventTypeID == appLogConst.eventRewardLPPoolPayedOut: 116 solarSystemType = _FormatLogEntry('CompletedAndPaidOut', d.rewardID) 117 elif d.eventTypeID == appLogConst.eventRewardLPPoolLost: 118 solarSystemType = _FormatLogEntry('CompletedAndNotPaidOut', d.rewardID) 119 elif d.rewardMessageKey is not None and isinstance(d.rewardMessageKey, int): 120 solarSystemType = localization.GetByMessageID(d.rewardMessageKey) 121 elif d.rewardMessageKey is not None and d.rewardMessageKey != '': 122 solarSystemType = localization.GetByLabel(d.rewardMessageKey) 123 if d.lpAmountAddedToPool is None: 124 d.lpAmountAddedToPool = 0 125 if d.lpAmountAddedToPool == 0: 126 LPAmountAddedToPool = '<color=0xFFFFFFFF>' + localization.formatters.FormatNumeric(0) + '</color>' 127 else: 128 LPAmountAddedToPool = '<color=0xFFFFFF00>' + localization.formatters.FormatNumeric(d.lpAmountAddedToPool) + '</color>' 129 if d.lpAmountPayedOut is None: 130 d.lpAmountPayedOut = 0 131 if d.lpAmountPayedOut == 0: 132 LPAmountPayedOut = '<color=0xFFFFFFFF>' + localization.formatters.FormatNumeric(0) + '</color>' 133 elif d.eventTypeID == appLogConst.eventRewardLPPoolLost: 134 LPAmountPayedOut = '<color=0xFFFF0000>' + localization.formatters.FormatNumeric(0) + '</color>' 135 else: 136 LPAmountPayedOut = '<color=0xFF00FF00>' + localization.formatters.FormatNumeric(d.lpAmountPayedOut) + '</color>' 137 if d.numberOfPlayers is None: 138 d.numberOfPlayers = 0 139 description = '' 140 if d.eventTypeID == appLogConst.eventRewardDisqualified: 141 if d.disqualifierType == appConst.rewardIneligibleReasonTrialAccount: 142 description = _FormatLogEntry('DisqualifiedTrialAccount', d.rewardID) 143 elif d.disqualifierType == appConst.rewardIneligibleReasonInvalidGroup: 144 groupName = evetypes.GetGroupNameByGroup(d.disqualifierData) 145 description = _FormatLogEntry('DisqualifiedInvalidShipGroup2', d.rewardID, groupName=groupName) 146 elif d.disqualifierType == appConst.rewardIneligibleReasonShipCloaked: 147 description = _FormatLogEntry('DisqualifiedCloaked', d.rewardID) 148 elif d.disqualifierType == appConst.rewardIneligibleReasonNotInFleet: 149 description = _FormatLogEntry('DisqualifiedNoFleet', d.rewardID) 150 elif d.disqualifierType == appConst.rewardIneligibleReasonNotBestFleet: 151 description = _FormatLogEntry('DisqualifiedNotBestFleet', d.rewardID) 152 elif d.disqualifierType == appConst.rewardIneligibleReasonNotTop5: 153 description = _FormatLogEntry('DisqualifiedNotInTopFive', d.rewardID) 154 elif d.disqualifierType == appConst.rewardIneligibleReasonNotTopN: 155 maxWinners = d.disqualifierData 156 description = _FormatLogEntry('DisqualifiedNotInTopN', d.rewardID, n=maxWinners) 157 elif d.disqualifierType == appConst.rewardIneligibleReasonNotRightAmountOfPlayers: 158 description = _FormatLogEntry('DisqualifiedNotEnoughParticipants', d.rewardID) 159 elif d.disqualifierType == appConst.rewardIneligibleReasonTaleAlreadyEnded: 160 description = _FormatLogEntry('DisqualifiedExpired', d.rewardID) 161 elif d.disqualifierType == appConst.rewardIneligibleReasonLowContribution: 162 description = _FormatLogEntry('DisqualifiedLowContribution', d.rewardID) 163 elif d.eventTypeID == appLogConst.eventRewardLPStoredInPool: 164 description = _FormatLogEntry('LoyaltyPointPilotRewardCount', d.rewardID, rewardedPlayers=d.numberOfPlayers) 165 elif d.eventTypeID == appLogConst.eventRewardLPPoolPayedOut: 166 description = _FormatLogEntry('LoyaltyPointPoolPaidOut', d.rewardID) 167 elif d.eventTypeID == appLogConst.eventRewardLPPoolLost: 168 description = _FormatLogEntry('LoyaltyPointPoolLost', d.rewardID) 169 elif d.eventTypeID == appLogConst.eventRewardLPPaidDirectly: 170 description = _FormatLogEntry('LPPaidDirectly', d.rewardID, rewardedPlayers=d.numberOfPlayers) 171 hint = description 172 texts = [FmtSimpleDateUTC(d.date), 173 solarSystemType, 174 d.dungeonName, 175 LPAmountAddedToPool, 176 LPAmountPayedOut, 177 description] 178 scrolllist.append(GetFromClass(Generic, {'label': '<t>'.join(texts), 179 'sort_' + localization.GetByLabel('UI/Incursion/Journal/StoredLP'): d.lpAmountAddedToPool, 180 'sort_' + localization.GetByLabel('UI/Incursion/Journal/PaidLP'): d.lpAmountPayedOut, 181 'hint': hint})) 182 183 headers = [localization.GetByLabel('UI/Common/Date'), 184 localization.GetByLabel('UI/Incursion/Journal/Type'), 185 localization.GetByLabel('UI/Incursion/Journal/EncounterName'), 186 localization.GetByLabel('UI/Incursion/Journal/StoredLP'), 187 localization.GetByLabel('UI/Incursion/Journal/PaidLP'), 188 localization.GetByLabel('UI/Incursion/Journal/Description')] 189 options = [(localization.GetByLabel('UI/Incursion/Journal/AllIncursionsFilter'), None)] 190 for taleID, constellationName in taleIDs.iteritems(): 191 options.append((constellationName, taleID)) 192 193 self.incursionTaleIDFilter.LoadOptions(options) 194 if selectedTaleID is None: 195 self.incursionTaleIDFilter.SelectItemByValue(taleIDFilter) 196 else: 197 self.incursionTaleIDFilter.SelectItemByValue(selectedTaleID) 198 options = [(localization.GetByLabel('UI/Incursion/Journal/AllTypesFilter'), None), (localization.GetByLabel('UI/Incursion/Journal/CompletedAndNotPaidOut'), LPTypeFilter.LPLost), (localization.GetByLabel('UI/Incursion/Journal/CompletedAndPaidOut'), LPTypeFilter.LPPayedOut)] 199 for dungeonType in dungeonTypes: 200 if dungeonType is not None and dungeonType != '': 201 if isinstance(dungeonType, int): 202 options.append((localization.GetByMessageID(dungeonType), dungeonType)) 203 else: 204 options.append((localization.GetByLabel(dungeonType), dungeonType)) 205 206 self.incursionTypeFilter.LoadOptions(options) 207 self.incursionTypeFilter.SelectItemByValue(incursionTypeFilter) 208 if scrolllist: 209 sortBy = self.scroll.GetSortBy() 210 sortDirection = self.scroll.GetSortDirection() 211 self.scroll.LoadContent(contentList=scrolllist, reversesort=1, headers=headers, scrollTo=0.0) 212 if sortBy is None: 213 self.scroll.Sort(by=localization.GetByLabel('UI/Common/Date'), reversesort=1) 214 else: 215 self.scroll.Sort(by=sortBy, reversesort=sortDirection) 216 else: 217 self.scroll.Clear() 218 self.scroll.ShowHint(localization.GetByLabel('UI/Incursion/Journal/NoRecordFound')) 219 220 221 def _GetInvasionLogEntry(label, **kwargs): 222 label_path = '/'.join(['UI/Invasion/Journal', label]) 223 return localization.GetByLabel(label_path, **kwargs) 224 225 226 def _GetIncursionLogEntry(label, **kwargs): 227 label_path = '/'.join(['UI/Incursion/Journal', label]) 228 return localization.GetByLabel(label_path, **kwargs) 229 230 231 def _FormatLogEntry(label, rewardID, **kwargs): 232 if rewardID == appConst.rewardInvasions: 233 return _GetInvasionLogEntry(label, **kwargs) 234 return _GetIncursionLogEntry(label, **kwargs) 235 236 237 class LPTypeFilter(): 238 LPLost = -1 239 LPPayedOut = -2