Пример #1
0
 private void recalcLightingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveMdiChild != null)
     {
         if ((ActiveMdiChild as frmMap).Map != null)
         {
             Profiler profSky = new Profiler("Sky Lighting");
             Profiler profBlock = new Profiler("Block Lighting");
             tsbStatus.Text = "Waiting for user response lol";
             DialogResult dr = MessageBox.Show("MineEdit will remove lighting data from all chunks, forcing a lighting recalculation (according to advice from Notch, anyway).\n\nThis will inevitably take a long time.  ARE YOU SURE?", "DO YOU HAVE THE PATIENCE", MessageBoxButtons.YesNo);
             if (dr == DialogResult.No)
             {
                 ResetStatus();
                 return;
             }
             dlgLongTask dlt = new dlgLongTask();
             dlt.Start(delegate()
             {
                 int NumChunks = 0;
                 dlt.VocabSubtask = "Chunk";
                 dlt.VocabSubtasks = "Chunks";
                 dlt.Title = "Stripping lighting from chunks.";
                 dlt.Subtitle = "This will take a while.  Go take a break.";
                 dlt.SetMarquees(false, false);
                 dlt.CurrentTask = "Replacing stuff in chunks...";
                 dlt.TasksComplete = 0;
                 dlt.TasksTotal = 1;
                 dlt.SubtasksTotal = 1;
                 (ActiveMdiChild as frmMap).Map.ForEachProgress += new ForEachProgressHandler(delegate(int Total, int Progress)
                 {
                     dlt.TasksTotal = Total;
                     dlt.TasksComplete = Progress;
                 });
                 int NumSkipped=0;
                 (ActiveMdiChild as frmMap).Map.ForEachChunk(delegate(long X, long Y)
                 {
                     Chunk c = (ActiveMdiChild as frmMap).Map.GetChunk(X, Y);
                     if (c == null)
                     {
                         ++NumSkipped;
                         return;
                     }
                     c.Save();
                     dlt.CurrentTask= string.Format("Stripping lighting... ({0}/{1}, {2} skipped)", dlt.TasksComplete, dlt.TasksTotal, NumSkipped);
                 });
                 dlt.Done();
             });
             dlt.ShowDialog();
             MessageBox.Show("Lighting stripped from "+dlt.TasksComplete+" chunks.", "Report");
             //(ActiveMdiChild as frmMap).Enabled = true;
             (ActiveMdiChild as frmMap).ReloadAll();
             ResetStatus();
         }
     }
 }
Пример #2
0
 internal void FixLava()
 {
     dlgLongTask dlt = new dlgLongTask();
     ThreadStart ts = new ThreadStart(delegate()
     {
         dlt.Title = "Fixing Lava";
         dlt.Subtitle = "This will take a very long time, take a break.";
         dlt.VocabSubtask = "subtask";
         dlt.VocabSubtasks = "subtasks";
         dlt.SubtasksTotal = (int)(Map.ChunkScale.X * Map.ChunkScale.Y * Map.ChunkScale.Z);
         dlt.TasksTotal = NumChunks;
         dlt.TasksComplete = 0;
         (ActiveMdiChild as frmMap).Map.ForEachProgress += new ForEachProgressHandler(delegate(int Total, int Progress)
         {
             dlt.TasksTotal = Total;
             dlt.TasksComplete = Progress;
         });
         Map.ForEachChunk(delegate(IMapHandler mh, long X, long Y)
         {
             if (dlt.STOP) return;
             Chunk c = Map.GetChunk(X, Y);
             if (c == null) return;
             byte[, ,] b = c.Blocks;
             for (int x = 0; x < Map.ChunkScale.X; x++)
             {
                 for (int y = 0; y < Map.ChunkScale.Y; y++)
                 {
                     for (int z = 0; z < Map.ChunkScale.Z; z++)
                     {
                         if (z == 0)
                             b[x, y, z] = 7;
                         else if (z == 1)
                             b[x, y, z] = 11;
                     }
                 }
             }
             c.Blocks = b;
             _Map.SaveChunk(c);
         });
         if (dlt.TasksTotal - dlt.TasksComplete > 0)
             MessageBox.Show(string.Format("{0} chunks were skipped?!", dlt.TasksTotal - dlt.TasksComplete));
         dlt.Done();
     });
     dlt.Start(ts);
     dlt.ShowDialog();
 }
