hacking.py (6933B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ess\bracket\main_bank\hacking.py 2 import eveui 3 import gametime 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_SUCCESS, COLOR_WARN, ICON_ALERT, ICON_SUCCESS, ICON_WARN, TransitionNotification 12 from dynamicresources.client.ess.bracket.state_machine import State, Transition 13 from dynamicresources.client.service import get_dynamic_resource_service 14 from dynamicresources.common.ess.const import LINK_ERROR_LINK_OCCUPIED 15 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel 16 from player_messaging.client.ui_message import prompt_player_fsd_dialog 17 18 class Hacking(State): 19 20 def __init__(self, panel, link_state): 21 self.panel = panel 22 self._link_id = link_state.link_id 23 self._link_state = link_state 24 self.content = None 25 self.state_token = None 26 27 @property 28 def link_state(self): 29 service = get_dynamic_resource_service() 30 link_state = service.ess_state_provider.state.main_bank.link 31 if link_state is not None: 32 self._link_state = link_state 33 return self._link_state 34 35 def close(self): 36 if self.content: 37 self.content.Close() 38 if self.state_token: 39 self.state_token.clear() 40 41 def enter(self): 42 self.content = ContainerAutoSize(parent=self.panel.content, align=uiconst.TOPLEFT) 43 if session.charid != self.link_state.character_id: 44 45 def display_link_error(): 46 message = text.link_error_description(LINK_ERROR_LINK_OCCUPIED) 47 if message is not None: 48 prompt_player_fsd_dialog('CustomNotify', {'notify': message}) 49 50 Header(parent=self.content, align=uiconst.TOPRIGHT, text=text.title_main_bank()) 51 self._button = Button(parent=self.content, align=uiconst.TOPRIGHT, top=30, label=text.action_hack_main_bank(), func=display_link_error, args=()) 52 53 def on_state_token(token): 54 if self.state_token: 55 self.state_token.clear() 56 self.state_token = token 57 58 return EnterSomeoneElseIsHacking(self.panel, self.content, on_state_token) 59 else: 60 return EnterThisClientIsHacking(self.panel, self.content) 61 62 def exit(self): 63 self.panel.clear_force_collapse() 64 transition = HackResultTransition(self._link_id, self.panel, self.content) 65 self.content = None 66 return transition 67 68 69 class EnterThisClientIsHacking(Transition): 70 71 def __init__(self, panel, content): 72 super(EnterThisClientIsHacking, self).__init__() 73 self.panel = panel 74 self.content = content 75 self._button = None 76 77 def animation(self): 78 with self.panel.tracking_override(anchor=(1.0, 0.5), offset=(0, 0)): 79 notification = TransitionNotification(parent=self.content, align=uiconst.TOPRIGHT, text=text.main_bank_hack_initiated(), iconHexColor=COLOR_WARN, icon=ICON_WARN) 80 notification.show() 81 self.sleep(2.0, interruptable=False) 82 notification.hide(close=True) 83 self.sleep(0.3, interruptable=False) 84 Header(parent=self.content, align=uiconst.TOPRIGHT, text=text.title_main_bank()) 85 self._button = Button(parent=self.content, align=uiconst.TOPRIGHT, top=30, label=text.action_disconnect_main_bank(), func=self._unlink, args=()) 86 animations.FadeTo(self.content, duration=0.3) 87 self.sleep(1.0) 88 self.panel.force_collapse() 89 90 def _unlink(self): 91 self._button.Disable() 92 try: 93 service = get_dynamic_resource_service() 94 service.RequestESSMainBankUnlink() 95 uthread2.sleep(1.0) 96 finally: 97 if not self._button.destroyed: 98 self._button.Enable() 99 100 101 class EnterSomeoneElseIsHacking(Transition): 102 103 def __init__(self, panel, content, on_state_token): 104 super(EnterSomeoneElseIsHacking, self).__init__() 105 self.panel = panel 106 self.content = content 107 self.on_state_token = on_state_token 108 109 def animation(self): 110 self.on_state_token(self.panel.force_collapse()) 111 112 113 class HackResultTransition(Transition): 114 115 def __init__(self, link_id, panel, content): 116 super(HackResultTransition, self).__init__() 117 self.link_id = link_id 118 self.panel = panel 119 self.content = content 120 121 def animation(self): 122 animations.FadeOut(self.content, duration=0.3) 123 self.sleep(0.32) 124 self.content.Flush() 125 self.content.opacity = 1.0 126 with self.panel.tracking_override(anchor=(1.0, 0.5), offset=(0, 0)): 127 wheel = LoadingWheel(parent=self.content, align=uiconst.TOPRIGHT, width=32, height=32, opacity=0.0) 128 animations.FadeIn(wheel, duration=1.0, timeOffset=1.0) 129 link_result = self._wait_for_link_result(self.link_id, timeout=10.0) 130 animations.FadeOut(wheel, duration=0.3, callback=wheel.Close) 131 if link_result is None: 132 self.sleep(0.3, interruptable=False) 133 return 134 if link_result.character_id == session.charid: 135 icon = None 136 iconColor = None 137 if link_result.successful: 138 icon = ICON_SUCCESS 139 iconColor = COLOR_SUCCESS 140 feedback_text = text.main_bank_hack_successful() 141 else: 142 icon = ICON_ALERT 143 iconColor = COLOR_ALERT 144 feedback_text = text.main_bank_disconnected() 145 feedback = TransitionNotification(parent=self.content, align=uiconst.TOPRIGHT, text=feedback_text, iconHexColor=iconColor, icon=icon) 146 feedback.show() 147 self.sleep(3.0, interruptable=False) 148 feedback.hide() 149 self.sleep(0.3, interruptable=False) 150 151 def on_close(self): 152 self.content.Close() 153 154 def _wait_for_link_result(self, link_id, timeout): 155 service = get_dynamic_resource_service() 156 link_result = service.ess_state_provider.state.main_bank.link_result 157 start = gametime.now() 158 while link_result is None or link_result.link_id != link_id: 159 if self.is_stopped or (gametime.now() - start).total_seconds() > timeout: 160 return 161 eveui.wait_for_next_frame() 162 link_result = service.ess_state_provider.state.main_bank.link_result 163 164 return link_result 165 166 167 from dynamicresources.client.ess.bracket.debug import __reload_update__