Пример #1
0
        public IScriptRegistrationParams GetRegistrationParams(ScriptType scriptType, Type type)
        {
            IScriptRegistrationParams registrationParams = null;

            if ((scriptType & ScriptType.Actor) == ScriptType.Actor)
                registrationParams = TryGetActorParams(type);
            else if ((scriptType & ScriptType.GameRules) == ScriptType.GameRules)
                registrationParams = TryGetGamemodeParams(type);
            else if ((scriptType & ScriptType.Entity) == ScriptType.Entity)
                registrationParams = TryGetEntityParams(type);
            else if ((scriptType & ScriptType.EntityFlowNode) == ScriptType.EntityFlowNode)
                registrationParams = TryGetEntityFlowNodeParams(type);
            else if ((scriptType & ScriptType.FlowNode) == ScriptType.FlowNode)
                registrationParams = TryGetFlowNodeParams(type);

            if ((scriptType & ScriptType.CryScriptInstance) == ScriptType.CryScriptInstance)
            {
                foreach (var member in type.GetMethods(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public))
                {
                    ConsoleCommandAttribute attribute;
                    if (member.TryGetAttribute(out attribute))
                        ConsoleCommand.Register(attribute.Name ?? member.Name, Delegate.CreateDelegate(typeof(ConsoleCommandDelegate), member) as ConsoleCommandDelegate, attribute.Comment, attribute.Flags);
                }
            }

            return registrationParams;
        }
        public ScriptInfo(string source, ScriptType scriptType, string key, string area = null)
        {
            IsInline = true;
            Source = source;
            ScriptType = scriptType;
            Area = area;
            LastModified = DateTime.Now;

            var hash = System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(Source));
            var sb = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2"));
            }

            var s = sb.ToString();
            LocalPath = "/local/" + s;

            UniqueKey = key;

            Trace.WriteLine(area + "." + key + " " + s);

            if (UniqueKey == null)
            {
                throw new ArgumentNullException("key");
            }
        }
Пример #3
0
 private void SetScriptType(RadioButton radioButton)
 {
     if (radioButton.Name.Equals("Scheme"))
         scriptType = ScriptType.Scheme;
     else
         scriptType = ScriptType.Enumeration;
 }
Пример #4
0
        private CryScript(Type type, ScriptType scriptType)
        {
            Type = type;
            ScriptName = type.Name;

            ScriptType = scriptType;
        }
Пример #5
0
 public ScriptDeclaration(string Name, ScriptApp App, ScriptType Type, bool Enabled)
 {
     this.Name = Name;
     this.App = App;
     this.Type = Type;
     this.Enabled = Enabled;
 }
Пример #6
0
        public string GetScript(ScriptType type)
        {
            if (type == ScriptType.PreDeploy)
                return _preDeployScript;

            return _postDeployScript;;
        }
Пример #7
0
 /// <summary>
 /// /
 /// </summary>
 /// <param name="scriptType"></param>
 /// <param name="aActionId"></param>
 /// <param name="actionGetter"></param>
 /// <param name="scriptScope"></param>
 /// <param name="ignoreAuthorize">忽略授权</param>
 public ScriptAction(ScriptType scriptType, int aActionId, ActionGetter actionGetter, object scriptScope, bool ignoreAuthorize)
     : base(aActionId, actionGetter)
 {
     _scriptType = scriptType;
     _scriptScope = scriptScope;
     _ignoreAuthorize = ignoreAuthorize;
 }
Пример #8
0
 public void Main(int processId, ScriptType scriptType)
 {
     int electricSchemeTypeCode = 0;
     E3Project project = new E3Project(processId);
     Sheet sheet = project.GetSheetById(0);
     E3Text text = project.GetTextById(0);
     HashSet<int> electricSchemeSheetIds = GetElectricSchemeSheetIds(project, sheet, electricSchemeTypeCode);
     Dictionary<int, DeviceConnection> deviceConnectionById;
     Dictionary<int, CableInfo> cableInfoById;
     GetDeviceConnectionByIdAndCableInfoById(project, electricSchemeSheetIds, out deviceConnectionById, out cableInfoById);
     Dictionary<int, DeviceSymbol> deviceSymbolById = GetDeviceSymbolById(project, text, deviceConnectionById);
     Dictionary<string, List<SymbolScheme>> schemesByAssignment = GetSchemesByAssignment(deviceConnectionById, deviceSymbolById, cableInfoById, sheet, text);
     if (scriptType == ScriptType.Scheme)
     {
         foreach (string assignment in schemesByAssignment.Keys)
             PlaceSchemes(schemesByAssignment[assignment], project, sheet, text, assignment);
     }
     else
     {
         Dictionary<string, List<int>> OWSSheetIdsByAssignment = GetOWSSheetIdsByAssignment(project, sheet, schemesByAssignment.Keys);
         foreach (string assignment in schemesByAssignment.Keys)
         {
             IEnumerable<int> allDeviceIds = schemesByAssignment[assignment].SelectMany(s => s.AllDeviceIds).Distinct();
             int schemeSheetCount = OWSSheetIdsByAssignment[assignment].Count;
             new SpecificationScript(allDeviceIds, ++schemeSheetCount, subProjectAttribute, "СВП", sheetMarkAttribute, assignment);
         }
     }
     project.Release();
 }
Пример #9
0
    public void ScriptIsParsedCorrectly(string script, ScriptType scriptType, string scriptValue)
    {
      var result = new DbScript {XmlRoot = script};

      Assert.That(result.ScriptType, Is.EqualTo(scriptType));
      Assert.That(result.ScriptValue, Is.EqualTo(scriptValue));
    }
        public IScriptFileList ListForType(ScriptType type)
        {
            string key = CreateKey(type);

            var list = (_context.Application[key] as IScriptFileList) ?? new ScriptFileList();

            return list;
        }
		public ScriptPropertyDescriptor (string propertyName, ScriptType type, bool readOnly, string serverPropertyName)
			: base (propertyName)
		{
			this.propertyName = propertyName;
			this.type = type;
			this.readOnly = readOnly;
			this.serverPropertyName = (serverPropertyName == null ? "" : serverPropertyName);
		}
