Beispiel #1
0
        public MacroObject(MacroType code, MacroSubType sub)
        {
            Code    = code;
            SubCode = sub;

            switch (code)
            {
            case MacroType.Walk:
            case MacroType.Open:
            case MacroType.Close:
            case MacroType.Minimize:
            case MacroType.Maximize:
            case MacroType.UseSkill:
            case MacroType.ArmDisarm:
            case MacroType.InvokeVirtue:
            case MacroType.CastSpell:
            case MacroType.SelectNext:
            case MacroType.SelectPrevious:
            case MacroType.SelectNearest:
            case MacroType.MovePlayer:
            case MacroType.UsePotion:

                if (sub == MacroSubType.MSC_NONE)
                {
                    int count  = 0;
                    int offset = 0;
                    Macro.GetBoundByCode(code, ref count, ref offset);
                    SubCode = (MacroSubType)offset;
                }

                HasSubMenu = 1;

                break;

            case MacroType.Say:
            case MacroType.Emote:
            case MacroType.Whisper:
            case MacroType.Yell:
            case MacroType.Delay:
            case MacroType.SetUpdateRange:
            case MacroType.ModifyUpdateRange:
                HasSubMenu = 2;

                break;

            default:
                HasSubMenu = 0;

                break;
            }
        }
Beispiel #2
0
            private void AddSubMacro(MacroObject obj)
            {
                if (obj == null || obj.Code == 0)
                {
                    return;
                }

                switch (obj.SubMenuType)
                {
                case 1:
                    int count  = 0;
                    int offset = 0;
                    Macro.GetBoundByCode(obj.Code, ref count, ref offset);

                    string[] names = new string[count];

                    for (int i = 0; i < count; i++)
                    {
                        names[i] = _allSubHotkeysNames[i + offset];
                    }

                    Combobox sub = new Combobox(20, Height, 180, names, (int)obj.SubCode - offset, 300);

                    sub.OnOptionSelected += (senderr, ee) =>
                    {
                        Macro.GetBoundByCode(obj.Code, ref count, ref offset);
                        MacroSubType subType = (MacroSubType)(offset + ee);
                        obj.SubCode = subType;
                    };

                    Add(sub);

                    Height += sub.Height;


                    break;

                case 2:

                    ResizePic background = new ResizePic(0x0BB8)
                    {
                        X      = 16,
                        Y      = Height,
                        Width  = 240,
                        Height = 60
                    };

                    Add(background);

                    StbTextBox textbox = new StbTextBox(0xFF, 80, 236, true, FontStyle.BlackBorder)
                    {
                        X      = background.X + 4,
                        Y      = background.Y + 4,
                        Width  = background.Width - 4,
                        Height = background.Height - 4
                    };

                    textbox.SetText(obj.HasString() ? ((MacroObjectString)obj).Text : string.Empty);

                    textbox.TextChanged += (sss, eee) =>
                    {
                        if (obj.HasString())
                        {
                            ((MacroObjectString)obj).Text = ((StbTextBox)sss).Text;
                        }
                    };

                    Add(textbox);

                    WantUpdateSize = true;
                    Height        += background.Height;

                    break;
                }

                _control._databox.ReArrangeChildren();
            }
