all_ui_rankings.py (5482B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\Alliances\all_ui_rankings.py 2 import carbonui.const as uiconst 3 import localization 4 import log 5 from carbon.common.script.util.format import FmtDate 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from eve.client.script.ui.control import eveScroll 9 from carbonui.button.group import ButtonGroup 10 from eve.client.script.ui.control.entries.generic import Generic 11 from eve.client.script.ui.control.entries.util import GetFromClass 12 from eveexceptions import UserError 13 from eveservices.menu import GetMenuService 14 from eve.common.lib import appConst as const 15 from player_messaging.client.ui_message import prompt_player_fsd_dialog 16 17 class FormAlliancesRankings(Container): 18 is_loaded = False 19 20 def Load(self, *args): 21 if self.is_loaded: 22 return 23 self.is_loaded = True 24 self.toolbarContainer = ContainerAutoSize(name='toolbarContainer', align=uiconst.TOBOTTOM, parent=self) 25 buttonLabel = localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/ShowAll') 26 buttonOptions = [[buttonLabel, 27 self.ShowRankings, 28 (0,), 29 81]] 30 btns = ButtonGroup(btns=buttonOptions, parent=self.toolbarContainer) 31 self.sr.mainBtns = btns 32 self.sr.scroll = eveScroll.Scroll(parent=self) 33 self.ShowRankings() 34 35 def SetHint(self, hintstr = None): 36 if self.sr.scroll: 37 self.sr.scroll.ShowHint(hintstr) 38 39 def ShowRankings(self, maxLen = 100): 40 log.LogInfo('ShowRankings', maxLen) 41 if maxLen == 0 and prompt_player_fsd_dialog('ConfirmShowAllRankedAlliances', {}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 42 return 43 try: 44 sm.GetService('corpui').ShowLoad() 45 headers = [localization.GetByLabel('UI/Common/Name'), 46 localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/ExecutorCorp'), 47 localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/ShortName'), 48 localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/Created'), 49 localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Members'), 50 localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/AllianceStanding')] 51 scrolllist = [] 52 hint = localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/NoRankingsFound') 53 if self is None or self.destroyed: 54 log.LogInfo('ShowRankings Destroyed or None') 55 else: 56 data = sm.GetService('alliance').GetRankedAlliances(maxLen) 57 rows = data.alliances 58 owners = [] 59 for row in rows: 60 if row.executorCorpID not in owners: 61 owners.append(row.executorCorpID) 62 63 if len(owners): 64 cfg.eveowners.Prime(owners) 65 for row in rows: 66 standing = data.standings.get(row.allianceID, 0) 67 self.__AddToList(row, standing, scrolllist) 68 69 self.sr.scroll.adjustableColumns = 1 70 self.sr.scroll.sr.id = 'alliances_rankings' 71 noFoundLabel = localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/NoRankingsFound') 72 self.sr.scroll.Load(contentList=scrolllist, headers=headers, noContentHint=noFoundLabel) 73 finally: 74 sm.GetService('corpui').HideLoad() 75 76 def __GetLabel(self, row, standing): 77 executor = None 78 if row.executorCorpID is not None: 79 executor = cfg.eveowners.GetIfExists(row.executorCorpID) 80 if executor is not None: 81 executorCorpName = executor.ownerName 82 else: 83 executorCorpName = '' 84 if standing is None: 85 standing = localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/NotSet') 86 label = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' % (row.allianceName, 87 executorCorpName, 88 row.shortName, 89 FmtDate(row.startDate, 'ls'), 90 row.memberCount, 91 standing) 92 return label 93 94 def __AddToList(self, ranking, standing, scrolllist): 95 scrolllist.append(GetFromClass(Generic, {'label': self.__GetLabel(ranking, standing), 96 'ranking': ranking, 97 'GetMenu': self.GetRankingMenu})) 98 99 def GetRankingMenu(self, entry): 100 allianceID = entry.sr.node.ranking.allianceID 101 res = GetMenuService().GetMenuFromItemIDTypeID(allianceID, const.typeAlliance) 102 joinLabel = localization.GetByLabel('UI/Corporations/CorporationWindow/Alliances/Rankings/ApplyToJoin') 103 if self._CanApplyToJoinAlliances(): 104 res.append([joinLabel, [[joinLabel, sm.GetService('corpui').ApplyToJoinAlliance, [allianceID]]]]) 105 else: 106 log.LogInfo('Apply to join', allianceID, 'will be disabled as pre-reqs for joining are not met') 107 res.append([joinLabel, [[joinLabel, sm.GetService('corpui').ApplyToJoinAlliance, [allianceID]]], [-1]]) 108 return res 109 110 @staticmethod 111 def _CanApplyToJoinAlliances(): 112 try: 113 return sm.GetService('corp').CheckCanApplyToJoinAlliance() 114 except UserError: 115 return False