BiomePainter.Settings.AddRecentWorld C# (CSharp) Method

AddRecentWorld() public static method

public static AddRecentWorld ( String path, String name ) : void
path String
name String
return void
        public static void AddRecentWorld(String path, String name)
        {
            recentWorlds.Insert(0, new RecentWorld { Path = path, Name = name });

            for (int i = recentWorlds.Count - 1; i > 0; i--)
            {
                if (recentWorlds[i].Path == path)
                    recentWorlds.RemoveAt(i);
            }

            if (recentWorlds.Count > MAXWORLDS)
                recentWorlds.RemoveRange(MAXWORLDS, recentWorlds.Count - MAXWORLDS);
        }

Usage Example

Example #1
0
        private void OpenWorld(String path)
        {
            ResetControls();

            try
            {
                world = new World(path);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show(this, String.Format("The file \"{0}\" could not be found. Unable to open world.", path), "Open", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                world = null;
                return;
            }
            catch (Exception)
            {
                MessageBox.Show(this, String.Format("The file \"{0}\" could not be parsed. Please be sure that it is a valid Minecraft level.dat.", path), "Open", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                world = null;
                return;
            }

            lastPath = Path.GetDirectoryName(path);

            String[] regions = world.GetRegionPaths();
            if (regions.Length == 0)
            {
                MessageBox.Show(this, "No region files (*.mca) found in the main, overworld dimension. If the world is older than March 2012 open it in Minecraft 1.2 or later to convert to the Anvil format. Otherwise try switching dimensions from the file menu.", "Open", MessageBoxButtons.OK);
                this.Text = "Biome Painter";
            }
            else
            {
                foreach (String r in regions)
                {
                    lstRegions.Items.Add(RegionFile.ToString(r));
                }
            }

            Settings.AddRecentWorld(path, world.WorldName);
            FillRecentWorldsList();
            this.Text = world.WorldName + " - Biome Painter";
        }