designCreationPage.py (6823B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\structure\pages\designCreationPage.py 2 import evetypes 3 from carbonui import AxisAlignment 4 from carbonui import const as uiconst, ButtonVariant 5 from carbonui.control.button import Button 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.fill import Fill 9 from cosmetics.common.structures.const import PAINT_ELIGIBLE_STRUCTURE_TYPE_IDS, StructurePaintSlot, SLOT_ORDER 10 from eve.client.script.ui.cosmetics.structure import const as paintToolConst 11 import eve.client.script.ui.cosmetics.structure.paintToolSelections as paintToolSelections 12 from eve.client.script.ui.cosmetics.structure.components.paintLibraryPanel import PaintLibraryPanel 13 from eve.client.script.ui.cosmetics.structure.components import paintSlot 14 from eve.client.script.ui.cosmetics.structure.components.structureSelector import StructureNameSelector 15 from eve.client.script.ui.cosmetics.structure.components.navigationButtons import BackButton 16 from eve.client.script.ui.cosmetics.structure.paintToolSignals import on_paintwork_selection_changed 17 from eve.client.script.ui.cosmetics.structure.components.previewScene import PreviewPanel 18 from eve.client.script.ui.cosmetics.structure.pages.basePage import BasePage 19 from localization import GetByLabel 20 CAROUSEL_CONT_HEIGHT = 100 21 SLOT_PADDING = 22 22 RIGHT_SIDE_WIDTH = 306 23 24 class DesignCreationPage(BasePage): 25 26 def __init__(self, **kw): 27 self._slots = {} 28 self._selected_slot = None 29 paintToolSelections.SELECTED_PAINTWORK.clear() 30 super(DesignCreationPage, self).__init__(**kw) 31 on_paintwork_selection_changed.connect(self._on_paint_selection_changed) 32 paintToolSelections.SELECTED_STRUCTURE_TYPE.on_change.connect(self._on_structure_selection_changed) 33 self._on_structure_selection_changed(paintToolSelections.SELECTED_STRUCTURE_TYPE.get()) 34 self._select_slot(StructurePaintSlot.PRIMARY) 35 self._update_apply_button() 36 37 def Close(self): 38 super(DesignCreationPage, self).Close() 39 for slot_cont in self._slots.itervalues(): 40 slot_cont.on_paint_slot_clicked.disconnect(self._on_paint_slot_clicked) 41 42 on_paintwork_selection_changed.disconnect(self._on_paint_selection_changed) 43 paintToolSelections.SELECTED_STRUCTURE_TYPE.on_change.disconnect(self._on_structure_selection_changed) 44 45 def _open_page(self): 46 self._live_preview.display = True 47 super(DesignCreationPage, self)._open_page() 48 49 def _close_page(self): 50 self._live_preview.display = False 51 super(DesignCreationPage, self)._close_page() 52 53 def _construct_layout(self): 54 Fill(bgParent=self, name='bgFill', color=(0.0, 0.0, 0.0, 0.4), align=uiconst.TORIGHT, width=RIGHT_SIDE_WIDTH) 55 self._right_side_cont = Container(parent=self, name='rightSideCont', align=uiconst.TORIGHT, width=RIGHT_SIDE_WIDTH, padTop=37, padBottom=54) 56 self._create_nav_button() 57 self._create_apply_button() 58 self._create_paint_library() 59 self._create_paint_slots() 60 self._create_structure_carousel() 61 self._create_live_preview() 62 63 def _create_paint_library(self): 64 self._paint_library = PaintLibraryPanel(parent=self._right_side_cont, name='paintLibrary', align=uiconst.TOALL, padRight=2, padLeft=24, padBottom=26, target_slot=self._selected_slot) 65 66 def _create_nav_button(self): 67 BackButton(name='back_button', parent=self, align=uiconst.TOPLEFT, left=23, top=23, onClick=self._on_back_clicked) 68 69 def _create_apply_button(self): 70 self._apply_button = Button(parent=self._right_side_cont, name='applyButton', align=uiconst.TOBOTTOM, height=40, label=GetByLabel('UI/Personalization/PaintTool/PaintLibrary/Apply'), variant=ButtonVariant.PRIMARY, func=self._on_next_clicked, padLeft=24, padRight=24) 71 72 def _create_structure_carousel(self): 73 structure_carousel_cont = Container(parent=self, name='structureCarouselCont', align=uiconst.TOBOTTOM_NOPUSH, height=CAROUSEL_CONT_HEIGHT) 74 self._structure_selector = StructureNameSelector(name='structureNameSelector', parent=structure_carousel_cont, options=[ (evetypes.GetName(idx), idx) for idx in PAINT_ELIGIBLE_STRUCTURE_TYPE_IDS ], contentAlignment=AxisAlignment.CENTER, contentSpacing=(4, 4), centerContent=True, callback=self._on_structure_select) 75 76 def _create_paint_slots(self): 77 paint_slots_cont = Container(parent=self, name='paintSlotsCont', align=uiconst.TORIGHT_NOPUSH, width=paintSlot.SLOT_SIZE + paintSlot.SELECTED_INDICATOR_WIDTH + 2 * paintSlot.SELECTED_INDICATOR_PADDING) 78 center_cont = ContainerAutoSize(parent=paint_slots_cont, name='centerCont', align=uiconst.CENTER, width=paintSlot.SLOT_SIZE + paintSlot.SELECTED_INDICATOR_WIDTH + 2 * paintSlot.SELECTED_INDICATOR_PADDING) 79 for i, slot_id in enumerate(SLOT_ORDER): 80 paint_slot = paintSlot.PaintSlot(name='paintSlot_%s' % slot_id, parent=center_cont, align=uiconst.TOTOP, height=paintSlot.SLOT_SIZE, slot_id=slot_id, padTop=SLOT_PADDING if i > 0 else 0) 81 paint_slot.on_paint_slot_clicked.connect(self._on_paint_slot_clicked) 82 self._slots[slot_id] = paint_slot 83 84 def _create_live_preview(self): 85 self._live_preview = PreviewPanel(name='preview_panel', parent=self) 86 self._live_preview.display = False 87 88 def _on_paint_slot_clicked(self, slot_id): 89 self._select_slot(slot_id) 90 91 def _select_slot(self, selected_slot_id): 92 for slot_id, slot in self._slots.iteritems(): 93 self._slots[slot_id].set_selected(slot_id == selected_slot_id) 94 95 self._selected_slot = selected_slot_id 96 self._paint_library.set_target_slot(self._selected_slot) 97 98 def _update_apply_button(self): 99 self._apply_button.enabled = any([ x is not None for x in paintToolSelections.SELECTED_PAINTWORK.get_slot_values() ]) 100 101 @staticmethod 102 def _on_structure_select(_combo, _key, value): 103 paintToolSelections.SELECTED_STRUCTURE_TYPE.set(value) 104 105 def _on_structure_selection_changed(self, type_id): 106 self._structure_selector.select_by_value(type_id, notify=False) 107 108 def _on_paint_selection_changed(self, _slot_id, _paint_id): 109 if _slot_id in self._slots: 110 self._slots[_slot_id].update_selected_paint() 111 self._live_preview.update(self._structure_selector.get_value(), fit_in_view=False) 112 self._update_apply_button() 113 114 @staticmethod 115 def _on_back_clicked(): 116 paintToolSelections.SELECTED_PAGE.set(paintToolConst.STRUCTURE_SELECTION_PAGE_ID) 117 118 @staticmethod 119 def _on_next_clicked(_btn): 120 paintToolSelections.SELECTED_PAGE.set(paintToolConst.DESIGN_APPLICATION_PAGE_ID)