Exemplo n.º 1
0
        /* ID's
         * 101   = Button	List Mobiles
         * 102   = Button	List Items
         * 103   = Button	List Types
         * 104   = Button	Previous
         * 105   = Button	Next
         * 106   = Button	Back to List
         * 1000+ = Button	Selections
         */
        public override void OnResponse(NetState state, RelayInfo info, ACCGumpParams subParams)
        {
            if (!Running || info.ButtonID == 0)
            {
                return;
            }

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

            CMGumpParams newParams = new CMGumpParams();

            //Switch to List Mobiles
            if (info.ButtonID == 101)
            {
                newParams.PageName = Pages.ListMobiles;
            }

            //Switch to List Items
            else if (info.ButtonID == 102)
            {
                newParams.PageName = Pages.ListItems;
            }

            //Previous Page
            else if (info.ButtonID == 104)
            {
                newParams.PageIndex = Params.PageIndex - 1;
            }

            //Next Page
            else if (info.ButtonID == 105)
            {
                newParams.PageIndex = Params.PageIndex + 1;
            }

            //Back to List
            else if (info.ButtonID == 106)
            {
                newParams.PageName = Pages.Home;
            }

            //Select Item from List
            else if (info.ButtonID >= 1000)
            {
                int selectedID = info.ButtonID - 1000;

                if (selectedID < 0 || selectedID >= m_DictionaryOfModuleLists.Count)
                {
                    return;
                }

                switch ((int)Params.PageName)
                {
                //Change page to List Modules with serial of selected item
                case (int)Pages.ListItems:
                {
                    if (selectedID < 0 || selectedID >= m_ItemList.Count)
                    {
                        return;
                    }

                    newParams.PageName       = Pages.ListModulesFor;
                    newParams.SelectedSerial = m_ItemList[selectedID].Serial;
                    newParams.PageIndex      = 0;

                    break;
                }

                //Change page to List Modules with serial of selected mobile
                case (int)Pages.ListMobiles:
                {
                    if (selectedID < 0 || selectedID >= m_MobileList.Count)
                    {
                        return;
                    }

                    newParams.PageName       = Pages.ListModulesFor;
                    newParams.SelectedSerial = m_MobileList[selectedID].Serial;
                    newParams.PageIndex      = 0;
                    break;
                }

                //Open the Edit Module Gump
                //Not implemented yet
                case (int)Pages.ListModulesFor:
                {
                    if (selectedID < 0 || selectedID >= m_ModuleList.Count)
                    {
                        return;
                    }

                    if (m_ModuleList[selectedID] == null)
                    {
                        return;
                    }

                    Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(SendEMG), state.Mobile);
                    break;
                }
                }
            }

            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), newParams));
        }
