Ejemplo n.º 1
0
            public CatSelGump(string sys, ACCGumpParams subParams, PGLocation loc)
                : base(0, 0)
            {
                if (sys == null || subParams == null || loc == null || m_CategoryList == null)
                {
                    return;
                }

                Sys = sys;
                if (subParams is PGGumpParams)
                {
                    Params = subParams as PGGumpParams;
                }
                Loc = loc;

                AddPage(0);
                AddBackground(640, 0, 160, 400, 5120);

                for (int i = 0; i < PGSystem.CategoryList.Count; i++)
                {
                    PGCategory PGC = m_CategoryList[i];
                    if (PGC != null)
                    {
                        AddButton(650, 10 + i * 30, 2501, 2501, 1 + i, GumpButtonType.Reply, 0);
                        AddLabel(675, 10 + i * 30, 1153, PGC.Name);
                    }
                }
            }
Ejemplo n.º 2
0
        public PGAddEditGump(Conditions conditions, int curC, int curL, PublicGate gate) : base(0, 0)
        {
            if (!PGSystem.Running)
            {
                return;
            }

            m_Conditions = conditions;
            m_CurCat     = curC;
            m_CurLoc     = curL;
            m_Gate       = gate;

            if (!GetFlag(Conditions.Category) || (GetFlag(Conditions.Category) && !GetFlag(Conditions.Adding)))
            {
                m_Cat = PGSystem.CategoryList[curC];
            }
            if (m_Cat != null && (!GetFlag(Conditions.Category) && !GetFlag(Conditions.Adding)))
            {
                m_Loc = m_Cat.Locations[curL];
            }


            string Name = "";

            if (!GetFlag(Conditions.Adding))
            {
                if (GetFlag(Conditions.Category))
                {
                    Name = m_Cat.Name;
                }
                else
                {
                    Name = m_Loc.Name;
                }
            }

            Point3D Loc = new Point3D(0, 0, 0);
            Map     Map = Map.Trammel;
            bool    Gen, Staff, Reds, Charge, Young;
            int     Hue, Cost;

            Gen = Staff = Reds = Charge = Young = false;
            Hue = Cost = 0;

            if (GetFlag(Conditions.Category) && !GetFlag(Conditions.Adding))
            {
                Gen    = m_Cat.GetFlag(EntryFlag.Generate);
                Staff  = m_Cat.GetFlag(EntryFlag.StaffOnly);
                Reds   = m_Cat.GetFlag(EntryFlag.Reds);
                Charge = m_Cat.GetFlag(EntryFlag.Charge);
                Young  = m_Cat.GetFlag(EntryFlag.Young);
                Cost   = m_Cat.Cost;
            }

            if (!GetFlag(Conditions.Category) && !GetFlag(Conditions.Adding))
            {
                Loc    = m_Loc.Location;
                Map    = m_Loc.Map;
                Gen    = m_Loc.GetFlag(EntryFlag.Generate);
                Staff  = m_Loc.GetFlag(EntryFlag.StaffOnly);
                Reds   = m_Loc.GetFlag(EntryFlag.Reds);
                Charge = m_Loc.GetFlag(EntryFlag.Charge);
                Young  = m_Loc.GetFlag(EntryFlag.Young);
                Hue    = m_Loc.Hue;
                Cost   = m_Loc.Cost;
            }

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddPage(0);

            AddBackground(530, 100, 230, 410, 2600);
            AddLabel(602, 120, 0, string.Format("{0} {1}", (GetFlag(Conditions.Adding) ? "Add" : "Edit"), (GetFlag(Conditions.Category) ? "Category" : "Location")));

            AddLabel(625, 145, 0, "Name :");
            AddImage(555, 170, 2446);
            AddTextEntry(565, 170, 160, 20, 0, 2, Name);

            AddLabel(715, 235, 0, ": C");
            AddImage(650, 235, 2443);
            AddTextEntry(655, 235, 55, 20, 0, 15, Cost.ToString());

            if (!GetFlag(Conditions.Category))
            {
                AddLabel(560, 210, 0, "X :");
                AddImage(580, 210, 2443);
                AddTextEntry(585, 210, 55, 20, 0, 3, Loc.X.ToString());

                AddLabel(560, 235, 0, "Y :");
                AddImage(580, 235, 2443);
                AddTextEntry(585, 235, 55, 20, 0, 4, Loc.Y.ToString());

                AddLabel(560, 260, 0, "Z :");
                AddImage(580, 260, 2443);
                AddTextEntry(585, 260, 55, 20, 0, 5, Loc.Z.ToString());

                AddLabel(715, 210, 0, ": H");
                AddImage(650, 210, 2443);
                AddTextEntry(655, 210, 55, 20, 0, 14, Hue.ToString());

                AddLabel(585, 315, 0, "Trammel");
                AddRadio(555, 315, 208, 209, (Map == Map.Trammel ? true : false), 6);

                AddLabel(585, 340, 0, "Felucca");
                AddRadio(555, 340, 208, 209, (Map == Map.Felucca ? true : false), 7);

                AddLabel(685, 315, 0, "Malas");
                AddRadio(655, 315, 208, 209, (Map == Map.Malas ? true : false), 8);

                AddLabel(685, 345, 0, "Ilshenar");
                AddRadio(655, 340, 208, 209, (Map == Map.Ilshenar ? true : false), 9);

                AddLabel(585, 365, 0, "Tokuno");
                AddRadio(555, 370, 208, 209, (Map == Map.Tokuno ? true : false), 10);

                AddLabel(685, 365, 0, "TerMur");
                AddRadio(655, 370, 208, 209, (Map == Map.TerMur ? true : false), 20);
            }


            AddLabel(585, 395, 0, "Generate?");
            AddCheck(555, 395, 210, 211, Gen, 11);

            AddLabel(665, 395, 0, "Young?");
            AddCheck(715, 395, 210, 211, Young, 16);

            AddLabel(585, 420, 0, "Reds?");
            AddCheck(555, 420, 210, 211, Reds, 13);

            AddLabel(658, 420, 0, "Charge?");
            AddCheck(715, 420, 210, 211, Charge, 17);

            AddLabel(585, 445, 0, "Staff Only?");
            AddCheck(555, 445, 210, 211, Staff, 12);

            AddButton(700, 450, 1417, 1417, 1, GumpButtonType.Reply, 0);
            AddLabel(728, 481, 69, "Apply");
        }
Ejemplo n.º 3
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (state.Mobile.AccessLevel < PGSystem.PGAccessLevel)
            {
                return;
            }

            Mobile from = state.Mobile;
            int    BID  = info.ButtonID;

            if (BID == 0)
            {
                return;
            }

            SetFlag(EntryFlag.Generate, info.IsSwitched(11));
            SetFlag(EntryFlag.StaffOnly, info.IsSwitched(12));
            SetFlag(EntryFlag.Reds, info.IsSwitched(13));
            SetFlag(EntryFlag.Young, info.IsSwitched(16));
            SetFlag(EntryFlag.Charge, info.IsSwitched(17));

            Map Map = null;

            for (int i = 0; i < info.Switches.Length; i++)
            {
                int m = info.Switches[i];
                switch (m)
                {
                case 6:  Map = Map.Trammel;  break;

                case 7:  Map = Map.Felucca;  break;

                case 8:  Map = Map.Malas;    break;

                case 9:  Map = Map.Ilshenar; break;

                case 10: Map = Map.Tokuno;   break;

                case 20: Map = Map.TerMur;   break;
                }
            }


            TextRelay NR = info.GetTextEntry(2);
            TextRelay XR = info.GetTextEntry(3);
            TextRelay YR = info.GetTextEntry(4);
            TextRelay ZR = info.GetTextEntry(5);
            TextRelay HR = info.GetTextEntry(14);
            TextRelay CR = info.GetTextEntry(15);
            string    NS = (NR == null ? null : NR.Text.Trim());
            string    XS = (XR == null ? null : XR.Text.Trim());
            string    YS = (YR == null ? null : YR.Text.Trim());
            string    ZS = (ZR == null ? null : ZR.Text.Trim());
            string    HS = (HR == null ? null : HR.Text.Trim());
            string    CS = (CR == null ? null : CR.Text.Trim());

            if (BID == 1)
            {
                if (GetFlag(Conditions.Category))
                {
                    if (GetFlag(Conditions.Adding))
                    {
                        if (NS == null || NS.Length == 0 || CS == null || CS.Length == 0)
                        {
                            from.SendMessage("Please enter a name and cost for this Category.");
                            from.CloseGump(typeof(PGAddEditGump));
                            from.SendGump(new PGAddEditGump(m_Conditions, m_CurCat, m_CurLoc, m_Gate));
                            return;
                        }

                        int c = 0;
                        try
                        {
                            c = Int32.Parse(CS);
                            PGSystem.CategoryList.Add(new PGCategory(NS, Flags, c));
                            from.SendMessage("Added Category.");
                        }
                        catch
                        {
                            from.SendMessage("Bad cost value, defaulting to 0.");
                            PGSystem.CategoryList.Add(new PGCategory(NS, Flags));
                        }
                    }

                    else
                    {
                        if (NS == null || NS.Length == 0)
                        {
                            from.SendMessage("Removed the Category.");
                            PGSystem.CategoryList.RemoveAt(m_CurCat);
                            m_CurCat = 0;
                        }

                        else
                        {
                            from.SendMessage("Changed the Category.");
                            PGSystem.CategoryList[m_CurCat].Name  = NS;
                            PGSystem.CategoryList[m_CurCat].Flags = Flags;
                            if (CS == null || CS.Length == 0)
                            {
                                PGSystem.CategoryList[m_CurCat].Cost = 0;
                            }
                            else
                            {
                                int c = 0;

                                try
                                {
                                    c = Int32.Parse(CS);
                                    PGSystem.CategoryList[m_CurCat].Cost = c;
                                }
                                catch
                                {
                                    PGSystem.CategoryList[m_CurCat].Cost = 0;
                                }
                            }
                        }
                    }
                }

                else
                {
                    if (NS == null || NS.Length == 0 ||
                        XS == null || XS.Length == 0 ||
                        YS == null || YS.Length == 0 ||
                        ZS == null || ZS.Length == 0 ||
                        HS == null || HS.Length == 0 ||
                        CS == null || CS.Length == 0)
                    {
                        if (GetFlag(Conditions.Adding))
                        {
                            from.SendMessage("Please fill in each field.");
                            from.CloseGump(typeof(PGAddEditGump));
                            from.SendGump(new PGAddEditGump(m_Conditions, m_CurCat, m_CurLoc, m_Gate));
                            return;
                        }

                        from.SendMessage("Removed the Location.");
                        PGSystem.CategoryList[m_CurCat].Locations.RemoveAt(m_CurLoc);
                    }

                    else if (Map == null)
                    {
                        from.SendMessage("Please select a Map.");
                        from.CloseGump(typeof(PGAddEditGump));
                        from.SendGump(new PGAddEditGump(m_Conditions, m_CurCat, m_CurLoc, m_Gate));
                        return;
                    }

                    else
                    {
                        int     x, y, z, h, c = 0;
                        Point3D Loc;
                        int     Hue;
                        int     Cost;
                        try
                        {
                            x    = Int32.Parse(XS);
                            y    = Int32.Parse(YS);
                            z    = Int32.Parse(ZS);
                            h    = Int32.Parse(HS);
                            c    = Int32.Parse(CS);
                            Loc  = new Point3D(x, y, z);
                            Hue  = h;
                            Cost = c;
                        }
                        catch
                        {
                            from.SendMessage("Please enter an integer in each of the info fields. (X, Y, Z, H, C)");
                            from.CloseGump(typeof(PGAddEditGump));
                            from.SendGump(new PGAddEditGump(m_Conditions, m_CurCat, m_CurLoc, m_Gate));
                            return;
                        }

                        PGLocation PGL = new PGLocation(NS, Flags, Loc, Map, Hue, Cost);
                        if (PGL == null)
                        {
                            from.SendMessage("Bad Location information, can't add!");
                            from.CloseGump(typeof(PGAddEditGump));
                            from.SendGump(new PGAddEditGump(m_Conditions, m_CurCat, m_CurLoc, m_Gate));
                            return;
                        }

                        if (GetFlag(Conditions.Adding))
                        {
                            from.SendMessage("Added the Location.");
                            PGSystem.CategoryList[m_CurCat].Locations.Add(PGL);
                        }
                        else
                        {
                            from.SendMessage("Changed the Location.");
                            PGSystem.CategoryList[m_CurCat].Locations[m_CurLoc] = PGL;
                        }
                    }
                }

                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, m_CurCat, m_Gate));
            }
        }
