skin_states_table.py (2470B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\cosmetics\client\ships\qa\skin_states_table.py 2 import carbonui.const as uiconst 3 from cosmetics.client.ships.ship_skin_signals import on_skin_state_set 4 from eve.client.script.ui.control.eveScroll import Scroll 5 from carbonui.control.window import Window 6 from eve.client.script.ui.control.entries.util import GetFromClass 7 from eve.client.script.ui.control.entries.generic import Generic 8 from carbon.common.script.sys.serviceConst import ROLE_GML 9 10 class SkinStatesTableWindow(Window): 11 __guid__ = 'SkinStatesTableWindow' 12 default_width = 600 13 default_height = 600 14 default_windowID = 'skinStatesTableWindow' 15 default_minSize = [default_width, default_height] 16 17 def __init__(self, *args): 18 super(SkinStatesTableWindow, self).__init__(*args) 19 self.SetCaption('Ship Skin States') 20 self._rebuilding = False 21 self.scroll = Scroll(name='scroll', parent=self.sr.maincontainer, align=uiconst.TOALL) 22 self.populate() 23 on_skin_state_set.connect(self._on_skin_state_set) 24 25 def _OnClose(self, *args, **kw): 26 on_skin_state_set.disconnect(self._on_skin_state_set) 27 super(SkinStatesTableWindow, self)._OnClose(*args, **kw) 28 29 def populate(self): 30 self._rebuilding = True 31 cached_states = sm.GetService('cosmeticsSvc')._skin_state_controller._cache 32 entries = [] 33 for ship_id, skin_state in cached_states.iteritems(): 34 data = [ str(x) or '' for x in [skin_state.character_id, 35 skin_state.ship_instance_id, 36 skin_state.skin_type, 37 skin_state.skin_data] ] 38 entries.append(GetFromClass(SkinStateCacheEntry, {'label': '<t>'.join(data), 39 'skin_state': skin_state})) 40 41 self.scroll.Load(contentList=entries, headers=self._get_headers()) 42 self._rebuilding = False 43 44 def _get_headers(self): 45 return ['char id', 46 'ship id', 47 'skin type', 48 'skin data'] 49 50 def _on_skin_state_set(self, ship_id, skin_state): 51 if not self._rebuilding: 52 self.scroll.Clear() 53 self.populate() 54 55 56 class SkinStateCacheEntry(Generic): 57 __guid__ = 'listentry.SkinStateCacheEntry' 58 __nonpersistvars__ = [] 59 60 def GetMenu(self): 61 if session and session.role & ROLE_GML: 62 menu = [['Flush', self._flush]] 63 return menu 64 65 def _flush(self): 66 pass