Пример #1
0
        /// <summary>
        /// Reads the information in the persistance item and exports it into a new ToolbarInfo class.
        /// </summary>
        public static void ReadInfo(Mobile mob, out ToolbarInfo info)
        {
            EnsureMaxed(mob);
            Account acc = mob.Account as Account;

            info = null;
            for (int i = 0; i < ToolbarHelper.Infos.Info.Count; i++)
            {
                if (ToolbarHelper.Infos.Info[i].Account == acc.Username)
                {
                    info = ToolbarHelper.Infos.Info[i];
                }
            }
            if (info == null)
            {
                info = ToolbarInfo.CreateNew(mob, acc);
            }
        }
Пример #2
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)ToolbarHelper.Version);

            writer.Write((int)Info.Count);

            for (int i = 0; i < Info.Count; i++)
            {
                ToolbarInfo t = Info[i] as ToolbarInfo;

                // Version 1.3
                writer.Write((int)t.Font);
                writer.Write((bool)t.Phantom);
                writer.Write((bool)t.Stealth);
                writer.Write((bool)t.Reverse);
                writer.Write((bool)t.Lock);

                // Version 1.0
                writer.Write((string)t.Account);

                writer.Write((int)t.Dimensions.Count);
                for (int j = 0; j < t.Dimensions.Count; j++)
                {
                    writer.Write((int)t.Dimensions[j]);
                }

                writer.Write((int)t.Entries.Count);
                for (int k = 0; k < t.Entries.Count; k++)
                {
                    writer.Write((string)t.Entries[k]);
                }

                writer.Write((int)t.Skin);

                writer.Write((int)t.Points.Count);
                for (int l = 0; l < t.Points.Count; l++)
                {
                    writer.Write((Point3D)t.Points[l]);
                }
            }
        }
Пример #3
0
        public ToolbarEdit(ToolbarInfo info, bool expanded, List <string> commands, int skin, int columns, int rows, int font, bool[] switches)  : base(0, 28)
        {
            p_Info        = info;
            p_Expanded    = expanded;
            p_ExpandedInt = expanded ? 2 : 1;

            p_Font    = font;
            p_Phantom = switches[0];
            p_Stealth = switches[1];
            p_Reverse = switches[2];
            p_Lock    = switches[3];

            p_Commands = commands;
            p_Skin     = skin;
            p_Columns  = columns;
            p_Rows     = rows;

            AddInit();
            AddControls();
            AddNavigation();
            AddResponses();
            AddEntries();
        }
Пример #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile m = sender.Mobile;

            TextRelays = CreateList(info.TextEntries);


            bool[] switches = new bool[4]
            {
                info.IsSwitched(21),
                info.IsSwitched(23),
                info.IsSwitched(25),
                info.IsSwitched(27)
            };

            switch (info.ButtonID)
            {
            case 0: break;

            case 1: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin + 1, Columns, Rows, Font, switches)); break;

            case 2: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin - 1, Columns, Rows, Font, switches)); break;

            case 3: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows + 1, Font, switches)); break;

            case 4: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows - 1, Font, switches)); break;

            case 5: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns + 1, Rows, Font, switches)); break;

            case 6: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns - 1, Rows, Font, switches)); break;

            //case 7:
            //m.SendGump( new ToolbarEdit( p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches ));
            //m.SendMessage( 32, "The Marker utility is not an active feature yet; please be patient." );
            //goto case 0;
            case 9:                             // Default
                List <string> toolbarinfo = ToolbarInfo.DefaultEntries((int)m.AccessLevel);
                CombineEntries(toolbarinfo);
                toolbarinfo.AddRange(AnalyzeEntries(toolbarinfo.Count));
                m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, toolbarinfo, Skin, Columns, Rows, Font, switches));
                break;

            case 10:                            // Okay
                goto case 12;

            case 11:                            // Cancel
                goto case 0;

            case 12:                            // Apply
                Account     acc   = m.Account as Account;
                ToolbarInfo infos = null;
                for (int i = 0; i < ToolbarHelper.Infos.Info.Count; i++)
                {
                    if (ToolbarHelper.Infos.Info[i].Account == acc.Username)
                    {
                        infos = ToolbarHelper.Infos.Info[i];
                    }
                }
                if (infos == null)
                {
                    infos = ToolbarInfo.CreateNew(m, acc);
                }
                List <int> dims = new List <int>();
                dims.Add(Columns);
                dims.Add(Rows);

                infos.SetAttributes(acc.Username, dims, AnalyzeEntries(), Skin, infos.Points, Font, switches);

                if (info.ButtonID == 12)
                {
                    m.SendGump(new ToolbarEdit(infos, this.p_Expanded));
                }
                m.CloseGump(typeof(Toolbar));
                m.SendGump(new Toolbar(infos));
                break;

            case 18: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font + 1, switches)); break;

            case 19: m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font - 1, switches)); break;

            case 20:
                m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches));
                m.SendMessage(2101, "Phantom mode turns the toolbar semi-transparent.");
                break;

            case 22:
                m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches));
                m.SendMessage(2101, "Stealth mode makes the toolbar automatically minimize when you click a button.");
                break;

            case 24:
                m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches));
                m.SendMessage(2101, "Reverse mode puts the minimize bar above the toolbar instead of below.");
                break;

            case 26:
                m.SendGump(new ToolbarEdit(p_Info, this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches));
                m.SendMessage(2101, "Lock mode disables closing the toolbar with right-click.");
                break;

            case 28:                            // Expand
                m.SendGump(new ToolbarEdit(p_Info, !this.p_Expanded, AnalyzeEntries(), Skin, Columns, Rows, Font, switches));
                m.SendMessage(2101, "Expanded view {0}activated.", this.p_Expanded ? "de" : "");
                break;
            }
        }
