confirmWnd.py (5170B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\itemTrader\confirmWnd.py 2 import evetypes 3 from carbonui import const as uiconst 4 from carbonui.button.group import ButtonGroup 5 from carbonui.control.button import Button 6 from carbonui.control.scrollContainer import ScrollContainer 7 from carbonui.control.window import Window 8 from carbonui.primitives.container import Container 9 from carbonui.primitives.containerAutoSize import ContainerAutoSize 10 from carbonui.primitives.gridcontainer import GridContainer 11 from carbonui.primitives.line import Line 12 from eve.client.script.ui.control.eveLabel import Label 13 from eve.common.script.util.eveFormat import FmtISK 14 from localization import GetByLabel 15 from player_messaging.client.ui_message import prompt_player_fsd_dialog 16 17 class ItemTraderDialogPopupWindow(Window): 18 __guid__ = 'form.ItemTraderDialogPopup' 19 default_windowID = 'itemTraderDialogPopup' 20 default_caption = GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/ConfirmationTitle') 21 default_isLightBackgroundConfigurable = False 22 default_isMinimizable = False 23 default_isStackable = False 24 default_isCollapseable = False 25 default_isLockable = False 26 default_isOverlayable = False 27 default_fixedWidth = 420 28 default_fixedHeight = 260 29 default_apply_content_padding = False 30 default_iconNum = 'res:/UI/Texture/WindowIcons/question.png' 31 32 def ApplyAttributes(self, attributes): 33 self.item_trader = attributes.item_trader 34 currentMultiplier = attributes.multiplier 35 currentRecipe = attributes.recipe 36 Window.ApplyAttributes(self, attributes) 37 self.ConstructLayout() 38 self.LoadItemAndPayoutContainers(currentMultiplier, currentRecipe) 39 40 def ConstructLayout(self): 41 self.main_container = Container(name='main_container', parent=self.content, width=self.default_fixedWidth, height=self.default_fixedHeight - 100, align=uiconst.TOTOP) 42 self.grid_container = GridContainer(name='grid_container', parent=self.main_container, contentSpacing=(12, 12), columns=2, padding=(12, 12, 12, 12)) 43 self.items_parent_container = Container(name='items_parent_container', parent=self.grid_container) 44 self.items_label = Label(parent=self.items_parent_container, text=GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/ConfirmationItems'), align=uiconst.TOTOP, padBottom=6) 45 self.items_container = ScrollContainer(name='items_container', parent=self.items_parent_container, align=uiconst.TOALL) 46 self.payouts_parent_container = Container(name='payouts_parent_container', parent=self.grid_container) 47 self.payouts_label = Label(parent=self.payouts_parent_container, text=GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/ConfirmationPayout'), align=uiconst.TOTOP, padBottom=6) 48 self.payouts_container = ScrollContainer(name='payouts_container', parent=self.payouts_parent_container, align=uiconst.TOALL) 49 50 def LoadItemAndPayoutContainers(self, multiplier, recipe): 51 self.items_container.Flush() 52 self.payouts_container.Flush() 53 self.currentMultiplier = multiplier 54 self.currentRecipe = recipe 55 for type_id, qty in recipe.inputItems.iteritems(): 56 newQty = multiplier * qty 57 cont = ContainerAutoSize(parent=self.items_container, align=uiconst.TOTOP, clipChildren=True, padRight=10) 58 Label(parent=cont, text=str(newQty) + ' ' + evetypes.GetName(type_id), align=uiconst.TOPLEFT, autoFadeSides=16, maxLines=1) 59 60 if recipe.inputIsk: 61 Label(parent=self.items_container, text=FmtISK(multiplier * recipe.inputIsk), align=uiconst.TOTOP, padTop=8) 62 for type_id, qty in recipe.outputItems.iteritems(): 63 newQty = multiplier * qty 64 cont = ContainerAutoSize(parent=self.payouts_container, align=uiconst.TOTOP, clipChildren=True) 65 Label(parent=cont, text=str(newQty) + ' ' + evetypes.GetName(type_id), align=uiconst.TOPLEFT, autoFadeSides=16) 66 67 self.action_container = Container(parent=self.sr.main) 68 Line(parent=self.action_container, align=uiconst.TOTOP) 69 self.button_group = ButtonGroup(parent=self.action_container, align=uiconst.CENTER) 70 self.yes_button = Button(parent=self.button_group, name='yes_button', label=GetByLabel('UI/Common/Buttons/Yes'), func=self.OnClickConfirm, state=uiconst.UI_NORMAL) 71 self.no_button = Button(parent=self.button_group, name='no_button', label=GetByLabel('UI/Common/Buttons/No'), func=self.OnClickCancel, state=uiconst.UI_NORMAL) 72 73 def OnClickConfirm(self, *args): 74 success, data = self.ProcessTrade() 75 sm.ScatterEvent('OnItemTraderProcessed', self.item_trader.itemID, self.currentRecipe) 76 if not success: 77 prompt_player_fsd_dialog('CustomNotify', {'notify': GetByLabel('UI/Inflight/SpaceComponents/ItemTrader/ItemTradeFailed')}) 78 self.Close() 79 80 def ProcessTrade(self, *args): 81 item_trader = self.item_trader 82 return item_trader.ProcessTrade(self.currentRecipe.recipeID, self.currentMultiplier) 83 84 def OnClickCancel(self, *args): 85 self.Close()