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

warningpanel.py (10120B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\agentinteraction\warningpanel.py
      2 import carbonui.text.styles
      3 from agentinteraction.textutils import get_menu_for_item
      4 from carbonui.control.scrollContainer import ScrollContainer
      5 from agentinteraction.constUI import HEADER_SIZE_MEDIUM, PADDING_XSMALL, PADDING_SMALL
      6 from agentinteraction.reward import RewardType, Reward, typeCredits
      7 import carbonui
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.primitives.frame import Frame
     10 from carbonui import uiconst
     11 from carbonui.primitives.container import Container
     12 from carbonui.primitives.sprite import Sprite
     13 from carbonui.util.color import Color
     14 from eve.client.script.ui import eveColor
     15 from eve.client.script.ui.control import eveLabel
     16 from eve.client.script.ui.control.eveIcon import Icon
     17 from eve.client.script.ui.control.eveLabel import Label
     18 from eve.client.script.ui.control.infoIcon import InfoGlyphIcon
     19 from eve.common.script.util.eveFormat import FmtISK
     20 from evelink.client import blueprint_link, type_link
     21 from localization import GetByLabel
     22 import trinity
     23 ICON_SIZE = 64
     24 
     25 class WarningPanel(ContainerAutoSize):
     26     USE_TEST_REWARDS = False
     27     default_padTop = PADDING_SMALL
     28     default_alignMode = uiconst.TOTOP
     29     CONTENT_BACKGROUND_COLOR = None
     30     CONTENT_COLOR = None
     31     TITLE_PATH = None
     32     HAS_UPPERCASE_TITLE = False
     33     TITLE_COLOR = None
     34     TEXT_PATH = None
     35     TEXT_COLOR = Color.GRAY6
     36     TEXTS_PADDING_H = 10
     37     TEXTS_PADDING_TOP_BOTTOM = 10
     38     TEXTS_PADDING_BOTTOM = 17
     39     LINE_WIDTH = 6
     40     CONTENT_LEFT_PAD = 5
     41     SUBTEXT_FONTSIZE = 14
     42     SUBTEXT_COLOR = None
     43     PADDING_TEXT_TO_SUBTEXT = 2
     44 
     45     def ApplyAttributes(self, attributes):
     46         self.line_container = None
     47         self.title = None
     48         self.title_cont = None
     49         self.text = None
     50         super(WarningPanel, self).ApplyAttributes(attributes)
     51         self._build_content()
     52 
     53     def _build_content(self):
     54         self._add_content()
     55 
     56     def _add_content(self):
     57         self.content_container = ContainerAutoSize(name='content_container', parent=self, align=uiconst.TOTOP, height=self.height, alignMode=uiconst.TOTOP)
     58         self._add_icon()
     59         Frame(name='warning_panel_background', bgParent=self.content_container, texturePath='res:/UI/Texture/Shared/bg_cutoff.png', textureSecondaryPath='res:/UI/Texture/Shared/DarkStyle/solid.png', spriteEffect=trinity.TR2_SFX_MODULATE, color=self.CONTENT_BACKGROUND_COLOR, cornerSize=6)
     60         self._add_texts()
     61 
     62     def _add_icon(self):
     63         self.icon_container = Container(name='icon_container', parent=self.content_container, align=uiconst.TOLEFT, width=ICON_SIZE, state=uiconst.UI_NORMAL, padLeft=PADDING_XSMALL)
     64         self.icon_container.Hide()
     65         self.icon = Icon(name='icon', parent=self.icon_container, align=uiconst.CENTER, width=ICON_SIZE, height=ICON_SIZE, state=uiconst.UI_DISABLED)
     66 
     67     def _add_texts(self):
     68         self.texts_container = ContainerAutoSize(name='texts_container', parent=self.content_container, align=uiconst.TOTOP, padding=(self.TEXTS_PADDING_H,
     69          self.TEXTS_PADDING_TOP_BOTTOM,
     70          self.TEXTS_PADDING_H,
     71          self.TEXTS_PADDING_TOP_BOTTOM), alignMode=uiconst.TOTOP)
     72         self._add_title()
     73         self._add_text()
     74 
     75     def _add_title(self):
     76         if self.TITLE_PATH:
     77             title = GetByLabel(self.TITLE_PATH)
     78             if self.HAS_UPPERCASE_TITLE:
     79                 title = title.upper()
     80             self.title_cont = ContainerAutoSize(parent=self.texts_container, align=uiconst.TOTOP, alignMode=uiconst.TOTOP)
     81             self.title = carbonui.text.styles.TextHeader(name='title', parent=self.title_cont, align=uiconst.TOTOP, text=title, color=self.TITLE_COLOR)
     82 
     83     def _add_text(self):
     84         if self.TEXT_PATH:
     85             self.text = carbonui.text.styles.TextBody(name='text', parent=self.texts_container, align=uiconst.TOTOP, color=self.TEXT_COLOR)
     86             self._update_text()
     87 
     88     def _add_subtext(self):
     89         self.subtext = Label(name='subtext', parent=self.texts_container, align=uiconst.TOTOP, fontsize=self.SUBTEXT_FONTSIZE, color=self.SUBTEXT_COLOR, padTop=self.PADDING_TEXT_TO_SUBTEXT)
     90 
     91     def _update_text(self):
     92         if self.TEXT_PATH:
     93             text = self._get_text()
     94             self.text.SetText(text)
     95 
     96     def _get_text(self):
     97         return GetByLabel(self.TEXT_PATH)
     98 
     99     def update_items(self, items):
    100         if self.USE_TEST_REWARDS:
    101             items = [Reward(RewardType.NORMAL, typeCredits, quantity=1000)]
    102         self.icon_container.Hide()
    103         for item in items:
    104             self._load_item(item)
    105             self.icon_container.Show()
    106             return
    107 
    108     def _load_item(self, item):
    109         hint = item.get_hint()
    110         self.icon_container.SetHint(hint)
    111         type_id = item.type_id
    112         is_blueprint_copy = item.is_blueprint_copy()
    113         self.icon.LoadIconByTypeID(type_id, ignoreSize=True, isCopy=is_blueprint_copy)
    114         if item.is_normal_type():
    115             self.icon_container.GetMenu = lambda *args: self._get_menu_for_item(item)
    116 
    117     def _get_menu_for_item(self, item):
    118         return get_menu_for_item(item)
    119 
    120 
    121 class ShipRequirementsPanel(WarningPanel):
    122     CONTENT_BACKGROUND_COLOR = eveColor.CHERRY_RED[:3] + (0.4,)
    123     CONTENT_COLOR = eveColor.DANGER_RED
    124     TITLE_COLOR = eveColor.DANGER_RED
    125     TEXT_COLOR = Color.WHITE
    126     TITLE_PATH = 'UI/Generic/Warning'
    127     TEXT_PATH = 'UI/Agents/StandardMission/ShipRequirementsText'
    128     HAS_UPPERCASE_TITLE = True
    129 
    130     def __init__(self, dungeon_id = None, in_valid_ship = False, ship_window_header = '', *args, **kwargs):
    131         self.in_valid_ship = in_valid_ship
    132         self.dungeon_id = dungeon_id
    133         self.ship_window_header = ship_window_header
    134         super(ShipRequirementsPanel, self).__init__(*args, **kwargs)
    135 
    136     def _build_content(self):
    137         container = ContainerAutoSize(parent=self, align=carbonui.Align.TOTOP, alignMode=carbonui.Align.TOLEFT, height=20, padBottom=8)
    138         carbonui.text.styles.TextBody(parent=container, align=carbonui.Align.TOLEFT, text=GetByLabel('UI/Dungeons/ShipRestrictionsLabel'), padRight=8)
    139         InfoGlyphIcon(parent=container, align=carbonui.Align.TOLEFT, width=16, height=16, func=self._open_ship_restrictions)
    140         self._add_line()
    141         self._add_content()
    142         if self.in_valid_ship:
    143             self.title_cont.Hide()
    144             self.content_container.Hide()
    145 
    146     def _open_ship_restrictions(self, *args, **kwargs):
    147         from evedungeons.client.ship_restrictions_window import ShipRestrictionsWindow
    148         ShipRestrictionsWindow.Open(dungeon_id=self.dungeon_id, header_text=self.ship_window_header)
    149 
    150     def _add_line(self):
    151         self.line_container = Container(name='line_container', parent=self, align=uiconst.TOLEFT, width=self.LINE_WIDTH, clipChildren=True, padRight=5)
    152         Sprite(name='line', parent=self.line_container, align=uiconst.TOALL, texturePath='res:/UI/Texture/Classes/AgentInteraction/HazardLine_6px.png', color=self.CONTENT_COLOR, tileY=True, state=uiconst.UI_DISABLED)
    153 
    154     def set_restrictions_info(self, dungeon_id, in_valid_ship, ship_window_header = ''):
    155         self.in_valid_ship = in_valid_ship
    156         self.dungeon_id = dungeon_id
    157         self.ship_window_header = ship_window_header
    158         if self.in_valid_ship:
    159             self.title_cont.Hide()
    160             self.content_container.Hide()
    161         else:
    162             self.title_cont.Show()
    163             self.content_container.Show()
    164 
    165     def _get_text(self):
    166         return GetByLabel(self.TEXT_PATH, startLink='', endLink='')
    167 
    168 
    169 class GrantedItemsPanel(WarningPanel):
    170     CONTENT_BACKGROUND_COLOR = eveColor.COPPER_OXIDE_GREEN[:3] + (0.4,)
    171     CONTENT_COLOR = eveColor.SUCCESS_GREEN
    172     TITLE_COLOR = Color.WHITE
    173     SUBTEXT_COLOR = CONTENT_COLOR
    174     TITLE_PATH = 'UI/Agents/StandardMission/GrantedItems'
    175     TEXT_PATH = 'UI/Agents/StandardMission/GrantedItemText'
    176     TEXTS_PADDING_TOP_BOTTOM = 14
    177 
    178     def _add_texts(self):
    179         super(GrantedItemsPanel, self)._add_texts()
    180         self._add_subtext()
    181 
    182     def update_items(self, items):
    183         super(GrantedItemsPanel, self).update_items(items)
    184         if self.USE_TEST_REWARDS:
    185             items += [Reward(RewardType.NORMAL, typeCredits, quantity=1000)]
    186             items += [Reward(RewardType.NORMAL, 1230, quantity=1000)]
    187         textList = []
    188         for item in items:
    189             details = item.get_text_details()
    190             if item.is_blueprint_copy():
    191                 text = blueprint_link(item.type_id, runs=item.get_runs_remaining(), isCopy=item.is_blueprint_copy(), te=item.get_productivity_level(), me=item.get_material_level())
    192             elif item.is_normal_type():
    193                 text = type_link(item.type_id, link_text=details)
    194             else:
    195                 text = details
    196             textList.append(text)
    197 
    198         if textList:
    199             text = ', '.join(textList)
    200             self.subtext.SetText(text=text)
    201             self.subtext.state = uiconst.UI_NORMAL
    202 
    203 
    204 class CollateralPanel(WarningPanel):
    205     CONTENT_BACKGROUND_COLOR = eveColor.DUSKY_ORANGE[:3] + (0.4,)
    206     CONTENT_COLOR = eveColor.WARNING_ORANGE
    207     TITLE_PATH = 'UI/Agents/StandardMission/CollateralTitle'
    208     TEXT_PATH = 'UI/Agents/StandardMission/CollateralText'
    209     TITLE_COLOR = Color.WHITE
    210     SUBTEXT_COLOR = CONTENT_COLOR
    211 
    212     def ApplyAttributes(self, attributes):
    213         self.subtext = None
    214         super(CollateralPanel, self).ApplyAttributes(attributes)
    215 
    216     def _add_texts(self):
    217         super(CollateralPanel, self)._add_texts()
    218         self._add_subtext()
    219 
    220     def _load_item(self, item):
    221         super(CollateralPanel, self)._load_item(item)
    222         self.subtext.SetText(text=FmtISK(item.quantity))
    223 
    224 
    225 class DisclaimerPanel(WarningPanel):
    226     CONTENT_BACKGROUND_COLOR = eveColor.SMOKE_BLUE[:3] + (0.4,)
    227     TEXT_COLOR = Color.WHITE
    228     TEXTS_PADDING_TOP_BOTTOM = 14
    229 
    230     def set_text(self, text):
    231         if self.text is None:
    232             self.text = eveLabel.EveLabelMedium(name='text', parent=self.texts_container, align=uiconst.TOTOP, color=self.TEXT_COLOR)
    233         self.text.SetText(text)