Ejemplo n.º 4
0
        public override void Gump(Mobile from, Gump gump, ACCGumpParams subParams)
        {
            gump.AddButton(195, 40, 2445, 2445, 101, GumpButtonType.Reply, 0);
            gump.AddLabel(200, 41, 1153, "Manage System");
            gump.AddButton(310, 40, 2445, 2445, 102, GumpButtonType.Reply, 0);
            gump.AddLabel(342, 41, 1153, "Import");

            if (subParams == null || !(subParams is PGGumpParams))
            {
                gump.AddHtml(215, 65, 300, 25, "<basefont size=7 color=white><center>Public Gates</center></font>", false, false);
                gump.AddHtml(140, 95, 450, 250, "<basefont color=white><center>Welcome to the Public Gate Admin Gump!</center><br>With this gump, you can manage the entire system and import and export locations or full categories.  Please choose an option from the top bar.<br><br>Manage System allows you to add/change/delete locations and categories from anywhere in the world.<br><br>Im/Ex port allows you to import or export categories and locations to files that you can distribute to other servers that use this system.</font>", false, false);
                return;
            }

            Params = subParams as PGGumpParams;

            switch ((int)Params.Page)
            {
                #region Manage Gump Code
            case (int)Pages.Manage:
            {
                gump.AddBackground(640, 0, 160, 400, 5120);
                gump.AddButton(425, 40, 2445, 2445, 123, GumpButtonType.Reply, 0);
                gump.AddLabel(456, 41, 1153, "Export");

                for (int i = 0; i < m_CategoryList.Count && i < 50; i++)
                {
                    PGCategory PGC = m_CategoryList[i];
                    if (PGC != null)
                    {
                        gump.AddButton(650, 10 + i * 30, 2501, 2501, 150 + i, GumpButtonType.Reply, 0);
                        gump.AddButton(655, 12 + i * 30, (Params.SelectedCategory.Key == PGC ? 5401 : 5402), (Params.SelectedCategory.Key == PGC ? 5402 : 5401), 150 + i, GumpButtonType.Reply, 0);
                        gump.AddLabel(675, 10 + i * 30, 1153, PGC.Name);
                    }
                }

                if (Params.SelectedCategory.Key != null)
                {
                    gump.AddBackground(425, 75, 170, 285, 5120);
                    gump.AddButton(195, 65, 2445, 2445, 121, GumpButtonType.Reply, 0);
                    gump.AddLabel(206, 66, 1153, "Add Category");
                    gump.AddButton(310, 65, 2445, 2445, 122, GumpButtonType.Reply, 0);
                    gump.AddLabel(322, 66, 1153, "Add Location");

                    for (int i = 0, c = 0, r = 0; i < Params.SelectedCategory.Key.Locations.Count; i++)
                    {
                        PGLocation PGL = Params.SelectedCategory.Key.Locations[i];
                        if (PGL != null)
                        {
                            gump.AddButton(120 + c * 150, 100 + r * 30, 2501, 2501, 200 + i, GumpButtonType.Reply, 0);
                            gump.AddButton(125 + c * 150, 102 + r * 30, (Params.SelectedLocation.Key == PGL ? 5401 : 5402), (Params.SelectedLocation.Key == PGL ? 5402 : 5401), 200 + i, GumpButtonType.Reply, 0);
                            gump.AddLabel(145 + c * 150, 100 + r * 30, 1153, PGL.Name);
                            r += (c == 1 ? 1 : 0);
                            c += (c == 1 ? -1 : 1);
                        }
                    }

                    if (Params.SelectedLocation.Key != null)
                    {
                        gump.AddButton(550, 265, 2642, 2643, 103, GumpButtonType.Reply, 0);         //Apply Location

                        gump.AddImage(440, 85, 2501);
                        gump.AddTextEntry(446, 85, 130, 20, 0, 105, Params.SelectedLocation.Key.Name);

                        gump.AddImage(445, 110, 2443);
                        gump.AddImage(513, 110, 2443);
                        gump.AddImage(445, 135, 2443);
                        gump.AddImage(513, 135, 2443);
                        gump.AddImage(445, 160, 2443);

                        gump.AddTextEntry(450, 110, 53, 20, 0, 106, Params.SelectedLocation.Key.Location.X.ToString());
                        gump.AddTextEntry(518, 110, 53, 20, 0, 107, Params.SelectedLocation.Key.Location.Y.ToString());
                        gump.AddTextEntry(450, 135, 53, 20, 0, 108, Params.SelectedLocation.Key.Location.Z.ToString());
                        gump.AddTextEntry(518, 135, 53, 20, 0, 109, Params.SelectedLocation.Key.Hue.ToString());
                        gump.AddTextEntry(450, 160, 53, 20, 0, 110, Params.SelectedLocation.Key.Cost.ToString());

                        gump.AddLabel(435, 112, 1153, "X");
                        gump.AddLabel(578, 112, 1153, "Y");
                        gump.AddLabel(435, 137, 1153, "Z");
                        gump.AddLabel(578, 137, 1153, "H");
                        gump.AddLabel(435, 162, 1153, "C");

                        gump.AddRadio(435, 190, 208, 209, (Params.SelectedLocation.Key.Map == Map.Trammel), 111);
                        gump.AddRadio(570, 190, 208, 209, (Params.SelectedLocation.Key.Map == Map.Malas), 112);
                        gump.AddRadio(435, 215, 208, 209, (Params.SelectedLocation.Key.Map == Map.Felucca), 113);
                        gump.AddRadio(570, 215, 208, 209, (Params.SelectedLocation.Key.Map == Map.Ilshenar), 114);
                        gump.AddRadio(435, 240, 208, 209, (Params.SelectedLocation.Key.Map == Map.Tokuno), 115);

                        gump.AddLabel(460, 192, 1153, "Tram");
                        gump.AddLabel(530, 192, 1153, "Malas");
                        gump.AddLabel(460, 217, 1153, "Fel");
                        gump.AddLabel(542, 217, 1153, "Ilsh");
                        gump.AddLabel(460, 242, 1153, "Tokuno");

                        gump.AddLabel(465, 282, 1153, "Young?");
                        gump.AddCheck(440, 280, 210, 211, Params.SelectedLocation.Key.GetFlag(EntryFlag.Young), 120);
                        gump.AddLabel(465, 307, 1153, "Gen?");
                        gump.AddCheck(440, 305, 210, 211, Params.SelectedLocation.Key.GetFlag(EntryFlag.Generate), 116);
                        gump.AddLabel(515, 307, 1153, "Staff?");
                        gump.AddCheck(565, 305, 210, 211, Params.SelectedLocation.Key.GetFlag(EntryFlag.StaffOnly), 117);
                        gump.AddLabel(465, 332, 1153, "Reds?");
                        gump.AddCheck(440, 330, 210, 211, Params.SelectedLocation.Key.GetFlag(EntryFlag.Reds), 118);
                        gump.AddLabel(522, 332, 1153, "Chrg?");
                        gump.AddCheck(565, 330, 210, 211, Params.SelectedLocation.Key.GetFlag(EntryFlag.Charge), 119);
                    }

                    else
                    {
                        gump.AddButton(550, 265, 2642, 2643, 104, GumpButtonType.Reply, 0);         //Apply Category

                        gump.AddImage(440, 110, 2501);
                        gump.AddTextEntry(446, 110, 130, 20, 0, 105, Params.SelectedCategory.Key.Name);

                        gump.AddImage(445, 160, 2443);
                        gump.AddTextEntry(450, 160, 53, 20, 0, 110, Params.SelectedCategory.Key.Cost.ToString());
                        gump.AddLabel(435, 162, 1153, "C");

                        gump.AddLabel(465, 282, 1153, "Young?");
                        gump.AddCheck(440, 280, 210, 211, Params.SelectedCategory.Key.GetFlag(EntryFlag.Young), 120);
                        gump.AddLabel(465, 307, 1153, "Gen?");
                        gump.AddCheck(440, 305, 210, 211, Params.SelectedCategory.Key.GetFlag(EntryFlag.Generate), 116);
                        gump.AddLabel(515, 307, 1153, "Staff?");
                        gump.AddCheck(565, 305, 210, 211, Params.SelectedCategory.Key.GetFlag(EntryFlag.StaffOnly), 117);
                        gump.AddLabel(465, 332, 1153, "Reds?");
                        gump.AddCheck(440, 330, 210, 211, Params.SelectedCategory.Key.GetFlag(EntryFlag.Reds), 118);
                        gump.AddLabel(522, 332, 1153, "Chrg?");
                        gump.AddCheck(565, 330, 210, 211, Params.SelectedCategory.Key.GetFlag(EntryFlag.Charge), 119);
                    }
                }
                break;
            }
                #endregion //Manage Gump Code

                #region Import Gump Code
            case (int)Pages.Import:
            {        //Import
                if (!Directory.Exists("Data/ACC Exports"))
                {
                    from.SendMessage("There are no files to import!");
                    return;
                }

                gump.AddButton(195, 65, 2445, 2445, 124, GumpButtonType.Reply, 0);         //Switch to Systems
                gump.AddLabel(220, 66, 1153, "Systems");

                gump.AddButton(310, 65, 2445, 2445, 125, GumpButtonType.Reply, 0);         //Switch to Categories
                gump.AddLabel(328, 66, 1153, "Categories");

                gump.AddButton(425, 65, 2445, 2445, 126, GumpButtonType.Reply, 0);         //Switch to Locations
                gump.AddLabel(447, 66, 1153, "Locations");
                switch ((int)Params.ImportSelection)
                {
                case (int)ImportSelections.Systems: { Dirs = Directory.GetFiles("Data/ACC Exports/", "*.pgs"); break; }

                case (int)ImportSelections.Categories: { Dirs = Directory.GetFiles("Data/ACC Exports/", "*.pgc"); break; }

                case (int)ImportSelections.Locations: { Dirs = Directory.GetFiles("Data/ACC Exports/", "*.pgl"); break; }

                default: { return; }
                }
                if (Dirs == null || Dirs.Length == 0)
                {
                    from.SendMessage("There are no files of that type!");
                    return;
                }
                for (int i = 0, r = 0, c = 0; i < Dirs.Length && c < 3; i++)
                {
                    string s = Dirs[i];
                    s = s.Remove(0, 12);
                    s = s.Remove(s.Length - 4, 4);
                    if (Params.ImportSelection == ImportSelections.Systems)
                    {
                        s = s.Remove(0, 9);
                    }

                    gump.AddButton(120 + c * 150, 100 + r * 30, 2501, 2501, 300 + i, GumpButtonType.Reply, 0);
                    gump.AddLabelCropped(125 + c * 150, 101 + r * 30, 140, 30, 1153, s);

                    c += (r == 7 ? 1 : 0);
                    r += (r == 7 ? -7 : 1);
                }
                break;
            }
                #endregion //Import Gump Code
            }
        }
