IsWorldNameTaken() static private method

static private IsWorldNameTaken ( string name ) : bool
name string
return bool
Example #1
0
 void tName_Validating(object sender, CancelEventArgs e)
 {
     if (fCraft.World.IsValidName(tName.Text) &&
         (!MainForm.IsWorldNameTaken(tName.Text) ||
          (originalWorldName != null && tName.Text.ToLower() == originalWorldName.ToLower())))
     {
         tName.ForeColor = SystemColors.ControlText;
     }
     else
     {
         tName.ForeColor = System.Drawing.Color.Red;
         e.Cancel        = true;
     }
 }
Example #2
0
 private void tName_Validating(object sender, CancelEventArgs e)
 {
     if (fCraft.World.IsValidName(tName.Text) &&
         (!MainForm.IsWorldNameTaken(tName.Text) ||
          (originalWorldName != null && tName.Text.Equals(originalWorldName, StringComparison.OrdinalIgnoreCase))))
     {
         tName.ForeColor = SystemColors.ControlText;
     }
     else
     {
         tName.ForeColor = System.Drawing.Color.Red;
         e.Cancel        = true;
     }
 }
Example #3
0
        void LoadMap(object sender, EventArgs args)
        {
            // Fill in the "Copy existing world" combobox
            foreach (WorldListEntry otherWorld in MainForm.Worlds)
            {
                if (otherWorld != World)
                {
                    cWorld.Items.Add(otherWorld.Name + " (" + otherWorld.Description + ")");
                    copyOptionsList.Add(otherWorld);
                }
            }

            if (World == null)
            {
                Text = "Adding a New World";

                // keep trying "NewWorld#" until we find an unused number
                int worldNameCounter = 1;
                while (MainForm.IsWorldNameTaken("NewWorld" + worldNameCounter))
                {
                    worldNameCounter++;
                }

                World = new WorldListEntry("NewWorld" + worldNameCounter);

                tName.Text            = World.Name;
                cAccess.SelectedIndex = 0;
                cBuild.SelectedIndex  = 0;
                cBackup.SelectedIndex = 0;
                xBlockDB.CheckState   = CheckState.Indeterminate;
                Map = null;
            }
            else
            {
                // Editing a world
                World                = new WorldListEntry(World);
                Text                 = "Editing World \"" + World.Name + "\"";
                originalWorldName    = World.Name;
                tName.Text           = World.Name;
                cAccess.SelectedItem = World.AccessPermission;
                cBuild.SelectedItem  = World.BuildPermission;
                cBackup.SelectedItem = World.Backup;
                xHidden.Checked      = World.Hidden;

                switch (World.BlockDBEnabled)
                {
                case YesNoAuto.Auto:
                    xBlockDB.CheckState = CheckState.Indeterminate;
                    break;

                case YesNoAuto.Yes:
                    xBlockDB.CheckState = CheckState.Checked;
                    break;

                case YesNoAuto.No:
                    xBlockDB.CheckState = CheckState.Unchecked;
                    break;
                }
            }

            // Disable "copy" tab if there are no other worlds
            if (cWorld.Items.Count > 0)
            {
                cWorld.SelectedIndex = 0;
            }
            else
            {
                tabs.TabPages.Remove(tabCopy);
            }

            // Disable "existing map" tab if mapfile does not exist
            fileToLoad = World.FullFileName;
            if (File.Exists(fileToLoad))
            {
                ShowMapDetails(tExistingMapInfo, fileToLoad);
                StartLoadingMap();
            }
            else
            {
                tabs.TabPages.Remove(tabExisting);
                tabs.SelectTab(tabLoad);
            }

            // Set Generator comboboxes to defaults
            cTemplates.SelectedIndex = (int)MapGenTemplate.River;

            savePreviewDialog.FileName = World.Name;
        }
Example #4
0
        void LoadMap(object sender, EventArgs args)
        {
            // get the list of existing worlds
            otherWorlds = MainForm.Worlds.Where(w => w != World).ToArray();

            // Fill in the "Copy existing world" combobox
            foreach (WorldListEntry otherWorld in otherWorlds)
            {
                cWorld.Items.Add(otherWorld.Name + " (" + otherWorld.Description + ")");
                copyOptionsList.Add(otherWorld);
                var item = new ToolStripMenuItem(otherWorld.Name)
                {
                    Tag = otherWorld
                };
                tsbCopyGenSettings.DropDownItems.Insert(0, item);
            }

            if (World == null)
            {
                // initialize defaults for a new world (Adding)
                Text = "Adding a New World";

                // keep trying "NewWorld#" until we find an unused number
                int worldNameCounter = 1;
                while (MainForm.IsWorldNameTaken("NewWorld" + worldNameCounter))
                {
                    worldNameCounter++;
                }

                World = new WorldListEntry("NewWorld" + worldNameCounter);

                tName.Text                = World.Name;
                cAccess.SelectedIndex     = 0;
                cBuild.SelectedIndex      = 0;
                cBackup.SelectedIndex     = 0;
                cBlockDB.SelectedIndex    = 0; // Auto
                cVisibility.SelectedIndex = 0;
                Map = null;
            }
            else
            {
                // Fill in information from an existing world (Editing)
                World                     = new WorldListEntry(World);
                Text                      = "Editing World \"" + World.Name + "\"";
                originalWorldName         = World.Name;
                tName.Text                = World.Name;
                cAccess.SelectedItem      = World.AccessPermission;
                cBuild.SelectedItem       = World.BuildPermission;
                cBackup.SelectedItem      = World.Backup;
                cVisibility.SelectedIndex = (World.Hidden ? 1 : 0);

                switch (World.BlockDBEnabled)
                {
                case YesNoAuto.Auto:
                    cBlockDB.SelectedIndex = 0;
                    break;

                case YesNoAuto.Yes:
                    cBlockDB.SelectedIndex = 1;
                    break;

                case YesNoAuto.No:
                    cBlockDB.SelectedIndex = 2;
                    break;
                }
            }

            // Disable "copy" tab if there are no other worlds
            if (cWorld.Items.Count > 0)
            {
                cWorld.SelectedIndex = 0;
            }
            else
            {
                tabs.TabPages.Remove(tabCopy);
            }

            // Disable "existing map" tab if map file does not exist
            fileToLoad = World.FullFileName;
            if (File.Exists(fileToLoad))
            {
                ShowMapDetails(tExistingMapInfo, fileToLoad);
                StartLoadingMap();
            }
            else
            {
                tabs.TabPages.Remove(tabExisting);
                tabs.SelectTab(tabLoad);
            }

            savePreviewDialog.FileName = World.Name;
        }