Пример #3
0
        private void generateTerrainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild != null)
            {
                if ((ActiveMdiChild as frmMap).Map != null)
                {
                    dlgTerrainGen terragen = new dlgTerrainGen((ActiveMdiChild as frmMap).Map);
                    if(terragen.ShowDialog() == DialogResult.Cancel)
                    {
                        ResetStatus();
                        return;
                    }
                    DialogResult dr = MessageBox.Show("This could DELETE EVERYTHING. ARE YOU SURE?", "ARE YOU NUTS", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        ResetStatus();
                        return;
                    }
                    IMapGenerator mg = (IMapGenerator)terragen.pgMapGen.SelectedObject;
                    (ActiveMdiChild as frmMap).Map.Generator = mg;
                    dlgLongTask dlt = new dlgLongTask();
                    dlt.Start(delegate()
                    {
                        dlt.SetMarquees(true, true);
                        dlt.VocabSubtask = "Chunk";
                        dlt.VocabSubtasks = "Chunks";
                        dlt.Title = "Generating chunks.";
                        dlt.Subtitle = "This will take a while.  Go take a break.";
                        dlt.SetMarquees(false, false);
                        dlt.CurrentTask = "Replacing stuff in chunks...";
                        dlt.TasksComplete = 0;
                        dlt.TasksTotal = 1;
                        dlt.SubtasksTotal = 1;

                        (ActiveMdiChild as frmMap).Map.ForEachProgress +=new ForEachProgressHandler(delegate(int Total, int Progress){
                            dlt.TasksTotal = Total;
                            dlt.TasksComplete = Progress;
                        });
                        (ActiveMdiChild as frmMap).Map.ForEachChunk(delegate(long X, long Y)
                        {
                            if (dlt.STOP) return;
                            dlt.SubtasksComplete = 0;
                            dlt.CurrentSubtask = string.Format("Generating chunk ({0},{1})", X, Y);
                            (ActiveMdiChild as frmMap).Map.Generate((ActiveMdiChild as frmMap).Map, X, Y);
                            dlt.SubtasksComplete = 1;
                        });
                        dlt.CurrentTask = "Fixing fluids, may take a while...";
                        dlt.SubtasksTotal = 2;
                        dlt.SubtasksComplete = 0;
                        IMapHandler mh = (ActiveMdiChild as frmMap).Map;
                        dlt.CurrentSubtask = "Fixing water...";
                        int hurr = 1;
                        int hurrT = 0;
                        int passes = 0;
                        while (hurr != 0)
                        {
                            passes++;
                            dlt.CurrentSubtask = string.Format("Fixing water (Pass #{0}, {1} blocks added)...", passes, hurrT);
                            hurr = mh.ExpandFluids(09, false, delegate(int Total,int Complete){
                                dlt.SubtasksTotal = Total;
                                dlt.SubtasksComplete = Complete;
                            });
                            hurrT += hurr;
                        }
                        dlt.SubtasksComplete++;
                        dlt.CurrentSubtask = "Fixing lava...";
                        passes = 0;
                        hurrT = 0;
                        hurr = 1;
                        while (hurr != 0)
                        {
                            passes++;
                            dlt.CurrentSubtask = string.Format("Fixing lava ({0} passes, {1} blocks added)...", passes, hurrT);
                            hurr = mh.ExpandFluids(11, false, delegate(int Total, int Complete)
                            {
                                dlt.SubtasksTotal = Total;
                                dlt.SubtasksComplete = Complete;
                            });
                            hurrT += hurr;
                        }
                        dlt.SubtasksComplete++;
                        (ActiveMdiChild as frmMap).Map = mh;
                        dlt.Done();
                        MessageBox.Show("Done.  Keep in mind that loading may initially be slow.");
                    });
                    dlt.ShowDialog();
                }
            }
        }
