コード例 #1
0
ファイル: Batch.cs プロジェクト: Polyum/BiomePainter
        private void Run()
        {
            String[] paths  = Directory.GetFiles(regionDir, "*.mca", SearchOption.TopDirectoryOnly);
            String   format = String.Format("{{0}} region {{1}} of {0}", paths.Length);
            int      count  = 0;

            foreach (String path in paths)
            {
                UpdateStatus(String.Format(format, "Reading", count));
                UpdateProgress(count, paths.Length);
                RegionFile region = new RegionFile(path);
                UpdateStatus(String.Format(format, replace ? "Replacing" : "Filling", count));
                if (!replace)
                {
                    RegionUtil.Fill(region, null, Color.Black, biome1, worldSeed);
                }
                else
                {
                    RegionUtil.Replace(region, null, Color.Black, ((BiomeType)biome1).ID, biome2, worldSeed);
                }
                UpdateStatus(String.Format(format, "Saving", count));
                mutex.WaitOne();
                region.Write(true);
                mutex.ReleaseMutex();
                count++;
            }
            UpdateProgress(paths.Length, paths.Length);
            UpdateStatus("Done");
        }
コード例 #2
0
        private void setChunksInSelectionToBePopulatedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }

            if (!warnedAboutPopulating)
            {
                DialogResult res = MessageBox.Show(this, String.Format("Setting a chunk to be popluated by Minecraft means the next time that chunk is loaded in Minecraft it will be filled with trees, snow cover, water, lava, and ores depending on the biome(s) the chunk is in.{0}{0}If that chunk has already been populated or already has player-made structures in it, you may find it clogged with more foliage than you wanted. Also smooth stone in your structures may be replaced with ores, dirt, or gravel. I strongly suggest you make a backup copy of your world before using this feature.{0}{0}Are you sure you want to proceed? As always, changes can be undone and won't take effect until you save the region.", Environment.NewLine), "DANGER", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                warnedAboutPopulating = true;
            }

            if (!chkShowPopulate.Checked)
            {
                chkShowPopulate.Checked = true;
            }

            RegionUtil.SetChunkstobePopulated(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, 0);
            RegionUtil.RenderRegionChunkstobePopulated(region, imgRegion.Layers[POPULATELAYER].Image);
            imgRegion.Redraw();
            history.RecordPopulateState(region, "Set Populate Flags");
        }
コード例 #3
0
 private void btnSelectChunks_Click(object sender, EventArgs e)
 {
     UpdateStatus("Expanding selection");
     RegionUtil.SelectChunks(imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor);
     UpdateStatus("");
     imgRegion.Redraw();
     history.RecordSelectionState(imgRegion.Layers[SELECTIONLAYER].Image, "Select Chunks");
 }
