Ejemplo n.º 1
0
 public StructMultiControl(CacheForm form, HaloOnlineCacheContext cacheContext, CachedTagInstance tagInstance, object definition) :
     this()
 {
     Form         = form;
     CacheContext = cacheContext;
     TagInstance  = tagInstance;
     Definition   = definition;
 }
Ejemplo n.º 2
0
 public StructMultiControl(CacheForm form, GameCache cache, CachedTag tag, object definition) :
     this()
 {
     Form       = form;
     Cache      = cache;
     Instance   = tag;
     Definition = definition;
 }
Ejemplo n.º 3
0
 public ArgbColorControl(GameCache cache, FieldInfo field) :
     this()
 {
     Cache       = cache;
     Field       = field;
     label1.Text = field.Name.ToSpaced().Replace("_", "");
     new ToolTip().SetToolTip(label1, $"{field.FieldType} {CacheForm.GetDocumentation(field)}");
 }
Ejemplo n.º 4
0
        public RealVector2dControl(HaloOnlineCacheContext cacheContext, FieldInfo field) :
            this()
        {
            CacheContext = cacheContext;
            Field        = field;
            label1.Text  = field.Name.ToSpaced().Replace("_", "");

            new ToolTip().SetToolTip(label1, $"{field.FieldType.Name} {CacheForm.GetDocumentation(field)}");
        }
Ejemplo n.º 5
0
        public ValueControl(GameCache cache, FieldInfo field) :
            this()
        {
            Cache       = cache;
            Field       = field;
            label1.Text = field.Name.ToSpaced();

            new ToolTip().SetToolTip(label1, $"{field.FieldType.Name} {CacheForm.GetDocumentation(field)}");
        }
Ejemplo n.º 6
0
        public TagReferenceControl(CacheForm form, HaloOnlineCacheContext cacheContext, FieldInfo field) :
            this()
        {
            Form         = form;
            CacheContext = cacheContext;
            Field        = field;
            label1.Text  = field.Name.ToSpaced();

            new ToolTip().SetToolTip(label1, $"{field.FieldType.Name} {CacheForm.GetDocumentation(field)}");
        }
Ejemplo n.º 7
0
        public BlockControl(CacheForm form, HaloOnlineCacheContext cacheContext, Type type, FieldInfo field) :
            this()
        {
            CacheContext = cacheContext;
            Field        = field;

            groupBox.Text = field.Name.ToSpaced().Replace("_", "");
            new ToolTip().SetToolTip(groupBox, $"{groupBox.Text} Block {CacheForm.GetDocumentation(field)}");

            Struct = new StructControl(form, CacheContext, type.GenericTypeArguments[0], null);
            groupBox.Controls.Add(Struct);
            Struct.Dock = DockStyle.Fill;
            Struct.BringToFront();

            Height = groupBox.Height;
        }
Ejemplo n.º 8
0
        public StructControl(CacheForm form, HaloOnlineCacheContext cacheContext, Type type, FieldInfo field) :
            this()
        {
            CacheContext = cacheContext;
            Field        = field;

            if (Field == null)
            {
                groupBox.Visible = false;
            }
            else
            {
                groupBox.Text = Field.Name.ToSpaced();
            }

            FieldControls = CreateFieldControls(form, Field == null ? (Control)this : groupBox, type);

            if (field != null)
            {
                new ToolTip().SetToolTip(this, $"{field.FieldType.Name} {CacheForm.GetDocumentation(field)}");
            }
        }