Пример #4
0
 private void randomSeedToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (ActiveMdiChild != null)
     {
         if ((ActiveMdiChild as frmMap).Map != null)
         {
             OpenFileDialog sfd = new OpenFileDialog();
             sfd.Filter = "Random Seed File|*.rnd|Any file|*.*";
             DialogResult dr = sfd.ShowDialog();
             if (dr == System.Windows.Forms.DialogResult.OK)
             {
                 long random;
                 if(!long.TryParse(File.ReadAllText(sfd.FileName),out random))
                 {
                     MessageBox.Show("Use a valid Random Seed File (all it can contain is the random seed value).");
                     return;
                 }
                 (ActiveMdiChild as frmMap).Map.RandomSeed = random;
                 (ActiveMdiChild as frmMap).Map.Save();
                 DialogResult dr2 = MessageBox.Show("Would you also like to REMOVE ALL CHUNKS?  This will allow you to regenerate the entire map, but it will REMOVE ALL CHANGES APPLIED TO THE MAP.", "Regenerate?", MessageBoxButtons.YesNo);
                 if (dr2 == System.Windows.Forms.DialogResult.Yes)
                 {
                     dlgLongTask dlt = new dlgLongTask();
                     dlt.Start(delegate()
                     {
                         int NumChunks = 0;
                         dlt.SetMarquees(true, true);
                         dlt.VocabSubtask = "Chunk";
                         dlt.VocabSubtasks = "Chunks";
                         dlt.Title = "Removing chunks.";
                         dlt.Subtitle = "This will take a while.  Go take a break.";
                         dlt.CurrentSubtask = "Counting chunks (0)...";
                         dlt.CurrentTask = "Replacing stuff in chunks...";
                         dlt.TasksComplete = 0;
                         dlt.TasksTotal = NumChunks;
                         dlt.SubtasksTotal = 2;
                         (ActiveMdiChild as frmMap).Map.ForEachProgress += new ForEachProgressHandler(delegate(int Total, int Progress)
                         {
                             dlt.TasksTotal = Total;
                             dlt.TasksComplete = Progress;
                         });
                         (ActiveMdiChild as frmMap).Map.ForEachChunk(new Chunk.ChunkModifierDelegate(delegate(long x, long y)
                         {
                             if (dlt.STOP) return;
                             dlt.CurrentTask = string.Format("Deleting chunk ({0},{1})...", x, y);
                             dlt.CurrentSubtask = string.Format("Loading chunk ({0},{1})...", x, y);
                             dlt.SubtasksComplete = 0;
                             Chunk c = (ActiveMdiChild as frmMap).Map.GetChunk(x, y);
                             if (c == null) return;
                             dlt.CurrentSubtask = string.Format("Deleting chunk ({0},{1})...", x, y);
                             dlt.SubtasksComplete = 1;
                             File.Delete(c.Filename);
                             dlt.SubtasksComplete = 2;
                         }));
                         dlt.Done();
                         MessageBox.Show("Done.");
                     });
                     dlt.ShowDialog();
                 }
             }
         }
     }
 }