Ejemplo n.º 5
0
        /* ID's:
         * 101 = Button Manage System
         * 102 = Button Import Page
         * 103 = Button Apply Location
         * 104 = Button Apply Category
         * 105 = Text   Name
         * 106 = Text   X
         * 107 = Text   Y
         * 108 = Text   Z
         * 109 = Text   Hue
         * 110 = Text   Cost
         * 111 = Radio  Trammel
         * 112 = Radio  Malas
         * 113 = Radio  Felucca
         * 114 = Radio  Ilshenar
         * 115 = Radio  Tokuno
         * 116 = Check  Generate
         * 117 = Check  StaffOnly
         * 118 = Check  Reds
         * 119 = Check  Charge
         * 120 = Check  Young
         * 121 = Button Add Category
         * 122 = Button Add Location
         * 123 = Button Export
         * 124 = Button Import Systems
         * 125 = Button Import Categories
         * 126 = Button Import Locations
         * 300+ = Imports
         */
        public override void OnResponse(NetState state, RelayInfo info, ACCGumpParams subParams)
        {
            if (info.ButtonID == 0 || state.Mobile.AccessLevel < ACC.GlobalMinimumAccessLevel)
            {
                return;
            }

            if (subParams is PGGumpParams)
            {
                Params = subParams as PGGumpParams;
            }

            PGGumpParams newParams = new PGGumpParams();

            if (info.ButtonID == 101)
            {
                newParams.Page = Pages.Manage;
            }

            else if (info.ButtonID == 102)
            {
                newParams.Page = Pages.Import;
            }

            #region Add/Remove
            else if (info.ButtonID == 103 || info.ButtonID == 104 || info.ButtonID == 121 || info.ButtonID == 122)
            {
                SetFlag(EntryFlag.Generate, info.IsSwitched(116));
                SetFlag(EntryFlag.StaffOnly, info.IsSwitched(117));
                SetFlag(EntryFlag.Reds, info.IsSwitched(118));
                SetFlag(EntryFlag.Charge, info.IsSwitched(119));

                Map Map = info.IsSwitched(111) ? Map.Trammel : info.IsSwitched(112) ? Map.Malas : info.IsSwitched(113) ? Map.Felucca : info.IsSwitched(114) ? Map.Ilshenar : info.IsSwitched(115) ? Map.Tokuno : Map.Trammel;

                string Name = GetString(info, 105);
                string X    = GetString(info, 106);
                string Y    = GetString(info, 107);
                string Z    = GetString(info, 108);
                string H    = GetString(info, 109);
                string C    = GetString(info, 110);

                if (Name == null || Name.Length == 0)
                {
                    try
                    {
                        state.Mobile.SendMessage("Removed the entry");
                        if (info.ButtonID == 103)
                        {
                            Params.SelectedCategory.Key.Locations.Remove(Params.SelectedLocation.Key);
                        }
                        else
                        {
                            m_CategoryList.Remove(Params.SelectedCategory.Key);
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Exception caught removing entry");
                    }
                }

                else
                {
                    if (info.ButtonID == 103 || info.ButtonID == 122)
                    {
                        int        x, y, z, h, c = 0;
                        Point3D    Loc;
                        int        Hue;
                        int        Cost;
                        PGLocation PGL;

                        if (X == null || X.Length == 0 ||
                            Y == null || Y.Length == 0 ||
                            Z == null || Z.Length == 0 ||
                            H == null || H.Length == 0 ||
                            C == null || C.Length == 0)
                        {
                            if (info.ButtonID == 122)
                            {
                                Hue  = 0;
                                Loc  = new Point3D(0, 0, 0);
                                Cost = 0;

                                PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                                if (PGL == null)
                                {
                                    state.Mobile.SendMessage("Error adding Location.");
                                    return;
                                }

                                m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                            }

                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            x    = Int32.Parse(X);
                            y    = Int32.Parse(Y);
                            z    = Int32.Parse(Z);
                            h    = Int32.Parse(H);
                            c    = Int32.Parse(C);
                            Loc  = new Point3D(x, y, z);
                            Hue  = h;
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer in each of the info fields. (X, Y, Z, H, Cost)");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                        if (PGL == null)
                        {
                            state.Mobile.SendMessage("Bad Location information, can't add!");
                        }
                        else
                        {
                            try
                            {
                                if (info.ButtonID == 122)
                                {
                                    m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                                    state.Mobile.SendMessage("Added the Location.");
                                }
                                else
                                {
                                    state.Mobile.SendMessage("Changed the Location.");
                                    m_CategoryList[Params.SelectedCategory.Value].Locations[Params.SelectedLocation.Value] = PGL;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Problem adding/changing Location!");
                            }
                        }
                    }

                    else
                    {
                        if (C == null || C.Length == 0)
                        {
                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        int c = 0;
                        int Cost;
                        try
                        {
                            c    = Int32.Parse(C);
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer for the Cost");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            if (info.ButtonID == 121)
                            {
                                m_CategoryList.Add(new PGCategory(Name, Flags, Cost));
                                state.Mobile.SendMessage("Added the Category.");
                            }
                            else
                            {
                                m_CategoryList[Params.SelectedCategory.Value].Name  = Name;
                                m_CategoryList[Params.SelectedCategory.Value].Flags = Flags;
                                m_CategoryList[Params.SelectedCategory.Value].Cost  = Cost;
                                state.Mobile.SendMessage("Changed the Category.");
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Problems adding/changing Category!");
                        }
                    }
                }
            }
            #endregion //Add/Remove

            #region Imports/Exports
            #region Exports
            else if (info.ButtonID == 123)
            {
                if (!Directory.Exists("ACC Exports"))
                {
                    Directory.CreateDirectory("ACC Exports");
                }

                string fileName;
                string Path = "ACC Exports/";

                if (Params.SelectedLocation.Key != null)
                {
                    fileName = String.Format("Location - {0}.pgl", Params.SelectedLocation.Key.Name);
                }
                else if (Params.SelectedCategory.Key != null)
                {
                    fileName = String.Format("Category - {0}.pgc", Params.SelectedCategory.Key.Name);
                }
                else
                {
                    fileName = String.Format("System - {0:yyMMdd-HHmmss}.pgs", DateTime.Now);
                }

                try
                {
                    using (FileStream m_FileStream = new FileStream(Path + fileName, FileMode.Create, FileAccess.Write))
                    {
                        GenericWriter writer = new BinaryFileWriter(m_FileStream, true);

                        if (Params.SelectedLocation.Key != null)
                        {
                            Params.SelectedLocation.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Location to {0}{1}", Path, fileName);
                        }
                        else if (Params.SelectedCategory.Key != null)
                        {
                            Params.SelectedCategory.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Category (and all Locations contained within) to {0}{1}", Path, fileName);
                        }
                        else
                        {
                            writer.Write((int)0); //version

                            writer.Write(m_CategoryList.Count);
                            for (int i = 0; i < m_CategoryList.Count; i++)
                            {
                                m_CategoryList[i].Serialize(writer);
                            }
                            state.Mobile.SendMessage("Exported the entire Public Gates System to {0}{1}", Path, fileName);
                        }

                        writer.Close();
                        m_FileStream.Close();
                    }
                }
                catch (Exception e)
                {
                    state.Mobile.SendMessage("Problem exporting the selection.  Please contact the admin.");
                    Console.WriteLine("Error exporting PGSystem : {0}", e);
                }
            }
            #endregion //Exports
            #region Imports
            //Switch between import types
            else if (info.ButtonID == 124 || info.ButtonID == 125 || info.ButtonID == 126)
            {
                newParams.Page = Pages.Import;
                switch (info.ButtonID)
                {
                case 124: newParams.ImportSelection = ImportSelections.Systems; break;

                case 125: newParams.ImportSelection = ImportSelections.Categories; break;

                case 126: newParams.ImportSelection = ImportSelections.Locations; break;
                }
            }
            //Perform the import
            else if (info.ButtonID >= 300 && Dirs != null && Dirs.Length > 0)
            {
                if (!Directory.Exists("ACC Exports"))
                {
                    Directory.CreateDirectory("ACC Exports");
                }

                string Path = null;
                try
                {
                    Path = Dirs[info.ButtonID - 300];

                    if (File.Exists(Path))
                    {
                        using (FileStream m_FileStream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            BinaryFileReader reader = new BinaryFileReader(new BinaryReader(m_FileStream));

                            switch ((int)Params.ImportSelection)
                            {
                            case (int)ImportSelections.Systems:
                            {        //Systems
                                int version            = reader.ReadInt();
                                int count              = reader.ReadInt();
                                List <PGCategory> list = new List <PGCategory>();
                                for (int i = 0; i < count; i++)
                                {
                                    list.Add(new PGCategory(reader));
                                }

                                state.Mobile.CloseGump(typeof(SysChoiceGump));
                                state.Mobile.SendGump(new SysChoiceGump(this.ToString(), Params, list));
                                reader.Close();
                                return;
                            }

                            case (int)ImportSelections.Categories:
                            {        //Categories
                                if (m_CategoryList == null)
                                {
                                    m_CategoryList = new List <PGCategory>();
                                }

                                m_CategoryList.Add(new PGCategory(reader));
                                state.Mobile.SendMessage("Added the Category.");
                                break;
                            }

                            case (int)ImportSelections.Locations:
                            {        //Locations
                                state.Mobile.CloseGump(typeof(CatSelGump));
                                state.Mobile.SendMessage("Please choose a Category to put this Location in.");
                                state.Mobile.SendGump(new CatSelGump(this.ToString(), Params, new PGLocation(reader)));
                                reader.Close();
                                return;
                            }
                            }

                            reader.Close();
                        }
                    }
                }
                catch
                {
                }
            }
            #endregion //Imports
            #endregion //Imports/Exports

            else if (info.ButtonID >= 150 && info.ButtonID < m_CategoryList.Count + 150)
            {
                newParams.SelectedCategory = new KeyValuePair <PGCategory, int>(m_CategoryList[info.ButtonID - 150], info.ButtonID - 150);
            }

            else if (info.ButtonID >= 200 && info.ButtonID < 200 + Params.SelectedCategory.Key.Locations.Count)
            {
                newParams.SelectedCategory = Params.SelectedCategory;
                newParams.SelectedLocation = new KeyValuePair <PGLocation, int>(Params.SelectedCategory.Key.Locations[info.ButtonID - 200], info.ButtonID - 200);
            }

            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), newParams));
        }
Ejemplo n.º 6
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            int    BID  = info.ButtonID;
            int    Loc  = -1;

            if (!PGSystem.Running)
            {
                return;
            }

            if (m_From.Deleted || m_Gate.Deleted || m_From.Map == null)
            {
                return;
            }

            if (info.Switches.Length > 0)
            {
                Loc = info.Switches[0];
            }

            Loc -= 200;

            if (BID == 0)
            {
                from.SendMessage("You choose not to go anywhere.");
                return;
            }

            if (BID == 1)
            {
                if (Loc <= -1)
                {
                    from.SendMessage("You must select a location!");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                    return;
                }

                PGCategory PGC = PGSystem.CategoryList[m_Page];
                if (PGC == null)
                {
                    return;
                }

                PGLocation PGL = PGC.Locations[Loc];
                if (PGL == null)
                {
                    return;
                }

                if (!from.InRange(m_Gate.GetWorldLocation(), 1) || from.Map != m_Gate.Map)
                {
                    from.SendLocalizedMessage(1019002);                       // You are too far away to use the gate.
                }
                else if (Factions.Sigil.ExistsOn(from) && PGL.Map != Factions.Faction.Facet)
                {
                    from.SendLocalizedMessage(1019004);                       // You are not allowed to travel there.
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                }
                else if (from.Criminal)
                {
                    from.SendLocalizedMessage(1005561, "", 0x22);                       // Thou'rt a criminal and cannot escape so easily.
                }
                else if (Server.Spells.SpellHelper.CheckCombat(from))
                {
                    from.SendLocalizedMessage(1005564, "", 0x22);                       // Wouldst thou flee during the heat of battle??
                }
                else if (from.Spell != null)
                {
                    from.SendLocalizedMessage(1049616);                       // You are too busy to do that at the moment.
                }
                else if (from.Map == PGL.Map && from.InRange(PGL.Location, 1))
                {
                    from.SendLocalizedMessage(1019003);                       // You are already there.
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                }
                else if (PGL.GetFlag(EntryFlag.Young) && !((PlayerMobile)from).Young && from.AccessLevel == AccessLevel.Player)
                {
                    from.SendMessage("You are too old to travel here.");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                }
                else if (!PGL.GetFlag(EntryFlag.Reds) && from.Kills >= 5 && from.AccessLevel == AccessLevel.Player)
                {
                    from.SendMessage("You too many murders to travel here.");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                }
                else if (PGL.GetFlag(EntryFlag.StaffOnly) && from.AccessLevel == AccessLevel.Player)
                {
                    from.SendMessage("You are not allowed to travel here.");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                }
                else
                {
                    bool charged = false;
                    if (PGC.GetFlag(EntryFlag.Charge) && PGC.Cost > 0 && from.AccessLevel == AccessLevel.Player)
                    {
                        Container pack = from.Backpack;
                        if (pack == null)
                        {
                            return;
                        }
                        if (!pack.ConsumeTotal(typeof(Gold), PGC.Cost))
                        {
                            from.SendMessage("You require {0} gold to travel there.", PGC.Cost);
                            from.SendGump(new PGGump(from, m_Page, m_Gate));
                            return;
                        }
                        charged = true;
                    }

                    if (!charged && PGL.GetFlag(EntryFlag.Charge) && PGL.Cost > 0 && from.AccessLevel == AccessLevel.Player)
                    {
                        Container pack = from.Backpack;
                        if (pack == null)
                        {
                            return;
                        }
                        if (!pack.ConsumeTotal(typeof(Gold), PGL.Cost))
                        {
                            from.SendMessage("You require {0} gold to travel there.", PGL.Cost);
                            from.SendGump(new PGGump(from, m_Page, m_Gate));
                            return;
                        }
                    }

                    BaseCreature.TeleportPets(from, PGL.Location, PGL.Map);

                    from.Combatant = null;
                    from.Warmode   = false;
                    from.Hidden    = true;

                    from.MoveToWorld(PGL.Location, PGL.Map);

                    Effects.PlaySound(PGL.Location, PGL.Map, 0x1FE);
                    from.SendMessage("You have been teleported to: " + PGL.Name);
                }
            }

            else if (BID >= 100)
            {
                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, BID - 100, m_Gate));
            }

            else if (BID == 2 && from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                SetFlag(Conditions.Adding, true);
                SetFlag(Conditions.Category, true);

                from.CloseGump(typeof(PGAddEditGump));
                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, -1, m_Gate));
            }

            else if (BID == 3 && from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                SetFlag(Conditions.Adding, false);
                SetFlag(Conditions.Category, true);

                from.CloseGump(typeof(PGAddEditGump));
                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, -1, m_Gate));
            }

            else if (BID == 4 && from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                SetFlag(Conditions.Adding, true);
                SetFlag(Conditions.Category, false);

                from.CloseGump(typeof(PGAddEditGump));
                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, Loc, m_Gate));
            }

            else if (BID == 5 && from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                if (Loc <= -1)
                {
                    from.SendMessage("You must select a location!");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                    return;
                }
                SetFlag(Conditions.Adding, false);
                SetFlag(Conditions.Category, false);

                from.CloseGump(typeof(PGAddEditGump));
                from.CloseGump(typeof(PGGump));
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, Loc, m_Gate));
            }

            else if (BID == 6 && from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                if (m_Gate.Parent != null)
                {
                    from.SendMessage("You must place the gate in the World to add it.");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                    return;
                }

                PGLocation PGL = new PGLocation("Un-named Gate", EntryFlag.None, m_Gate.Location, m_Gate.Map, 0);
                if (PGL == null)
                {
                    from.SendMessage("Could not add.");
                    from.SendGump(new PGGump(from, m_Page, m_Gate));
                    return;
                }

                from.SendMessage("Added the Gate.  Please edit any other features you wish it to have.");
                PGSystem.CategoryList[m_Page].Locations.Add(PGL);
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, PGSystem.CategoryList[m_Page].Locations.Count - 1, m_Gate));
            }

            else
            {
                from.SendMessage("Undefined button pressed: {0}", BID);
            }
        }