Пример #12
0
		protected void DoProperty (ScriptPropertyDescriptor p, string propertyName, ScriptType type, bool readOnly, string serverPropertyName)
		{
			Assert.AreEqual (propertyName, p.PropertyName, propertyName + " PropertyName");
			Assert.AreEqual (propertyName, p.MemberName, propertyName + " MemberName");
			Assert.AreEqual (serverPropertyName, p.ServerPropertyName, propertyName + " ServerPropertyName");
			Assert.AreEqual (readOnly, p.ReadOnly, propertyName + " ReadOnly");
			Assert.AreEqual (type, p.Type, propertyName + " Type");
		}
 public void Type_Test()
 {
     ScriptGenerationInfo target = new ScriptGenerationInfo(); // TODO: Initialize to an appropriate value
     ScriptType expected = new ScriptType(); // TODO: Initialize to an appropriate value
     ScriptType actual;
     target.Type = expected;
     actual = target.Type;
     Assert.AreEqual(expected, actual);
 }
Пример #14
0
        private string CreateScriptFile(string scriptBody, ScriptType scriptType)
        {
            var fileExtension = this.GetScriptExtension(scriptType);
            var fileName = "DeploymentCockpit_{0:N}{1}".FormatString(Guid.NewGuid(), fileExtension);
            var filePath = Path.Combine(Path.GetTempPath(), fileName);

            File.WriteAllText(filePath, scriptBody);

            return filePath;
        }
 public void ScriptInfoConstructor_Test()
 {
     string url = "Foo";
     string localPath = "Foo";
     string cdnPath = "Foo";
     ScriptType scriptType = new ScriptType();
     bool siteWide = false;
     string area = "Foo";
     ScriptInfo target = new ScriptInfo(url, localPath, scriptType, area);
 }
        public override MvcHtmlString CombinedScript(HtmlHelper html, string[] files, ScriptType scriptType)
        {
            if (files.IsEmpty())
                return null;

            var key = GetKey(files, scriptType); 

            string url = (scriptType == ScriptType.Css ? controllerCssRoute : controllerJsRoute).FormatWith(key);
            return MvcHtmlString.Create((scriptType == ScriptType.Css ? cssElement : jsElement).FormatWith(Subdomain(url)));
        }
 public void ScriptInfoConstructor_Source_Test()
 {
     string source = "Foo";
     string cdnPath = "Foo";
     ScriptType scriptType = new ScriptType();
     bool siteWide = false;
     string area = "Foo";
     string key = "123";
     ScriptInfo target = new ScriptInfo(source, scriptType, key, area);
 }
Пример #18
0
        public virtual MvcHtmlString CombinedScript(HtmlHelper html, string[] files, ScriptType scriptType)
        {
            string scriptElement = scriptType == ScriptType.Css ? cssElement : jsElement;

            HtmlStringBuilder sb = new HtmlStringBuilder();
            foreach (var f in files)
                sb.AddLine(MvcHtmlString.Create(scriptElement.Formato(Subdomain(f + "?v=" + Version))));

            return sb.ToHtml();
        }
Пример #19
0
        public UnityScript(ScriptType type)
        {
            ScriptName = "Script";

            Methods = new List<ScriptMethod>();
            Using = new List<string>();
            Properties = new List<ScriptProperty>();
            Type = type;

            UsingAddDefaults();
        }
Пример #20
0
 private string CreateCommand(string scriptPath, ScriptType scriptType)
 {
     if (scriptType == ScriptType.PowerShell)
     {
         return "PowerShell -NoProfile -ExecutionPolicy Bypass -Command \"& '{0}'\"".FormatString(scriptPath);
     }
     else  // Batch
     {
         return scriptPath;
     }
 }
        public override string[] GerUrlsFor(string[] files, ScriptType scriptType)
        {
            if (files.IsEmpty())
                return null;

            string key = GetKey(files, scriptType);

            string route = (scriptType == ScriptType.Css ? controllerCssRoute : controllerJsRoute).FormatWith(key);
            
            return new string[] { Subdomain(route) };
        }
Пример #22
0
		internal void SetScriptInformation(ScriptInformation scriptInformation) {
			__sScriptName = scriptInformation.FullName;
			__cScriptType = scriptInformation.Property.ScriptType;

			switch (__cScriptType) {
				case ScriptType.Script:
					break;
				case ScriptType.Signal:
					__cScriptSetting = new SignalSetting();
					break;
			}
		}
Пример #23
0
 static IScriptEngine GetSpecificScriptEngine(ScriptType scriptType)
 {
     switch (scriptType)
     {
         case ScriptType.Powershell:
             return new PowerShellScriptEngine();
         case ScriptType.ScriptCS:
             return new ScriptCSScriptEngine();
         case ScriptType.Bash:
             return new BashScriptEngine();
         default:
             throw new InvalidEnumArgumentException("scriptType");
     }
 }
        public ScriptInfo(string url, string localPath, ScriptType scriptType, string area = null)
        {
            Url = url;
            LocalPath = localPath;
            ScriptType = scriptType;
            Area = area;

            UniqueKey = localPath;

            if (UniqueKey == null)
            {
                throw new ArgumentNullException("localPath");
            }
        }
 public void ScriptType_Test()
 {
     string url = "Foo";
     string localPath = "Foo";
     string cdnPath = "Foo";
     ScriptType scriptType = new ScriptType();
     bool siteWide = false;
     string area = "Foo";
     ScriptInfo target = new ScriptInfo(url, localPath,scriptType, area);
     ScriptType expected = new ScriptType();
     ScriptType actual;
     target.ScriptType = expected;
     actual = target.ScriptType;
     Assert.AreEqual(expected, actual);
 }
Пример #26
0
 public UI()
 {
     applicationInfo = new E3ApplicationInfo();
     InitializeComponent();
     MinHeight = Height;
     MinWidth = Width;
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     scriptType = ScriptType.Scheme;
     if (applicationInfo.Status == SelectionStatus.Selected)
         richTextBox.AppendText(applicationInfo.MainWindowTitle);
     else
     {
         richTextBox.AppendText(applicationInfo.StatusReasonDescription);
         DoButton.IsEnabled = false;
     }
 }
Пример #27
0
        public string Run(string scriptBody, ScriptType scriptType)
        {
            if (scriptBody.IsNullOrWhiteSpace())
                throw new ArgumentException("Script body is empty.");

            var scriptPath = string.Empty;

            try
            {
                scriptPath = this.CreateScriptFile(scriptBody, scriptType);
                var command = this.CreateCommand(scriptPath, scriptType);
                return this.ExecuteCommand(command);
            }
            finally
            {
                if (File.Exists(scriptPath))
                    File.Delete(scriptPath);
            }
        }
 public void Read (TProtocol iprot)
 {
   bool isset_Source = false;
   bool isset_ScriptType = false;
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.String) {
           Source = iprot.ReadString();
           isset_Source = true;
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.I32) {
           ScriptType = (ScriptType)iprot.ReadI32();
           isset_ScriptType = true;
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
   if (!isset_Source)
     throw new TProtocolException(TProtocolException.INVALID_DATA);
   if (!isset_ScriptType)
     throw new TProtocolException(TProtocolException.INVALID_DATA);
 }