Пример #5
0
        private void ReplaceBlocks()
        {
            this.Enabled = false;
            string        q    = "Are you sure you want to do the following replacements:\n\n\t{0}\n\nTHIS WILL TAKE A VERY LONG TIME!";
            List <string> reps = new List <string>();

            foreach (KeyValuePair <byte, byte> rep in Replacements.Items)
            {
                reps.Add(string.Format("{0} to {1}", Blocks.Get((short)rep.Key).Name, Blocks.Get((short)rep.Value).Name));
            }
            DialogResult dr = MessageBox.Show(string.Format(q, string.Join("\n\t", reps.ToArray())), "Clear snow?", MessageBoxButtons.YesNo);

            long nchunks = (_Map.MapMax.X - _Map.MapMin.X) * (_Map.MapMax.Y - _Map.MapMin.Y);

            if (dr == DialogResult.Yes)
            {
                Dictionary <byte, byte> replacers = new Dictionary <byte, byte>();
                foreach (KeyValuePair <byte, byte> kvp in Replacements.Items)
                {
                    replacers.Add(kvp.Key, kvp.Value);
                }
                dlgLongTask dlt = new dlgLongTask();
                dlt.Title          = "Replacing blocks";
                dlt.Subtitle       = "This will take a long time.  Take a break.";
                dlt.VocabSubtask   = "subtask";
                dlt.VocabSubtasks  = "subtasks";
                dlt.VocabTask      = "chunk";
                dlt.VocabTasks     = "chunks";
                dlt.CurrentSubtask = "";
                dlt.CurrentTask    = "Counting chunks...";
                dlt.Start(delegate()
                {
                    _Map.ForEachChunk(delegate(IMapHandler mh, long X, long Y)
                    {
                        if (dlt.STOP)
                        {
                            return;
                        }
                        ++dlt.TasksTotal;
                        dlt.CurrentSubtask = "Counted " + dlt.TasksTotal.ToString() + " chunks so far...";
                    });

                    Dictionary <byte, byte> durr = new Dictionary <byte, byte>();
                    foreach (KeyValuePair <byte, byte> derp in Replacements.Items)
                    {
                        durr.Add(derp.Key, derp.Value);
                    }
                    _Map.ForEachChunk(delegate(IMapHandler mh, long X, long Y)
                    {
                        if (dlt.STOP)
                        {
                            return;
                        }

                        _Map.ReplaceBlocksIn(X, Y, replacers);
                    });
                    dlt.Done();
                });
                if (dlt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    MessageBox.Show("Done, lighting was removed, so minecraft may freeze while it recalculates lighting.", "Done.");
                }
            }
            this.Enabled = true;
        }