Ejemplo n.º 7
0
        public PGGump(Mobile from, int Page, PublicGate gate) : base(0, 0)
        {
            if (!PGSystem.Running)
            {
                return;
            }

            if (PGSystem.CategoryList == null || PGSystem.CategoryList.Count == 0)
            {
                SetFlag(EntryFlag.StaffOnly, true);
                SetFlag(EntryFlag.Generate, false);
                PGSystem.CategoryList = new List <PGCategory>();
                PGSystem.CategoryList.Add(new PGCategory("Empty System", EFlags));
            }

            m_From = from;
            m_Page = Page;
            m_Gate = gate;

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddPage(0);

            #region Categories
            int Cats = CountCats();

            int CStart = (250 - ((Cats / 2) * 25));
            if (CStart < 0)
            {
                CStart = 0;
            }

            AddBackground(0, CStart, 230, 100 + Cats * 25, 2600);
            AddHtml(0, CStart + 15, 230, 20, "<BASEFONT COLOR=#58D3F7 SIZE=8><CENTER>Traveler's Traverse</CENTER></BASEFONT>", false, false);

            int CurC = 0;
            for (int i = 0; i < PGSystem.CategoryList.Count; i++)
            {
                PGCategory PGC = PGSystem.CategoryList[i];
                if (PGC != null)
                {
                    if (from.AccessLevel >= PGSystem.PGAccessLevel)
                    {
                        AddButton(20, CStart + 53 + CurC * 25, (Page == i ? 209 : 208), (Page == i ? 208 : 209), 100 + i, GumpButtonType.Reply, 0);
                        AddLabel(50, CStart + 53 + CurC * 25, (Page == i ? 69 : 0), PGC.Name);
                        CurC++;
                        continue;
                    }

                    if (PGC.GetFlag(EntryFlag.StaffOnly) && from.AccessLevel == AccessLevel.Player)
                    {
                        continue;
                    }
                    if (!PGC.GetFlag(EntryFlag.StaffOnly))
                    {
                        if (PGC.GetFlag(EntryFlag.Young) && !((PlayerMobile)from).Young)
                        {
                            continue;
                        }
                        if (!PGC.GetFlag(EntryFlag.Reds) && from.Kills >= 5)
                        {
                            continue;
                        }
                    }

                    AddButton(20, CStart + 53 + CurC * 25, (Page == i ? 209 : 208), (Page == i ? 208 : 209), 100 + i, GumpButtonType.Reply, 0);
                    AddLabel(50, CStart + 53 + CurC * 25, (Page == i ? 69 : 0), PGC.Name);
                    CurC++;
                }
            }

            if (from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                AddLabel(75, CStart + 65 + Cats * 25, 0, "Add");
                AddButton(50, CStart + 65 + Cats * 25, 208, 209, 2, GumpButtonType.Reply, 0);
                AddLabel(125, CStart + 65 + Cats * 25, 0, "Edit");
                AddButton(160, CStart + 65 + Cats * 25, 208, 209, 3, GumpButtonType.Reply, 0);
            }
            #endregion             //Categories

            #region Locations
            int Locs = CountLocs();
            if (Locs == -1)
            {
                Locs = 0;
            }

            int LStart = (250 - ((Locs / 2) * 25));
            if (LStart < 20)
            {
                LStart = 20;
            }

            AddBackground(230, LStart, 300, 100 + Locs * 25, 2600);

            int        CurL = 0;
            PGCategory PGCL = PGSystem.CategoryList[m_Page];
            if (PGCL != null && PGCL.Locations != null)
            {
                for (int i = 0; i < PGCL.Locations.Count; i++)
                {
                    PGLocation PGL = PGCL.Locations[i];
                    if (PGL != null)
                    {
                        if (from.AccessLevel >= PGSystem.PGAccessLevel)
                        {
                            AddRadio(250, LStart + 53 + CurL * 25, 208, 209, false, 200 + i);
                            AddLabel(280, LStart + 53 + CurL * 25, 0, PGL.Name);
                            CurL++;
                            continue;
                        }

                        if (PGL.GetFlag(EntryFlag.StaffOnly) && from.AccessLevel == AccessLevel.Player)
                        {
                            continue;
                        }
                        if (!PGL.GetFlag(EntryFlag.StaffOnly))
                        {
                            if (PGL.GetFlag(EntryFlag.Young) && !((PlayerMobile)from).Young)
                            {
                                continue;
                            }
                            if (!PGL.GetFlag(EntryFlag.Reds) && from.Kills >= 5)
                            {
                                continue;
                            }
                        }

                        AddRadio(250, LStart + 53 + CurL * 25, 208, 209, false, 200 + i);
                        AddLabel(280, LStart + 53 + CurL * 25, 0, PGL.Name);
                        CurL++;
                    }
                }
            }

            AddButton(465, LStart - 20, 1417, 1417, 1, GumpButtonType.Reply, 0);
            AddHtml(485, LStart + 10, 40, 40, "<BODY><BASEFONT SIZE=7 COLOR=#2E64FE><CENTER><I><B>GO</B></I></CENTER></BASEFONT></BODY>", false, false);

            if (from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                AddLabel(305, LStart + 15, 0, "Add Current Gate");
                AddButton(280, LStart + 15, 208, 209, 6, GumpButtonType.Reply, 0);

                AddLabel(305, LStart + 65 + Locs * 25, 0, "Add");
                AddButton(280, LStart + 65 + Locs * 25, 208, 209, 4, GumpButtonType.Reply, 0);

                AddLabel(430, LStart + 65 + Locs * 25, 0, "Edit");
                AddButton(460, LStart + 65 + Locs * 25, 208, 209, 5, GumpButtonType.Reply, 0);
            }
            #endregion             //Locations
        }
