Example #1
0
 private void btnGenerateWorld_Click(object sender, EventArgs e)
 {
     if (btnGenerateWorld.Text == "Cancel")
     {
         btnGenerateWorld.Text    = "Cancelling";
         btnGenerateWorld.Enabled = false;
         City.stop = true;
     }
     else if (btnGenerateWorld.Text == "&Generate World")
     {
         if (numAmountOfCities.Value >= 10)
         {
             switch (MessageBox.Show("You have requested " + numAmountOfCities.Value.ToString() + " cities. This could take a long time to create. You will be able to cancel the world generation at any time. Proceed?", "Mace", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
             {
             case System.Windows.Forms.DialogResult.No:
                 return;
             }
         }
         if (clbCityThemesToUse.CheckedItems.Count == 0)
         {
             MessageBox.Show("You must select at least one city theme.", "No themes selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             btnGenerateWorld.Text = "Cancel";
             // setup for city generation
             tabOptions.SelectTab(tpLog);
             lblProgress.Visible     = true;
             lblProgressBack.Visible = true;
             txtLogNormal.Text       = String.Empty;
             txtLogVerbose.Text      = String.Empty;
             this.Cursor             = Cursors.WaitCursor;
             City.id   = 0;
             City.stop = false;
             UpdateProgress(0);
             this.ControlBox = false;
             //btnGenerateWorld.Enabled = false;
             startTime = DateTime.Now;
             GenerateWorld.Generate(this, txtWorldName.Text, txtWorldSeed.Text, cmbWorldType.Text,
                                    chkMapFeatures.Checked, (int)numAmountOfCities.Value,
                                    clbCityThemesToUse.CheckedItems.OfType <string>().ToArray(),
                                    (int)numMinimumChunksBetweenCities.Value,
                                    cmbSpawnPoint.Text, chkExportCities.Checked,
                                    cmbNPCs.Text, cbUndergroundOres.Text);
             TimeSpan duration = DateTime.Now - startTime;
             UpdateLog("Completed in " + Math.Round(duration.TotalSeconds, 2) + " seconds", false, true);
             btnSaveLogNormal.Enabled  = true;
             btnSaveLogVerbose.Enabled = true;
             // restore
             Version ver = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
             this.Text = String.Format("Mace v{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
             lblProgressBack.Visible  = false;
             lblProgress.Visible      = false;
             btnGenerateWorld.Enabled = true;
             this.ControlBox          = true;
             this.Cursor           = Cursors.Default;
             btnGenerateWorld.Text = "&Generate World";
         }
     }
 }
Example #2
0
 private void btnGenerateWorld_Click(object sender, EventArgs e)
 {
     if (clbCityThemesToUse.CheckedItems.Count == 0)
     {
         MessageBox.Show("You must select at least one city theme.", "No themes selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         // setup for city generation
         tabOptions.SelectTab(tpLog);
         lblProgress.Visible     = true;
         lblProgressBack.Visible = true;
         txtLogNormal.Text       = String.Empty;
         txtLogVerbose.Text      = String.Empty;
         this.Cursor             = Cursors.WaitCursor;
         City.ID = 0;
         UpdateProgress(0);
         this.ControlBox          = false;
         btnGenerateWorld.Enabled = false;
         startTime = DateTime.Now;
         GenerateWorld.Generate(this, txtWorldName.Text, txtWorldSeed.Text, cmbWorldType.Text,
                                chkMapFeatures.Checked, (int)numAmountOfCities.Value,
                                clbCityThemesToUse.CheckedItems.OfType <string>().ToArray(),
                                (int)numMinimumChunksBetweenCities.Value,
                                cmbSpawnPoint.Text, chkExportCities.Checked,
                                cmbNPCs.Text, cbUndergroundOres.Text);
         TimeSpan duration = DateTime.Now - startTime;
         UpdateLog("Completed in " + Math.Round(duration.TotalSeconds, 2) + " seconds", false, true);
         btnSaveLogNormal.Enabled  = true;
         btnSaveLogVerbose.Enabled = true;
         // restore
         Version ver = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
         this.Text = String.Format("Mace v{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
         lblProgressBack.Visible  = false;
         lblProgress.Visible      = false;
         btnGenerateWorld.Enabled = true;
         this.ControlBox          = true;
         this.Cursor = Cursors.Default;
     }
 }