Пример #6
0
        private void generateTerrainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild != null)
            {
                if ((ActiveMdiChild as frmMap).Map != null)
                {
                    dlgTerrainGen terragen = new dlgTerrainGen((ActiveMdiChild as frmMap).Map);
                    if(terragen.ShowDialog() == DialogResult.Cancel)
                    {
                        ResetStatus();
                        return;
                    }
                    DialogResult dr = MessageBox.Show("This could DELETE EVERYTHING. ARE YOU SURE?", "ARE YOU NUTS", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        ResetStatus();
                        return;
                    }
                    IMapGenerator mg = (IMapGenerator)terragen.pgMapGen.SelectedObject;

                    (ActiveMdiChild as frmMap).Map.Generator = mg;
                    dlgLongTask dlt = new dlgLongTask();
                    dlt.Start(delegate()
                    {
                        // ACTIVATE AUTOREPAIR
                        (ActiveMdiChild as frmMap).Map.Autorepair = true;

                        /////////////////////////////////////////////////////////////////
                        // UI Stuff
                        /////////////////////////////////////////////////////////////////
                        dlt.SetMarquees(true, true);
                        dlt.VocabSubtask = "chunk";
                        dlt.VocabSubtasks = "chunks";
                        dlt.Title = "Generating chunks.";
                        dlt.Subtitle = "This will take a while.  Go take a break.";
                        dlt.SetMarquees(false, false);
                        dlt.CurrentTask = "Replacing stuff in chunks...";
                        dlt.TasksComplete = 0;
                        dlt.TasksTotal = 1;
                        dlt.SubtasksTotal = 1;

                        int numchunks = 0;
                        // Generate terrain
                        // Drop soil
                        // Add pbarriers
                        // Add dungeons
                        // Add trees
                        // Fix fluids
                        // Fix lava

                        int stage = 0;
                        int numstages = 1;
                        ForEachProgressHandler feph = new ForEachProgressHandler(delegate(int Total, int Progress)
                        {
                            numchunks = Total;
                            dlt.TasksTotal = numchunks * numstages;
                            dlt.TasksComplete = Progress + (stage * numchunks);
                            dlt.SubtasksComplete = Progress;
                            dlt.SubtasksTotal = Total;
                        });
                        ForEachProgressHandler fl_feph = new ForEachProgressHandler(delegate(int Total, int Progress)
                        {
                            numchunks = Total;
                            dlt.TasksTotal = numchunks * numstages;
                            dlt.TasksComplete = Progress + (stage * numchunks);
                            dlt.SubtasksComplete = Progress;
                            dlt.SubtasksTotal = Total;

                            dlt.perfChart.AddValue((ActiveMdiChild as frmMap).Map.ChunksLoaded);
                        });

                        Vector3i Max = new Vector3i(0,0,0);
                        Vector3i Min = new Vector3i(int.MaxValue, int.MaxValue, int.MaxValue);
                        dlt.CurrentTask = "Determining map scale...";
                        (ActiveMdiChild as frmMap).Map.ForEachProgress += feph;
                        dlt.ShowPerfChart(true);
                        dlt.perfChart.Clear();
                        dlt.perfChart.ScaleMode = SpPerfChart.ScaleMode.Relative;
                        (ActiveMdiChild as frmMap).Map.ForEachChunk(delegate(IMapHandler _mh, long X, long Z)
                        {
                            if (Min.X > X) Min.X = X;
                            if (Max.X < X) Max.X = X;
                            if (Min.Z > Z) Min.Z = Z;
                            if (Max.Z < Z) Max.Z = Z;
                            dlt.CurrentSubtask = string.Format("Map Scale: ({0},{1})", Max.X - Min.X, Max.Z - Min.Z);
                            _mh.SaveAll();
                        });

                        (ActiveMdiChild as frmMap).Map.Cache.Enabled = false;

                        int total = (int)((Max.X - Min.X) * (Max.Z - Min.Z));
                        int completed = 0;
                        (ActiveMdiChild as frmMap).Map.ForEachKnownChunk(0,delegate(IMapHandler _mh, long X, long Z)
                        {
                            if (dlt.STOP) return;
                            dlt.CurrentSubtask = string.Format("Generating chunk ({0},{1})", X, Z);
                            double min, max;
                            (ActiveMdiChild as frmMap).Map.Generate(X, Z, out min, out max);
                            dlt.grpPerformance.Text = string.Format("Terrain Profile [{0},{1}]m", (int)(min * 100), (int)(max * 100));
                            dlt.perfChart.AddValue((decimal)max);
                            feph(total, completed++);
                        });

                        if ((ActiveMdiChild as frmMap).Map.Generator.GenerateCaves)
                        {
                            dlt.CurrentTask = "Generating caves...";
                            dlt.grpPerformance.Text = "Generation time (ms)";
                            Random rand = new Random((int)(ActiveMdiChild as frmMap).Map.RandomSeed);
                            Profiler profCaves = new Profiler("Cave");
                            (ActiveMdiChild as frmMap).Map.ForEachKnownChunk(0, delegate(IMapHandler _mh, long X, long Z)
                            {
                                if (dlt.STOP) return;
                                dlt.CurrentSubtask = string.Format("Generating caves in chunk ({0},{1})", X, Z);
                                if (rand.Next(3) != 0)
                                {
                                    int xo = (int)(X * _mh.ChunkScale.X);
                                    int zo = (int)(Z * _mh.ChunkScale.Z);
                                    int x = rand.Next((int)_mh.ChunkScale.X - 1);
                                    int z = rand.Next((int)_mh.ChunkScale.Z - 1);
                                    int y = rand.Next((int)(_mh.GetHeightAt(x, z) * 127) + 5);
                                    profCaves.Start();
                                    new Cave(ref rand, ref _mh, new Vector3i(x + xo, y, z + zo));
                                    Console.WriteLine("LOLDONE");
                                    dlt.perfChart.AddValue(profCaves.Stop());
                                    feph(total, completed++);
                                }
                            });
                        }
                        completed = 0;
                        /*
                        Profiler profTrees = new Profiler("Trees");
                        for (int X = (int)Min.X; X < Max.X + 1; X++)
                        {
                            for (int Z = (int)Min.Z; Z < Max.Z + 1; Z++)
                            {
                                profTrees.Start();
                                if (dlt.STOP) return;
                                dlt.CurrentSubtask = string.Format("Adding trees to chunk ({0},{1})", X, Z);
                                (ActiveMdiChild as frmMap).Map.Populate(X, Z);
                                dlt.grpPerformance.Text = "Performance";
                                profTrees.Stop();
                                dlt.perfChart.AddValue(profTrees.Stop());
                                feph(total, completed++);
                            }
                        }
                        */
                        /*
                        stage++;
                        dlt.CurrentTask = "Eroding chunk surfaces...";
                        (ActiveMdiChild as frmMap).Map.ForEachProgress += feph;
                        (ActiveMdiChild as frmMap).Map.ForEachChunk(delegate(IMapHandler _mh, long X, long Y)
                        {
                            dlt.CurrentSubtask = string.Format("Eroding chunk ({0},{1}, thermal)", X, Y);
                            //(ActiveMdiChild as frmMap).Map.ErodeThermal(5, 10, (int)X, (int)Y);

                            dlt.CurrentSubtask = string.Format("Eroding chunk ({0},{1}, hydraulic)", X, Y);
                            //(ActiveMdiChild as frmMap).Map.Erode(5, 10, (int)X, (int)Y);

                            dlt.CurrentSubtask = string.Format("Eroding chunk ({0},{1}, silt)", X, Y);
                            //(ActiveMdiChild as frmMap).Map.Silt(63,true, (int)X, (int)Y);

                            dlt.grpPerformance.Text = string.Format("Chunks in-memory ({0})", _mh.ChunksLoaded);
                            dlt.perfChart.AddValue(_mh.ChunksLoaded);
                        });
                        */

                        dlt.CurrentSubtask = "SAVING CHUNKS";
                        (ActiveMdiChild as frmMap).Map.SaveAll();
                        dlt.SetMarquees(false,false);
                        dlt.Done();
                        ClearReport();
                        (ActiveMdiChild as frmMap).Map.Time = 0;
                        //Utils.FixPlayerPlacement(ref (ActiveMdiChild as frmMap).Map);
                        (ActiveMdiChild as frmMap).Map.Save();

                        (ActiveMdiChild as frmMap).Map.Cache.Enabled = true;

                        MessageBox.Show("Done.  Keep in mind that loading may initially be slow.");

                        // DEACTIVATE AUTOREPAIR
                        (ActiveMdiChild as frmMap).Map.Autorepair = false;
                    });
                    dlt.ShowDialog();
                }
            }
        }