Ejemplo n.º 8
0
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			int BID = info.ButtonID;
			int Loc = -1;

			if( !PGSystem.Running )
				return;

			if( m_From.Deleted || m_Gate.Deleted || m_From.Map == null )
				return;

			if( info.Switches.Length > 0 )
				Loc = info.Switches[0];

			Loc -= 200;

			if( BID == 0 )
			{
				from.SendMessage( "You choose not to go anywhere." );
				return;
			}

			if( BID == 1 )
			{
				if( Loc <= -1 )
				{
					from.SendMessage( "You must select a location!" );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
					return;
				}

				PGCategory PGC = PGSystem.CategoryList[m_Page];
				if( PGC == null )
					return;

				PGLocation PGL = PGC.Locations[Loc];
				if( PGL == null )
					return;

				if( !from.InRange( m_Gate.GetWorldLocation(), 1 ) || from.Map != m_Gate.Map )
				{
					from.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate.
				}
				else if( Factions.Sigil.ExistsOn( from ) && PGL.Map != Factions.Faction.Facet )
				{
					from.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				}
				else if( from.Criminal )
				{
					from.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
				}
				else if( Server.Spells.SpellHelper.CheckCombat( from ) )
				{
					from.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
				}
				else if( from.Spell != null )
				{
					from.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
				}
				else if( from.Map == PGL.Map && from.InRange( PGL.Location, 1 ) )
				{
					from.SendLocalizedMessage( 1019003 ); // You are already there.
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				}
				else if( PGL.GetFlag( EntryFlag.Young ) && !((PlayerMobile)from).Young && from.AccessLevel == AccessLevel.Player )
				{
					from.SendMessage( "You are too old to travel here." );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				}
				else if( !PGL.GetFlag( EntryFlag.Reds ) && from.Kills >= 5 && from.AccessLevel == AccessLevel.Player )
				{
					from.SendMessage( "You too many murders to travel here." );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				}
				else if( PGL.GetFlag( EntryFlag.StaffOnly ) && from.AccessLevel == AccessLevel.Player )
				{
					from.SendMessage( "You are not allowed to travel here." );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				}
				else
				{
					bool charged = false;
					if( PGC.GetFlag( EntryFlag.Charge ) && PGC.Cost > 0 && from.AccessLevel == AccessLevel.Player )
					{
						Container pack = from.Backpack;
						if( pack == null )
							return;
						if( !pack.ConsumeTotal( typeof( Gold ), PGC.Cost ) )
						{
							from.SendMessage( "You require {0} gold to travel there.", PGC.Cost );
							from.SendGump( new PGGump( from, m_Page, m_Gate ) );
							return;
						}
						charged = true;
					}

					if( !charged && PGL.GetFlag( EntryFlag.Charge ) && PGL.Cost > 0 && from.AccessLevel == AccessLevel.Player )
					{
						Container pack = from.Backpack;
						if( pack == null )
							return;
						if( !pack.ConsumeTotal( typeof( Gold ), PGL.Cost ) )
						{
							from.SendMessage( "You require {0} gold to travel there.", PGL.Cost );
							from.SendGump( new PGGump( from, m_Page, m_Gate ) );
							return;
						}
					}

					BaseCreature.TeleportPets( from, PGL.Location, PGL.Map );

					from.Combatant = null;
					from.Warmode = false;
					from.Hidden = true;

					from.MoveToWorld( PGL.Location, PGL.Map );

					Effects.PlaySound( PGL.Location, PGL.Map, 0x1FE );
					from.SendMessage( "You have been teleported to: " + PGL.Name );
				}
			}

			else if( BID >= 100 )
			{
				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, BID-100, m_Gate ) );
			}

			else if( BID == 2 && from.AccessLevel >= PGSystem.PGAccessLevel)
			{
				SetFlag( Conditions.Adding, true );
				SetFlag( Conditions.Category, true );

				from.CloseGump( typeof( PGAddEditGump ) );
				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				from.SendGump( new PGAddEditGump( Flags, m_Page, -1, m_Gate ) );
			}

            else if (BID == 3 && from.AccessLevel >= PGSystem.PGAccessLevel)
			{
				SetFlag( Conditions.Adding, false );
				SetFlag( Conditions.Category, true );

				from.CloseGump( typeof( PGAddEditGump ) );
				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				from.SendGump( new PGAddEditGump( Flags, m_Page, -1, m_Gate ) );
			}

            else if (BID == 4 && from.AccessLevel >= PGSystem.PGAccessLevel)
			{
				SetFlag( Conditions.Adding, true );
				SetFlag( Conditions.Category, false );

				from.CloseGump( typeof( PGAddEditGump ) );
				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				from.SendGump( new PGAddEditGump( Flags, m_Page, Loc, m_Gate ) );
			}

            else if (BID == 5 && from.AccessLevel >= PGSystem.PGAccessLevel)
			{
				if( Loc <= -1 )
				{
					from.SendMessage( "You must select a location!" );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
					return;
				}
				SetFlag( Conditions.Adding, false );
				SetFlag( Conditions.Category, false );

				from.CloseGump( typeof( PGAddEditGump ) );
				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, m_Page, m_Gate ) );
				from.SendGump( new PGAddEditGump( Flags, m_Page, Loc, m_Gate ) );
			}

            else if (BID == 6 && from.AccessLevel >= PGSystem.PGAccessLevel)
			{
				if( m_Gate.Parent != null )
				{
					from.SendMessage( "You must place the gate in the World to add it." );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
					return;
				}

				PGLocation PGL = new PGLocation( "Un-named Gate", EntryFlag.None, m_Gate.Location, m_Gate.Map, 0 );
				if( PGL == null )
				{
					from.SendMessage( "Could not add." );
					from.SendGump( new PGGump( from, m_Page, m_Gate ) );
					return;
				}

				from.SendMessage( "Added the Gate.  Please edit any other features you wish it to have." );
				PGSystem.CategoryList[m_Page].Locations.Add( PGL );
                from.SendGump(new PGGump(from, m_Page, m_Gate));
                from.SendGump(new PGAddEditGump(Flags, m_Page, PGSystem.CategoryList[m_Page].Locations.Count-1, m_Gate));
			}

			else
			{
				from.SendMessage( "Undefined button pressed: {0}", BID );
			}
		}
