Ejemplo n.º 1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            SaveCheckBoxes(info);

            int index = (int)info.ButtonID - numOffset;

            if (index >= 0)
            {
                FileName = (string)MC.FileImportList[index];
            }

            switch (info.ButtonID)
            {
            case -100:                     // Page Number
            {
                MessagesTitle = "Help: Page Number";
                Messages      = "This is where the current page number out of total pages is shown. You may delete the page number and type in a page you would like to go to, then click refresh to jump to that page.\n\nFor Example:\nThe page number is 1/20, delete the 1/20 and type in 6, then click refresh. You will jump to page 6.";

                OpenGump();

                break;
            }

            case -101:                     // Files Loaded Into The Mega Spawner System
            {
                MessagesTitle = "Help: Files Loaded Into The Mega Spawner System";
                Messages      = "This displays all files that are currently loaded into the Mega Spawner System.";

                OpenGump();

                break;
            }

            case -9:                     // Selection Checkbox
            {
                if (Help)
                {
                    MessagesTitle = "Help: Selection Checkbox Column";
                    Messages      = "This column of checkboxes allow you to select any amount loaded files, to perform certain commands on.\n\nFor Example: You select a couple loaded files, then choose [Unload Selected Files], you will unload the selected files only.";

                    OpenGump();

                    break;
                }

                int chkd = 0, unchkd = 0;

                for (int i = offsetMin; i <= offsetMax; i++)
                {
                    if ((bool)FMCheckBoxesList[i])
                    {
                        chkd++;
                    }
                    else
                    {
                        unchkd++;
                    }
                }

                for (int i = offsetMin; i <= offsetMax; i++)
                {
                    if (chkd > unchkd)
                    {
                        FMCheckBoxesList[i] = (bool)false;
                    }
                    else if (unchkd > chkd)
                    {
                        FMCheckBoxesList[i] = (bool)true;
                    }
                    else
                    {
                        FMCheckBoxesList[i] = (bool)false;
                    }
                }

                OpenGump();

                break;
            }

            case -8:                     // Display Messages
            {
                if (Help)
                {
                    if (DisplayMessages)
                    {
                        MessagesTitle = "Help: Minimize Messages Button";
                        Messages      = "That button will minimize the messages window.";
                    }
                    else
                    {
                        MessagesTitle = "Help: Restore Messages Button";
                        Messages      = "That button will restore the messages window.";
                    }

                    OpenGump();

                    break;
                }

                DisplayMessages = !DisplayMessages;

                OpenGump();

                break;
            }

            case -7:                     // Refresh
            {
                if (Help)
                {
                    MessagesTitle = "Help: Refresh Button";
                    Messages      = "That button will refresh the current window and also change the page number if specified in the upper right hand corner. To change the page number, delete the current page number and type in the page you want to go to.";

                    OpenGump();

                    break;
                }

                int    intPage   = 0;
                string checkPage = Convert.ToString(info.GetTextEntry(0).Text).ToLower();

                if (checkPage == String.Format("{0}/{1}", pg, totalPages))
                {
                    OpenGump();

                    break;
                }

                try{ intPage = Convert.ToInt32(checkPage); }
                catch
                {
                    MessagesTitle = "Refresh";
                    Messages      = "The page number must be an integer.";

                    OpenGump();

                    break;
                }

                if (intPage > 0 && intPage <= totalPages)
                {
                    pg = intPage;
                }
                else
                {
                    MessagesTitle = "Refresh";
                    Messages      = "That page number does not exist.";
                }

                OpenGump();

                break;
            }

            case -6:                     // Clear Messages
            {
                if (Help)
                {
                    MessagesTitle = "Help: Clear Messages Button";
                    Messages      = "That button will clear all the messages in the messages window.";

                    OpenGump();

                    break;
                }

                MessagesTitle = "Messages";
                Messages      = null;

                OpenGump();

                break;
            }

            case -5:                     // Help
            {
                if (Help)
                {
                    MessagesTitle = "Help";
                    Messages      = "Help is now off.";

                    Help = false;
                }
                else
                {
                    MessagesTitle = "Help";
                    Messages      = "Help is now on. Click on the button you wish to receive help on. If any buttons appear when you click help, those are help buttons you may click as well. You may click on as many buttons as you wish, and you must click the help button again to turn off help.";

                    Help = true;
                }

                OpenGump();

                break;
            }

            case -4:                     // Previous Page
            {
                if (Help)
                {
                    MessagesTitle = "Help: Previous Page Button";
                    Messages      = "That button will switch to the previous page.";

                    OpenGump();

                    break;
                }

                pg--;

                OpenGump();

                break;
            }

            case -3:                     // Next Page
            {
                if (Help)
                {
                    MessagesTitle = "Help: Next Page Button";
                    Messages      = "That button will switch to the next page.";

                    OpenGump();

                    break;
                }

                pg++;

                OpenGump();

                break;
            }

            case -2:                     // Previous Command Page
            {
                if (Help)
                {
                    MessagesTitle = "Help: Previous Command Page Button";
                    Messages      = "That button will switch to the previous command list page.";

                    OpenGump();

                    break;
                }

                cpg--;

                OpenGump();

                break;
            }

            case -1:                     // Next Command Page
            {
                if (Help)
                {
                    MessagesTitle = "Help: Next Command Page Button";
                    Messages      = "That button will switch to the next command list page.";

                    OpenGump();

                    break;
                }

                cpg++;

                OpenGump();

                break;
            }

            case 0:                     // Close Gump
            {
                if (Help)
                {
                    MessagesTitle = "Help: Close Button";
                    Messages      = "That button will close the gump and return to the previous gump.";

                    OpenGump();

                    break;
                }

                ResetHideSpawnerList();

                FileName = "";

                SetArgsList();

                gumpMobile.SendGump(new MegaSpawnerGump(gumpMobile, ArgsList));

                break;
            }

            case 1:                     // Manual Load File
            {
                if (Help)
                {
                    MessagesTitle = "Help: Manual Load File Button";
                    Messages      = "That button will load a specified file if it is of a supported file type. Supported types are as follows:\n*.msf, *.mbk";

                    OpenGump();

                    break;
                }

                gumpMobile.SendGump(new LoadFileGump(gumpMobile, ArgsList, LoadType.Manual, ""));

                break;
            }

            case 2:                     // Unload Selected Files
            {
                if (Help)
                {
                    MessagesTitle = "Help: Unload Selected Files Button";
                    Messages      = "That button will unload all selected files from the Mega Spawner System.";

                    OpenGump();

                    break;
                }

                if (MC.FileImportList.Count == 0)
                {
                    MessagesTitle = "Unload Selected Files";
                    Messages      = "There are no files currently loaded into the Mega Spawner System.";

                    OpenGump();

                    break;
                }

                bool found = false;

                for (int i = 0; i < MC.FileImportList.Count; i++)
                {
                    if ((bool)FMCheckBoxesList[i])
                    {
                        found = true;

                        break;
                    }
                }

                if (!found)
                {
                    MessagesTitle = "Unload Selected Files";
                    Messages      = "There are no files selected.";

                    OpenGump();

                    break;
                }

                gumpMobile.SendGump(new ConfirmUnloadFilesGump(gumpMobile, ArgsList, 2));

                break;
            }

            case 3:                     // Unload All Files
            {
                if (Help)
                {
                    MessagesTitle = "Help: Unload All Files Button";
                    Messages      = "That button will unload all files from the Mega Spawner System.";

                    OpenGump();

                    break;
                }

                if (MC.FileImportList.Count == 0)
                {
                    MessagesTitle = "Unload All Files";
                    Messages      = "There are no files currently loaded into the Mega Spawner System.";

                    OpenGump();

                    break;
                }

                gumpMobile.SendGump(new ConfirmUnloadFilesGump(gumpMobile, ArgsList, 1));

                break;
            }

            case 4:                     // Open File Browser
            {
                if (Help)
                {
                    MessagesTitle = "Help: Open File Browser Button";
                    Messages      = "That button will open the file browser in which you may load files into the Mega Spawner System.";

                    OpenGump();

                    break;
                }

                PageInfoList[10] = 1;                                           // File Browser Gump Command Page
                PageInfoList[11] = 1;                                           // File Browser Gump Page

                SetArgsList();

                gumpMobile.SendGump(new FileBrowserGump(gumpMobile, ArgsList));

                break;
            }

            case 5:                     // Save Selected From Spawner List
            {
                if (Help)
                {
                    MessagesTitle = "Help: Save Selected From Spawner List Button";
                    Messages      = String.Format("That button will save all selected Mega Spawners on the Mega Spawner list to a file with *.msf extension in your \"{0}\" directory.", MC.CropCoreDirectory(MC.SpawnerExportsDirectory));

                    OpenGump();

                    break;
                }

                CompileSpawnerList();
                CheckSpawners();

                if (SpawnerList.Count == 0)
                {
                    MessagesTitle = "Save Selected From Spawner List";
                    Messages      = "There are no Mega Spawners on the Mega Spawner list.";

                    OpenGump();

                    break;
                }

                MC.CheckSpawners();

                bool found = false;

                for (int i = 0; i < MC.SpawnerList.Count; i++)
                {
                    if ((bool)MSGCheckBoxesList[i])
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    MessagesTitle = "Save Selected From Spawner List";
                    Messages      = "There are no Mega Spawners selected.";

                    OpenGump();

                    break;
                }

                gumpMobile.SendGump(new SaveFileGump(gumpMobile, ArgsList, SaveType.FromFileMenu, ""));

                break;
            }

            case 6:                     // Save All Spawners
            {
                if (Help)
                {
                    MessagesTitle = "Help: Save All Spawners Button";
                    Messages      = String.Format("That button will save all Mega Spawners on the entire server to a file with *.msf extension in your \"{0}\" directory.", MC.CropCoreDirectory(MC.SpawnerExportsDirectory));

                    OpenGump();

                    break;
                }

                MC.CheckSpawners();

                if (MC.SpawnerList.Count == 0)
                {
                    MessagesTitle = "Save All Spawners";
                    Messages      = "There are no Mega Spawners on the entire server.";

                    OpenGump();

                    break;
                }

                for (int i = 0; i < MC.SpawnerList.Count; i++)
                {
                    MSGCheckBoxesList[i] = (bool)true;
                }

                gumpMobile.SendGump(new SaveFileGump(gumpMobile, ArgsList, SaveType.FromFileMenu, ""));

                break;
            }

            case 7:                     // New Spawner Workspace
            {
                if (Help)
                {
                    MessagesTitle = "Help: New Spawner Workspace Button";
                    Messages      = "That button will open a new Spawner Workspace allowing you to add spawners and set up a file to export. After you are done and choose to save your Spawner Workspace, all of the Mega Spawners will be removed.";

                    OpenGump();

                    break;
                }

                SetNewSpawnerWorkspaceList();

                FileName = "new";

                SetArgsList();

                gumpMobile.SendGump(new MegaSpawnerGump(gumpMobile, ArgsList));

                break;
            }

            case 10:                     // Create Backup File
            {
                if (Help)
                {
                    MessagesTitle = "Help: Create Backup File Button";
                    Messages      = String.Format("That button will create a Mega Spawner backup file with *.mbk extension in your \"{0}\" directory.", MC.BackupDirectory);

                    OpenGump();

                    break;
                }

                MC.CheckSpawners();

                if (MC.SpawnerList.Count == 0)
                {
                    MessagesTitle = "Create Backup File";
                    Messages      = "There are no Mega Spawners on the entire server.";

                    OpenGump();

                    break;
                }

                BackupSystem.SaveBackup(gumpMobile, ArgsList);

                break;
            }

            default:
            {
                if (Help)
                {
                    MessagesTitle = "Help: Filename Button";
                    Messages      = "That button will open the filename and allow you to edit the spawner list.";

                    OpenGump();

                    break;
                }

                CompileHideSpawnerList(FileName);

                PageInfoList[1] = 1;                                            // MegaSpawnerGumpPage

                SetArgsList();

                ArgsList[9] = "";                                               // DirectoryPath

                gumpMobile.SendGump(new MegaSpawnerGump(gumpMobile, ArgsList));

                break;
            }
            }
        }