Пример #7
0
        private void recalcLightingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild != null)
            {
                if ((ActiveMdiChild as frmMap).Map != null)
                {
                    tsbStatus.Text = "Waiting for user response lol";
                    DialogResult dr = MessageBox.Show("MineEdit will try and recalculate lighting GLOBALLY using quartz-lightgen.\n\nThis will inevitably take a long time.  ARE YOU SURE?", "DO YOU HAVE THE PATIENCE", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        ResetStatus();
                        return;
                    }
                    dlgLongTask dlt = new dlgLongTask();
                    dlt.Start(delegate()
                    {
                        ShittyLighter lighter = new ShittyLighter();
                        dlt.VocabSubtask = "chunk";
                        dlt.VocabSubtasks = "chunks";
                        dlt.Title = "Relighting Map";
                        dlt.Subtitle = "This will take a while.  Go take a break.";
                        dlt.SetMarquees(false, false);
                        dlt.CurrentTask = "Relighting...";
                        dlt.TasksComplete = 0;
                        dlt.TasksTotal = 1;
                        dlt.SubtasksTotal = 1;

                        IMapHandler mh = (ActiveMdiChild as frmMap).Map;
                        ForEachProgressHandler FEPH = new ForEachProgressHandler(delegate(int Total, int Progress)
                        {
                            dlt.TasksTotal = Total;
                            dlt.TasksComplete = Progress;

                            dlt.CurrentSubtask = "Processes";
                            dlt.SubtasksComplete = mh.ChunksLoaded;
                            dlt.SubtasksTotal = 200;
                            if (mh.ChunksLoaded>200)
                            {
                                string ot = dlt.CurrentTask;
                                Console.WriteLine("****SAVING****");
                                dlt.CurrentTask = "[Saving to avoid overusing RAM]";
                                (ActiveMdiChild as frmMap).Map.SaveAll();
                                dlt.CurrentTask = ot;
                            }
                            (ActiveMdiChild as frmMap).Map.CullUnchanged();
                        });

                        dlt.CurrentTask = "Gathering chunks needing light...";
                        mh.ForEachProgress += FEPH;
                        List<string> chunks = new List<string>();
                        string tf = Path.GetTempFileName();
                        mh.ForEachChunk(delegate(IMapHandler _map,long X, long Y)
                        {
                            chunks.Add(string.Format("{0},{1}",X,Y));
                            //_map.RegenerateLighting(X, Y);
                        });
                        File.WriteAllLines(tf, chunks.ToArray());
                        string args = "'" + Path.GetDirectoryName(mh.Filename) + Path.DirectorySeparatorChar + "' '"+tf+"'";
                        Process child = Process.Start("lightgen.exe", args);
                        //child.WaitForInputIdle();
                        /*
                        // Skylight
                        dlt.CurrentTask = "Skylight...";
                        mh.ForEachProgress += FEPH;
                        lighter.SkylightGlobal(ref mh);
                        mh.SaveAll();

                        // Blocklight
                        dlt.CurrentTask = "Relighting (BlockLight)...";
                        mh.ForEachProgress += FEPH;
                        lighter.BlocklightGlobal(ref mh);
                        mh.SaveAll();
                        */
                        (ActiveMdiChild as frmMap).Map = mh;
                        dlt.Done();
                    });

                    (ActiveMdiChild as frmMap).Map.Autorepair = true;
                    dlt.ShowDialog();
                    (ActiveMdiChild as frmMap).Map.Autorepair = false;
                    MessageBox.Show("Lighting regenerated for "+dlt.TasksComplete+" chunks.", "Report");
                    //(ActiveMdiChild as frmMap).Enabled = true;
                    (ActiveMdiChild as frmMap).ReloadAll();
                    ResetStatus();
                }
            }
        }
