missingItemsPopup.py (4922B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\missingItemsPopup.py 2 import evetypes 3 from carbon.common.script.sys.serviceConst import ROLE_GML 4 from carbonui.primitives.container import Container 5 from carbonui.util.sortUtil import SortListOfTuples 6 from carbonui.button.group import ButtonGroup 7 from eve.client.script.ui.control.entries.item import Item 8 from eve.client.script.ui.control.entries.util import GetFromClass 9 from eve.client.script.ui.control.eveLabel import EveCaptionLarge, EveLabelMedium 10 from eve.client.script.ui.control.eveScroll import Scroll 11 from carbonui.control.window import Window 12 import carbonui.const as uiconst 13 from eve.client.script.ui.control.themeColored import SpriteThemeColored 14 from eve.common.lib.appConst import defaultPadding 15 from localization import GetByLabel 16 from player_messaging.client.ui_message import prompt_player_fsd_dialog 17 from shipfitting.multiBuyUtil import BuyMultipleTypesWithQty 18 import dynamicitemattributes 19 20 class BuyAllMessageBox(Window): 21 __guid__ = 'BuyAllMessageBox' 22 default_width = 340 23 default_height = 210 24 default_windowID = 'buyAllMessageBox' 25 default_iconNum = 'res:/ui/Texture/WindowIcons/info.png' 26 27 def ApplyAttributes(self, attributes): 28 Window.ApplyAttributes(self, attributes) 29 self.sr.main.clipChildren = True 30 self.MakeUnMinimizable() 31 self.HideHeader() 32 descText = attributes.missingText 33 self.faildToLoadInfo = attributes.faildToLoadInfo 34 self.fitting = attributes.fitting 35 self.topParent = Container(name='topParent', parent=self.GetMainArea(), align=uiconst.TOTOP, height=52, clipChildren=True) 36 SpriteThemeColored(name='mainicon', parent=self.topParent, state=uiconst.UI_DISABLED, pos=(0, -3, 64, 64), texturePath=self.iconNum, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW) 37 title = GetByLabel('UI/Common/Information') 38 caption = EveCaptionLarge(text=title, align=uiconst.CENTERLEFT, parent=self.topParent, left=64, width=270) 39 self.topParent.height = max(56, caption.textheight + 16) 40 descLabel = EveLabelMedium(parent=self.sr.main, text=descText, align=uiconst.TOTOP, padding=(11, 41 11, 42 defaultPadding, 43 defaultPadding)) 44 buttonGroup = ButtonGroup(parent=self.sr.main, idx=0) 45 buyAllBtn = buttonGroup.AddButton(GetByLabel('UI/Market/MarketQuote/BuyAll'), self.BuyAll) 46 closeBtn = buttonGroup.AddButton(GetByLabel('/Carbon/UI/Common/Close'), self.Close) 47 if session.role & ROLE_GML == ROLE_GML: 48 buttonGroup.AddButton('GM: Give all', self.GiveAllGM) 49 self.typeScroll = Scroll(name='typeScroll', parent=self.sr.main, padding=(defaultPadding, 50 0, 51 defaultPadding, 52 0)) 53 self.LoadTypes(self.faildToLoadInfo) 54 55 def LoadTypes(self, typeIDsAndQty): 56 scrolllist = [] 57 for eachTypeID, qty in typeIDsAndQty.iteritems(): 58 typeName = evetypes.GetName(eachTypeID) 59 scrolllist.append((typeName, GetFromClass(Item, {'label': '%sx %s' % (qty, typeName), 60 'typeID': eachTypeID, 61 'itemID': None, 62 'getIcon': 1}))) 63 64 scrolllist = SortListOfTuples(scrolllist) 65 self.typeScroll.Load(contentList=scrolllist) 66 self.height = self.GetNewHeight() 67 68 def BuyAll(self, *args): 69 BuyMultipleTypesWithQty(self.faildToLoadInfo, self.fitting) 70 self.Close() 71 72 def GetNewHeight(self): 73 contentHeight = self.typeScroll.GetContentHeight() 74 newHeight = 150 + contentHeight 75 return min(400, newHeight) 76 77 def GiveAllGM(self, *args): 78 GiveAllGM(self.faildToLoadInfo) 79 self.Close() 80 81 82 def GiveAllGM(missingDict): 83 return GiveOrLoadAllGM(missingDict, 'create') 84 85 86 def LoadAllGM(missingDict): 87 return GiveOrLoadAllGM(missingDict, 'load me') 88 89 90 def GiveOrLoadAllGM(missingDict, slashCmd): 91 numToCountTo = len(missingDict) + 1 92 header = 'GM Item Gift (%s)' % slashCmd 93 sm.GetService('loading').ProgressWnd(header, '', 1, numToCountTo) 94 counter = 1 95 itemsRemoved = False 96 for typeID, qty in missingDict.iteritems(): 97 if dynamicitemattributes.IsDynamicType(typeID): 98 itemsRemoved = True 99 continue 100 counter += 1 101 sm.GetService('loading').ProgressWnd(header, '', counter, numToCountTo) 102 sm.RemoteSvc('slash').SlashCmd('/%s %s %s' % (slashCmd, typeID, qty)) 103 104 sm.GetService('loading').ProgressWnd('Done', '', numToCountTo, numToCountTo) 105 if itemsRemoved: 106 prompt_player_fsd_dialog('CustomNotify', {'notify': 'Not all items were created'}) 107 108 109 def OpenBuyAllBox(faildToLoadInfoCounters, fitting): 110 faildToLoadInfo = dict(faildToLoadInfoCounters) 111 BuyAllMessageBox.Open(missingText=GetByLabel('UI/Fitting/MissingItemsHeader'), faildToLoadInfo=faildToLoadInfo, fitting=fitting)