Exemplo n.º 2
0
        public override void Gump(Mobile from, Gump gump, ACCGumpParams subParams)
        {
            gump.AddButton(190, 40, 2445, 2445, 101, GumpButtonType.Reply, 0);
            gump.AddLabel(204, 42, 1153, "List Mobiles");
            gump.AddButton(310, 40, 2445, 2445, 102, GumpButtonType.Reply, 0);
            gump.AddLabel(331, 42, 1153, "List Items");
            gump.AddButton(430, 40, 2445, 2445, 103, GumpButtonType.Reply, 0);
            gump.AddLabel(450, 42, 1153, "List Types");
            //			gump.AddButton( 190, 70, 2445, 2445, 104, GumpButtonType.Reply, 0 );
            //			gump.AddLabel(  208, 72, 1153, "Add Module" );
            //			gump.AddButton( 310, 70, 2445, 2445, 105, GumpButtonType.Reply, 0 );
            //			gump.AddLabel(  326, 72, 1153, "Edit Module" );
            //			gump.AddButton( 430, 70, 2445, 2445, 106, GumpButtonType.Reply, 0 );
            //			gump.AddLabel(  439, 72, 1153, "Delete Module" );

            if (subParams == null || !(subParams is CMGumpParams))
            {
                gump.AddHtml(215, 15, 300, 25, "<basefont size=7 color=white><center>Central Memory</center></font>", false, false);
                gump.AddHtml(140, 95, 450, 250, "<basefont color=white><center>Welcome to the Central Memory Admin Gump!</center><br>With this gump, you can see a list of all entries that the CM contains.  You can add new Modules or modify or delete existing Modules.<br><br>Make your selection from the top buttons, either List Mobiles or Items.  This will bring up a list of all Mobiles or Items that the CM is keeping track of.<br><br>You may then select one of the entries to list the Modules that are stored to that entry.  You can then add, modify or remove modules to that entry.</font>", false, false);
                return;
            }

            Params = subParams as CMGumpParams;

            switch ((int)Params.PageName)
            {
                #region ListMobiles
            case (int)Pages.ListMobiles:
                gump.AddLabel(120, 95, 1153, "Listing all Mobiles:");

                m_MobileList = GetMobiles();
                if (m_MobileList == null || m_MobileList.Count == 0)
                {
                    return;
                }

                if (Params.PageIndex < 0)
                {
                    Params.PageIndex = 0;
                }


                if (Params.PageIndex > 0)
                {
                    gump.AddButton(120, 332, 4014, 4015, 104, GumpButtonType.Reply, 0);
                }
                if ((Params.PageIndex + 1) * 21 <= m_MobileList.Count)
                {
                    gump.AddButton(540, 332, 4005, 4006, 105, GumpButtonType.Reply, 0);
                }

                for (int i = Params.PageIndex * 21, r = 0, c = 0; i < m_MobileList.Count; i++)
                {
                    if (m_MobileList[i] == null)
                    {
                        continue;
                    }
                    gump.AddButton(120 + c * 155, 125 + r * 30, 2501, 2501, 1000 + i, GumpButtonType.Reply, 0);
                    gump.AddLabel(130 + c * 155, 126 + r * 30, 1153, (m_MobileList[i].Name == null ? m_MobileList[i].Serial.ToString() : m_MobileList[i].Name));
                }

                break;
                #endregion //ListMobiles

                #region ListItems
            case (int)Pages.ListItems:
                gump.AddLabel(120, 95, 1153, "Listing all Items:");

                m_ItemList = GetItems();
                if (m_ItemList == null || m_ItemList.Count == 0)
                {
                    return;
                }

                if (Params.PageIndex < 0)
                {
                    Params.PageIndex = 0;
                }

                if (Params.PageIndex > 0)
                {
                    gump.AddButton(120, 332, 4014, 4015, 104, GumpButtonType.Reply, 0);
                }
                if ((Params.PageIndex + 1) * 21 <= m_ItemList.Count)
                {
                    gump.AddButton(540, 332, 4005, 4006, 105, GumpButtonType.Reply, 0);
                }

                for (int i = Params.PageIndex * 21, r = 0, c = 0; i < m_ItemList.Count; i++)
                {
                    if (m_ItemList[i] == null)
                    {
                        continue;
                    }
                    gump.AddButton(120 + c * 155, 125 + r * 30, 2501, 2501, 1000 + i, GumpButtonType.Reply, 0);
                    gump.AddLabel(130 + c * 155, 126 + r * 30, 1153, (m_ItemList[i].Name == null ? m_ItemList[i].Serial.ToString() : m_ItemList[i].Name));
                }

                break;
                #endregion //ListItems

                #region ListModulesFor
            case (int)Pages.ListModulesFor:
                if (!m_DictionaryOfModuleLists.ContainsKey(Params.SelectedSerial))
                {
                    gump.AddLabel(120, 95, 1153, "This entity no longer exists in the Central Memory!");
                    return;
                }

                if (m_DictionaryOfModuleLists[Params.SelectedSerial] == null || m_DictionaryOfModuleLists[Params.SelectedSerial].Count == 0)
                {
                    gump.AddLabel(120, 95, 1153, "This entity has no Modules!");
                    Remove(Params.SelectedSerial);
                    return;
                }

                string name = "";
                if (Params.SelectedSerial.IsMobile)
                {
                    name = World.FindMobile(Params.SelectedSerial).Name;
                }
                else if (Params.SelectedSerial.IsItem)
                {
                    name = World.FindItem(Params.SelectedSerial).Name;
                }

                if (name == null || name.Length == 0)
                {
                    name = Params.SelectedSerial.ToString();
                }

                gump.AddLabel(120, 95, 1153, String.Format("Listing all Modules for {0}:", name));

                m_ModuleList = m_DictionaryOfModuleLists[Params.SelectedSerial].GetListOfModules();

                if (m_ModuleList == null || m_ModuleList.Count == 0)
                {
                    return;
                }

                if (Params.PageIndex < 0)
                {
                    Params.PageIndex = 0;
                }
                if (Params.PageIndex * 21 >= m_ModuleList.Count)
                {
                    Params.PageIndex = m_ModuleList.Count - 21;
                }

                if (Params.PageIndex > 0)
                {
                    gump.AddButton(120, 332, 4014, 4015, 104, GumpButtonType.Reply, 0);
                }
                if ((Params.PageIndex + 1) * 21 <= m_ModuleList.Count)
                {
                    gump.AddButton(540, 332, 4005, 4006, 105, GumpButtonType.Reply, 0);
                }

                gump.AddButton(331, 332, 4008, 4009, 106, GumpButtonType.Reply, 0);

                for (int i = Params.PageIndex * 21, r = 0, c = 0; i < m_ModuleList.Count; i++)
                {
                    if (m_ModuleList[i] == null)
                    {
                        continue;
                    }

                    gump.AddButton(120 + c * 155, 125 + r * 30, 2501, 2501, 1000 + i, GumpButtonType.Reply, 0);
                    gump.AddLabel(130 + c * 155, 126 + r * 30, 1153, (m_ModuleList[i].Name().Length == 0 ? m_ModuleList[i].Owner.ToString() : m_ModuleList[i].Name()));
                }

                break;
                #endregion //ListModulesFor
            }
        }