Exemple #1
0
        private void CreateParamEditor(Subaction action)
        {
            if (action == null)
            {
                return;
            }

            panel1.Controls.Clear();

            for (int i = action.Parameters.Length - 1; i >= 0; i--)
            {
                var p = action.Parameters[i];

                if (p.Name == "None")
                {
                    continue;
                }

                Panel group = new Panel();
                group.Dock   = DockStyle.Top;
                group.Height = 24;

                if (p.IsFloat)
                {
                    SAFloatEditor editor = new SAFloatEditor();
                    group.Controls.Add(editor);
                }
                else
                if (p.IsPointer)
                {
                    if (Reference == null)
                    {
                        PointerBox.SelectedIndex = 0;
                    }
                    group.Controls.Add(PointerBox);
                }
                else
                if (p.Hex)
                {
                    SAHexEditor editor = new SAHexEditor();
                    editor.SetBitSize(p.BitCount);
                    group.Controls.Add(editor);

                    group.Controls.Add(new Label()
                    {
                        Text = "0x", Dock = DockStyle.Left
                    });
                }
                else
                if (p.HasEnums)
                {
                    SAEnumEditor editor = new SAEnumEditor();
                    editor.SetEnums(p.Enums);
                    group.Controls.Add(editor);
                }
                else
                {
                    SAIntEditor editor = new SAIntEditor();
                    editor.SetBitSize(p.BitCount);
                    group.Controls.Add(editor);
                }

                group.Controls.Add(new Label()
                {
                    Text = p.Name + ":", Dock = DockStyle.Left, Width = 200
                });

                panel1.Controls.Add(group);
            }

            ReadjustHeight();
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        private void CreateEditor()
        {
            if (cbOpCode.SelectedItem is ParticleManager.ParticleDescriptor des)
            {
                panel1.SuspendLayout();

                // clear controls
                foreach (Control c in panel1.Controls)
                {
                    c.Dispose();
                }

                panel1.Controls.Clear();

                if (des.ParamDesc == null)
                {
                    return;
                }

                var paramdesc = des.ParamDesc.ToCharArray();

                if (des.ParamDesc.Length != des.Params.Length)
                {
                    throw new Exception("Param count mismatch");
                }

                Editors = new Control[paramdesc.Length];

                for (int i = 0; i < paramdesc.Length; i++)
                {
                    var panel = new Panel();
                    panel.Width  = 400;
                    panel.Height = 24;
                    panel.Dock   = DockStyle.Top;

                    Control editcontrol = null;

                    switch (paramdesc[i])
                    {
                    case 'c':
                    {
                        var editor = new CheckBox()
                        {
                            Dock = DockStyle.Left
                        };
                        editor.Checked = i < OpCode.Params.Length && OpCode.Params[i] is bool?(bool)OpCode.Params[i] : false;
                        editcontrol    = editor;
                    }
                    break;

                    case 'b':
                    {
                        var editor = new SAUIntEditor()
                        {
                            Dock = DockStyle.Left
                        };
                        editor.SetBitSize(8);
                        editor.SetValue(i < OpCode.Params.Length && OpCode.Params[i] is byte?(byte)OpCode.Params[i] : 0);
                        editcontrol = editor;
                    }
                    break;

                    case 's':
                    {
                        var editor = new SAUIntEditor()
                        {
                            Dock = DockStyle.Left
                        };
                        editor.SetBitSize(16);
                        editor.SetValue(i < OpCode.Params.Length && OpCode.Params[i] is short?(short)OpCode.Params[i] : 0);
                        editcontrol = editor;
                    }
                    break;

                    case 'f':
                    {
                        var editor = new SAFloatEditor()
                        {
                            Dock = DockStyle.Left
                        };
                        editor.SetFloatValue(i < OpCode.Params.Length && OpCode.Params[i] is float?(float)OpCode.Params[i] : 0);
                        editcontrol = editor;
                    }
                    break;
                    }

                    if (editcontrol != null)
                    {
                        panel.Controls.Add(editcontrol);
                        editcontrol.SendToBack();
                        Editors[i] = editcontrol;
                    }

                    panel.Controls.Add(new Label()
                    {
                        Text = des.Params[i], Dock = DockStyle.Left
                    });

                    panel1.Controls.Add(panel);
                }

                panel1.ResumeLayout();
            }
        }