NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

contentPageZarzakh.py (5299B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\agencyNew\ui\contentPages\contentPageZarzakh.py
      2 from carbonui import uiconst
      3 from carbonui.text.styles import TextBody
      4 from carbonui.control.baseScrollContEntry import BaseScrollContEntry
      5 from carbonui.control.scrollContainer import ScrollContainer
      6 from carbonui.control.section import Section
      7 from carbonui.primitives.container import Container
      8 from eve.client.script.ui.quickFilter import QuickFilterEdit
      9 from eve.client.script.ui.shared.agencyNew.contentGroups import contentGroupConst
     10 from eve.client.script.ui.shared.agencyNew.ui.contentGroupPages.baseContentGroupPage import BaseContentGroupPage
     11 from eve.client.script.ui.shared.agencyNew.ui.contentPages.baseGuide import TopicScrollEntry
     12 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.overview import OverviewPanel
     13 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.rules import RulesPanel
     14 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.hq import HQPanel
     15 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.zones import ZonesPanel
     16 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.jovian import JovianPanel
     17 from eve.client.script.ui.shared.agencyNew.ui.contentPagesUI.zarzakh.panels.shipcaster import ShipcasterPanel
     18 from localization import GetByLabel
     19 
     20 class Topics(object):
     21     OVERVIEW = 'overview'
     22     RULES = 'rules'
     23     HQ = 'hq'
     24     ZONES = 'zones'
     25     JOVIAN = 'jovian'
     26     SHIPCASTER = 'shipcaster'
     27     LABELS = {OVERVIEW: GetByLabel('UI/Agency/Zarzakh/TopicOverview'),
     28      RULES: GetByLabel('UI/Agency/Zarzakh/TopicRules'),
     29      HQ: GetByLabel('UI/Agency/Zarzakh/TopicHQ'),
     30      ZONES: GetByLabel('UI/Agency/Zarzakh/TopicZones'),
     31      JOVIAN: GetByLabel('UI/Agency/Zarzakh/TopicJovian'),
     32      SHIPCASTER: GetByLabel('UI/Agency/Zarzakh/TopicShipcaster')}
     33     ORDERED = [OVERVIEW,
     34      RULES,
     35      HQ,
     36      ZONES,
     37      JOVIAN,
     38      SHIPCASTER]
     39 
     40     @staticmethod
     41     def get_label(topic_id):
     42         return Topics.LABELS[topic_id]
     43 
     44 
     45 class ContentPageZarzakh(BaseContentGroupPage):
     46     default_name = 'ContentPageZarzakh'
     47     default_align = uiconst.TOALL
     48     default_padding = 20
     49     contentGroupID = contentGroupConst.contentGroupZarzakh
     50 
     51     def ConstructLayout(self):
     52         super(ContentPageZarzakh, self).ConstructLayout()
     53         self._construct_topic_section()
     54         self._create_panels()
     55         self._populate_topic_scroll()
     56         self.select_topic(Topics.OVERVIEW)
     57 
     58     def _construct_topic_section(self):
     59         topic_section = Section(name='topic_section', parent=self, align=uiconst.TOLEFT_PROP, width=0.3, headerText=GetByLabel('UI/Agency/PirateIncursions/Guides/GuideBrowserSectionTitle'))
     60         self._topic_search = QuickFilterEdit(name='topic_search', parent=topic_section, align=uiconst.TOTOP, height=24, padTop=5)
     61         self._topic_search.ReloadFunction = self.on_search_changed
     62         self._topic_scroll = ScrollContainer(name='topic_scroll', parent=topic_section, align=uiconst.TOALL, top=5, multiSelect=False)
     63 
     64     def _create_panels(self):
     65         panel_container = Container(name='panel_container', align=uiconst.TOALL, parent=self, padLeft=20)
     66         self._panels = {Topics.OVERVIEW: OverviewPanel(name=Topics.OVERVIEW, parent=panel_container),
     67          Topics.RULES: RulesPanel(name=Topics.RULES, parent=panel_container),
     68          Topics.HQ: HQPanel(name=Topics.HQ, parent=panel_container),
     69          Topics.ZONES: ZonesPanel(name=Topics.ZONES, parent=panel_container),
     70          Topics.JOVIAN: JovianPanel(name=Topics.JOVIAN, parent=panel_container),
     71          Topics.SHIPCASTER: ShipcasterPanel(name=Topics.SHIPCASTER, parent=panel_container)}
     72 
     73     def _populate_topic_scroll(self):
     74         self._topic_scroll.Flush()
     75         topics_to_display = self._get_filtered_topics()
     76         for topic_id in topics_to_display:
     77             entry = TopicScrollEntry(parent=self._topic_scroll, topic_id=topic_id, label_text=Topics.get_label(topic_id))
     78             entry.on_clicked.connect(self.on_topic_selected)
     79 
     80     def _get_filtered_topics(self):
     81         search_text = self._topic_search.GetValue().lower()
     82         if len(search_text) < 3:
     83             return Topics.ORDERED
     84         filtered_topics = []
     85         for topic_id in Topics.ORDERED:
     86             if topic_id in filtered_topics:
     87                 continue
     88             topic_label = Topics.get_label(topic_id).lower()
     89             if search_text in topic_label:
     90                 filtered_topics.append(topic_id)
     91                 continue
     92             panel_texts = self._panels[topic_id].get_searchable_strings()
     93             for text in panel_texts:
     94                 if topic_id not in filtered_topics and search_text in text.lower():
     95                     filtered_topics.append(topic_id)
     96                     continue
     97 
     98         return filtered_topics
     99 
    100     def select_topic(self, topic_id):
    101         for panel_topic_id, panel in self._panels.items():
    102             panel.state = uiconst.UI_PICKCHILDREN if panel_topic_id == topic_id else uiconst.UI_HIDDEN
    103 
    104     def on_search_changed(self):
    105         self._populate_topic_scroll()
    106 
    107     def on_topic_selected(self, scroll_entry):
    108         self.select_topic(scroll_entry.topic_id)