Пример #29
0
        public static string GetScriptFileName(string _name, ScriptType _type)
        {
            string extension = Path.GetExtension(_name);
            string fileName = _name;

            if (!extension.Trim().ToUpper().Equals(".GS"))
                fileName = _name + ".gs";

            switch (_type)
            {
                case ScriptType.G:
                    fileName = Path.Combine(path_gScript__, fileName);
                    break;
                case ScriptType.Simple:
                    fileName = Path.Combine(path_simpleScript__, fileName);
                    break;
                default:
                    throw new Exception();
            }
            return fileName;
        }
Пример #30
0
        /// <summary>
        /// This function the Loads the LanguageWriter specific to  ScriptType provided.
        /// </summary>
        /// <param name="scriptType"></param>
        /// <returns>Returns Language Provider for specific Language Exists or not.</returns>
        public static bool LoadLanguageWriter(ScriptType scriptType)
        {
            var selectedLanguage = string.Empty;

            switch (scriptType)
            {
                case ScriptType.CSharp:
                    selectedLanguage = "CSharp";
                    break;
                case ScriptType.Vb:
                    selectedLanguage = "VB";
                    break;
                case ScriptType.Java:
                    selectedLanguage = "Java";
                    break;
                case ScriptType.Ruby:
                    selectedLanguage = "Ruby";
                    break;
            }

            var isExists = LanguageSelector.AssignSelectedLanguageTypeDbToPoco(selectedLanguage);
            return isExists;
        }
Пример #31
0
 public int RemoveInstances(ScriptType scriptType, Predicate <CryScriptInstance> match)
 {
     return(RemoveInstances <CryScriptInstance>(scriptType, match));
 }
Пример #32
0
 /// <summary>
 /// Gets the items for the type
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns>The items.</returns>
 protected virtual List <ItemInfo> GetItemsForType(ScriptType type)
 {
     return(GetItemsForType(type, type.IsClass, true));
 }
Пример #33
0
        /// <summary>
        /// 拡張編集で使ったスクリプトを抽出する
        /// </summary>
        /// <param name="exedit">拡張編集のデータ</param>
        /// <param name="setting">アプリの設定</param>
        /// <returns></returns>
        static List <ScriptData> ExtractScript(ExEditProject exedit, Setting setting)
        {
            var knownScripts = setting.GetScripts();
            var usedScripts  = new Dictionary <UsedScriptKey, ScriptData>();

            foreach (var obj in exedit.Objects)
            {
                if (obj.Chain)
                {
                    continue;
                }

                foreach (var effect in obj.Effects)
                {
                    ScriptType type       = ScriptType.Other;
                    string     scriptName = "";
                    switch (effect)
                    {
                    case AnimationEffect anm:
                        type       = ScriptType.Anm;
                        scriptName = string.IsNullOrEmpty(anm.Name)
                                ? AnimationEffect.Defaults[anm.ScriptId]
                                : anm.Name;
                        break;

                    case CustomObjectEffect coe:
                        type       = ScriptType.Obj;
                        scriptName = string.IsNullOrEmpty(coe.Name)
                                ? CustomObjectEffect.Defaults[coe.ScriptId]
                                : coe.Name;
                        break;

                    case CameraEffect cam:
                        type       = ScriptType.Cam;
                        scriptName = string.IsNullOrEmpty(cam.Name)
                                ? CameraEffect.Defaults[cam.ScriptId]
                                : cam.Name;
                        break;

                    case SceneChangeEffect scn when scn.Params != null:
                        type       = ScriptType.Scn;
                        scriptName = scn.Name;
                        break;
                    }
                    if (!string.IsNullOrEmpty(scriptName))
                    {
                        AddUsedScript(knownScripts, usedScripts, scriptName, type);
                    }
                    foreach (var trackbar in effect.Trackbars)
                    {
                        if (trackbar.Type == TrackbarType.Script)
                        {
                            scriptName = exedit.TrackbarScripts[trackbar.ScriptIndex].Name;
                            AddUsedScript(knownScripts, usedScripts, scriptName, ScriptType.Tra);
                        }
                    }
                }
            }

            return(usedScripts.Values.ToList());
        }
Пример #34
0
        public static void Devman(this Panel p, Vessel v)
        {
            // avoid corner-case when this is called in a lambda after scene changes
            v = FlightGlobals.FindVessel(v.id);

            // if vessel doesn't exist anymore, leave the panel empty
            if (v == null)
            {
                return;
            }

            // get info from the cache
            Vessel_info vi = Cache.VesselInfo(v);

            // if not a valid vessel, leave the panel empty
            if (!vi.is_valid)
            {
                return;
            }

            // set metadata
            p.Title(Lib.BuildString(Lib.Ellipsis(v.vesselName, Styles.ScaleStringLength(20)), " <color=#cccccc>" + Localizer.Format("#KERBALISM_UI_devman") + "</color>"));
            p.Width(Styles.ScaleWidthFloat(355.0f));
            p.paneltype = Panel.PanelType.scripts;

            // time-out simulation
            if (p.Timeout(vi))
            {
                return;
            }

            // get devices
            Dictionary <uint, Device> devices = Computer.Boot(v);
            int deviceCount = 0;

            // direct control
            if (script_index == 0)
            {
                // draw section title and desc
                p.AddSection
                (
                    Localizer.Format("#KERBALISM_UI_devices"),
                    Description(),
                    () => p.Prev(ref script_index, (int)ScriptType.last),
                    () => p.Next(ref script_index, (int)ScriptType.last),
                    true
                );

                // for each device
                foreach (var pair in devices)
                {
                    // render device entry
                    Device dev = pair.Value;
                    if (!dev.IsVisible())
                    {
                        continue;
                    }
                    p.AddContent(dev.Name(), dev.Info(), string.Empty, dev.Toggle, () => Highlighter.Set(dev.Part(), Color.cyan));
                    deviceCount++;
                }
            }
            // script editor
            else
            {
                // get script
                ScriptType script_type = (ScriptType)script_index;
                string     script_name = script_type.ToString().Replace('_', ' ').ToUpper();
                Script     script      = DB.Vessel(v).computer.Get(script_type);

                // draw section title and desc
                p.AddSection
                (
                    script_name,
                    Description(),
                    () => p.Prev(ref script_index, (int)ScriptType.last),
                    () => p.Next(ref script_index, (int)ScriptType.last),
                    true
                );

                // for each device
                foreach (var pair in devices)
                {
                    Device dev = pair.Value;
                    if (!dev.IsVisible())
                    {
                        continue;
                    }

                    // determine tribool state
                    int state = !script.states.ContainsKey(pair.Key)
                                          ? -1
                                          : !script.states[pair.Key]
                                          ? 0
                                          : 1;

                    // render device entry
                    p.AddContent
                    (
                        dev.Name(),
                        state == -1 ? "<color=#999999>" + Localizer.Format("#KERBALISM_UI_dontcare") + " </color>" : state == 0 ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_OFF") + "</color>" : "<color=cyan>" + Localizer.Format("#KERBALISM_Generic_ON") + "</color>",
                        string.Empty,
                        () =>
                    {
                        switch (state)
                        {
                        case -1: script.Set(dev, true); break;

                        case 0: script.Set(dev, null); break;

                        case 1: script.Set(dev, false); break;
                        }
                    },
                        () => Highlighter.Set(dev.Part(), Color.cyan)
                    );
                    deviceCount++;
                }
            }

            // no devices case
            if (deviceCount == 0)
            {
                p.AddContent("<i>no devices</i>");
            }
        }