コード例 #4
0
        private void lstRegions_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (world == null || lstRegions.SelectedIndex == lastSelectedRegionIndex)
            {
                return;
            }

            if (!SaveIfNecessary())
            {
                lstRegions.SelectedIndex = lastSelectedRegionIndex;
                return;
            }

            history.FilterOutType(typeof(BiomeAction));
            history.FilterOutType(typeof(PopulateAction));

            Match  m          = Regex.Match(lstRegions.SelectedItem.ToString(), @"Region (-?\d+), (-?\d+)");
            int    x          = int.Parse(m.Groups[1].Value);
            int    z          = int.Parse(m.Groups[2].Value);
            String pathFormat = String.Format("{0}{1}r.{{0}}.{{1}}.mca", world.GetRegionDirectory(dim), Path.DirectorySeparatorChar);

            UpdateStatus("Reading region file");
            region = new RegionFile(String.Format(pathFormat, x, z));
            history.RecordBiomeState(region, "Initial Biomes");
            history.RecordPopulateState(region, "Initial Populate Flags");
            history.SetLastSaveActions();
            imgRegion.Reset();
            UpdateStatus("Generating terrain map");
            RegionUtil.RenderRegionTerrain(region, imgRegion.Layers[MAPLAYER].Image, false);
            UpdateStatus("Generating biome map");
            RegionUtil.RenderRegionBiomes(region, imgRegion.Layers[BIOMELAYER].Image, imgRegion.ToolTips, false);
            UpdateStatus("");
            RegionUtil.RenderRegionChunkstobePopulated(region, imgRegion.Layers[POPULATELAYER].Image, false);
            imgRegion.Redraw();

            RegionFile[,] surrounding = new RegionFile[3, 3];
            UpdateStatus("Reading surrounding chunks");
            surrounding[0, 0] = new RegionFile(String.Format(pathFormat, x - 1, z - 1), 30, 31, 30, 31);
            surrounding[1, 0] = new RegionFile(String.Format(pathFormat, x, z - 1), 0, 31, 30, 31);
            surrounding[2, 0] = new RegionFile(String.Format(pathFormat, x + 1, z - 1), 0, 1, 30, 31);
            surrounding[0, 1] = new RegionFile(String.Format(pathFormat, x - 1, z), 30, 31, 0, 31);
            surrounding[1, 1] = null;
            surrounding[2, 1] = new RegionFile(String.Format(pathFormat, x + 1, z, 0, 1, 0, 31));
            surrounding[0, 2] = new RegionFile(String.Format(pathFormat, x - 1, z + 1), 30, 31, 0, 1);
            surrounding[1, 2] = new RegionFile(String.Format(pathFormat, x, z + 1), 0, 31, 0, 1);
            surrounding[2, 2] = new RegionFile(String.Format(pathFormat, x + 1, z + 1), 0, 1, 0, 1);
            UpdateStatus("Generating map for surrounding chunks");
            RegionUtil.RenderSurroundingRegions(surrounding, imgRegion.Layers[MAPLAYER].Image, imgRegion.Layers[BIOMELAYER].Image, imgRegion.ToolTips, imgRegion.Layers[POPULATELAYER].Image);
            UpdateStatus("");
            imgRegion.Redraw();

            lastSelectedRegionIndex = lstRegions.SelectedIndex;
        }
コード例 #5
0
        private void btnAddorRemovebyBiomes_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }
            bool add = sender == btnAddbyBiomes ? true : false;

            UpdateStatus(add ? "Adding to selection" : "Removing from selection");
            RegionUtil.AddorRemoveBiomesSelection(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, ((BiomeType)cmbBiomeType.SelectedItem).ID, add);
            UpdateStatus("");
            imgRegion.Redraw();
            history.RecordSelectionState(imgRegion.Layers[SELECTIONLAYER].Image, add ? "Select by Biome" : "Deselect by Biome");
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            menuRedrawTerrainMap.Checked = Settings.RedrawTerrainMap;
            menuBiomeFoliage.Checked     = Settings.BiomeFoliage;
            menuTransparency.Checked     = Settings.Transparency;
            FillRecentWorldsList();

            RegionUtil.RenderChunkBoundaries(imgRegion.Layers[CHUNKLAYER].Image);

            FillLists();
            ColorPalette.Preload(); //matters to multi-threaded chunk rendering

            history = new HistoryManager(HistoryChange);
            history.RecordSelectionState(imgRegion.Layers[SELECTIONLAYER].Image, "Initial Selection");
        }
コード例 #7
0
 private void imgRegion_CustomBrushClick(object sender, CustomBrushClickEventArgs e)
 {
     if (ClipboardManager.Paste(region, e.MouseX - RegionUtil.OFFSETX, e.MouseY - RegionUtil.OFFSETY))
     {
         if (Settings.RedrawTerrainMap)
         {
             UpdateStatus("Generating terrain map");
             RegionUtil.RenderRegionTerrain(region, imgRegion.Layers[MAPLAYER].Image);
         }
         UpdateStatus("Generating biome map");
         RegionUtil.RenderRegionBiomes(region, imgRegion.Layers[BIOMELAYER].Image, imgRegion.ToolTips);
         UpdateStatus("");
         imgRegion.Redraw();
         history.RecordBiomeState(region, "Paste Biomes");
     }
 }
コード例 #8
0
        private void unsetChunksInSelectionToBePopulatedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }

            if (!chkShowPopulate.Checked)
            {
                chkShowPopulate.Checked = true;
            }

            RegionUtil.SetChunkstobePopulated(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, 1);
            RegionUtil.RenderRegionChunkstobePopulated(region, imgRegion.Layers[POPULATELAYER].Image);
            imgRegion.Redraw();
            history.RecordPopulateState(region, "Unset Populate Flags");
        }
