unlocked.py (5552B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ess\bracket\reserve_bank\unlocked.py 2 import locks 3 import threadutils 4 import uthread2 5 from carbonui import uiconst 6 from carbonui.control.button import Button 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.uianimations import animations 9 from dynamicresources.client import text 10 from dynamicresources.client.ess.bracket.label import Header 11 from dynamicresources.client.ess.bracket.notification import COLOR_ALERT, COLOR_WARN, ICON_ALERT, ICON_WARN, TransitionNotification 12 from dynamicresources.client.ess.bracket.state_machine import State, StateMachine, Transition 13 from dynamicresources.client.service import get_dynamic_resource_service 14 from player_messaging.client.ui_message import prompt_player_fsd_dialog 15 16 class Unlocked(State): 17 18 def __init__(self, panel): 19 super(Unlocked, self).__init__() 20 self._panel = panel 21 self._watch_token = None 22 self._state_machine = StateMachine() 23 24 def enter(self): 25 self._on_state_update() 26 27 def exit(self): 28 self._panel.clear_force_collapse() 29 self._panel.unfocus() 30 31 def close(self): 32 if self._state_machine: 33 self._state_machine.close() 34 35 def _on_state_update(self, *args): 36 service = get_dynamic_resource_service() 37 linked, self._watch_token = service.ess_state_provider.select(callback=self._on_state_update, lens=lambda s: s.reserve_bank.linked) 38 if linked: 39 self._panel.focus() 40 self._state_machine.move_to(Linked(self._panel)) 41 else: 42 self._panel.unfocus() 43 self._state_machine.move_to(Unlinked(self._panel)) 44 45 46 class Unlinked(State): 47 48 def __init__(self, panel): 49 self._panel = panel 50 self._content = None 51 self._button = None 52 53 def enter(self): 54 self._content = ContainerAutoSize(parent=self._panel.content) 55 animations.FadeTo(self._content, duration=0.3) 56 Header(parent=self._content, align=uiconst.TOPLEFT, text=text.title_reserve_bank()) 57 self._button = Button(parent=self._content, align=uiconst.TOPLEFT, top=30, label=text.action_link_to_reserve_bank(), func=self._link, args=()) 58 59 def close(self): 60 self._content.Close() 61 62 @locks.SingletonCall 63 @threadutils.threaded 64 def _link(self): 65 self._button.Disable() 66 try: 67 service = get_dynamic_resource_service() 68 error = service.RequestESSReserveBankLink() 69 if error is not None: 70 message = text.link_error_description(error) 71 if message is not None: 72 prompt_player_fsd_dialog('CustomNotify', {'notify': message}) 73 uthread2.sleep(1.0) 74 finally: 75 if not self._button.destroyed: 76 self._button.Enable() 77 78 79 class Linked(State): 80 81 def __init__(self, panel): 82 self._panel = panel 83 self._content = None 84 self._button = None 85 86 def enter(self): 87 self._content = ContainerAutoSize(parent=self._panel.content) 88 return Link(self._content, self._panel) 89 90 def exit(self): 91 transition = Unlink(self._panel, self._content) 92 self._content = None 93 return transition 94 95 def close(self): 96 if self._content: 97 self._content.Close() 98 99 100 class Link(Transition): 101 102 def __init__(self, content, panel): 103 super(Link, self).__init__() 104 self.content = content 105 self.panel = panel 106 self._button = None 107 108 def animation(self): 109 notification = TransitionNotification(parent=self.content, align=uiconst.TOPLEFT, text=text.reserve_bank_linked(), iconHexColor=COLOR_WARN, icon=ICON_WARN) 110 notification.show() 111 self.sleep(2.0, interruptable=False) 112 notification.hide(close=True) 113 self.sleep(0.3, interruptable=False) 114 animations.FadeTo(self.content, duration=0.3, callback=self.panel.force_collapse) 115 Header(parent=self.content, align=uiconst.TOPLEFT, text=text.title_reserve_bank()) 116 self._button = Button(parent=self.content, align=uiconst.TOPLEFT, top=30, label=text.action_unlink_from_reserve_bank(), func=self._unlink, args=()) 117 118 @locks.SingletonCall 119 @threadutils.threaded 120 def _unlink(self): 121 self._button.Disable() 122 try: 123 service = get_dynamic_resource_service() 124 service.RequestESSReserveBankUnlink() 125 finally: 126 uthread2.sleep(1.0) 127 if not self._button.destroyed: 128 self._button.Enable() 129 130 131 class Unlink(Transition): 132 133 def __init__(self, panel, content): 134 super(Unlink, self).__init__() 135 self.panel = panel 136 self.content = content 137 138 def animation(self): 139 animations.FadeOut(self.content, duration=0.3) 140 self.sleep(0.31) 141 self.content.Flush() 142 self.content.opacity = 1.0 143 with self.panel.tracking_override(anchor=(0.0, 0.5), offset=(0, 0)): 144 notification = TransitionNotification(parent=self.content, align=uiconst.TOPLEFT, text=text.reserve_bank_unlinked(), iconHexColor=COLOR_ALERT, icon=ICON_ALERT) 145 notification.show() 146 self.sleep(2.0, interruptable=False) 147 notification.hide(close=True) 148 self.sleep(0.3, interruptable=False) 149 self.panel.clear_force_collapse() 150 151 def on_close(self): 152 self.content.Close() 153 154 155 from dynamicresources.client.ess.bracket.debug import __reload_update__