Пример #35
0
 /// <summary>
 /// Gets all the derived types from the given base type (excluding that type) within the given assembly.
 /// </summary>
 /// <param name="assembly">The target assembly to check its types.</param>
 /// <param name="baseType">The base type.</param>
 /// <param name="result">The result collection. Elements will be added to it. Clear it before usage.</param>
 public static void GetDerivedTypes(Assembly assembly, ScriptType baseType, List <ScriptType> result)
 {
     GetDerivedTypes(assembly, baseType, result, type => true);
 }
Пример #36
0
 /// <inheritdoc />
 public CachedAllTypesCollection(int capacity, ScriptType type, Func <ScriptType, bool> checkFunc, Func <Assembly, bool> checkAssembly)
     : base(capacity, type, checkFunc, checkAssembly)
 {
 }
Пример #37
0
 private static bool ValidateDragActorType(ScriptType actorType)
 {
     return(true);
 }
Пример #38
0
 /// <summary>
 /// Gets the color for the connection.
 /// </summary>
 /// <param name="type">The connection type.</param>
 /// <param name="hint">The connection hint.</param>
 /// <param name="color">The color.</param>
 public void GetConnectionColor(ScriptType type, ConnectionsHint hint, out Color color)
 {
     if (type == ScriptType.Null)
     {
         color = Colors.Default;
     }
     else if (type.IsPointer || type.IsReference)
     {
         // Find underlying type without `*` or `&`
         var typeName = type.TypeName;
         type = TypeUtils.GetType(typeName.Substring(0, typeName.Length - 1));
         GetConnectionColor(type, hint, out color);
     }
     else if (type.IsArray)
     {
         GetConnectionColor(type.GetElementType(), hint, out color);
     }
     else if (type.Type == typeof(void))
     {
         color = Colors.Impulse;
     }
     else if (type.Type == typeof(bool))
     {
         color = Colors.Bool;
     }
     else if (type.Type == typeof(byte) || type.Type == typeof(sbyte) || type.Type == typeof(char) || type.Type == typeof(short) || type.Type == typeof(ushort) || type.Type == typeof(int) || type.Type == typeof(uint) || type.Type == typeof(long) || type.Type == typeof(ulong))
     {
         color = Colors.Integer;
     }
     else if (type.Type == typeof(float) || type.Type == typeof(double) || hint == ConnectionsHint.Scalar)
     {
         color = Colors.Float;
     }
     else if (type.Type == typeof(Vector2) || type.Type == typeof(Vector3) || type.Type == typeof(Vector4) || type.Type == typeof(Color))
     {
         color = Colors.Vector;
     }
     else if (type.Type == typeof(Float2) || type.Type == typeof(Float3) || type.Type == typeof(Float4))
     {
         color = Colors.Vector;
     }
     else if (type.Type == typeof(Double2) || type.Type == typeof(Double3) || type.Type == typeof(Double4))
     {
         color = Colors.Vector;
     }
     else if (type.Type == typeof(Int2) || type.Type == typeof(Int3) || type.Type == typeof(Int4))
     {
         color = Colors.Vector;
     }
     else if (type.Type == typeof(string))
     {
         color = Colors.String;
     }
     else if (type.Type == typeof(Quaternion))
     {
         color = Colors.Rotation;
     }
     else if (type.Type == typeof(Transform))
     {
         color = Colors.Transform;
     }
     else if (type.Type == typeof(BoundingBox) || type.Type == typeof(BoundingSphere) || type.Type == typeof(BoundingFrustum))
     {
         color = Colors.Bounds;
     }
     else if (type.IsEnum || hint == ConnectionsHint.Enum)
     {
         color = Colors.Enum;
     }
     else if (type.IsValueType)
     {
         color = Colors.Structures;
     }
     else if (ScriptType.FlaxObject.IsAssignableFrom(type) || type.IsInterface)
     {
         color = Colors.Object;
     }
     else if (hint == ConnectionsHint.Vector)
     {
         color = Colors.Vector;
     }
     else
     {
         color = Colors.Default;
     }
 }
Пример #39
0
 public void RemoveInstance(int instanceId, ScriptType scriptType)
 {
     RemoveInstances <CryScriptInstance>(scriptType, x => x.ScriptId == instanceId);
 }