コード例 #9
0
        private void reloadCurrentRegionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }

            UpdateStatus("Reading region file");
            region = new RegionFile(region.Path);
            history.RecordBiomeState(region, "Reload Biomes");
            history.RecordPopulateState(region, "Reload Populate Flags");
            history.SetLastSaveActions();
            UpdateStatus("Generating terrain map");
            RegionUtil.RenderRegionTerrain(region, imgRegion.Layers[MAPLAYER].Image);
            UpdateStatus("Generating biome map");
            RegionUtil.RenderRegionBiomes(region, imgRegion.Layers[BIOMELAYER].Image, imgRegion.ToolTips);
            UpdateStatus("");
            RegionUtil.RenderRegionChunkstobePopulated(region, imgRegion.Layers[POPULATELAYER].Image);
            imgRegion.Redraw();
        }
コード例 #10
0
        private void btnReplace_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }

            UpdateStatus("Replacing in selected area");
            RegionUtil.Replace(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, ((BiomeType)cmbReplace1.SelectedItem).ID, cmbReplace2.SelectedItem, world.Seed);
            if (Settings.RedrawTerrainMap)
            {
                UpdateStatus("Generating terrain map");
                RegionUtil.RenderRegionTerrain(region, imgRegion.Layers[MAPLAYER].Image);
            }
            UpdateStatus("Generating biome map");
            RegionUtil.RenderRegionBiomes(region, imgRegion.Layers[BIOMELAYER].Image, imgRegion.ToolTips);
            UpdateStatus("");
            imgRegion.Redraw();
            history.RecordBiomeState(region, "Replace Biomes");
        }
コード例 #11
0
        private void btnAddorRemovebyBlocks_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }
            int[] blockIds = null;
            bool  add      = sender == btnAddbyBlocks ? true : false;

            switch ((String)cmbBlockType.SelectedItem)
            {
            case "Cacti & Dead Bushes":
                blockIds = new int[] { 81, 32 };
                break;

            case "Dirt & Grass":
                blockIds = new int[] { 2, 3 };
                break;

            case "Flowers & Tall Grass":
                blockIds = new int[] { 31, 37, 38 };
                break;

            case "Gravel":
                blockIds = new int[] { 13 };
                break;

            case "Lily Pads & Vines":
                blockIds = new int[] { 111, 106 };
                break;

            case "Leaves & Logs":
                blockIds = new int[] { 17, 18 };
                break;

            case "Ice":
                blockIds = new int[] { 79 };
                break;

            case "Sand":
                blockIds = new int[] { 12 };
                break;

            case "Snow":
                blockIds = new int[] { 78, 80 };
                break;

            case "Stone":
                blockIds = new int[] { 1 };
                break;

            case "Water":
                blockIds = new int[] { 8, 9 };
                break;

            case "Input Block ID":
            {
                String msg   = String.Format("Type the ID number of the block type you want to {0}.{1}See http://www.minecraftwiki.net/wiki/Data_values for more info.", add ? "add to the selection" : "remove from the selection", Environment.NewLine);
                String input = "";
                while (true)
                {
                    input = InputBox.Show(msg, add ? "Add to Selection" : "Remove From Selection", input);
                    if (input.Length == 0)
                    {
                        break;
                    }

                    Match m = Regex.Match(input, @"^(\d+)$");
                    if (m.Groups.Count < 2)
                    {
                        msg = "Unable to parse block ID. Please try again or click cancel.";
                    }
                    else
                    {
                        int id;
                        if (!Int32.TryParse(m.Groups[1].Value, out id))
                        {
                            msg = "Unable to parse block ID. Please try again or click cancel.";
                        }
                        else
                        {
                            blockIds = new int[] { id };
                            break;
                        }
                    }
                }
            }
            break;
            }
            if (blockIds != null)
            {
                UpdateStatus(add ? "Adding to selection" : "Removing from selection");
                RegionUtil.AddorRemoveBlocksSelection(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, blockIds, add);
                UpdateStatus("");
                imgRegion.Redraw();
                history.RecordSelectionState(imgRegion.Layers[SELECTIONLAYER].Image, add ? "Select by Block" : "Deselect by Block");
            }
        }