NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

warpVector.py (6238B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\devtools\script\warpVector.py
      2 from __future__ import print_function
      3 import geo2
      4 from carbonui import ButtonVariant, ButtonStyle, Density
      5 from carbonui.control.button import Button
      6 from carbonui.control.scrollContainer import ScrollContainer
      7 from carbonui.control.singlelineedits.singleLineEditFloat import SingleLineEditFloat
      8 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger
      9 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
     10 from carbonui.control.window import Window
     11 import carbonui.const as uiconst
     12 from carbonui.primitives.container import Container
     13 from carbonui.util.various_unsorted import GetClipboardData
     14 from eve.client.script.ui.control.eveLabel import EveCaptionSmall, EveLabelSmall
     15 from eve.common.lib import appConst
     16 import blue
     17 
     18 class WarpVectorWnd(Window):
     19     __notifyevents__ = []
     20     default_height = 630
     21     default_width = 740
     22     default_minSize = [450, 256]
     23     default_windowID = 'warpVectorWnd'
     24 
     25     def DebugReload(self, *args):
     26         self.Reload(self)
     27 
     28     def ApplyAttributes(self, attributes):
     29         super(WarpVectorWnd, self).ApplyAttributes(attributes)
     30         reloadBtn = Button(parent=self.content, label='Reload', align=uiconst.TOPRIGHT, func=self.DebugReload, top=0, idx=0)
     31         self.ConstructLayout()
     32 
     33     def ConstructLayout(self):
     34         self.vectorContainer = ScrollContainer(name='vectorContainer', parent=self.sr.main, align=uiconst.TOALL, padding=8)
     35         EveCaptionSmall(parent=self.vectorContainer, text='Set Warp Vectors [m]:', align=uiconst.TOTOP, top=20)
     36         for i in range(10):
     37             SetAndWarp(name='vectorEditSection', parent=self.vectorContainer, align=uiconst.TOTOP, width=self.parent.width, height=25, top=25, index=i)
     38 
     39 
     40 class SetAndWarp(Container):
     41 
     42     def ApplyAttributes(self, attributes):
     43         super(SetAndWarp, self).ApplyAttributes(attributes)
     44         self.index = attributes.index
     45         self.default_value = 0.0
     46         self.vector = [self.default_value, self.default_value, self.default_value]
     47         self.ConstructLayout()
     48 
     49     def ConstructLayout(self):
     50         vectorName = 'Vector {}'.format(self.index + 1)
     51         savedValueForName = settings.user.ui.Get(self.GetVectorName())
     52         if savedValueForName is not None:
     53             vectorName = savedValueForName
     54         savedValueForX = settings.user.ui.Get(self.GetConfigNameForField(0))
     55         savedValueForY = settings.user.ui.Get(self.GetConfigNameForField(1))
     56         savedValueForZ = settings.user.ui.Get(self.GetConfigNameForField(2))
     57         self.nameEditField = SingleLineEditText(parent=self, align=uiconst.TOLEFT, setvalue=vectorName, width=80, OnChange=self.SetName)
     58         self.xEditField = SingleLineEditInteger(parent=self, align=uiconst.TOLEFT, setvalue=savedValueForX, OnChange=self.SetX, width=120, left=10, minValue=-appConst.maxBigint, maxValue=appConst.maxBigint)
     59         self.yEditField = SingleLineEditInteger(parent=self, align=uiconst.TOLEFT, setvalue=savedValueForY, OnChange=self.SetY, width=120, left=10, minValue=-appConst.maxBigint, maxValue=appConst.maxBigint)
     60         self.zEditField = SingleLineEditInteger(parent=self, align=uiconst.TOLEFT, setvalue=savedValueForZ, OnChange=self.SetZ, width=120, left=10, minValue=-appConst.maxBigint, maxValue=appConst.maxBigint)
     61         if self.index == 0:
     62             self.xEditField.SetLabel('x')
     63             self.yEditField.SetLabel('y')
     64             self.zEditField.SetLabel('z')
     65             self.nameEditField.SetLabel('Name')
     66         button = Button(parent=self, label='Warp!', varient=ButtonVariant.PRIMARY, style=ButtonStyle.NORMAL, align=uiconst.TOLEFT, left=10, func=self.Warp)
     67         button = Button(parent=self, label='Copy', varient=ButtonVariant.GHOST, align=uiconst.TOLEFT, left=10, func=self.CopyCoords)
     68         button = Button(parent=self, label='Paste', varient=ButtonVariant.GHOST, align=uiconst.TOLEFT, left=10, func=self.PasteCoords)
     69 
     70     def GetConfigNameForField(self, axis):
     71         return 'warpvector_%s_%s' % (self.index, axis)
     72 
     73     def GetVectorName(self):
     74         return 'vectorname_%s' % self.index
     75 
     76     def SetName(self, name):
     77         settings.user.ui.Set('warpvectorname_%s' % self.index, name)
     78 
     79     def SetX(self, x_value):
     80         self.vector[0] = x_value
     81         settings.user.ui.Set('warpvector_%s_%s' % (self.index, 0), x_value)
     82         print(self.vector)
     83         print(type(self.vector[0]))
     84 
     85     def SetY(self, y_value):
     86         self.vector[1] = y_value
     87         settings.user.ui.Set('warpvector_%s_%s' % (self.index, 1), y_value)
     88         print(self.vector)
     89 
     90     def SetZ(self, z_value):
     91         self.vector[2] = z_value
     92         settings.user.ui.Set('warpvector_%s_%s' % (self.index, 2), z_value)
     93         print(self.vector)
     94 
     95     def Warp(self, *args):
     96         vector_x = float(settings.user.ui.Get(self.GetConfigNameForField(0)))
     97         vector_y = float(settings.user.ui.Get(self.GetConfigNameForField(1)))
     98         vector_z = float(settings.user.ui.Get(self.GetConfigNameForField(2)))
     99         warpVector = [vector_x, vector_y, vector_z]
    100         current_pos = sm.GetService('slash').SlashCmd('/getpos')
    101         desired_pos = geo2.Vec3AddD(current_pos, warpVector)
    102         print('warpVector.warp:')
    103         print(('current_pos: ', current_pos))
    104         print(('self.vector: ', self.vector))
    105         print(('desired_pos: ', desired_pos))
    106         sm.GetService('slash').SlashCmd('/warptopoint {} {} {}'.format(desired_pos[0], desired_pos[1], desired_pos[2]))
    107 
    108     def CopyCoords(self, *args):
    109         blue.pyos.SetClipboardData((self.xEditField.GetValue(), self.yEditField.GetValue(), self.zEditField.GetValue()))
    110 
    111     def PasteCoords(self, *args):
    112         paste = GetClipboardData()
    113         import re
    114         r = re.compile('(.*,.*,.*)')
    115         if r.match(paste) is None:
    116             return
    117         coords = paste.split(',')
    118         for i in range(len(coords)):
    119             coords[i] = re.sub('[( )]', '', coords[i])
    120 
    121         self.xEditField.SetText(coords[0])
    122         self.SetX(coords[0])
    123         self.yEditField.SetText(coords[1])
    124         self.SetY(coords[1])
    125         self.zEditField.SetText(coords[2])
    126         self.SetZ(coords[2])