Пример #40
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            // Area for drag&drop scripts
            var dragArea = layout.CustomContainer <DragAreaControl>();

            dragArea.CustomControl.ScriptsEditor = this;

            // No support for showing scripts from multiple actors that have different set of scripts
            var scripts = (Script[])Values[0];

            _scripts.Clear();
            _scripts.AddRange(scripts);
            for (int i = 1; i < Values.Count; i++)
            {
                var e = (Script[])Values[i];
                if (scripts.Length != e.Length)
                {
                    return;
                }
                for (int j = 0; j < e.Length; j++)
                {
                    var t1 = scripts[j]?.TypeName;
                    var t2 = e[j]?.TypeName;
                    if (t1 != t2)
                    {
                        return;
                    }
                }
            }

            // Scripts arrange bar
            var dragBar = layout.Custom <ScriptArrangeBar>();

            dragBar.CustomControl.Init(0, this);

            // Scripts
            var elementType = new ScriptType(typeof(Script));

            _scriptToggles = new CheckBox[scripts.Length];
            for (int i = 0; i < scripts.Length; i++)
            {
                var script = scripts[i];
                if (script == null)
                {
                    AddMissingScript(i, layout);
                    continue;
                }

                var values     = new ScriptsContainer(elementType, i, Values);
                var scriptType = TypeUtils.GetObjectType(script);
                var editor     = CustomEditorsUtil.CreateEditor(scriptType, false);

                // Create group
                var title = CustomEditorsUtil.GetPropertyNameUI(scriptType.Name);
                var group = layout.Group(title);
                if (Presenter.CacheExpandedGroups)
                {
                    if (Editor.Instance.ProjectCache.IsCollapsedGroup(title))
                    {
                        group.Panel.Close(false);
                    }
                    else
                    {
                        group.Panel.Open(false);
                    }
                    group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed);
                }
                else
                {
                    group.Panel.Open(false);
                }

                // Customize
                var typeAttributes = scriptType.GetAttributes(true);
                var tooltip        = (TooltipAttribute)typeAttributes.FirstOrDefault(x => x is TooltipAttribute);
                if (tooltip != null)
                {
                    group.Panel.TooltipText = tooltip.Text;
                }
                if (script.HasPrefabLink)
                {
                    group.Panel.HeaderTextColor = FlaxEngine.GUI.Style.Current.ProgressNormal;
                }

                // Add toggle button to the group
                var scriptToggle = new CheckBox
                {
                    TooltipText  = "If checked, script will be enabled.",
                    IsScrollable = false,
                    Checked      = script.Enabled,
                    Parent       = group.Panel,
                    Size         = new Vector2(14, 14),
                    Bounds       = new Rectangle(2, 0, 14, 14),
                    BoxSize      = 12.0f,
                    Tag          = script,
                };
                scriptToggle.StateChanged += OnScriptToggleCheckChanged;
                _scriptToggles[i]          = scriptToggle;

                // Add drag button to the group
                const float dragIconSize = 14;
                var         scriptDrag   = new ScriptDragIcon(this, script)
                {
                    TooltipText  = "Script reference",
                    AutoFocus    = true,
                    IsScrollable = false,
                    Color        = FlaxEngine.GUI.Style.Current.ForegroundGrey,
                    Parent       = group.Panel,
                    Bounds       = new Rectangle(scriptToggle.Right, 0.5f, dragIconSize, dragIconSize),
                    Margin       = new Margin(1),
                    Brush        = new SpriteBrush(Editor.Instance.Icons.DragBar12),
                    Tag          = script,
                };

                // Add settings button to the group
                const float settingsButtonSize = 14;
                var         settingsButton     = new Image
                {
                    TooltipText  = "Settings",
                    AutoFocus    = true,
                    AnchorPreset = AnchorPresets.TopRight,
                    Parent       = group.Panel,
                    Bounds       = new Rectangle(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize),
                    IsScrollable = false,
                    Color        = FlaxEngine.GUI.Style.Current.ForegroundGrey,
                    Margin       = new Margin(1),
                    Brush        = new SpriteBrush(FlaxEngine.GUI.Style.Current.Settings),
                    Tag          = script,
                };
                settingsButton.Clicked += OnSettingsButtonClicked;

                group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2);
                group.Object(values, editor);

                // Scripts arrange bar
                dragBar = layout.Custom <ScriptArrangeBar>();
                dragBar.CustomControl.Init(i + 1, this);
            }

            base.Initialize(layout);
        }
Пример #41
0
 public static bool IsSupportedScriptType(ScriptType scriptType)
 {
     return(_supportedScriptTypes.Contains(scriptType));
 }
Пример #42
0
        internal static ArmDeploymentScriptData DeserializeArmDeploymentScriptData(JsonElement element)
        {
            if (element.TryGetProperty("kind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AzureCLI": return(AzureCliScript.DeserializeAzureCliScript(element));

                case "AzurePowerShell": return(AzurePowerShellScript.DeserializeAzurePowerShellScript(element));
                }
            }
            Optional <ArmDeploymentScriptManagedIdentity> identity = default;
            AzureLocation location = default;
            Optional <IDictionary <string, string> > tags = default;
            ScriptType         kind       = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = ArmDeploymentScriptManagedIdentity.DeserializeArmDeploymentScriptManagedIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = new ScriptType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
            }
            return(new ArmDeploymentScriptData(id, name, type, systemData, identity.Value, location, Optional.ToDictionary(tags), kind));
        }
Пример #43
0
        public static System.Web.WebPages.HelperResult Script(ScriptType type)
        {
            return(new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 6 "..\..\App_Code\Content.cshtml"

                string src;
                switch (type)
                {
                case ScriptType.JQuery:
                    src = "https://code.jquery.com/jquery.min.js";
                    break;

                case ScriptType.JQueryValidate:
                    src = "https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js";
                    break;

                case ScriptType.JQueryValidateLocalized:
                    src = "https://ajax.aspnetcdn.com/ajax/jQuery.Validate/1.6/localization/messages_se.js";
                    break;

                case ScriptType.JQueryValidateUnobtrusive:
                    src = "https://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js";
                    break;

                case ScriptType.JQueryUI:
                    src = "https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js";
                    break;

                case ScriptType.JQueryUII18N:
                    src = "https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/i18n/jquery-ui-i18n.min.js";
                    break;

                case ScriptType.Modernizr:
                    src = "https://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.0.6-development-only.js";
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
                }

#line default
#line hidden

                WebViewPage.WriteLiteralTo(@__razor_helper_writer, "    <script src=\"");



#line 35 "..\..\App_Code\Content.cshtml"
                WebViewPage.WriteTo(@__razor_helper_writer, src);

#line default
#line hidden

                WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" type=\"text/javascript\"></script>\r\n");



#line 36 "..\..\App_Code\Content.cshtml"

#line default
#line hidden
            }));
        }
Пример #44
0
        public void ReplaceScriptInstance(CryScriptInstance newInstance, int scriptId, ScriptType scriptType)
        {
            RemoveInstance(scriptId, scriptType);

            var script = FindScript(scriptType, x => x.Type == newInstance.GetType());

            if (script == null)
            {
                if (CryScript.TryCreate(newInstance.GetType(), out script))
                {
                    Scripts.Add(script);
                }
                else
                {
                    return;
                }
            }

            AddScriptInstance(script, newInstance, scriptId);
        }