Ejemplo n.º 9
0
        public bool UseGate(Mobile m)
        {
            if (!PGSystem.Running)
            {
                m.SendMessage("The Public Gate System is not active.  Please page a GM for assistance.");
                return(false);
            }

            /*if ( m.Criminal )
             * {
             *      m.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
             *      return false;
             * }*/
            else if (Server.Spells.SpellHelper.CheckCombat(m))
            {
                m.SendLocalizedMessage(1005564, "", 0x22);                   // Wouldst thou flee during the heat of battle??
                return(false);
            }
            else if (m.Spell != null)
            {
                m.SendLocalizedMessage(1049616);                   // You are too busy to do that at the moment.
                return(false);
            }
            else
            {
                int  page  = 0;
                bool found = false;
                for (int i = 0; i < PGSystem.CategoryList.Count && !found; i++)
                {
                    PGCategory PGC = PGSystem.CategoryList[i];
                    if (PGC != null && PGC.Locations != null && PGC.Locations.Count > 0 &&
                        (PGC.GetFlag(EntryFlag.StaffOnly) && m.AccessLevel > AccessLevel.Player) ||
                        (!PGC.GetFlag(EntryFlag.StaffOnly) && ((!PGC.GetFlag(EntryFlag.Reds) && m.Kills < 5) || PGC.GetFlag(EntryFlag.Reds))) ||
                        (m.AccessLevel > AccessLevel.Player))
                    {
                        for (int j = 0; j < PGC.Locations.Count && !found; j++)
                        {
                            PGLocation PGL = PGC.Locations[j];
                            if (PGL != null && (PGL.GetFlag(EntryFlag.StaffOnly) && m.AccessLevel > AccessLevel.Player) ||
                                (!PGL.GetFlag(EntryFlag.StaffOnly) && ((!PGL.GetFlag(EntryFlag.Reds) && m.Kills < 5) || PGL.GetFlag(EntryFlag.Reds))) ||
                                (m.AccessLevel > AccessLevel.Player))
                            {
                                if (PGL.Location == this.Location && PGL.Map == this.Map)
                                {
                                    page  = i;
                                    found = true;
                                }
                            }
                        }
                    }
                }

                m.CloseGump(typeof(PGGump));
                m.SendGump(new PGGump(m, page, this));

                if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
                {
                    Effects.PlaySound(m.Location, m.Map, 0x20E);
                }

                return(true);
            }
        }