Ejemplo n.º 9
0
        private Dictionary <string, IFieldControl> CreateFieldControls(CacheForm form, Control parent, FieldInfo field, Type type, bool toplevel)
        {
            Enabled = false;

            var result     = new Dictionary <string, IFieldControl>();
            var enumerator = TagStructure.GetTagFieldEnumerable(new TagStructureInfo(type, Cache.Version));

            var currentLocation = new Point(parent is GroupBox ? 3 : 0, parent is GroupBox ? 16 : 0);

            foreach (var fieldInfo in enumerator)
            {
                if (fieldInfo.Attribute.Flags.HasFlag(TagFieldFlags.Padding))
                {
                    continue;
                }

                var fieldType   = fieldInfo.FieldInfo.FieldType;
                var isFlagsEnum = (fieldType.GetCustomAttributes(typeof(FlagsAttribute), false).FirstOrDefault() as FlagsAttribute ?? null) != null;
                var isTagBlock  = (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(List <>));
                var isStruct    = (fieldType.GetCustomAttributes(typeof(TagStructureAttribute), false).FirstOrDefault() as TagStructureAttribute ?? null) != null;
                var isBounds    = (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Bounds <>));

                if (toplevel && (isStruct || isTagBlock))
                {
                    continue;
                }

                if (field != null && field != fieldInfo.FieldInfo)
                {
                    continue;
                }

                Control control = null;

                if (fieldType == typeof(StringId))
                {
                    control = new StringIdControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType.IsEnum)
                {
                    if (isFlagsEnum)
                    {
                        control = new FlagsControl(fieldInfo.FieldInfo);
                    }
                    else
                    {
                        control = new EnumControl(fieldInfo.FieldInfo);
                    }
                }
                else if (fieldType == typeof(Point2d))
                {
                    control = new Point2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(Rectangle2d))
                {
                    control = new Rectangle2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(ArgbColor))
                {
                    control = new ArgbColorControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealPoint2d))
                {
                    control = new RealPoint2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealPoint3d))
                {
                    control = new RealPoint3dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealVector2d))
                {
                    control = new RealVector2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealVector3d))
                {
                    control = new RealVector3dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealQuaternion))
                {
                    control = new RealQuaternionControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealRgbColor))
                {
                    control = new RealRgbColorControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealArgbColor))
                {
                    control = new RealArgbColorControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealEulerAngles2d))
                {
                    control = new RealEulerAngles2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealEulerAngles3d))
                {
                    control = new RealEulerAngles3dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealPlane2d))
                {
                    control = new RealPlane2dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(RealPlane3d))
                {
                    control = new RealPlane3dControl(Cache, fieldInfo.FieldInfo);
                }
                else if (fieldType == typeof(CachedTag))
                {
                    control = new TagReferenceControl(form, Cache, fieldInfo.FieldInfo);
                }
                else if (isTagBlock)
                {
                    control = new BlockControl(form, Cache, fieldType, fieldInfo.FieldInfo);

                    if (((BlockControl)control).Struct.FieldControls.Count == 0)
                    {
                        continue;
                    }
                }
                else if (isStruct)
                {
                    control = new StructControl(form, Cache, fieldType, fieldInfo.FieldInfo);

                    if (((StructControl)control).FieldControls.Count == 0)
                    {
                        continue;
                    }
                }
                else if (isBounds)
                {
                    control = new BoundsControl(Cache, fieldInfo.FieldInfo);
                }
                else
                {
                    control = new ValueControl(Cache, fieldInfo.FieldInfo);
                }

                control.Location = new Point(currentLocation.X, currentLocation.Y);
                parent.Controls.Add(control);

                currentLocation.Y = control.Bottom;

                if (parent is GroupBox gb && gb.AutoSize == false)
                {
                    parent.Width  = control.Right + 8;
                    parent.Height = control.Bottom + 6;
                }

                if (isStruct || isTagBlock)
                {
                    control.BringToFront();
                }

                result[fieldInfo.FieldInfo.Name] = (IFieldControl)control;

                Application.DoEvents();
            }

            Enabled = true;

            return(result);
        }
Ejemplo n.º 10
0
        public FlagsControl(FieldInfo field) :
            this()
        {
            Field       = field;
            label1.Text = field.Name.ToSpaced();

            new ToolTip().SetToolTip(label1, $"{field.FieldType.GetEnumUnderlyingType().Name} Flags {CacheForm.GetDocumentation(field)}");

            var names  = Enum.GetNames(field.FieldType);
            var values = Enum.GetValues(field.FieldType);

            for (var i = 1; i < names.Length; i++)
            {
                var value = values.GetValue(i);
                checkedListBox1.Items.Add(new FlagsBit(names[i].ToSpaced().Replace("_", ""), value));
            }

            checkedListBox1.Height = (checkedListBox1.Items.Count * 15) + 7;

            Height = label1.Height = checkedListBox1.Bottom;
        }
Ejemplo n.º 11
0
        public EnumControl(FieldInfo field) :
            this()
        {
            Field       = field;
            label1.Text = field.Name.ToSpaced();

            new ToolTip().SetToolTip(label1, $"{field.FieldType.GetEnumUnderlyingType().Name} Enum {CacheForm.GetDocumentation(field)}");

            var names  = Enum.GetNames(field.FieldType);
            var values = Enum.GetValues(field.FieldType);

            for (var i = 0; i < names.Length; i++)
            {
                var value = values.GetValue(i);
                itemsComboBox.Items.Add(new EnumOption(names[i].ToSpaced().Replace("_", ""), value));
            }
        }
Ejemplo n.º 12
0
        public BoundsControl(HaloOnlineCacheContext cacheContext, FieldInfo field) :
            this()
        {
            CacheContext = cacheContext;
            Field        = field;
            label1.Text  = field.Name.ToSpaced().Replace("_", "");

            new ToolTip().SetToolTip(label1, $"{field.FieldType.GenericTypeArguments[0].Name} Bounds {CacheForm.GetDocumentation(field)}");
        }