Пример #45
0
            private unsafe void UpdateBoxes()
            {
                var       valueBox  = (InputBox)GetBox(0);
                const int firstBox  = 2;
                const int maxBoxes  = 40;
                bool      isInvalid = false;
                var       data      = Utils.GetEmptyArray <byte>();

                if (valueBox.HasAnyConnection)
                {
                    var valueType = valueBox.CurrentType;
                    if (valueType.IsEnum)
                    {
                        // Get enum entries
                        var entries = new List <EnumComboBox.Entry>();
                        EnumComboBox.BuildEntriesDefault(valueType.Type, entries);

                        // Setup switch value inputs
                        int        id   = firstBox;
                        ScriptType type = new ScriptType();
                        for (; id < maxBoxes; id++)
                        {
                            var box = GetBox(id);
                            if (box == null)
                            {
                                break;
                            }
                            if (box.HasAnyConnection)
                            {
                                type = box.Connections[0].CurrentType;
                                break;
                            }
                        }
                        id = firstBox;
                        for (; id < entries.Count + firstBox; id++)
                        {
                            var e   = entries[id - firstBox];
                            var box = AddBox(false, id, id - 1, e.Name, type, true);
                            if (!string.IsNullOrEmpty(e.Tooltip))
                            {
                                box.TooltipText = e.Tooltip;
                            }
                        }
                        for (; id < maxBoxes; id++)
                        {
                            var box = GetBox(id);
                            if (box == null)
                            {
                                break;
                            }
                            RemoveElement(box);
                        }

                        // Setup output
                        var outputBox = (OutputBox)GetBox(1);
                        outputBox.CurrentType = type;

                        // Build data about enum entries values for the runtime
                        if (Values[0] is byte[] dataPrev && dataPrev.Length == entries.Count * 4)
                        {
                            data = dataPrev;
                        }
                        else
                            data = new byte[entries.Count * 4];
                        fixed(byte *dataPtr = data)
                        {
                            int *dataValues = (int *)dataPtr;

                            for (int i = 0; i < entries.Count; i++)
                            {
                                dataValues[i] = entries[i].Value;
                            }
                        }
                    }
                    else
                    {
                        // Not an enum
                        isInvalid = true;
                    }
                }
Пример #46
0
 private Item CreateActorItem(string name, ScriptType type)
 {
     return(new Item(name, GUI.Drag.DragActorType.GetDragData(type)));
 }
Пример #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadOnlyValueContainer"/> class.
 /// </summary>
 /// <param name="type">The values type.</param>
 /// <param name="value">The initial value.</param>
 public ReadOnlyValueContainer(ScriptType type, object value)
     : base(ScriptMemberInfo.Null, type)
 {
     Add(value);
 }
Пример #48
0
 public static void GenerateScriptForClient(ScriptType type)
 {
     GenerateScriptForClient(GlobalVars.UserConfiguration.SelectedClient, type);
 }
Пример #49
0
 public ScriptData(Byte[] Unused, UInt32 ReferenceCount, UInt32 CompiledSize, UInt32 VariableCount, ScriptType Type, ScriptFlags Flags)
 {
     this.Unused         = Unused;
     this.ReferenceCount = ReferenceCount;
     this.CompiledSize   = CompiledSize;
     this.VariableCount  = VariableCount;
     this.Type           = Type;
     this.Flags          = Flags;
 }
Пример #50
0
        public static string CompileScript(string ClientName, string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true)
        {
            string start = tag;
            string end   = endtag;

            FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);

            ScriptType type = GetTypeFromTag(start);

            //we must have the ending tag before we continue.
            if (string.IsNullOrWhiteSpace(end))
            {
                return("");
            }

            if (usesharedtags)
            {
                string sharedstart = "<shared>";
                string sharedend   = "</shared>";

                if (code.Contains(sharedstart) && code.Contains(sharedend))
                {
                    start = sharedstart;
                    end   = sharedend;
                }
            }

            if (info.Fix2007)
            {
                Generator.GenerateScriptForClient(type);
            }

            string extractedCode = GetArgsFromTag(code, start, end);

            if (extractedCode.Contains("%donothing%"))
            {
                return("");
            }

#if LAUNCHER
            string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
#else
            string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
#endif
            string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
            string md5exe    = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
            string md5sd     = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
            string md5s      = "'" + info.ClientMD5 + "','" + md5dir + "','" + info.ScriptMD5 + "'";
            string compiled  = extractedCode.Replace("%version%", GlobalVars.ProgramInformation.Version)
                               .Replace("%mapfile%", mapfile)
                               .Replace("%luafile%", luafile)
                               .Replace("%charapp%", GlobalVars.UserCustomization.CharacterID)
                               .Replace("%ip%", GlobalVars.IP)
                               .Replace("%port%", GlobalVars.UserConfiguration.RobloxPort.ToString())
                               .Replace("%joinport%", GlobalVars.JoinPort.ToString())
                               .Replace("%name%", GlobalVars.UserConfiguration.PlayerName)
                               .Replace("%icone%", ConvertIconStringToInt().ToString())
                               .Replace("%icon%", GlobalVars.UserCustomization.Icon)
                               .Replace("%id%", GlobalVars.UserConfiguration.UserID.ToString())
                               .Replace("%face%", GlobalVars.UserCustomization.Face)
                               .Replace("%head%", GlobalVars.UserCustomization.Head)
                               .Replace("%tshirt%", GlobalVars.UserCustomization.TShirt)
                               .Replace("%shirt%", GlobalVars.UserCustomization.Shirt)
                               .Replace("%pants%", GlobalVars.UserCustomization.Pants)
                               .Replace("%hat1%", GlobalVars.UserCustomization.Hat1)
                               .Replace("%hat2%", GlobalVars.UserCustomization.Hat2)
                               .Replace("%hat3%", GlobalVars.UserCustomization.Hat3)
                               .Replace("%faced%", GlobalVars.UserCustomization.Face.Contains("http://") ? GlobalVars.UserCustomization.Face : GlobalPaths.faceGameDir + GlobalVars.UserCustomization.Face)
                               .Replace("%headd%", GlobalPaths.headGameDir + GlobalVars.UserCustomization.Head)
                               .Replace("%tshirtd%", GlobalVars.UserCustomization.TShirt.Contains("http://") ? GlobalVars.UserCustomization.TShirt : GlobalPaths.tshirtGameDir + GlobalVars.UserCustomization.TShirt)
                               .Replace("%shirtd%", GlobalVars.UserCustomization.Shirt.Contains("http://") ? GlobalVars.UserCustomization.Shirt : GlobalPaths.shirtGameDir + GlobalVars.UserCustomization.Shirt)
                               .Replace("%pantsd%", GlobalVars.UserCustomization.Pants.Contains("http://") ? GlobalVars.UserCustomization.Pants : GlobalPaths.pantsGameDir + GlobalVars.UserCustomization.Pants)
                               .Replace("%hat1d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat1)
                               .Replace("%hat2d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat2)
                               .Replace("%hat3d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat3)
                               .Replace("%headcolor%", GlobalVars.UserCustomization.HeadColorID.ToString())
                               .Replace("%torsocolor%", GlobalVars.UserCustomization.TorsoColorID.ToString())
                               .Replace("%larmcolor%", GlobalVars.UserCustomization.LeftArmColorID.ToString())
                               .Replace("%llegcolor%", GlobalVars.UserCustomization.LeftLegColorID.ToString())
                               .Replace("%rarmcolor%", GlobalVars.UserCustomization.RightArmColorID.ToString())
                               .Replace("%rlegcolor%", GlobalVars.UserCustomization.RightLegColorID.ToString())
                               .Replace("%md5launcher%", md5dir)
                               .Replace("%md5script%", info.ScriptMD5)
                               .Replace("%md5exe%", info.ClientMD5)
                               .Replace("%md5scriptd%", md5script)
                               .Replace("%md5exed%", md5exe)
                               .Replace("%md5s%", md5s)
                               .Replace("%md5sd%", md5sd)
                               .Replace("%limit%", GlobalVars.UserConfiguration.PlayerLimit.ToString())
                               .Replace("%extra%", GlobalVars.UserCustomization.Extra)
                               .Replace("%hat4%", GlobalVars.UserCustomization.Extra)
                               .Replace("%extrad%", GlobalPaths.extraGameDir + GlobalVars.UserCustomization.Extra)
                               .Replace("%hat4d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Extra)
                               .Replace("%mapfiled%", GlobalPaths.BaseGameDir + GlobalVars.UserConfiguration.MapPathSnip.Replace(@"\\", @"\").Replace(@"/", @"\"))
                               .Replace("%mapfilec%", extractedCode.Contains("%mapfilec%") ? GlobalFuncs.CopyMapToRBXAsset() : "")
                               .Replace("%tripcode%", GlobalVars.PlayerTripcode)
                               .Replace("%scripttype%", Generator.GetNameForType(type))
                               .Replace("%addonscriptpath%", GlobalPaths.AddonScriptPath)
                               .Replace("%notifications%", GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower())
                               .Replace("%loadout%", code.Contains("<solo>") ? GlobalVars.soloLoadout : GlobalVars.Loadout)
                               .Replace("%doublequote%", "\"")
                               .Replace("%validatedextrafiles%", GlobalVars.ValidatedExtraFiles.ToString())
                               .Replace("%argstring%", GetRawArgsForType(type, ClientName, luafile))
                               .Replace("%tshirttexid%", GlobalVars.TShirtTextureID)
                               .Replace("%shirttexid%", GlobalVars.ShirtTextureID)
                               .Replace("%pantstexid%", GlobalVars.PantsTextureID)
                               .Replace("%facetexid%", GlobalVars.FaceTextureID)
                               .Replace("%tshirttexidlocal%", GlobalVars.TShirtTextureLocal)
                               .Replace("%shirttexidlocal%", GlobalVars.ShirtTextureLocal)
                               .Replace("%pantstexidlocal%", GlobalVars.PantsTextureLocal)
                               .Replace("%facetexlocal%", GlobalVars.FaceTextureLocal)
                               .Replace("%newgui%", GlobalVars.UserConfiguration.NewGUI.ToString().ToLower());

            if (compiled.Contains("%disabled%"))
            {
                MessageBox.Show("This option has been disabled for this client.", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return("");
            }

            return(compiled);
        }
Пример #51
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            // No support for different collections for now
            if (HasDifferentValues || HasDifferentTypes)
            {
                return;
            }

            var type      = Values.Type;
            var size      = Count;
            var argTypes  = type.GetGenericArguments();
            var keyType   = argTypes[0];
            var valueType = argTypes[1];

            _canEditKeys  = keyType == typeof(string) || keyType.IsPrimitive || keyType.IsEnum;
            _background   = FlaxEngine.GUI.Style.Current.CollectionBackgroundColor;
            _readOnly     = false;
            _notNullItems = false;

            // Try get CollectionAttribute for collection editor meta
            var   attributes         = Values.GetAttributes();
            Type  overrideEditorType = null;
            float spacing            = 0.0f;
            var   collection         = (CollectionAttribute)attributes?.FirstOrDefault(x => x is CollectionAttribute);

            if (collection != null)
            {
                _readOnly     = collection.ReadOnly;
                _notNullItems = collection.NotNullItems;
                if (collection.BackgroundColor.HasValue)
                {
                    _background = collection.BackgroundColor.Value;
                }
                overrideEditorType = TypeUtils.GetType(collection.OverrideEditorTypeName).Type;
                spacing            = collection.Spacing;
            }

            // Size
            if (_readOnly || !_canEditKeys)
            {
                layout.Label("Size", size.ToString());
            }
            else
            {
                _size = layout.IntegerValue("Size");
                _size.IntValue.MinValue      = 0;
                _size.IntValue.MaxValue      = _notNullItems ? size : ushort.MaxValue;
                _size.IntValue.Value         = size;
                _size.IntValue.ValueChanged += OnSizeChanged;
            }

            // Elements
            if (size > 0)
            {
                var panel = layout.VerticalPanel();
                panel.Panel.BackgroundColor = _background;
                var keysEnumerable = ((IDictionary)Values[0]).Keys.OfType <object>();
                var keys           = keysEnumerable as object[] ?? keysEnumerable.ToArray();
                var valuesType     = new ScriptType(valueType);

                // Use separate layout cells for each collection items to improve layout updates for them in separation
                var useSharedLayout = valueType.IsPrimitive || valueType.IsEnum;

                for (int i = 0; i < size; i++)
                {
                    if (i != 0 && spacing > 0f)
                    {
                        if (panel.Children.Count > 0 && panel.Children[panel.Children.Count - 1] is PropertiesListElement propertiesListElement)
                        {
                            if (propertiesListElement.Labels.Count > 0)
                            {
                                var label  = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1];
                                var margin = label.Margin;
                                margin.Bottom += spacing;
                                label.Margin   = margin;
                            }
                            propertiesListElement.Space(spacing);
                        }
                        else
                        {
                            panel.Space(spacing);
                        }
                    }

                    var key            = keys.ElementAt(i);
                    var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null;
                    var property       = panel.AddPropertyItem(new DictionaryItemLabel(this, key));
                    var itemLayout     = useSharedLayout ? (LayoutElementsContainer)property : property.VerticalPanel();
                    itemLayout.Object(new DictionaryValueContainer(valuesType, key, Values), overrideEditor);
                }
            }
            _elementsCount = size;

            // Add/Remove buttons
            if (!_readOnly && _canEditKeys)
            {
                var area      = layout.Space(20);
                var addButton = new Button(area.ContainerControl.Width - (16 + 16 + 2 + 2), 2, 16, 16)
                {
                    Text         = "+",
                    TooltipText  = "Add new item",
                    AnchorPreset = AnchorPresets.TopRight,
                    Parent       = area.ContainerControl,
                    Enabled      = !_notNullItems,
                };
                addButton.Clicked += () =>
                {
                    if (IsSetBlocked)
                    {
                        return;
                    }

                    Resize(Count + 1);
                };
                var removeButton = new Button(addButton.Right + 2, addButton.Y, 16, 16)
                {
                    Text         = "-",
                    TooltipText  = "Remove last item",
                    AnchorPreset = AnchorPresets.TopRight,
                    Parent       = area.ContainerControl,
                    Enabled      = size > 0,
                };
                removeButton.Clicked += () =>
                {
                    if (IsSetBlocked)
                    {
                        return;
                    }

                    Resize(Count - 1);
                };
            }
        }
Пример #52
0
 public static string GetScriptFuncForType(ScriptType type)
 {
     return(GetScriptFuncForType(GlobalVars.UserConfiguration.SelectedClient, type));
 }
Пример #53
0
 public ScriptInfo(ScriptType scriptType, string fileName, string text)
     : this(scriptType, fileName, text, null, null)
 {
 }
Пример #54
0
        public static string GetScriptFuncForType(string ClientName, ScriptType type)
        {
            FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);

            string rbxexe = "";

            if (info.LegacyMode)
            {
                rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp.exe";
            }
            else if (info.SeperateFolders)
            {
                rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\client\\RobloxApp_client.exe";
            }
            else if (info.UsesCustomClientEXEName)
            {
                rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\" + info.CustomClientEXEName;
            }
            else
            {
                rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_client.exe";
            }

#if LAUNCHER
            string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
#else
            string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
#endif
            string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
            string md5exe    = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
            string md5s      = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";

            switch (type)
            {
            case ScriptType.Client:
                return("_G.CSConnect("
                       + (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
                       + GlobalVars.IP + "',"
                       + GlobalVars.JoinPort + ",'"
                       + (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
                       + GlobalVars.Loadout + ","
                       + md5s + ",'"
                       + GlobalVars.PlayerTripcode
                       + ((GlobalVars.ValidatedExtraFiles > 0) ? "'," + GlobalVars.ValidatedExtraFiles.ToString() + "," : "',0,")
                       + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");");

            case ScriptType.Server:
                return("_G.CSServer("
                       + GlobalVars.UserConfiguration.RobloxPort + ","
                       + GlobalVars.UserConfiguration.PlayerLimit + ","
                       + md5s + ","
                       + GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower()
                       + ((GlobalVars.ValidatedExtraFiles > 0) ? "," + GlobalVars.ValidatedExtraFiles.ToString() + "," : ",0,")
                       + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");");

            case ScriptType.Solo:
            case ScriptType.EasterEgg:
                return("_G.CSSolo("
                       + (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
                       + (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
                       + GlobalVars.soloLoadout + ","
                       + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");");

            case ScriptType.Studio:
                return("_G.CSStudio("
                       + GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");");

            default:
                return("");
            }
        }
 void ToDefault()
 {
     scriptType = ScriptType.None;
 }
 public static string GetScriptName(string deploymentStage, ScriptType scriptType)
 {
     return("Octopus.Action.CustomScripts." + deploymentStage + "." + scriptType.FileExtension());
 }
        public IScriptConfig Generate(string scriptTypeString, string id)
        {
            ScriptType scriptType = scriptTypeString.ToEnum <ScriptType>();

            return(Generate(scriptType, id));
        }
Пример #58
0
        /// <summary>
        /// Main run method.
        /// This causes any modified code to be recompiled and executed on the mouse crawler.
        /// </summary>
        public void RunCrawler()
        {
            // Get the C# code from the input field
            string cSharpSource = runCrawlerInput.text;

            // Dont recompile the same code
            if (activeCSharpSource != cSharpSource || activeCrawlerScript == null)
            {
                // Remove any other scripts
                StopCrawler();

                try
                {
                    // Compile code
                    ScriptType type = domain.CompileAndLoadMainSource(cSharpSource, ScriptSecurityMode.UseSettings, assemblyReferences);

                    // Check for null
                    if (type == null)
                    {
                        if (domain.RoslynCompilerService.LastCompileResult.Success == false)
                        {
                            throw new Exception("Maze crawler code contained errors. Please fix and try again");
                        }
                        else if (domain.SecurityResult.IsSecurityVerified == false)
                        {
                            throw new Exception("Maze crawler code failed code security verification");
                        }
                        else
                        {
                            throw new Exception("Maze crawler code does not define a class. You must include one class definition of any name that inherits from 'RoslynCSharp.Example.MazeCrawler'");
                        }
                    }

                    // Check for base class
                    if (type.IsSubTypeOf <MazeCrawler>() == false)
                    {
                        throw new Exception("Maze crawler code must define a single type that inherits from 'RoslynCSharp.Example.MazeCrawler'");
                    }



                    // Create an instance
                    activeCrawlerScript = type.CreateInstance(mazeMouse);
                    activeCSharpSource  = cSharpSource;

                    // Set speed value
                    activeCrawlerScript.Fields["breadcrumbPrefab"] = breadcrumbPrefab;
                    activeCrawlerScript.Fields["moveSpeed"]        = mouseSpeed;
                }
                catch (Exception e)
                {
                    // Show the code editor window
                    codeEditorWindow.SetActive(true);
                    throw e;
                }
            }
            else
            {
                // Get the maze crawler instance
                MazeCrawler mazeCrawler = activeCrawlerScript.GetInstanceAs <MazeCrawler>(false);

                // Call the restart method
                mazeCrawler.Restart();
            }
        }
Пример #59
0
 public VehicleScript(ScriptType scriptType)
 {
     this.scriptType = scriptType;
 }
Пример #60
0
 public ScriptRequest(string[] files, ScriptType scriptType, string version)
 {
     this.VirtualFiles = files;
     this.ScriptType   = scriptType;
     this.toString     = string.Join(",", VirtualFiles) + "," + version;
 }