Ejemplo n.º 10
0
        public PGGump(Mobile from, int Page, PublicGate gate) : base(0, 0)
        {
            if (!PGSystem.Running)
            {
                return;
            }

            if (PGSystem.CategoryList == null || PGSystem.CategoryList.Count == 0)
            {
                SetFlag(EntryFlag.StaffOnly, true);
                SetFlag(EntryFlag.Generate, false);
                PGSystem.CategoryList = new List <PGCategory>();
                PGSystem.CategoryList.Add(new PGCategory("Empty System", EFlags));
            }

            m_From = from;
            m_Page = Page;
            m_Gate = gate;

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddPage(0);

            int Locs     = CountLocs();
            int Cats     = CountCats();
            int BHeightT = Locs;
            int BWidth   = 430;

            if (Locs < Cats)
            {
                BHeightT = Cats;
            }

            int BHeight = 280 > (100 + (BHeightT * 25)) ? 280 : (100 + (BHeightT * 25));


            AddBackground(0, 0, BWidth, BHeight, 9270);
            AddLabel(20, 10, 1153, "The Grove");
            AddLabel(215, 10, 1153, "Where ya headed?:");

            AddButton(15, BHeight - 70, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddLabel(50, BHeight - 70, 1153, "OKAY");

            AddButton(15, BHeight - 45, 4005, 4007, 0, GumpButtonType.Reply, 0);
            AddLabel(50, BHeight - 45, 1153, "CANCEL");

            #region Categories
            int CStart = 35;

            int CurC = 0;
            for (int i = 0; i < PGSystem.CategoryList.Count; i++)
            {
                PGCategory PGC = PGSystem.CategoryList[i];
                if (PGC != null)
                {
                    if (from.AccessLevel >= PGSystem.PGAccessLevel)
                    {
                        AddButton(15, CStart + (CurC * 25), (Page == i ? 2118 : 2117), (Page == i ? 2117 : 2118), 100 + i, GumpButtonType.Reply, 0);
                        AddLabel(35, CStart + (CurC * 25), (Page == i ? 53 : PGC.Hue == 0 ? 1153 : PGC.Hue), (Page == i ? (PGC.Name + " <--") : PGC.Name));
                        CurC++;
                        continue;
                    }

                    if (PGC.GetFlag(EntryFlag.StaffOnly) && from.AccessLevel == AccessLevel.Player)
                    {
                        continue;
                    }
                    if (!PGC.GetFlag(EntryFlag.StaffOnly))
                    {
                        if (PGC.GetFlag(EntryFlag.Young) && !((PlayerMobile)from).Young)
                        {
                            continue;
                        }
                        if (!PGC.GetFlag(EntryFlag.Reds) && from.Kills >= 5)
                        {
                            continue;
                        }
                    }

                    AddButton(15, CStart + (CurC * 25), (Page == i ? 2118 : 2117), (Page == i ? 2117 : 2118), 100 + i, GumpButtonType.Reply, 0);
                    AddLabel(35, CStart + (CurC * 25), (Page == i ? 53 : PGC.Hue == 0 ? 1153 : PGC.Hue), (Page == i ? (PGC.Name + " <--") : PGC.Name));
                    CurC++;
                }
            }

            if (from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                AddLabel(160, BHeight - 70, 1153, "ADD");
                AddButton(125, BHeight - 70, 4005, 4007, 2, GumpButtonType.Reply, 0);
                AddLabel(160, BHeight - 45, 1153, "EDIT");
                AddButton(125, BHeight - 45, 4005, 4007, 3, GumpButtonType.Reply, 0);
            }
            #endregion             //Categories

            #region Locations
            if (Locs == -1)
            {
                Locs = 0;
            }

            int LStart = 35;


            int        CurL = 0;
            PGCategory PGCL = PGSystem.CategoryList[m_Page];
            if (PGCL != null && PGCL.Locations != null)
            {
                for (int i = 0; i < PGCL.Locations.Count; i++)
                {
                    PGLocation PGL = PGCL.Locations[i];
                    if (PGL != null)
                    {
                        if (from.AccessLevel >= PGSystem.PGAccessLevel)
                        {
                            AddRadio(215, LStart + (CurL * 25), 210, 211, false, 200 + i);
                            AddLabel(235, LStart + (CurL * 25), PGL.Hue == 0 ? 1153 : PGL.Hue, PGL.Name);
                            CurL++;
                            continue;
                        }

                        if (PGL.GetFlag(EntryFlag.StaffOnly) && from.AccessLevel == AccessLevel.Player)
                        {
                            continue;
                        }
                        if (!PGL.GetFlag(EntryFlag.StaffOnly))
                        {
                            if (PGL.GetFlag(EntryFlag.Young) && !((PlayerMobile)from).Young)
                            {
                                continue;
                            }
                            if (!PGL.GetFlag(EntryFlag.Reds) && from.Kills >= 5)
                            {
                                continue;
                            }
                        }

                        AddRadio(215, LStart + (CurL * 25), 210, 211, false, 200 + i);
                        AddLabel(235, LStart + (CurL * 25), PGL.Hue == 0 ? 1153 : PGL.Hue, PGL.Name);
                        CurL++;
                    }
                }
            }


            if (from.AccessLevel >= PGSystem.PGAccessLevel)
            {
                AddButton(215, BHeight - 45, 4005, 4007, 6, GumpButtonType.Reply, 0);
                AddLabel(250, BHeight - 45, 1153, "Add Current");

                AddLabel(370, BHeight - 70, 1153, "ADD");
                AddButton(335, BHeight - 70, 4005, 4007, 4, GumpButtonType.Reply, 0);

                AddLabel(370, BHeight - 45, 1153, "EDIT");
                AddButton(335, BHeight - 45, 4005, 4007, 5, GumpButtonType.Reply, 0);
            }
            #endregion             //Locations
        }
Ejemplo n.º 11
0
		public PGAddEditGump( Conditions conditions, int curC, int curL, PublicGate gate ) : base( 0, 0 )
		{
			if( !PGSystem.Running )
				return;

			m_Conditions = conditions;
			m_CurCat     = curC;
			m_CurLoc     = curL;
			m_Gate       = gate;

			if( !GetFlag( Conditions.Category ) || (GetFlag( Conditions.Category ) && !GetFlag( Conditions.Adding )) )
				m_Cat = PGSystem.CategoryList[curC];
			if( m_Cat != null && (!GetFlag( Conditions.Category ) && !GetFlag( Conditions.Adding )) )
				m_Loc = m_Cat.Locations[curL];


			string Name = "";
			if( !GetFlag( Conditions.Adding ) )
			{
				if( GetFlag( Conditions.Category ) )
					Name = m_Cat.Name;
				else
					Name = m_Loc.Name;
			}

			Point3D Loc = new Point3D( 0, 0, 0 );
			Map Map = Map.Trammel;
			bool Gen, Staff, Reds, Charge, Young;
			int Hue, Cost;
			Gen = Staff = Reds = Charge = Young = false;
			Hue = Cost = 0;

			if( GetFlag( Conditions.Category ) && !GetFlag( Conditions.Adding ) )
			{
				Gen    = m_Cat.GetFlag( EntryFlag.Generate );
				Staff  = m_Cat.GetFlag( EntryFlag.StaffOnly );
				Reds   = m_Cat.GetFlag( EntryFlag.Reds );
				Charge = m_Cat.GetFlag( EntryFlag.Charge );
				Young  = m_Cat.GetFlag( EntryFlag.Young );
				Cost   = m_Cat.Cost;
			}

			if( !GetFlag( Conditions.Category ) && !GetFlag( Conditions.Adding ) )
			{
				Loc    = m_Loc.Location;
				Map    = m_Loc.Map;
				Gen    = m_Loc.GetFlag( EntryFlag.Generate );
				Staff  = m_Loc.GetFlag( EntryFlag.StaffOnly );
				Reds   = m_Loc.GetFlag( EntryFlag.Reds );
				Charge = m_Loc.GetFlag( EntryFlag.Charge );
				Young  = m_Loc.GetFlag( EntryFlag.Young );
				Hue    = m_Loc.Hue;
				Cost   = m_Loc.Cost;
			}

			Closable   = true;
			Disposable = true;
			Dragable   = true;
			Resizable  = false;

			AddPage(0);

			AddBackground( 530, 100, 230, 410, 2600 );
			AddLabel( 602, 120, 0, string.Format("{0} {1}", (GetFlag(Conditions.Adding) ? "Add" : "Edit"), (GetFlag(Conditions.Category) ? "Category" : "Location")) );

			AddLabel( 625, 145, 0, "Name :" );
			AddImage( 555, 170, 2446 );
			AddTextEntry( 565, 170, 160, 20, 0, 2, Name );

			AddLabel( 715, 235, 0, ": C" );
			AddImage( 650, 235, 2443 );
			AddTextEntry( 655, 235, 55, 20, 0, 15, Cost.ToString() );

			if( !GetFlag(Conditions.Category) )
			{

				AddLabel( 560, 210, 0, "X :" );
				AddImage( 580, 210, 2443 );
				AddTextEntry( 585, 210, 55, 20, 0, 3, Loc.X.ToString() );

				AddLabel( 560, 235, 0, "Y :" );
				AddImage( 580, 235, 2443 );
				AddTextEntry( 585, 235, 55, 20, 0, 4, Loc.Y.ToString() );

				AddLabel( 560, 260, 0, "Z :" );
				AddImage( 580, 260, 2443 );
				AddTextEntry( 585, 260, 55, 20, 0, 5, Loc.Z.ToString() );

				AddLabel( 715, 210, 0, ": H" );
				AddImage( 650, 210, 2443 );
				AddTextEntry( 655, 210, 55, 20, 0, 14, Hue.ToString() );

				AddLabel( 585, 315, 0, "Trammel" );
				AddRadio( 555, 315, 208, 209, (Map == Map.Trammel ? true : false), 6 );

				AddLabel( 585, 340, 0, "Felucca" );
				AddRadio( 555, 340, 208, 209, (Map == Map.Felucca ? true : false), 7 );

				AddLabel( 685, 315, 0, "Malas" );
				AddRadio( 655, 315, 208, 209, (Map == Map.Malas ? true : false), 8 );

				AddLabel( 685, 345, 0, "Ilshenar" );
				AddRadio( 655, 340, 208, 209, (Map == Map.Ilshenar ? true : false), 9 );

				AddLabel( 585, 365, 0, "Tokuno" );
				AddRadio( 555, 370, 208, 209, (Map == Map.Tokuno ? true : false), 10 );
			}


			AddLabel( 585, 395, 0, "Generate?" );
			AddCheck( 555, 395, 210, 211, Gen, 11 );

			AddLabel( 665, 395, 0, "Young?" );
			AddCheck( 715, 395, 210, 211, Young, 16 );

			AddLabel( 585, 420, 0, "Reds?" );
			AddCheck( 555, 420, 210, 211, Reds, 13 );

			AddLabel( 658, 420, 0, "Charge?" );
			AddCheck( 715, 420, 210, 211, Charge, 17 );

			AddLabel( 585, 445, 0, "Staff Only?" );
			AddCheck( 555, 445, 210, 211, Staff, 12 );

			AddButton( 700, 450, 1417, 1417, 1, GumpButtonType.Reply, 0 );
			AddLabel( 728, 481, 69, "Apply" );
		}
Ejemplo n.º 12
0
		public override void OnResponse( NetState state, RelayInfo info )
		{
			if( state.Mobile.AccessLevel < PGSystem.PGAccessLevel )
				return;

			Mobile from = state.Mobile;
			int BID = info.ButtonID;
			if( BID == 0 )
				return;

			SetFlag( EntryFlag.Generate, info.IsSwitched( 11 ) );
			SetFlag( EntryFlag.StaffOnly, info.IsSwitched( 12 ) );
			SetFlag( EntryFlag.Reds, info.IsSwitched( 13 ) );
			SetFlag( EntryFlag.Young, info.IsSwitched( 16 ) );
			SetFlag( EntryFlag.Charge, info.IsSwitched( 17 ) );

			Map Map = null;
			for( int i = 0; i < info.Switches.Length; i++ )
			{
				int m = info.Switches[i];
				switch( m )
				{
					case 6:  Map = Map.Trammel;  break;
					case 7:  Map = Map.Felucca;  break;
					case 8:  Map = Map.Malas;    break;
					case 9:  Map = Map.Ilshenar; break;
					case 10: Map = Map.Tokuno;   break;
				}
			}


			TextRelay NR = info.GetTextEntry( 2 );
			TextRelay XR = info.GetTextEntry( 3 );
			TextRelay YR = info.GetTextEntry( 4 );
			TextRelay ZR = info.GetTextEntry( 5 );
			TextRelay HR = info.GetTextEntry( 14 );
			TextRelay CR = info.GetTextEntry( 15 );
			string NS = (NR == null ? null : NR.Text.Trim());
			string XS = (XR == null ? null : XR.Text.Trim());
			string YS = (YR == null ? null : YR.Text.Trim());
			string ZS = (ZR == null ? null : ZR.Text.Trim());
			string HS = (HR == null ? null : HR.Text.Trim());
			string CS = (CR == null ? null : CR.Text.Trim());

			if( BID == 1 )
			{
				if( GetFlag( Conditions.Category ) )
				{
					if( GetFlag( Conditions.Adding ) )
					{
						if( NS == null || NS.Length == 0 || CS == null || CS.Length == 0 )
						{
							from.SendMessage( "Please enter a name and cost for this Category." );
							from.CloseGump( typeof( PGAddEditGump ) );
							from.SendGump( new PGAddEditGump( m_Conditions, m_CurCat, m_CurLoc, m_Gate ) );
							return;
						}

						int c = 0;
						try
						{
							c = Int32.Parse( CS );
							PGSystem.CategoryList.Add( new PGCategory( NS, Flags, c ) );
							from.SendMessage( "Added Category." );
						}
						catch
						{
							from.SendMessage( "Bad cost value, defaulting to 0." );
							PGSystem.CategoryList.Add( new PGCategory( NS, Flags ) );
						}
					}

					else
					{
						if( NS == null || NS.Length == 0 )
						{
							from.SendMessage( "Removed the Category." );
							PGSystem.CategoryList.RemoveAt( m_CurCat );
							m_CurCat = 0;
						}

						else
						{
							from.SendMessage( "Changed the Category." );
							PGSystem.CategoryList[m_CurCat].Name = NS;
							PGSystem.CategoryList[m_CurCat].Flags = Flags;
							if( CS == null || CS.Length == 0 )
								PGSystem.CategoryList[m_CurCat].Cost = 0;
							else
							{
								int c = 0;

								try
								{
									c = Int32.Parse( CS );
									PGSystem.CategoryList[m_CurCat].Cost = c;
								}
								catch
								{
									PGSystem.CategoryList[m_CurCat].Cost = 0;
								}
							}
						}
					}
				}

				else
				{
					if( NS == null || NS.Length == 0 ||
						XS == null || XS.Length == 0 ||
						YS == null || YS.Length == 0 ||
						ZS == null || ZS.Length == 0 ||
						HS == null || HS.Length == 0 ||
						CS == null || CS.Length == 0 )
					{
						if( GetFlag( Conditions.Adding ) )
						{
							from.SendMessage( "Please fill in each field." );
							from.CloseGump( typeof( PGAddEditGump ) );
							from.SendGump( new PGAddEditGump( m_Conditions, m_CurCat, m_CurLoc, m_Gate ) );
							return;
						}

						from.SendMessage( "Removed the Location." );
						PGSystem.CategoryList[m_CurCat].Locations.RemoveAt( m_CurLoc );
					}

					else if( Map == null )
					{
						from.SendMessage( "Please select a Map." );
						from.CloseGump( typeof( PGAddEditGump ) );
						from.SendGump( new PGAddEditGump( m_Conditions, m_CurCat, m_CurLoc, m_Gate ) );
						return;
					}

					else
					{
						int x, y, z, h, c = 0;
						Point3D Loc;
						int Hue;
						int Cost;
						try
						{
							x = Int32.Parse( XS );
							y = Int32.Parse( YS );
							z = Int32.Parse( ZS );
							h = Int32.Parse( HS );
							c = Int32.Parse( CS );
							Loc = new Point3D( x, y, z );
							Hue = h;
							Cost = c;
						}
						catch
						{
							from.SendMessage( "Please enter an integer in each of the info fields. (X, Y, Z, H, C)" );
							from.CloseGump( typeof( PGAddEditGump ) );
							from.SendGump( new PGAddEditGump( m_Conditions, m_CurCat, m_CurLoc, m_Gate ) );
							return;
						}

						PGLocation PGL = new PGLocation( NS, Flags, Loc, Map, Hue, Cost );
						if( PGL == null )
						{
							from.SendMessage( "Bad Location information, can't add!" );
							from.CloseGump( typeof( PGAddEditGump ) );
							from.SendGump( new PGAddEditGump( m_Conditions, m_CurCat, m_CurLoc, m_Gate ) );
							return;
						}

						if( GetFlag( Conditions.Adding ) )
						{
							from.SendMessage( "Added the Location." );
							PGSystem.CategoryList[m_CurCat].Locations.Add( PGL );
						}
						else
						{
							from.SendMessage( "Changed the Location." );
							PGSystem.CategoryList[m_CurCat].Locations[m_CurLoc] = PGL;
						}
					}
				}

				from.CloseGump( typeof( PGGump ) );
				from.SendGump( new PGGump( from, m_CurCat, m_Gate ) );
			}
		}
Ejemplo n.º 13
0
            public CatSelGump(string sys, ACCGumpParams subParams, PGLocation loc)
                : base(0, 0)
            {
                if (sys == null || subParams == null || loc == null || m_CategoryList == null)
                    return;

                Sys = sys;
                if (subParams is PGGumpParams)
                    Params = subParams as PGGumpParams;
                Loc = loc;

                AddPage(0);
                AddBackground(640, 0, 160, 400, 5120);

                for (int i = 0; i < PGSystem.CategoryList.Count; i++)
                {
                    PGCategory PGC = m_CategoryList[i];
                    if (PGC != null)
                    {
                        AddButton(650, 10 + i * 30, 2501, 2501, 1 + i, GumpButtonType.Reply, 0);
                        AddLabel(675, 10 + i * 30, 1153, PGC.Name);
                    }
                }
            }
Ejemplo n.º 14
0
        /* ID's:
         101 = Button Manage System
         102 = Button Import Page
         103 = Button Apply Location
         104 = Button Apply Category
         105 = Text   Name
         106 = Text   X
         107 = Text   Y
         108 = Text   Z
         109 = Text   Hue
         110 = Text   Cost
         111 = Radio  Trammel
         112 = Radio  Malas
         113 = Radio  Felucca
         114 = Radio  Ilshenar
         115 = Radio  Tokuno
         116 = Check  Generate
         117 = Check  StaffOnly
         118 = Check  Reds
         119 = Check  Charge
         120 = Check  Young
         121 = Button Add Category
         122 = Button Add Location
         123 = Button Export
         124 = Button Import Systems
         125 = Button Import Categories
         126 = Button Import Locations
         300+ = Imports 
          */
        public override void OnResponse(NetState state, RelayInfo info, ACCGumpParams subParams)
        {
            if (info.ButtonID == 0 || state.Mobile.AccessLevel < ACC.GlobalMinimumAccessLevel)
                return;

            if (subParams is PGGumpParams)
                Params = subParams as PGGumpParams;

            PGGumpParams newParams = new PGGumpParams();

            if (info.ButtonID == 101)
                newParams.Page = Pages.Manage;

            else if (info.ButtonID == 102)
                newParams.Page = Pages.Import;

            #region Add/Remove
            else if (info.ButtonID == 103 || info.ButtonID == 104 || info.ButtonID == 121 || info.ButtonID == 122)
            {
                SetFlag(EntryFlag.Generate, info.IsSwitched(116));
                SetFlag(EntryFlag.StaffOnly, info.IsSwitched(117));
                SetFlag(EntryFlag.Reds, info.IsSwitched(118));
                SetFlag(EntryFlag.Charge, info.IsSwitched(119));

                Map Map = info.IsSwitched(111) ? Map.Trammel : info.IsSwitched(112) ? Map.Malas : info.IsSwitched(113) ? Map.Felucca : info.IsSwitched(114) ? Map.Ilshenar : info.IsSwitched(115) ? Map.Tokuno : Map.Trammel;

                string Name = GetString(info, 105);
                string X = GetString(info, 106);
                string Y = GetString(info, 107);
                string Z = GetString(info, 108);
                string H = GetString(info, 109);
                string C = GetString(info, 110);

                if (Name == null || Name.Length == 0)
                {
                    try
                    {
                        state.Mobile.SendMessage("Removed the entry");
                        if (info.ButtonID == 103)
                            Params.SelectedCategory.Key.Locations.Remove(Params.SelectedLocation.Key);
                        else
                            m_CategoryList.Remove(Params.SelectedCategory.Key);
                    }
                    catch
                    {
                        Console.WriteLine("Exception caught removing entry");
                    }
                }

                else
                {
                    if (info.ButtonID == 103 || info.ButtonID == 122)
                    {
                        int x, y, z, h, c = 0;
                        Point3D Loc;
                        int Hue;
                        int Cost;
                        PGLocation PGL;

                        if (X == null || X.Length == 0 ||
                            Y == null || Y.Length == 0 ||
                            Z == null || Z.Length == 0 ||
                            H == null || H.Length == 0 ||
                            C == null || C.Length == 0)
                        {
                            if (info.ButtonID == 122)
                            {
                                Hue = 0;
                                Loc = new Point3D(0, 0, 0);
                                Cost = 0;

                                PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                                if (PGL == null)
                                {
                                    state.Mobile.SendMessage("Error adding Location.");
                                    return;
                                }

                                m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                            }

                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            x = Int32.Parse(X);
                            y = Int32.Parse(Y);
                            z = Int32.Parse(Z);
                            h = Int32.Parse(H);
                            c = Int32.Parse(C);
                            Loc = new Point3D(x, y, z);
                            Hue = h;
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer in each of the info fields. (X, Y, Z, H, Cost)");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                        if (PGL == null)
                        {
                            state.Mobile.SendMessage("Bad Location information, can't add!");
                        }
                        else
                        {
                            try
                            {
                                if (info.ButtonID == 122)
                                {
                                    m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                                    state.Mobile.SendMessage("Added the Location.");
                                }
                                else
                                {
                                    state.Mobile.SendMessage("Changed the Location.");
                                    m_CategoryList[Params.SelectedCategory.Value].Locations[Params.SelectedLocation.Value] = PGL;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Problem adding/changing Location!");
                            }
                        }
                    }

                    else
                    {
                        if (C == null || C.Length == 0)
                        {
                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        int c = 0;
                        int Cost;
                        try
                        {
                            c = Int32.Parse(C);
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer for the Cost");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            if (info.ButtonID == 121)
                            {
                                m_CategoryList.Add(new PGCategory(Name, Flags, Cost));
                                state.Mobile.SendMessage("Added the Category.");
                            }
                            else
                            {
                                m_CategoryList[Params.SelectedCategory.Value].Name = Name;
                                m_CategoryList[Params.SelectedCategory.Value].Flags = Flags;
                                m_CategoryList[Params.SelectedCategory.Value].Cost = Cost;
                                state.Mobile.SendMessage("Changed the Category.");
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Problems adding/changing Category!");
                        }
                    }
                }
            }
            #endregion //Add/Remove

            #region Imports/Exports
            #region Exports
            else if (info.ButtonID == 123)
            {
                if (!Directory.Exists("ACC Exports"))
                    Directory.CreateDirectory("ACC Exports");

                string fileName;
                string Path = "ACC Exports/";

                if (Params.SelectedLocation.Key != null)
                    fileName = String.Format("Location - {0}.pgl", Params.SelectedLocation.Key.Name);
                else if (Params.SelectedCategory.Key != null)
                    fileName = String.Format("Category - {0}.pgc", Params.SelectedCategory.Key.Name);
                else
                    fileName = String.Format("System - {0:yyMMdd-HHmmss}.pgs", DateTime.Now);

                try
                {
                    using (FileStream m_FileStream = new FileStream(Path + fileName, FileMode.Create, FileAccess.Write))
                    {
                        GenericWriter writer = new BinaryFileWriter(m_FileStream, true);

                        if (Params.SelectedLocation.Key != null)
                        {
                            Params.SelectedLocation.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Location to {0}{1}", Path, fileName);
                        }
                        else if (Params.SelectedCategory.Key != null)
                        {
                            Params.SelectedCategory.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Category (and all Locations contained within) to {0}{1}", Path, fileName);
                        }
                        else
                        {
                            writer.Write((int)0); //version

                            writer.Write(m_CategoryList.Count);
                            for (int i = 0; i < m_CategoryList.Count; i++)
                            {
                                m_CategoryList[i].Serialize(writer);
                            }
                            state.Mobile.SendMessage("Exported the entire Public Gates System to {0}{1}", Path, fileName);
                        }

                        writer.Close();
                        m_FileStream.Close();
                    }
                }
                catch (Exception e)
                {
                    state.Mobile.SendMessage("Problem exporting the selection.  Please contact the admin.");
                    Console.WriteLine("Error exporting PGSystem : {0}", e);
                }
            }
            #endregion //Exports
            #region Imports
            //Switch between import types
            else if (info.ButtonID == 124 || info.ButtonID == 125 || info.ButtonID == 126)
            {
                newParams.Page = Pages.Import;
                switch (info.ButtonID)
                {
                    case 124: newParams.ImportSelection = ImportSelections.Systems; break;
                    case 125: newParams.ImportSelection = ImportSelections.Categories; break;
                    case 126: newParams.ImportSelection = ImportSelections.Locations; break;
                }
            }
            //Perform the import
            else if (info.ButtonID >= 300 && Dirs != null && Dirs.Length > 0)
            {
                if (!Directory.Exists("ACC Exports"))
                    Directory.CreateDirectory("ACC Exports");

                string Path = null;
                try
                {
                    Path = Dirs[info.ButtonID - 300];

                    if (File.Exists(Path))
                    {
                        using (FileStream m_FileStream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            BinaryFileReader reader = new BinaryFileReader(new BinaryReader(m_FileStream));

                            switch ((int)Params.ImportSelection)
                            {
                                case (int)ImportSelections.Systems:
                                    {//Systems
                                        int version = reader.ReadInt();
                                        int count = reader.ReadInt();
                                        List<PGCategory> list = new List<PGCategory>();
                                        for (int i = 0; i < count; i++)
                                            list.Add(new PGCategory(reader));

                                        state.Mobile.CloseGump(typeof(SysChoiceGump));
                                        state.Mobile.SendGump(new SysChoiceGump(this.ToString(), Params, list));
                                        reader.Close();
                                        return;
                                    }
                                case (int)ImportSelections.Categories:
                                    {//Categories
                                        if (m_CategoryList == null)
                                            m_CategoryList = new List<PGCategory>();

                                        m_CategoryList.Add(new PGCategory(reader));
                                        state.Mobile.SendMessage("Added the Category.");
                                        break;
                                    }
                                case (int)ImportSelections.Locations:
                                    {//Locations
                                        state.Mobile.CloseGump(typeof(CatSelGump));
                                        state.Mobile.SendMessage("Please choose a Category to put this Location in.");
                                        state.Mobile.SendGump(new CatSelGump(this.ToString(), Params, new PGLocation(reader)));
                                        reader.Close();
                                        return;
                                    }
                            }

                            reader.Close();
                        }
                    }
                }
                catch
                {
                }
            }
            #endregion //Imports
            #endregion //Imports/Exports

            else if (info.ButtonID >= 150 && info.ButtonID < m_CategoryList.Count + 150)
                newParams.SelectedCategory = new KeyValuePair<PGCategory, int>(m_CategoryList[info.ButtonID - 150], info.ButtonID - 150);

            else if (info.ButtonID >= 200 && info.ButtonID < 200 + Params.SelectedCategory.Key.Locations.Count)
            {
                newParams.SelectedCategory = Params.SelectedCategory;
                newParams.SelectedLocation = new KeyValuePair<PGLocation, int>(Params.SelectedCategory.Key.Locations[info.ButtonID - 200], info.ButtonID - 200);
            }

            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), newParams));
        }