depletionPinManager.py (6732B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\planet\depletionPinManager.py 2 import carbonui.const as uiconst 3 from carbonui.control.singlelineedits.singleLineEditFloat import SingleLineEditFloat 4 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger 5 from carbonui.primitives.container import Container 6 from carbonui.util.color import Color 7 from eve.client.script.ui.control import eveLabel, eveScroll 8 from carbonui.button.group import ButtonGroup 9 from eve.client.script.ui.control.entries.generic import Generic 10 from eve.client.script.ui.control.entries.util import GetFromClass 11 from carbonui.control.window import Window 12 from eve.common.lib import appConst as const 13 14 class DepletionManager(Window): 15 __guid__ = 'form.DepletionManager' 16 default_windowID = 'depletionManager' 17 18 def ApplyAttributes(self, attributes): 19 Window.ApplyAttributes(self, attributes) 20 self.selected = None 21 self.SetCaption('Depletion Manager') 22 self.SetMinSize([280, 500]) 23 headerContainer = Container(name='headerParent', parent=self.sr.main, align=uiconst.TOTOP, height=100, padding=(2, 2, 2, 2)) 24 text = "This gives you a list of depletion\npoints that you've placed on the planet.\nYou can edit some aspects of these points\n * amount - is the base extraction amount\n * duration - is the in minutes and tells how many times the program will be resubmitted\n * headRadius - tells the size of the head\n " 25 eveLabel.EveLabelMedium(parent=headerContainer, text=text, align=uiconst.TOALL) 26 timeContainer = Container(name='timeParent', parent=self.sr.main, align=uiconst.TOBOTTOM, height=40) 27 editContainer = Container(name='editParent', parent=self.sr.main, align=uiconst.TOBOTTOM, top=20, height=50, padTop=12) 28 scrollContainer = Container(name='scrollParent', parent=self.sr.main, align=uiconst.TOALL) 29 self.depletionPointScroll = eveScroll.Scroll(parent=scrollContainer, align=uiconst.TOALL, padding=(0, 30 const.defaultPadding, 31 0, 32 const.defaultPadding)) 33 self.depletionPointScroll.multiSelect = 0 34 self.pinManager = attributes.get('pinManager', None) 35 amountContainer = Container(name='amountParent', parent=editContainer, align=uiconst.TOLEFT, width=90) 36 durationContainer = Container(name='durationParent', parent=editContainer, align=uiconst.TOLEFT, width=90) 37 headRadiusContainer = Container(name='headRadiusParent', parent=editContainer, align=uiconst.TOLEFT, width=90) 38 self.amountEdit = SingleLineEditInteger(name='amount', parent=amountContainer, align=uiconst.TOPLEFT, pos=(const.defaultPadding, 39 1, 40 80, 41 0), label='amount', OnReturn=self.OnAmountSubmit) 42 self.amountEdit.OnFocusLost = self.OnAmountSubmit 43 self.durationEdit = SingleLineEditInteger(name='duration', parent=durationContainer, align=uiconst.TOPLEFT, pos=(const.defaultPadding, 44 1, 45 80, 46 0), label='duration', OnReturn=self.OnDurationSubmit) 47 self.durationEdit.OnFocusLost = self.OnDurationSubmit 48 self.headRadiusEdit = SingleLineEditFloat(name='headRadius', parent=headRadiusContainer, align=uiconst.TOPLEFT, pos=(const.defaultPadding, 49 1, 50 80, 51 0), label='headRadius', OnReturn=self.OnHeadRadiusSubmit) 52 self.headRadiusEdit.OnFocusLost = self.OnHeadRadiusSubmit 53 self.timeEdit = SingleLineEditInteger(name='timeEdit', parent=timeContainer, align=uiconst.TOPLEFT, pos=(const.defaultPadding, 54 1, 55 80, 56 0), label='Time in days', setvalue='14') 57 self.LoadDepletionPointScroll() 58 self.sr.saveDeleteButtons = ButtonGroup(btns=[['Submit', self.Submit, ()]], parent=self.sr.main, idx=0) 59 60 def LoadDepletionPointScroll(self): 61 scrolllist = [] 62 for point in self.pinManager.depletionPoints: 63 scrolllist.append(GetFromClass(Generic, {'label': '%d<t>%d<t>%d<t>%.3f' % (point.index, 64 point.GetAmount(), 65 point.GetDuration(), 66 point.GetHeadRadius()), 67 'index': point.index, 68 'OnClick': self.OnDepletionPointClicked})) 69 70 self.depletionPointScroll.Load(contentList=scrolllist, headers=['index', 71 'amount', 72 'duration', 73 'headRadius']) 74 75 def Submit(self): 76 totalDuration = int(self.timeEdit.GetValue()) * const.DAY 77 self.pinManager.GMRunDepletionSim(totalDuration) 78 79 def OnDepletionPointClicked(self, entry): 80 index = entry.sr.node.index 81 self.selected = index 82 depletionPoint = self.pinManager.depletionPoints[index] 83 duration = depletionPoint.GetDuration() 84 amount = depletionPoint.GetAmount() 85 headRadius = depletionPoint.GetHeadRadius() 86 self.amountEdit.SetValue(str(amount)) 87 self.durationEdit.SetValue(str(duration)) 88 self.headRadiusEdit.SetValue(str(headRadius)) 89 for i, depletionPoint in enumerate(self.pinManager.depletionPoints): 90 if i == index: 91 depletionPoint.drillArea.pinColor = Color.GREEN 92 else: 93 depletionPoint.drillArea.pinColor = Color.YELLOW 94 95 def GetSelectedDepletionPoint(self): 96 if self.selected is None: 97 return 98 return self.pinManager.depletionPoints[self.selected] 99 100 def OnAmountSubmit(self, *args): 101 if not self or self.destroyed: 102 return 103 newAmount = int(self.amountEdit.GetValue()) 104 depletionPoint = self.GetSelectedDepletionPoint() 105 if depletionPoint is None: 106 return 107 depletionPoint.amount = newAmount 108 self.LoadDepletionPointScroll() 109 110 def OnDurationSubmit(self, *args): 111 if not self or self.destroyed: 112 return 113 depletionPoint = self.GetSelectedDepletionPoint() 114 if depletionPoint is None: 115 return 116 newDuration = int(self.durationEdit.GetValue()) 117 depletionPoint.duration = newDuration 118 self.LoadDepletionPointScroll() 119 120 def OnHeadRadiusSubmit(self, *args): 121 if not self or self.destroyed: 122 return 123 depletionPoint = self.GetSelectedDepletionPoint() 124 if depletionPoint is None: 125 return 126 newHeadRadius = float(self.headRadiusEdit.GetValue()) 127 depletionPoint.headRadius = newHeadRadius 128 depletionPoint.drillArea.pinRadius = newHeadRadius 129 self.LoadDepletionPointScroll() 130 131 def _OnClose(self, *args): 132 for depletionPoint in self.pinManager.depletionPoints: 133 depletionPoint.drillArea.pinColor = Color.YELLOW