示例#1
0
        private void SetupMacroUI()
        {
            if (Macro == null)
            {
                return;
            }

            _databox.Clear();
            _databox.Children.Clear();

            if (Macro.Items == null)
            {
                Macro.Items = Macro.Create(MacroType.None);
            }

            MacroObject obj = (MacroObject)Macro.Items;

            while (obj != null)
            {
                _databox.Add(new MacroEntry(this, obj, _allHotkeysNames));

                if (obj.Next != null && obj.Code == MacroType.None)
                {
                    break;
                }

                obj = (MacroObject)obj.Next;
            }

            _databox.WantUpdateSize = true;
            _databox.ReArrangeChildren();
        }
示例#2
0
        private void AddEmptyMacro()
        {
            MacroObject ob = (MacroObject)Macro.Items;

            if (ob.Code == MacroType.None)
            {
                return;
            }

            while (ob.Next != null)
            {
                MacroObject next = (MacroObject)ob.Next;

                if (next.Code == MacroType.None)
                {
                    return;
                }

                ob = next;
            }

            MacroObject obj = Macro.Create(MacroType.None);

            Macro.PushToBack(obj);

            _databox.Add(new MacroEntry(this, obj, _allHotkeysNames));
            _databox.WantUpdateSize = true;
            _databox.ReArrangeChildren();
        }
示例#3
0
            public MacroEntry(MacroControl control, MacroObject obj, string[] items)
            {
                _control = control;
                _items   = items;

                Combobox mainBox = new Combobox
                                   (
                    0,
                    0,
                    200,
                    _items,
                    (int)obj.Code
                                   )
                {
                    Tag = obj
                };

                mainBox.OnOptionSelected += BoxOnOnOptionSelected;

                Add(mainBox);

                Width  = mainBox.Width;
                Height = mainBox.Height;

                AddSubMacro(obj);

                WantUpdateSize = true;
            }
示例#4
0
        public void AddEmpty()
        {
            MacroObject ob = Macro.FirstNode;

            if (ob.Code == MacroType.None)
            {
                return;
            }

            while (ob.Right != null)
            {
                if (ob.Right.Code == MacroType.None)
                {
                    return;
                }

                ob = ob.Right;
            }

            MacroObject obj = Macro.Create(MacroType.None);

            ob.Right  = obj;
            obj.Left  = ob;
            obj.Right = null;

            CreateCombobox(obj);
        }
示例#5
0
            private void BoxOnOnOptionSelected(object sender, int e)
            {
                WantUpdateSize = true;

                Combobox    box = (Combobox)sender;
                MacroObject m   = (MacroObject)box.Tag;

                if (e == 0)
                {
                    _control.Macro.Remove(m);

                    box.Tag = null;

                    Dispose();

                    _control.SetupMacroUI();
                }
                else
                {
                    MacroObject newmacro = Macro.Create((MacroType)e);

                    _control.Macro.Remove(m);
                    _control.Macro.PushToBack(newmacro);

                    box.Tag = newmacro;


                    for (int i = 1; i < Children.Count; i++)
                    {
                        Children[i]?.Dispose();
                    }

                    Height = box.Height;

                    AddSubMacro(newmacro);
                }
            }
示例#6
0
        public MacroCollectionControl(string name, int w, int h)
        {
            CanMove     = true;
            _scrollArea = new ScrollArea(0, 50, w, h, true);
            Add(_scrollArea);


            GameScene scene = CUOEnviroment.Client.GetScene <GameScene>();

            foreach (Macro macro in scene.Macros.GetAllMacros())
            {
                if (macro.Name == name)
                {
                    Macro = macro;

                    break;
                }
            }

            if (Macro == null)
            {
                Macro = Macro.CreateEmptyMacro(name);
                scene.Macros.AppendMacro(Macro);

                CreateCombobox(Macro.FirstNode);
            }
            else
            {
                MacroObject o = Macro.FirstNode;

                while (o != null)
                {
                    CreateCombobox(o);
                    o = o.Right;
                }
            }
        }
示例#7
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();
            }
示例#8
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;
                }
            }
        }