public AddWorldPopup(WorldListEntry world) { InitializeComponent(); fileBrowser.Filter = MapLoadFilter; cBackup.Items.AddRange(WorldListEntry.BackupEnumNames); cTemplates.Items.AddRange(Enum.GetNames(typeof(MapGenTemplate))); cTheme.Items.AddRange(Enum.GetNames(typeof(MapGenTheme))); bwLoader.DoWork += AsyncLoad; bwLoader.RunWorkerCompleted += AsyncLoadCompleted; bwGenerator.DoWork += AsyncGen; bwGenerator.WorkerReportsProgress = true; bwGenerator.ProgressChanged += AsyncGenProgress; bwGenerator.RunWorkerCompleted += AsyncGenCompleted; bwRenderer.WorkerReportsProgress = true; bwRenderer.WorkerSupportsCancellation = true; bwRenderer.DoWork += AsyncDraw; bwRenderer.ProgressChanged += AsyncDrawProgress; bwRenderer.RunWorkerCompleted += AsyncDrawCompleted; nMapWidth.Validating += MapDimensionValidating; nMapLength.Validating += MapDimensionValidating; nMapHeight.Validating += MapDimensionValidating; cAccess.Items.Add("(everyone)"); cBuild.Items.Add("(everyone)"); foreach (Rank rank in RankManager.Ranks) { cAccess.Items.Add(MainForm.ToComboBoxOption(rank)); cBuild.Items.Add(MainForm.ToComboBoxOption(rank)); } tStatus1.Text = ""; tStatus2.Text = ""; World = world; savePreviewDialog.Filter = "PNG Image|*.png|TIFF Image|*.tif;*.tiff|Bitmap Image|*.bmp|JPEG Image|*.jpg;*.jpeg"; savePreviewDialog.Title = "Saving preview image..."; browseTemplateDialog.Filter = "MapGenerator Template|*.ftpl"; browseTemplateDialog.Title = "Opening a MapGenerator template..."; saveTemplateDialog.Filter = browseTemplateDialog.Filter; saveTemplateDialog.Title = "Saving a MapGenerator template..."; Shown += LoadMap; }
public WorldListEntry([NotNull] WorldListEntry original) { if (original == null) { throw new ArgumentNullException("original"); } name = original.Name; Hidden = original.Hidden; Backup = original.Backup; BlockDBEnabled = original.BlockDBEnabled; blockDBIsPreloaded = original.blockDBIsPreloaded; blockDBLimit = original.blockDBLimit; blockDBTimeLimit = original.blockDBTimeLimit; accessSecurity = new SecurityController(original.accessSecurity); buildSecurity = new SecurityController(original.buildSecurity); LoadedBy = original.LoadedBy; LoadedOn = original.LoadedOn; MapChangedBy = original.MapChangedBy; MapChangedOn = original.MapChangedOn; environmentEl = original.environmentEl; }
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 = 5; 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; }