tourneyBanUI.py (3522B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\extras\tourneyBanUI.py 2 import evetypes 3 import carbonui.const as uiconst 4 import blue 5 from carbon.common.script.util import timerstuff 6 from carbonui.control.combo import Combo 7 from carbonui.control.window import Window 8 from carbonui.primitives.container import Container 9 from carbonui.uicore import uicore 10 from eve.client.script.ui.control import eveLabel 11 from eve.common.lib import appConst as const 12 from carbonui.control.button import Button 13 from localization.common.util import is_localization_message_unresolved 14 15 class TourneyBanUI(Window): 16 __guid__ = 'form.TourneyBanUI' 17 default_alwaysLoadDefaults = True 18 19 def ApplyAttributes(self, attributes): 20 Window.ApplyAttributes(self, attributes) 21 self.SetCaption('Tournament Ban Prompt') 22 self.SetMinSize((300, 375)) 23 24 def SetModalResult(self, result, caller = None): 25 if result == uiconst.ID_OK: 26 return 27 super(TourneyBanUI, self).SetModalResult(result, caller) 28 29 def Execute(self, banID, numBans, curBans, deadline, respondToNodeID, shipList): 30 self.banID = banID 31 self.deadline = deadline 32 self.respondToNodeID = respondToNodeID 33 self.resetButton = Button(label='Submit Ban' if numBans > 0 else 'Okay', parent=self.sr.main, align=uiconst.TOBOTTOM, func=self.Submit, state=uiconst.UI_NORMAL, padding=5) 34 eveLabel.EveLabelLarge(text="Let's ban some ships!" if numBans > 0 else "Here's the bans:", parent=self.sr.main, align=uiconst.TOTOP, top=10, padding=5, color=(0.5, 0.5, 1, 1)) 35 eveLabel.Label(text='You have banned:', parent=self.sr.main, align=uiconst.TOTOP, top=5, padding=5) 36 eveLabel.Label(text='<br>'.join([ evetypes.GetName(typeID) for typeID in curBans[0] ]), padding=5, parent=self.sr.main, align=uiconst.TOTOP) 37 eveLabel.Label(text='They have banned:', parent=self.sr.main, align=uiconst.TOTOP, top=5, padding=5) 38 eveLabel.Label(text='<br>'.join([ evetypes.GetName(typeID) for typeID in curBans[1] ]), padding=5, parent=self.sr.main, align=uiconst.TOTOP) 39 banOptions = [('Pass', -1)] + sorted(shipList) 40 self.banChoices = [] 41 for banNum in xrange(numBans): 42 self.banChoices.append(Combo(label='Ban: ', parent=self.sr.main, options=banOptions, top=20, padding=5, align=uiconst.TOTOP)) 43 44 if numBans > 0: 45 banCont = Container(name='banTimer', parent=self.sr.main, align=uiconst.TOTOP, height=50) 46 self.countdownText = eveLabel.Label(parent=banCont, align=uiconst.CENTER, fontsize=36, color=(1, 0, 0, 1)) 47 self.countdownTimer = timerstuff.AutoTimer(100, self.UpdateTimer) 48 uicore.registry.SetFocus(self) 49 self.MakeUnKillable() 50 51 def Submit(self, *args): 52 machoNet = sm.GetService('machoNet') 53 remoteTourneyMgr = machoNet.ConnectToRemoteService('tourneyMgr', self.respondToNodeID) 54 banTypes = [] 55 for choice in self.banChoices: 56 shipTypeToBan = choice.GetValue() 57 if shipTypeToBan != -1: 58 banTypes.append(shipTypeToBan) 59 60 remoteTourneyMgr.BanShip(self.banID, banTypes) 61 self.Close() 62 63 def UpdateTimer(self): 64 timeDiffMS = max(0, blue.os.TimeDiffInMs(blue.os.GetWallclockTime(), self.deadline)) 65 self.countdownText.text = '%.1f' % (float(timeDiffMS) / 1000.0,) 66 if timeDiffMS == 0: 67 self.MakeKillable() 68 self.countdownTimer = None