Пример #8
0
        private void ReplaceBlocks()
        {
            this.Enabled = false;
            string q = "Are you sure you want to do the following replacements:\n\n\t{0}\n\nTHIS WILL TAKE A VERY LONG TIME!";
            List<string> reps = new List<string>();
            foreach (KeyValuePair<byte, byte> rep in Replacements.Items)
            {
                reps.Add(string.Format("{0} to {1}", Blocks.Get((short)rep.Key).Name, Blocks.Get((short)rep.Value).Name));
            }
            DialogResult dr = MessageBox.Show(string.Format(q, string.Join("\n\t", reps.ToArray())), "Clear snow?", MessageBoxButtons.YesNo);

            long nchunks = (_Map.MapMax.X - _Map.MapMin.X) * (_Map.MapMax.Y - _Map.MapMin.Y);
            if (dr == DialogResult.Yes)
            {
                Dictionary<byte, byte> replacers = new Dictionary<byte, byte>();
                foreach (KeyValuePair<byte, byte> kvp in Replacements.Items)
                    replacers.Add(kvp.Key, kvp.Value);
                dlgLongTask dlt = new dlgLongTask();
                dlt.Title = "Replacing blocks";
                dlt.Subtitle = "This will take a long time.  Take a break.";
                dlt.VocabSubtask = "subtask";
                dlt.VocabSubtasks = "subtasks";
                dlt.VocabTask = "chunk";
                dlt.VocabTasks = "chunks";
                dlt.CurrentSubtask = "";
                dlt.CurrentTask = "Counting chunks...";
                dlt.Start(delegate()
                {
                    _Map.ForEachChunk(delegate(long X, long Y)
                    {
                        if (dlt.STOP) return;
                        ++dlt.TasksTotal;
                        dlt.CurrentSubtask = "Counted " + dlt.TasksTotal.ToString() + " chunks so far...";
                    });

                    Dictionary<byte, byte> durr = new Dictionary<byte, byte>();
                    foreach (KeyValuePair<byte, byte> derp in Replacements.Items)
                    {
                        durr.Add(derp.Key, derp.Value);
                    }
                    _Map.ForEachChunk(delegate(long X, long Y)
                    {
                        if (dlt.STOP) return;

                        _Map.ReplaceBlocksIn(X, Y, replacers);
                    });
                    dlt.Done();
                });
                if (dlt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    MessageBox.Show("Done, lighting was removed, so minecraft may freeze while it recalculates lighting.", "Done.");
                }
            }
            this.Enabled = true;
        }