Пример #5
0
 public ToolbarEdit(ToolbarInfo info, List <string> commands, int skin, int columns, int rows, int font, bool[] switches) : this(info, false, commands, skin, columns, rows, font, switches)
 {
 }
Пример #6
0
 public ToolbarEdit(ToolbarInfo info, bool expanded) : this(info, expanded, info.Entries, info.Skin, info.Dimensions[0], info.Dimensions[1], info.Font, new bool[] { info.Phantom, info.Stealth, info.Reverse, info.Lock })
 {
 }
Пример #7
0
 public ToolbarEdit(ToolbarInfo info) : this(info, false)
 {
 }
Пример #8
0
        public Toolbar(ToolbarInfo info) : base(0, 28)
        {
            p_Info = info;

            // Version 1.3
            p_Font    = info.Font;
            p_Phantom = info.Phantom;
            p_Stealth = info.Stealth;
            p_Reverse = info.Reverse;
            p_Lock    = info.Lock;

            // Version 1.0
            p_Commands = info.Entries;
            p_Skin     = info.Skin;
            p_Columns  = info.Dimensions[0];
            p_Rows     = info.Dimensions[1];

            if (Lock)
            {
                Closable = false;
            }

            int offset = GumpIDs.Misc[(int)GumpIDs.MiscIDs.ButtonOffset].Content[p_Skin, 0];
            int bx = ((offset * 2) + (Columns * 110)), by = ((offset * 2) + (Rows * 24)), byx = by, cy = 0;

            SetCoords(offset);

            if (Reverse)
            {
                cy = InitOptsH;
                by = 0;
            }

            AddPage(0);
            AddPage(1);
            if (Stealth)
            {
                AddMinimized(by, offset);
                AddPage(2);
            }

            AddInitOpts(by, offset);

            AddBackground(0, cy, bx, byx, GumpIDs.Misc[(int)GumpIDs.MiscIDs.Background].Content[p_Skin, 0]);

            string font = GumpIDs.Fonts[Font];

            if (Phantom)
            {
                font += "<BASEFONT COLOR=#FFFFFF>";
            }

            int temp = 0, x = 0, y = 0;

            for (int i = 0; i < Columns * Rows; i++)
            {
                x = offset + ((i % Columns) * 110);
                y = offset + (int)(Math.Floor((double)(i / Columns)) * 24) + cy;
                AddButton(x + 1, y, 2445, 2445, temp + 10, GumpButtonType.Reply, 0);
                AddBackground(x, y, 110, 24, GumpIDs.Misc[(int)GumpIDs.MiscIDs.Buttonground].Content[p_Skin, 0]);

                if (Phantom)
                {
                    AddImageTiled(x + 2, y + 2, 106, 20, 2624);                  // Alpha Area 1_1
                    AddAlphaRegion(x + 2, y + 2, 106, 20);                       // Alpha Area 1_2
                }

                AddHtml(x + 5, y + 3, 100, 20, String.Format("<center>{0}{1}", font, Commands[temp]), false, false);
                //AddLabelCropped(x + 5, y + 3, 100, 20, GumpIDs.Misc[(int)GumpIDs.MiscIDs.Color].Content[p_Skin,0], Commands[temp]);

                if (i % Columns == Columns - 1)
                {
                    temp += 9 - Columns;
                }
                temp++;
            }

            /*TEST---
             * 0%5 == 0
             * 1%5 == 1
             * 2%5 == 2
             * 3%5 == 3
             * 4%5 == 4
             * 5%5 == 0
             * END TEST---*/

            if (!Stealth)
            {
                AddPage(2);
                AddMinimized(by, offset);
            }
        }
Пример #9
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            ToolbarHelper.Infos = this;

            int count = reader.ReadInt();

            // Version 1.3
            int  font = 0;
            bool phantom = true, stealth = false, reverse = false, locked = true;

            // Version 1.0
            string         account;
            List <int>     dimensions;
            List <string>  entries;
            int            subcount, skin;
            List <Point3D> points;

            for (int i = 0; i < count; i++)
            {
                switch (version)
                {
                case 130:
                {
                    font    = reader.ReadInt();
                    phantom = reader.ReadBool();
                    stealth = reader.ReadBool();
                    reverse = reader.ReadBool();
                    locked  = reader.ReadBool();
                    goto case 100;
                }

                default:
                case 100:
                {
                    account = reader.ReadString();

                    dimensions = new List <int>();

                    subcount = reader.ReadInt();
                    for (int j = 0; j < subcount; j++)
                    {
                        dimensions.Add(reader.ReadInt());
                    }

                    entries = new List <string>();

                    subcount = reader.ReadInt();
                    for (int k = 0; k < subcount; k++)
                    {
                        entries.Add(reader.ReadString());
                    }

                    skin = reader.ReadInt();

                    points = new List <Point3D>();

                    subcount = reader.ReadInt();
                    for (int l = 0; l < subcount; l++)
                    {
                        points.Add(reader.ReadPoint3D());
                    }

                    break;
                }
                }

                ToolbarInfo info = new ToolbarInfo(account, dimensions, entries, skin, points, font, new bool[] { phantom, stealth, reverse, locked });
            }
        }