// builds AlphaDerivedType, and then applies an implicit inheritence converter.
            public void Func([Test6("{k}")] AlphaType w)
            {
                // Actually passed in a derived instance
                Assert.IsType <AlphaDerivedType>(w);

                _log = w._value;
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConstantAlphaModel"/> class
        /// </summary>
        /// <param name="type">The type of alpha</param>
        /// <param name="direction">The direction of the alpha</param>
        /// <param name="period">The period over which the alpha with come to fruition</param>
        /// <param name="magnitude">The predicted change in magnitude as a +- percentage</param>
        /// <param name="confidence">The confidence in the alpha</param>
        public ConstantAlphaModel(AlphaType type, AlphaDirection direction, TimeSpan period, double?magnitude, double?confidence)
        {
            _type      = type;
            _direction = direction;
            _period    = period;

            // Optional
            _magnitude  = magnitude;
            _confidence = confidence;

            _securities        = new HashSet <Security>();
            _alphaTimeBySymbol = new Dictionary <Symbol, DateTime>();
        }
        /// <summary>
        /// Gets the security value corresponding to the specified alpha type
        /// </summary>
        /// <param name="type">The alpha type</param>
        /// <returns>The security value for the specified alpha type</returns>
        public decimal Get(AlphaType type)
        {
            switch (type)
            {
            case AlphaType.Price:
                return(Price);

            case AlphaType.Volatility:
                return(Volatility);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Alpha"/> class
        /// </summary>
        /// <param name="symbol">The symbol this alpha is for</param>
        /// <param name="type">The type of alpha, price/volatility</param>
        /// <param name="direction">The predicted direction</param>
        /// <param name="period">The period over which the prediction will come true</param>
        /// <param name="magnitude">The predicted magnitude as a percentage change</param>
        /// <param name="confidence">The confidence in this alpha</param>
        public Alpha(Symbol symbol, AlphaType type, AlphaDirection direction, TimeSpan period, double?magnitude, double?confidence)
        {
            Id    = Guid.NewGuid();
            Score = new AlphaScore();

            Symbol    = symbol;
            Type      = type;
            Direction = direction;
            Period    = period;

            // Optional
            Magnitude  = magnitude;
            Confidence = confidence;
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     <para>Generates a secure password of a random length using the specified allowed characters and symbols</para>
        /// </summary>
        /// <param name="passPhrase">Required. Secure string used to ______________</param>
        /// <param name="minLength">Required. Minimum length for the password</param>
        /// <param name="maxLength">Required. Maximum length for the password</param>
        /// <param name="allowedAlpha">
        ///     <para>Recommended. Specifies what type of characters to use.</para>
        ///     <para>Defaults to any alphabet character, both upper- and lowercases.</para>
        /// </param>
        /// <param name="inclNums">
        ///     <para>Recommended. Specifies whether to include numbers in the password.</para>
        ///     <para>Defaults to including numbers in the password.</para>
        /// </param>
        /// <param name="allowedSymbols">Recommended. Specifies whether to allow symbols in the password, and if so, what symbols to include.</param>
        /// <param name="minChars">Optional. Number of minimum symbols to include in the password</param>
        /// <returns></returns>
        public static Char[] Generate(String passPhrase, Int32 minLength, Int32 maxLength, AlphaType allowedAlpha = AlphaType.ALPHA_ALL,
            Boolean inclNums = true, String allowedSymbols = "", Int32 minChars = 0)
        {
            StringBuilder sb = new StringBuilder();
            Int32 length = (new Random().Next(minLength, maxLength));

            StringBuilder charString = new StringBuilder();
            switch (allowedAlpha)
            {
                case AlphaType.ALPHA_ALL: { charString.Append(Password.ALPHABET_ALL); } break;
                case AlphaType.ALPHA_LOW: { charString.Append(Password.ALPHABET_LOWER); } break;
                case AlphaType.ALPHA_UP: { charString.Append(Password.ALPHABET_UPPER); } break;
            }

            Boolean symbols = false;
            if (!String.IsNullOrEmpty(allowedSymbols))
            {
                charString.Append(allowedSymbols);
                symbols = true;
            }

            if (inclNums)
            {
                // see: http://stackoverflow.com/a/145864/63609
                charString.Append(String.Join("", Password.NUMBERS.Select(x => x.ToString()).ToArray()));
            }

            String chars = charString.ToString();

            for (Int32 i = 0; i <= length; ++i)
            {
                // something
            }

            return sb.ToString().ToCharArray();
        }
 // Input Rule (exact match): --> Widget
 public void Func([Test6("{k}")] AlphaType w)
 {
     _log = w._value;
 }
            public async Task Func([Test6("{k}")] IAsyncCollector <AlphaType> collector)
            {
                await collector.AddAsync(AlphaType.New("v1"));

                await collector.AddAsync(AlphaType.New("v2"));
            }
Ejemplo n.º 8
0
        /// <summary>
        ///     <para>Generates a secure password of a random length using the specified allowed characters and symbols</para>
        /// </summary>
        /// <param name="passPhrase">Required. Secure string used to ______________</param>
        /// <param name="minLength">Required. Minimum length for the password</param>
        /// <param name="maxLength">Required. Maximum length for the password</param>
        /// <param name="allowedAlpha">
        ///     <para>Recommended. Specifies what type of characters to use.</para>
        ///     <para>Defaults to any alphabet character, both upper- and lowercases.</para>
        /// </param>
        /// <param name="inclNums">
        ///     <para>Recommended. Specifies whether to include numbers in the password.</para>
        ///     <para>Defaults to including numbers in the password.</para>
        /// </param>
        /// <param name="allowedSymbols">Recommended. Specifies whether to allow symbols in the password, and if so, what symbols to include.</param>
        /// <param name="minChars">Optional. Number of minimum symbols to include in the password</param>
        /// <returns></returns>
        public static Char[] Generate(String passPhrase, Int32 minLength, Int32 maxLength, AlphaType allowedAlpha = AlphaType.ALPHA_ALL,
                                      Boolean inclNums = true, String allowedSymbols = "", Int32 minChars = 0)
        {
            StringBuilder sb     = new StringBuilder();
            Int32         length = (new Random().Next(minLength, maxLength));

            StringBuilder charString = new StringBuilder();

            switch (allowedAlpha)
            {
            case AlphaType.ALPHA_ALL: { charString.Append(Password.ALPHABET_ALL); } break;

            case AlphaType.ALPHA_LOW: { charString.Append(Password.ALPHABET_LOWER); } break;

            case AlphaType.ALPHA_UP: { charString.Append(Password.ALPHABET_UPPER); } break;
            }

            Boolean symbols = false;

            if (!String.IsNullOrEmpty(allowedSymbols))
            {
                charString.Append(allowedSymbols);
                symbols = true;
            }

            if (inclNums)
            {
                // see: http://stackoverflow.com/a/145864/63609
                charString.Append(String.Join("", Password.NUMBERS.Select(x => x.ToString()).ToArray()));
            }

            String chars = charString.ToString();

            for (Int32 i = 0; i <= length; ++i)
            {
                // something
            }

            return(sb.ToString().ToCharArray());
        }
 object IConverter <AlphaType, object> .Convert(AlphaType input)
 {
     return($"Alpha2Obj({input._value})");
 }
Ejemplo n.º 10
0
        /// <summary>
        /// The h 2 shader info.
        /// </summary>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void H2ShaderInfo(int TagIndex, Map map)
        {
            bool alreadyOpen = true;
            if (!(map.isOpen && map.openMapType == MapTypes.Internal))
            {
                map.OpenMap(MapTypes.Internal);
                alreadyOpen = false;
            }

            this.TagIndex = TagIndex;
            if (this.TagIndex == -1)
            {
                return;
            }

            this.shaderName = map.FileNames.Name[this.TagIndex];
            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 4;
            int tempstem = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
            if (tempstem != -1)
            {
                if (map.FileNames.Name[tempstem].IndexOf("alphatest") != -1)
                {
                    this.Alpha = AlphaType.AlphaTest;
                }
                else if (map.FileNames.Name[tempstem].IndexOf("alpha") != -1)
                {
                    this.Alpha = AlphaType.AlphaBlend;
                }
                else if (map.FileNames.Name[tempstem].IndexOf("water") != -1)
                {
                    this.Alpha = AlphaType.AlphaBlend;
                }
                else
                {
                    this.Alpha = AlphaType.None;
                }
            }
            else
            {
                this.Alpha = AlphaType.None;
            }

            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 12;
            int tempc2 = map.BR.ReadInt32();
            int tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;
            if (tempc2 != 0)
            {
                map.BR.BaseStream.Position = tempr2 + 4;
                int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                if (tempcrap != -1)
                {
                    Meta tempmeta = new Meta(map);
                    tempmeta.ReadMetaFromMap(tempcrap, false);
                    ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                    this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                    this.MainName = map.FileNames.Name[tempcrap];
                    this.levels = pm.Properties[0].mipMapCount;
                }
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 32;
            tempc2 = map.BR.ReadInt32();
            tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            map.BR.BaseStream.Position = tempr2 + 24;
            int fuckr = map.BR.ReadInt32();
            if (fuckr != 0)
            {
                fuckr -= map.SecondaryMagic;
                map.BR.BaseStream.Position = fuckr;
                this.primarydetailuscale = map.BR.ReadSingle();
                this.primarydetailvscale = map.BR.ReadSingle();
                this.primarydetailwscale = map.BR.ReadSingle();
                map.BR.ReadSingle();
                this.secondarydetailuscale = map.BR.ReadSingle();
                this.secondarydetailvscale = map.BR.ReadSingle();
                this.secondarydetailwscale = map.BR.ReadSingle();
            }

            map.BR.BaseStream.Position = tempr2 + 4;
            tempc2 = map.BR.ReadInt32();
            tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            /*

            for (int x = 0; x < tempc2; x++)
            {
                map.BR.BaseStream.Position = tempr2 + (x * 12);
                int tempcrap = map.Functions.Meta.FindMetaByID(map.BR.ReadInt32(), map);
                if (tempcrap == -1) { continue; }
                Meta tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(tempcrap, map, false);
                Raw.ParsedBitmap pm = new Raw.ParsedBitmap(ref tempmeta, map);
                Bitmaps.Add(pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0));
               BitmapNames.Add(map.FileNames.Name[tempcrap]);
            }

            */
            // map.BR.BaseStream.Position = tempr + 20;
            // tempc2 = map.BR.ReadInt32();
            // tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            // tempc2 = tempc;
            // tempr2 = tempr;
            if (tempc2 != 0)
            {
                map.BR.BaseStream.Position = tempr2;
                int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                if (tempcrap != -1)
                {
                    int test = map.FileNames.Name[tempcrap].IndexOf("reflection_maps");
                    if (map.FileNames.Name[tempcrap].IndexOf("_bump") != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                      //  this.BumpMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.BumpMapName = map.FileNames.Name[tempcrap];
                    }
                    else if (map.FileNames.Name[tempcrap].IndexOf("_cube_map") != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                      //  this.CubeMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.CubeMapName = map.FileNames.Name[tempcrap];
                    }
                    else if (map.FileNames.Name[tempcrap].IndexOf("default_") == -1 && this.MainBitmap == null &&
                             test == -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);

                        // Try to load LOD2-MIP3 if that fails, load LOD2-MIP0, otherwise LOD0-MIP0
                        this.MainBitmap = pm.FindChunkAndDecode(0, 2, 3, ref tempmeta, map, 0, 0);
                        if (this.MainBitmap == null)
                        {
                            this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0);
                            if (this.MainBitmap == null)
                                this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        }

                        this.MainName = map.FileNames.Name[tempcrap];
                        this.levels = pm.Properties[0].mipMapCount;
                    }
                    else if (test != -1)
                    {
                        map.BR.BaseStream.Position += 8;
                        tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);

                        // this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map);
                        // this.MainName = map.FileNames.Name[tempcrap];
                    }
                }

                map.BR.BaseStream.Position = tempr2 + 24;
                tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                if (tempcrap != -1 && this.MainBitmap == null)
                {
                    Meta tempmeta = new Meta(map);
                    tempmeta.ReadMetaFromMap(tempcrap, false);
                    ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                    this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                    this.MainName = map.FileNames.Name[tempcrap];
                    this.levels = pm.Properties[0].mipMapCount;
                }
                else if (this.MainBitmap == null)
                {
                    map.BR.BaseStream.Position = tempr2 + 12;
                    tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    if (tempcrap != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                        this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.MainName = map.FileNames.Name[tempcrap];
                        this.levels = pm.Properties[0].mipMapCount;
                    }
                }
            }

            if (!alreadyOpen)
            {
                map.CloseMap();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// The ce shader info.
        /// </summary>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void CEShaderInfo(int TagIndex, Map map)
        {
            this.TagIndex = TagIndex;
            if (this.TagIndex == -1)
            {
                return;
            }

            this.shaderName = map.FileNames.Name[this.TagIndex];

            map.OpenMap(MapTypes.Internal);
            int mainid = 0;
            int primarydetail = -1;
            int secondarydetail = -1;
            int micro = -1;
            switch (map.MetaInfo.TagType[TagIndex])
            {
                case "schi":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 228;
                    mainid = map.BR.ReadInt32();
                    break;
                case "soso":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 176;
                    mainid = map.BR.ReadInt32();
                    break;
                case "sgla":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 356;
                    mainid = map.BR.ReadInt32();
                    break;
                case "scex":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 900;
                    mainid = map.BR.ReadInt32();
                    break;
                case "senv":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 148;
                    mainid = map.BR.ReadInt32();
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 180;
                    this.primarydetailuscale = map.BR.ReadSingle();
                    this.primarydetailvscale = this.primarydetailuscale;
                    this.primarydetailwscale = 1;
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 196;
                    primarydetail = map.BR.ReadInt32();

                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 200;
                    this.secondarydetailuscale = map.BR.ReadSingle();
                    this.secondarydetailvscale = this.secondarydetailuscale;
                    this.secondarydetailwscale = 1;
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 216;
                    secondarydetail = map.BR.ReadInt32();

                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 248;
                    this.microdetailuscale = map.BR.ReadSingle();
                    this.microdetailvscale = this.secondarydetailuscale;
                    this.microdetailwscale = 1;
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 264;
                    micro = map.BR.ReadInt32();

                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 40;
                    byte alphatest = map.BR.ReadByte();
                    int test = alphatest & 1;
                    if (test != 0)
                    {
                        this.Alpha = AlphaType.AlphaTest;
                    }

                    break;
                case "swat":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88;
                    mainid = map.BR.ReadInt32();
                    break;
                case "smet":
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88;
                    mainid = map.BR.ReadInt32();
                    break;
            }

            map.CloseMap();

            mainid = map.Functions.ForMeta.FindMetaByID(mainid);
            primarydetail = map.Functions.ForMeta.FindMetaByID(primarydetail);
            secondarydetail = map.Functions.ForMeta.FindMetaByID(secondarydetail);
            micro = map.Functions.ForMeta.FindMetaByID(micro);
            if (mainid == -1)
            {
                return;
            }

            if (map.MetaInfo.external[mainid])
            {
                map.OpenMap(MapTypes.Bitmaps);
            }
            else
            {
                map.OpenMap(MapTypes.Internal);
            }

            Meta tempmeta = new Meta(map);
            tempmeta.ReadMetaFromMap(mainid, false);

            map.CloseMap();
            ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
            // Attempt to load LOD2, if that fails, load LOD0
            try
            {
                this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0);
            }
            catch
            {
                this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
            }
            this.MainName = map.FileNames.Name[mainid];

            if (primarydetail != -1)
            {
                if (map.MetaInfo.external[primarydetail])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(primarydetail, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.primarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.primarydetailName = map.FileNames.Name[primarydetail];
            }

            if (secondarydetail != -1)
            {
                if (map.MetaInfo.external[secondarydetail])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(secondarydetail, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.secondarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.secondarydetailName = map.FileNames.Name[secondarydetail];
            }

            if (micro != -1)
            {
                if (map.MetaInfo.external[micro])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(micro, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.microdetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.microdetailName = map.FileNames.Name[micro];
            }
        }
Ejemplo n.º 12
0
 public Wielder AddRandomString(Int32 valueLength, AlphaType type) => AddRandom(valueLength, alphaTypeDict[type].Split(' '));
Ejemplo n.º 13
0
        public Shader(string TagPath)
        {
            // Save the old Plugin
            TagDefinition oldplugin = (TagDefinition)Globals.Plugin;

            // Load the new one
            Plugin p = new Plugin(TagPath.Substring(TagPath.LastIndexOf(".") + 1), null);

            p.Layout.Read(new BinaryReader(new FileStream(Globals.p.Directory + TagPath, FileMode.Open, FileAccess.Read, FileShare.Read)));
            TagDefinition shad = ((TagDefinition)Globals.Plugin);

            #region Alpha Blending Properties

            string Stem = (string)shad.Fields[0].GetValue();
            if (Stem.Contains("alpha") || Stem.Contains("water"))
            {
                Alpha = AlphaType.AlphaBlend;
            }
            else if (Stem.Contains("alphatest"))
            {
                Alpha = AlphaType.AlphaTest;
            }

            #endregion

            #region Illumination Properties

            IMetaNode[] IlluminationProperties = (IMetaNode[])shad.Fields[2].GetValue();
            string      Bitmap = "";

            // If the main bitmap exists
            if (((HaloObjects.H2XTagBlock)shad.Fields[2]).GetChunkCount() > 0 && ((string)IlluminationProperties[0].GetValue()) != "Null Reference")
            {
                Bitmap = Globals.p.Directory + (string)IlluminationProperties[0].GetValue();
            }

            // Open and Read the Bitmap
            if (File.Exists(Bitmap))
            {
                MainBitmap = new Bitmap(Bitmap);
            }

            #endregion

            #region Shader Properties

            IMetaNode[] Properties = (IMetaNode[])shad.Fields[6].GetValue();

            // Bitmaps
            HaloObjects.H2XTagBlock Bitmaps = (HaloObjects.H2XTagBlock)Properties[1];
            for (int i = 0; i < Bitmaps.GetChunkCount(); i++)
            {
                // Get Fields
                Bitmaps.ChangeIndex(i);
                IMetaNode[] Fields = (IMetaNode[])Bitmaps.GetValue();
                Bitmap = (string)Fields[0].GetValue();

                // Figure out what Bitmap this is
                if (Bitmap.Contains("_bump"))
                {
                    BumpMap = new Bitmap(Globals.p.Directory + Bitmap);
                }
                else if (Bitmap.Contains("_cube_map"))
                {
                    CubeMap = new Bitmap(Globals.p.Directory + Bitmap);
                }
                else if (!Bitmap.Contains("default_") && !Bitmap.Contains("reflection_maps") && MainBitmap == null)
                {
                    MainBitmap = new Bitmap(Globals.p.Directory + Bitmap);
                }
            }

            // Double Check
            if (MainBitmap == null)
            {
                Bitmaps.ChangeIndex(2);
                IMetaNode[] Fields = (IMetaNode[])Bitmaps.GetValue();
                MainBitmap = new Bitmap(Globals.p.Directory + (string)Fields[0].GetValue());
            }

            #endregion

            // Reset Plugin
            Globals.Plugin = oldplugin;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Alpha"/> class
 /// </summary>
 /// <param name="symbol">The symbol this alpha is for</param>
 /// <param name="type">The type of alpha, price/volatility</param>
 /// <param name="direction">The predicted direction</param>
 /// <param name="period">The period over which the prediction will come true</param>
 public Alpha(Symbol symbol, AlphaType type, AlphaDirection direction, TimeSpan period)
     : this(symbol, type, direction, period, null, null)
 {
 }
Ejemplo n.º 15
0
        /// <summary>
        /// The h 2 shader info.
        /// </summary>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void H2ShaderInfo(int TagIndex, Map map)
        {
            bool alreadyOpen = true;

            if (!(map.isOpen && map.openMapType == MapTypes.Internal))
            {
                map.OpenMap(MapTypes.Internal);
                alreadyOpen = false;
            }

            this.TagIndex = TagIndex;
            if (this.TagIndex == -1)
            {
                return;
            }

            this.shaderName            = map.FileNames.Name[this.TagIndex];
            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 4;
            int tempstem = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

            if (tempstem != -1)
            {
                if (map.FileNames.Name[tempstem].IndexOf("alphatest") != -1)
                {
                    this.Alpha = AlphaType.AlphaTest;
                }
                else if (map.FileNames.Name[tempstem].IndexOf("alpha") != -1)
                {
                    this.Alpha = AlphaType.AlphaBlend;
                }
                else if (map.FileNames.Name[tempstem].IndexOf("water") != -1)
                {
                    this.Alpha = AlphaType.AlphaBlend;
                }
                else
                {
                    this.Alpha = AlphaType.None;
                }
            }
            else
            {
                this.Alpha = AlphaType.None;
            }

            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 12;
            int tempc2 = map.BR.ReadInt32();
            int tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            if (tempc2 != 0)
            {
                map.BR.BaseStream.Position = tempr2 + 4;
                int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                if (tempcrap != -1)
                {
                    Meta tempmeta = new Meta(map);
                    tempmeta.ReadMetaFromMap(tempcrap, false);
                    ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                    this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                    this.MainName   = map.FileNames.Name[tempcrap];
                    this.levels     = pm.Properties[0].mipMapCount;
                }
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 32;
            tempc2 = map.BR.ReadInt32();
            tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            map.BR.BaseStream.Position = tempr2 + 24;
            int fuckr = map.BR.ReadInt32();

            if (fuckr != 0)
            {
                fuckr -= map.SecondaryMagic;
                map.BR.BaseStream.Position = fuckr;
                this.primarydetailuscale   = map.BR.ReadSingle();
                this.primarydetailvscale   = map.BR.ReadSingle();
                this.primarydetailwscale   = map.BR.ReadSingle();
                map.BR.ReadSingle();
                this.secondarydetailuscale = map.BR.ReadSingle();
                this.secondarydetailvscale = map.BR.ReadSingle();
                this.secondarydetailwscale = map.BR.ReadSingle();
            }

            map.BR.BaseStream.Position = tempr2 + 4;
            tempc2 = map.BR.ReadInt32();
            tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            /*
             *
             * for (int x = 0; x < tempc2; x++)
             * {
             *  map.BR.BaseStream.Position = tempr2 + (x * 12);
             *  int tempcrap = map.Functions.Meta.FindMetaByID(map.BR.ReadInt32(), map);
             *  if (tempcrap == -1) { continue; }
             *  Meta tempmeta = new Meta(map);
             *  tempmeta.ReadMetaFromMap(tempcrap, map, false);
             *  Raw.ParsedBitmap pm = new Raw.ParsedBitmap(ref tempmeta, map);
             *  Bitmaps.Add(pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0));
             * BitmapNames.Add(map.FileNames.Name[tempcrap]);
             * }
             *
             */
            // map.BR.BaseStream.Position = tempr + 20;
            // tempc2 = map.BR.ReadInt32();
            // tempr2 = map.BR.ReadInt32() - map.SecondaryMagic;

            // tempc2 = tempc;
            // tempr2 = tempr;
            if (tempc2 != 0)
            {
                map.BR.BaseStream.Position = tempr2;
                int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                if (tempcrap != -1)
                {
                    int test = map.FileNames.Name[tempcrap].IndexOf("reflection_maps");
                    if (map.FileNames.Name[tempcrap].IndexOf("_bump") != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                        //  this.BumpMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.BumpMapName = map.FileNames.Name[tempcrap];
                    }
                    else if (map.FileNames.Name[tempcrap].IndexOf("_cube_map") != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                        //  this.CubeMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.CubeMapName = map.FileNames.Name[tempcrap];
                    }
                    else if (map.FileNames.Name[tempcrap].IndexOf("default_") == -1 && this.MainBitmap == null &&
                             test == -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);

                        // Try to load LOD2-MIP3 if that fails, load LOD2-MIP0, otherwise LOD0-MIP0
                        this.MainBitmap = pm.FindChunkAndDecode(0, 2, 3, ref tempmeta, map, 0, 0);
                        if (this.MainBitmap == null)
                        {
                            this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0);
                            if (this.MainBitmap == null)
                            {
                                this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                            }
                        }

                        this.MainName = map.FileNames.Name[tempcrap];
                        this.levels   = pm.Properties[0].mipMapCount;
                    }
                    else if (test != -1)
                    {
                        map.BR.BaseStream.Position += 8;
                        tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);

                        // this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map);
                        // this.MainName = map.FileNames.Name[tempcrap];
                    }
                }

                map.BR.BaseStream.Position = tempr2 + 24;
                tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                if (tempcrap != -1 && this.MainBitmap == null)
                {
                    Meta tempmeta = new Meta(map);
                    tempmeta.ReadMetaFromMap(tempcrap, false);
                    ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                    this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                    this.MainName   = map.FileNames.Name[tempcrap];
                    this.levels     = pm.Properties[0].mipMapCount;
                }
                else if (this.MainBitmap == null)
                {
                    map.BR.BaseStream.Position = tempr2 + 12;
                    tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    if (tempcrap != -1)
                    {
                        Meta tempmeta = new Meta(map);
                        tempmeta.ReadMetaFromMap(tempcrap, false);
                        ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);
                        this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                        this.MainName   = map.FileNames.Name[tempcrap];
                        this.levels     = pm.Properties[0].mipMapCount;
                    }
                }
            }

            if (!alreadyOpen)
            {
                map.CloseMap();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// The ce shader info.
        /// </summary>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void CEShaderInfo(int TagIndex, Map map)
        {
            this.TagIndex = TagIndex;
            if (this.TagIndex == -1)
            {
                return;
            }

            this.shaderName = map.FileNames.Name[this.TagIndex];

            map.OpenMap(MapTypes.Internal);
            int mainid          = 0;
            int primarydetail   = -1;
            int secondarydetail = -1;
            int micro           = -1;

            switch (map.MetaInfo.TagType[TagIndex])
            {
            case "schi":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 228;
                mainid = map.BR.ReadInt32();
                break;

            case "soso":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 176;
                mainid = map.BR.ReadInt32();
                break;

            case "sgla":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 356;
                mainid = map.BR.ReadInt32();
                break;

            case "scex":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 900;
                mainid = map.BR.ReadInt32();
                break;

            case "senv":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 148;
                mainid = map.BR.ReadInt32();
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 180;
                this.primarydetailuscale   = map.BR.ReadSingle();
                this.primarydetailvscale   = this.primarydetailuscale;
                this.primarydetailwscale   = 1;
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 196;
                primarydetail = map.BR.ReadInt32();

                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 200;
                this.secondarydetailuscale = map.BR.ReadSingle();
                this.secondarydetailvscale = this.secondarydetailuscale;
                this.secondarydetailwscale = 1;
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 216;
                secondarydetail            = map.BR.ReadInt32();

                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 248;
                this.microdetailuscale     = map.BR.ReadSingle();
                this.microdetailvscale     = this.secondarydetailuscale;
                this.microdetailwscale     = 1;
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 264;
                micro = map.BR.ReadInt32();

                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 40;
                byte alphatest = map.BR.ReadByte();
                int  test      = alphatest & 1;
                if (test != 0)
                {
                    this.Alpha = AlphaType.AlphaTest;
                }

                break;

            case "swat":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88;
                mainid = map.BR.ReadInt32();
                break;

            case "smet":
                map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88;
                mainid = map.BR.ReadInt32();
                break;
            }

            map.CloseMap();

            mainid          = map.Functions.ForMeta.FindMetaByID(mainid);
            primarydetail   = map.Functions.ForMeta.FindMetaByID(primarydetail);
            secondarydetail = map.Functions.ForMeta.FindMetaByID(secondarydetail);
            micro           = map.Functions.ForMeta.FindMetaByID(micro);
            if (mainid == -1)
            {
                return;
            }

            if (map.MetaInfo.external[mainid])
            {
                map.OpenMap(MapTypes.Bitmaps);
            }
            else
            {
                map.OpenMap(MapTypes.Internal);
            }

            Meta tempmeta = new Meta(map);

            tempmeta.ReadMetaFromMap(mainid, false);

            map.CloseMap();
            ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map);

            // Attempt to load LOD2, if that fails, load LOD0
            try
            {
                this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0);
            }
            catch
            {
                this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
            }
            this.MainName = map.FileNames.Name[mainid];

            if (primarydetail != -1)
            {
                if (map.MetaInfo.external[primarydetail])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(primarydetail, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.primarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.primarydetailName   = map.FileNames.Name[primarydetail];
            }

            if (secondarydetail != -1)
            {
                if (map.MetaInfo.external[secondarydetail])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(secondarydetail, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.secondarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.secondarydetailName   = map.FileNames.Name[secondarydetail];
            }

            if (micro != -1)
            {
                if (map.MetaInfo.external[micro])
                {
                    map.OpenMap(MapTypes.Bitmaps);
                }
                else
                {
                    map.OpenMap(MapTypes.Internal);
                }

                tempmeta = new Meta(map);
                tempmeta.ReadMetaFromMap(micro, false);

                map.CloseMap();
                pm = new ParsedBitmap(ref tempmeta, map);
                this.microdetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0);
                this.microdetailName   = map.FileNames.Name[micro];
            }
        }
Ejemplo n.º 17
0
 public Wielder AddRandomString(Int32 valueLength, AlphaType type, String backSeparator) => AddRandom(valueLength, alphaTypeDict[type].Split(' '), backSeparator);
Ejemplo n.º 18
0
 public Wielder AddRandomString(Int32 valueLength, AlphaType type) => AddRandomString(valueLength, type, String.Empty);
 static BetaType ConvertAlpha2Beta(AlphaType x)
 {
     return(BetaType.New($"A2B({x._value})"));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Alpha"/> class.
 /// This constructor is provided mostly for testing purposes. When running inside an algorithm,
 /// the generated and close times are set based on the algorithm's time.
 /// </summary>
 /// <param name="generatedTimeUtc">The time this alpha was generated in utc</param>
 /// <param name="symbol">The symbol this alpha is for</param>
 /// <param name="type">The type of alpha, price/volatility</param>
 /// <param name="direction">The predicted direction</param>
 /// <param name="period">The period over which the prediction will come true</param>
 /// <param name="magnitude">The predicted magnitude as a percentage change</param>
 /// <param name="confidence">The confidence in this alpha</param>
 public Alpha(DateTime generatedTimeUtc, Symbol symbol, AlphaType type, AlphaDirection direction, TimeSpan period, double?magnitude, double?confidence)
     : this(symbol, type, direction, period, magnitude, confidence)
 {
     GeneratedTimeUtc = generatedTimeUtc;
     CloseTimeUtc     = generatedTimeUtc + period;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstantAlphaModel"/> class
 /// </summary>
 /// <param name="type">The type of alpha</param>
 /// <param name="direction">The direction of the alpha</param>
 /// <param name="period">The period over which the alpha with come to fruition</param>
 public ConstantAlphaModel(AlphaType type, AlphaDirection direction, TimeSpan period)
     : this(type, direction, period, null, null)
 {
 }
Ejemplo n.º 22
0
        void ProcessButton_Click(Object sender, RoutedEventArgs e)
        {
            if (Count > 0)
            {
                var builder = new StringBuilder();
                for (Int32 counter = 0; counter < Count; counter++)
                {
                    if (Uppercase && Lowercase && Numeric && Symbol)
                    {
                        GeneratorType = AlphaType.UpperLowerNumericSymbol;
                    }
                    else if (Uppercase && Lowercase && Numeric)
                    {
                        GeneratorType = AlphaType.UpperLowerNumeric;
                    }
                    else if (Uppercase && Lowercase && Symbol)
                    {
                        GeneratorType = AlphaType.UpperLowerSymbol;
                    }
                    else if (Uppercase && Lowercase)
                    {
                        GeneratorType = AlphaType.UpperLower;
                    }
                    else if (Uppercase && Numeric)
                    {
                        GeneratorType = AlphaType.UpperNumeric;
                    }
                    else if (Uppercase && Symbol)
                    {
                        GeneratorType = AlphaType.UpperSymbol;
                    }
                    else if (Uppercase)
                    {
                        GeneratorType = AlphaType.Upper;
                    }
                    else if (Lowercase && Numeric)
                    {
                        GeneratorType = AlphaType.LowerNumeric;
                    }
                    else if (Lowercase && Symbol)
                    {
                        GeneratorType = AlphaType.LowerSymbol;
                    }
                    else if (Lowercase)
                    {
                        GeneratorType = AlphaType.Lower;
                    }
                    else if (Numeric && Symbol)
                    {
                        GeneratorType = AlphaType.NumericSymbol;
                    }
                    else if (Numeric)
                    {
                        GeneratorType = AlphaType.Numeric;
                    }
                    else if (Symbol)
                    {
                        GeneratorType = AlphaType.Symbol;
                    }

                    builder.AppendLine(
                        Wielder.New()
                        .AddRandomString(Length, GeneratorType)
                        .BuildKey());
                }

                CommonView.Output = builder.ToString();
            }
        }
 /// <inheritdoc />
 public IAlphaScoreFunction GetScoreFunction(AlphaType alphaType, AlphaScoreType scoreType)
 {
     return(Function);
 }