Пример #9
0
        private void DoReplace()
        {
            this.Enabled = false;
            string q = "Are you sure you want to do the following replacements:\n\n\t{0}\n\nTHIS WILL TAKE A VERY LONG TIME!";
            List<string> reps = new List<string>();
            foreach (KeyValuePair<byte, byte> rep in Replacements.Items)
            {
                reps.Add(string.Format("{0} to {1}",Blocks.Get((short)rep.Key).Name,Blocks.Get((short)rep.Value).Name));
            }
            DialogResult dr = MessageBox.Show(string.Format(q,string.Join("\n\t",reps.ToArray())), "Are you sure?", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                dlgLongTask dlt = new dlgLongTask();
                dlt.Title = "Replacing blocks";
                dlt.Subtitle = "This will take a long time, take a break.";
                dlt.VocabSubtask = "subtask";
                dlt.VocabSubtasks = "subtasks";
                dlt.VocabTask = "chunk";
                dlt.VocabTasks = "chunks";
                dlt.Start(delegate()
                {
                    Map.ForEachProgress += new ForEachProgressHandler(delegate(int Total, int Progress)
                    {
                        dlt.TasksTotal = Total;
                        dlt.TasksComplete = Progress;
                    });
                    dlt.CurrentTask = "Replacing blocks...";
                    _Map.ForEachChunk(delegate(long X, long Y)
                    {
                        dlt.CurrentTask = string.Format("Replacing stuff in chunk {0} of {1}...", dlt.TasksComplete, dlt.TasksTotal);
                        Dictionary<byte, byte> durr = new Dictionary<byte, byte>();
                        foreach (KeyValuePair<byte, byte> derp in Replacements.Items)
                        {
                            durr.Add(derp.Key, derp.Value);
                        }
                        _Map.ReplaceBlocksIn(X, Y, durr);
                        ++ProcessedChunks;
                    });
                });
                dlt.ShowDialog();
                (MdiParent as frmMain).ResetStatus();
                dlt.Done();
                MessageBox.Show("Done.", "Operation complete!");
            }
            this.Enabled = true;
        }