public void SetWorld(MinecraftWorld world) { WorldSide = world; WorldSide.MapsChanged += WorldSide_MapsChanged; WorldSide_MapsChanged(this, EventArgs.Empty); ImportSide = new ImportMaps(); ImportSide.MapsChanged += ImportSide_MapsChanged; ImportSide_MapsChanged(this, EventArgs.Empty); }
private void DoOpenWorld(MinecraftWorld world) { OpenedWorld = world; WorldView.SetWorld(OpenedWorld); MapViewZone.Visible = true; string title = $"Image Map – {OpenedWorld.Name}"; if (world is JavaWorld java) { title += $" (Java {java.Version})"; } else if (world is BedrockWorld bedrock) { title += $" (Bedrock {bedrock.Version})"; } this.Text = title; }
// use a function to defer loading of the world; it's pointless to construct a world only to discard it if the user wants to wait private void OpenWorld(Func <MinecraftWorld> getworld) { if (!WorldView.HasUnsavedChanges() || MessageBox.Show("You have unsaved maps waiting to be imported! If you select a new world, these will be lost!\n\nDiscard unsaved maps?", "Wait a minute!", MessageBoxButtons.YesNo) == DialogResult.Yes) { MinecraftWorld world = null; try { world = getworld(); } catch (Exception ex) { MessageBox.Show($"Error opening that world:\n\n{Util.ExceptionMessage(ex)}", "World error!"); } if (world != null) { DoOpenWorld(world); } } }
private async Task GetMaps(MapCreationSettings settings, MinecraftWorld world) { var progress = new Progress <MapCreationProgress>(); progress.ProgressChanged += (s, e) => ProgressChanged?.Invoke(this, e); var maps = (await Task.Run(() => world.MapsFromSettings(settings, progress))).ToList(); lock (IDModificationLock) { var ids = UsedIDs; foreach (int index in DiscardIndexes.OrderByDescending(x => x)) { ids.RemoveAt(index); maps.RemoveAt(index); } ResultMaps = ids.Zip(maps, (k, v) => new { k, v }).ToDictionary(x => x.k, x => x.v); } Finish(); }
public ActionResult OpenWorld(Edition edition, string folder, bool bypass_mapwarning = false) { if (!bypass_mapwarning && ImportingMapPreviews.Any()) { return(ActionResult.MapsNotImported); } var oldworld = SelectedWorld; try { if (edition == Edition.Java) { SelectedWorld = new JavaWorld(folder); } else if (edition == Edition.Bedrock) { SelectedWorld = new BedrockWorld(folder); } else { throw new ArgumentException($"Don't know what edition {edition} is"); } } catch (Exception ex) { MessageBox.Show("Could not open this world. Perhaps it's the wrong edition, or is missing some important files.\n\n" + ex.Message, "Failed to open world!"); return(ActionResult.Failure); } SelectedWorld.Initialize(); NewWorldOpened(); oldworld?.Dispose(); // that's right, I did it! GC.Collect(); PlayerDestinations = new List <string>(); PlayerDestinations.Add(LOCAL_IDENTIFIER); foreach (var uuid in SelectedWorld.GetPlayerIDs()) { PlayerDestinations.Add(uuid); } return(ActionResult.Success); }
public PendingMapsWithID(long first_id, MapCreationSettings settings, MinecraftWorld world) { UsedIDs = Util.CreateRange(first_id, settings.NumberOfMaps).ToList(); Settings = settings; _ = GetMaps(settings, world); }