Ejemplo n.º 2
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:                     // Close Gump
            {
                MessagesTitle = "Load File";
                Messages      = "You have chosen not to load a file.";

                SetArgsList();

                switch (loadType)
                {
                case LoadType.Manual: { gumpMobile.SendGump(new FileMenuGump(gumpMobile, ArgsList)); break; }

                default: { gumpMobile.SendGump(new FileBrowserGump(gumpMobile, ArgsList)); break; }
                }

                break;
            }

            case 1:                     // Load File
            {
                string fileName = null;

                switch (loadType)
                {
                case LoadType.Manual:
                {
                    TextRelay textInput = info.GetTextEntry(0);
                    fileName = Convert.ToString(textInput.Text).ToLower();

                    break;
                }

                default: { fileName = FileName; break; }
                }

                if (loadType == LoadType.FileBrowserMbk)
                {
                    MC.CheckSpawners();

                    if (MC.SpawnerList.Count > 0)
                    {
                        foreach (MegaSpawner megaSpawner in MC.SpawnerList)
                        {
                            megaSpawner.Delete();
                        }

                        ArgsList[6]  = new ArrayList();                                         // HideSpawnerList
                        ArgsList[13] = new ArrayList();                                         // MSGCheckBoxesList

                        MC.SpawnerList.Clear();
                    }

                    BackupSystem.LoadBackup(gumpMobile, ArgsList, fileName);
                }
                else
                {
                    LoadFile(fileName);
                }

                break;
            }
            }
        }