baseGuide.py (3995B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\agencyNew\ui\contentPages\baseGuide.py 2 from carbonui import uiconst 3 from carbonui.control.baseScrollContEntry import BaseScrollContEntry 4 from carbonui.control.scrollContainer import ScrollContainer 5 from carbonui.control.section import Section 6 from carbonui.primitives.container import Container 7 from carbonui.text.styles import TextBody 8 from eve.client.script.ui.quickFilter import QuickFilterEdit 9 from localization import GetByLabel 10 11 class BaseTopic(object): 12 LABELS = {} 13 ORDERED = [] 14 15 @staticmethod 16 def get_label(topic_id): 17 return BaseTopic.LABELS[topic_id] 18 19 20 class BaseContentGuide(Container): 21 default_padding = 20 22 topics = BaseTopic 23 24 def __init__(self, *args, **kwargs): 25 super(BaseContentGuide, self).__init__(*args, **kwargs) 26 self._panels = {} 27 self._topic_search = None 28 self._topic_scroll = None 29 self._construct_layout() 30 31 def _select_topic(self, topic_id): 32 for panel_topic_id, panel in self._panels.items(): 33 panel.state = uiconst.UI_PICKCHILDREN if panel_topic_id == topic_id else uiconst.UI_HIDDEN 34 35 def _construct_layout(self): 36 self._construct_topic_section() 37 self._create_panels() 38 self._populate_topic_scroll() 39 40 def _construct_topic_section(self): 41 topic_section = Section(name='topic_section', parent=self, align=uiconst.TOLEFT_PROP, width=0.25, headerText=GetByLabel('UI/Agency/PirateIncursions/Guides/GuideBrowserSectionTitle')) 42 self._topic_search = QuickFilterEdit(name='topic_search', parent=topic_section, align=uiconst.TOTOP, height=24, padTop=5) 43 self._topic_search.ReloadFunction = self.on_search_changed 44 self._topic_scroll = ScrollContainer(name='topic_scroll', parent=topic_section, align=uiconst.TOALL, top=5, multiSelect=False) 45 46 def _create_panels(self): 47 pass 48 49 def _populate_topic_scroll(self): 50 self._topic_scroll.Flush() 51 topics_to_display = self._get_filtered_topics() 52 for topic_id in topics_to_display: 53 entry = TopicScrollEntry(parent=self._topic_scroll, topic_id=topic_id, label_text=self.topics.get_label(topic_id)) 54 entry.on_clicked.connect(self.on_topic_selected) 55 56 def _get_filtered_topics(self): 57 search_text = self._topic_search.GetValue().lower() 58 if len(search_text) < 3: 59 return self.topics.ORDERED 60 filtered_topics = [] 61 for topic_id in self.topics.ORDERED: 62 if topic_id in filtered_topics: 63 continue 64 topic_label = self.topics.get_label(topic_id).lower() 65 if search_text in topic_label: 66 filtered_topics.append(topic_id) 67 continue 68 panel_texts = self._panels[topic_id].get_searchable_strings() 69 for text in panel_texts: 70 if topic_id not in filtered_topics and search_text in text.lower(): 71 filtered_topics.append(topic_id) 72 continue 73 74 return filtered_topics 75 76 def on_search_changed(self): 77 self._populate_topic_scroll() 78 79 def on_topic_selected(self, scroll_entry): 80 self._select_topic(scroll_entry.topic_id) 81 82 83 class TopicScrollEntry(BaseScrollContEntry): 84 default_height = 30 85 86 def __init__(self, *args, **kwargs): 87 self._topic_id = None 88 self._label_text = '' 89 super(TopicScrollEntry, self).__init__(*args, **kwargs) 90 91 def ApplyAttributes(self, attributes): 92 super(TopicScrollEntry, self).ApplyAttributes(attributes) 93 self._topic_id = attributes.Get('topic_id', None) 94 self._label_text = attributes.Get('label_text', None) 95 self._construct_layout() 96 97 def _construct_layout(self): 98 TextBody(parent=self, name='label', align=uiconst.TOLEFT, text=self._label_text, padding=5) 99 100 @property 101 def topic_id(self): 102 return self._topic_id