Beispiel #3
0
        private void CreateCombobox(MacroObject obj)
        {
            Combobox box = new Combobox(0, 0, 200, Enum.GetNames(typeof(MacroType)), (int)obj.Code, 300);

            box.OnOptionSelected += (sender, e) =>
            {
                Combobox b = (Combobox)sender;

                if (b.SelectedIndex == 0) // MacroType.None
                {
                    MacroObject m = (MacroObject)b.Tag;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = m.Right;
                    }

                    if (m.Right != null)
                    {
                        m.Right.Left = m.Left;
                    }

                    if (m.Left != null)
                    {
                        m.Left.Right = m.Right;
                    }

                    m.Left  = null;
                    m.Right = null;

                    b.Tag = null;

                    b.Parent.Dispose();
                    _comboboxes.Remove(b);

                    if (_comboboxes.Count == 0 || _comboboxes.All(s => s.IsDisposed))
                    {
                        Macro.FirstNode = Macro.Create(MacroType.None);
                        CreateCombobox(Macro.FirstNode);
                    }
                }
                else
                {
                    MacroType t = (MacroType)b.SelectedIndex;

                    MacroObject m        = (MacroObject)b.Tag;
                    MacroObject newmacro = Macro.Create(t);

                    MacroObject left  = m.Left;
                    MacroObject right = m.Right;

                    if (left != null)
                    {
                        left.Right = newmacro;
                    }

                    if (right != null)
                    {
                        right.Left = newmacro;
                    }

                    newmacro.Left  = left;
                    newmacro.Right = right;

                    b.Tag = newmacro;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = newmacro;
                    }


                    b.Parent.Children
                    .Where(s => s != b)
                    .ToList()
                    .ForEach(s => s.Dispose());

                    switch (newmacro.HasSubMenu)
                    {
                    case 1:     // another combo
                        int count  = 0;
                        int offset = 0;

                        Macro.GetBoundByCode(t, ref count, ref offset);

                        Combobox subBox = new Combobox(20, b.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                                                       .Skip(offset)
                                                       .Take(count)
                                                       .ToArray(), 0, 300);


                        subBox.OnOptionSelected += (ss, ee) =>
                        {
                            Macro.GetBoundByCode(newmacro.Code, ref count, ref offset);
                            MacroSubType subType = (MacroSubType)(offset + ee);
                            newmacro.SubCode = subType;
                        };

                        b.Parent.Add(subBox);
                        b.Parent.WantUpdateSize = true;

                        break;

                    case 2:     // string

                        b.Parent.Add(new ResizePic(0x0BB8)
                        {
                            X      = 18,
                            Y      = b.Height + 2,
                            Width  = 240,
                            Height = b.Height * 2 + 4
                        });

                        TextBox textbox = new TextBox(new TextEntry(0xFF, 80, 0, 236, true, FontStyle.BlackBorder), true)
                        {
                            X      = 20,
                            Y      = b.Height + 5,
                            Height = b.Height * 2
                        };
                        textbox.TxEntry.SetHeight(b.Height * 2);

                        textbox.TextChanged += (sss, eee) =>
                        {
                            if (newmacro.HasString())
                            {
                                ((MacroObjectString)newmacro).Text = ((TextBox)sss).Text;
                            }
                        };

                        b.Parent.Add(textbox);
                        b.Parent.WantUpdateSize = true;

                        break;
                    }
                }
            };

            box.Tag = obj;
            _scrollArea.Add(box);
            _comboboxes.Add(box);


            if (obj.Code != MacroType.None)
            {
                switch (obj.HasSubMenu)
                {
                case 1:
                    int count  = 0;
                    int offset = 0;

                    Macro.GetBoundByCode(obj.Code, ref count, ref offset);

                    Combobox subBox = new Combobox(20, box.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                                                   .Skip(offset)
                                                   .Take(count)
                                                   .ToArray(), (int)(obj.SubCode - offset), 300);


                    subBox.OnOptionSelected += (ss, ee) =>
                    {
                        Macro.GetBoundByCode(obj.Code, ref count, ref offset);
                        MacroSubType subType = (MacroSubType)(offset + ee);
                        obj.SubCode = subType;
                    };

                    box.Parent.Add(subBox);
                    box.Parent.WantUpdateSize = true;

                    break;

                case 2:

                    box.Parent.Add(new ResizePic(0x0BB8)
                    {
                        X      = 18,
                        Y      = box.Height + 2,
                        Width  = 240,
                        Height = box.Height * 2 + 4
                    });

                    TextBox textbox = new TextBox(new TextEntry(0xFF, 80, 0, 236, true, FontStyle.BlackBorder), true)
                    {
                        X      = 20,
                        Y      = box.Height + 5,
                        Height = box.Height * 2
                    };
                    textbox.TxEntry.SetHeight(box.Height * 2);
                    textbox.SetText(obj.HasString() ? ((MacroObjectString)obj).Text : string.Empty);
                    textbox.TextChanged += (sss, eee) =>
                    {
                        if (obj.HasString())
                        {
                            ((MacroObjectString)obj).Text = ((TextBox)sss).Text;
                        }
                    };

                    box.Parent.Add(textbox);
                    box.Parent.WantUpdateSize = true;

                    break;
                }
            }
        }
Beispiel #4
0
 public MacroObjectString(MacroType code, MacroSubType sub, string str = "") : base(code, sub)
 {
     Text = str;
 }