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

structureSelector.py (3481B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\structure\components\structureSelector.py
      2 import eveicon
      3 from carbonui import uiconst, TextAlign
      4 from carbonui.control.buttonIcon import ButtonIcon
      5 from carbonui.primitives.flowcontainer import FlowContainer
      6 from carbonui.primitives.vectorarc import VectorArc
      7 from carbonui.primitives.container import Container
      8 from eve.client.script.ui.control.eveLabel import EveCaptionLarge
      9 from localization import GetByLabel
     10 
     11 class StructureNameSelector(FlowContainer):
     12 
     13     def __init__(self, options = None, selected_index = 0, callback = None, *args, **kwargs):
     14         super(StructureNameSelector, self).__init__(*args, **kwargs)
     15         if options is None:
     16             raise ValueError('No options list provided')
     17         self._options = options
     18         self._selected_index = selected_index
     19         self._callback = callback
     20         self._name_label = None
     21         self._construct_layout()
     22 
     23     def _construct_layout(self):
     24         button_size = 26
     25         icon_size = 8
     26         text_width = 240
     27         left_arrow_cont = Container(parent=self, name='left_arrow_cont', align=uiconst.NOALIGN, width=button_size, height=button_size)
     28         VectorArc(name='circle', parent=left_arrow_cont, align=uiconst.CENTER, radius=0.5 * button_size, lineWidth=1, fill=False, glowBrightness=0)
     29         ButtonIcon(name='prev_button', parent=left_arrow_cont, align=uiconst.CENTER, width=button_size, height=button_size, iconSize=icon_size, texturePath=eveicon.chevron_left, func=self.select_prev)
     30         label_container = Container(name='label_container', parent=self, align=uiconst.NOALIGN, width=text_width, height=button_size, state=uiconst.UI_NORMAL)
     31         self._name_label = EveCaptionLarge(name='name_label', parent=label_container, align=uiconst.CENTER, textAlign=TextAlign.CENTER, width=240)
     32         label_container.hint = GetByLabel('UI/Personalization/PaintTool/SelectedStructureTooltip')
     33         right_arrow_cont = Container(parent=self, name='right_arrow_cont', align=uiconst.NOALIGN, width=button_size, height=button_size)
     34         VectorArc(name='circle', parent=right_arrow_cont, align=uiconst.CENTER, radius=0.5 * button_size, lineWidth=1, fill=False, glowBrightness=0)
     35         ButtonIcon(name='next_button', parent=right_arrow_cont, align=uiconst.CENTER, width=button_size, height=button_size, iconSize=icon_size, texturePath=eveicon.chevron_right, func=self.select_next)
     36 
     37     def select_prev(self):
     38         if self._selected_index == 0:
     39             self.select_by_index(len(self._options) - 1)
     40         else:
     41             self.select_by_index(self._selected_index - 1)
     42 
     43     def select_next(self):
     44         if self._selected_index == len(self._options) - 1:
     45             self.select_by_index(0)
     46         else:
     47             self.select_by_index(self._selected_index + 1)
     48 
     49     def select_by_index(self, index, notify = True):
     50         self._selected_index = index
     51         selected_name, selected_value = self._options[self._selected_index]
     52         self._name_label.text = selected_name
     53         if notify and self._callback:
     54             self._callback(self, selected_name, selected_value)
     55 
     56     def select_by_value(self, value, notify = True):
     57         for i, option in enumerate(self._options):
     58             if option[1] == value:
     59                 self.select_by_index(i, notify=notify)
     60                 return
     61 
     62     def get_value(self):
     63         return self._options[self._selected_index][1]