slotAdder.py (4933B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fitting\slotAdder.py 2 import math 3 import dogma.data as dogma_data 4 from carbonui.const import UI_NORMAL 5 from carbonui.primitives.sprite import Sprite 6 from eve.client.script.ui.shared.fitting.fittingUtil import GetScaleFactor, GetBaseShapeSize 7 import telemetry 8 9 class SlotAdder(object): 10 11 def __init__(self, controller, slotClass): 12 self.controller = controller 13 self.slotClass = slotClass 14 scaleFactor = GetScaleFactor() 15 self.width = int(round(44.0 * scaleFactor)) 16 self.height = int(round(54.0 * scaleFactor)) 17 self.rad = int(239 * scaleFactor) 18 self.center = GetBaseShapeSize() / 2 19 20 def AddSlot(self, parent, flagID, slotClass = None): 21 left, top, cos, sin = self.GetPositionNumbers(self.angle) 22 radCosSin = (self.rad, 23 cos, 24 sin, 25 self.center, 26 self.center) 27 if slotClass is None: 28 slotClass = self.slotClass 29 ret = slotClass(name='%s' % flagID, parent=parent, pos=(left, 30 top, 31 self.width, 32 self.height), rotation=-math.radians(self.angle), opacity=0.0, radCosSin=radCosSin, controller=self.controller.GetSlotController(flagID)) 33 self.angle += self.stepSize 34 return ret 35 36 def StartGroup(self, arcStart, arcLength, numSlots): 37 self.angle = arcStart 38 self.stepSize = arcLength / numSlots 39 40 @telemetry.ZONE_METHOD 41 def GetPositionNumbers(self, angle): 42 cos = math.cos((angle - 90.0) * math.pi / 180.0) 43 sin = math.sin((angle - 90.0) * math.pi / 180.0) 44 left = int(round(self.rad * cos + self.center - self.width / 2.0)) 45 top = int(round(self.rad * sin + self.center - self.height / 2.0)) 46 return (left, 47 top, 48 cos, 49 sin) 50 51 52 class HardpointAdder(object): 53 iconAngle = 313.2 54 markerAngle = 310 55 iconRad = 276 56 markerRad = 278 57 iconSize = 16 58 59 def __init__(self, attributeConst, cX, cY, isleftSide = False): 60 self.isleftSide = isleftSide 61 self.attribute = dogma_data.get_attribute(attributeConst) 62 self.cX = cX 63 self.cY = cY 64 self.slots = [] 65 self.step = 3.0 / GetScaleFactor() 66 if not self.isleftSide: 67 self.iconAngle += 1.8 68 self.markerAngle += 1.8 69 70 def AddIcon(self, parent, texturePath, tooltipCallback): 71 angle = self.iconAngle 72 iconRad = int(self.iconRad * GetScaleFactor()) 73 left, top, cos, sin = self.GetPositionNumbers(angle, iconRad, offset=self.iconSize / 2) 74 icon = Sprite(name='%s_Icon' % self.attribute.name, texturePath=texturePath, parent=parent, state=UI_NORMAL, hint=dogma_data.get_attribute_display_name(self.attribute.attributeID), pos=(left, 75 top, 76 self.iconSize, 77 self.iconSize), idx=0) 78 icon.LoadTooltipPanel = tooltipCallback 79 80 def AddMarkers(self, parent): 81 markerRad = int(self.markerRad * GetScaleFactor()) 82 angle = self.markerAngle - self.step * 7.5 83 for i in xrange(8): 84 left, top, cos, sin = self.GetPositionNumbers(angle, markerRad, offset=8) 85 icon = MarkerIcon(name='%s_%s_Marker' % (i, self.attribute.name), parent=parent, state=UI_NORMAL, pos=(left, 86 top, 87 16, 88 16), hint=dogma_data.get_attribute_display_name(self.attribute.attributeID), idx=0) 89 icon.display = False 90 self.slots.insert(0, icon) 91 angle += self.step 92 93 def GetPositionNumbers(self, angle, rad, offset): 94 if self.isleftSide: 95 angle = 180 - angle 96 cos = math.cos(angle * math.pi / 180.0) 97 sin = math.sin(angle * math.pi / 180.0) 98 left = int(round(rad * cos + self.cX - offset)) 99 top = int(round(rad * sin + self.cY - offset)) 100 return (left, 101 top, 102 cos, 103 sin) 104 105 106 class MarkerIcon(Sprite): 107 slotTaken = 'res:/UI/Texture/classes/Fitting/slotTaken.png' 108 slotLeft = 'res:/UI/Texture/classes/Fitting/slotLeft.png' 109 default_texturePath = slotLeft 110 slotColorNormal = (1.0, 1.0, 1.0, 0.7) 111 slotColorRed = (1.0, 0.0, 0.0, 0.7) 112 slotColorYellow = (1.0, 1.0, 0.0, 0.7) 113 114 def ModifyLook(self, slotIdx, slotsLeft, slotsFitted, slotsAddition): 115 if slotIdx < slotsFitted: 116 self.texturePath = self.slotTaken 117 else: 118 self.texturePath = self.slotLeft 119 if slotIdx < slotsLeft + slotsFitted: 120 if slotIdx < slotsLeft + slotsFitted + slotsAddition: 121 self.SetRGBA(*self.slotColorNormal) 122 else: 123 self.SetRGBA(*self.slotColorRed) 124 self.display = True 125 elif slotIdx < slotsLeft + slotsFitted + slotsAddition: 126 self.SetRGBA(*self.slotColorYellow) 127 self.display = True 128 else: 129 self.display = False