public void StartAutomapping(AutomapSettings settings) { StopAutomapping(); m_automap.Start(m_threadSafeAutomapCanvas, settings); m_dontAskAboutAmbiguities = false; }
public void StartAutomapping(AutomapSettings settings) { if (m_automap != null) { StopAutomapping(); } m_automap = new Automap(m_threadSafeAutomapCanvas, settings); m_dontAskAboutAmbiguities = false; }
public Automap(IAutomapCanvas canvas, AutomapSettings settings) { m_canvas = canvas; m_settings = settings; Debug.Assert(m_settings.AssumeRoomsWithSameNameAreSameRoom || m_settings.VerboseTranscript, "Must assume rooms with same name are same room unless transcript is verbose."); m_thread = new Thread(ThreadMain); m_thread.Start(); Status = "Automapping has started."; }
private static void ResetApplicationSettings() { DontCareAboutVersion = new Version(0, 0, 0, 0); s_automap = AutomapSettings.Default; InfiniteScrollBounds = false; ShowMiniMap = true; SaveAt100 = true; SaveToImage = true; SaveToPDF = true; RecentProjects.Clear(); // TODO: add other application settings here }
internal async void Start(IAutomapCanvas canvas, AutomapSettings settings) { if (Running) { Stop(); } m_canvas = canvas; m_settings = settings; m_firstRoom = true; Debug.Assert(m_settings.AssumeRoomsWithSameNameAreSameRoom || m_settings.VerboseTranscript, "Must assume rooms with same name are same room unless transcript is verbose."); Status = "Automapping has started."; try { using (var stream = File.Open(m_settings.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var reader = new StreamReader(stream)) using (m_tokenSource = new CancellationTokenSource()) { var lastline = ""; if (m_settings.ContinueTranscript) { while (!reader.EndOfStream) lastline = await reader.ReadLineAsync(); } // keep track of lines we read between here and the next prompt var linesBetweenPrompts = new List<string>(); Status = "Automapping is processing the transcript."; var promptLine = string.Empty; var line = string.Empty; var atFileEnd = false; // loop until cancelled while (true) { if (m_settings.ContinueTranscript) { line = lastline; m_settings.ContinueTranscript = false; } else { // ...read a line of text try { line = await WaitForNewLine(reader, m_tokenSource.Token); atFileEnd = reader.EndOfStream; // store this now so that it's still valid when we use it below } catch (TaskCanceledException) { break; } } //Trace("[" + line + "]"); string command; if (IsPrompt(line, out command)) { // this is a prompt line // let's process everything leading up to it since the last prompt, but not necessarily this new prompt itself await ProcessTranscriptText(linesBetweenPrompts); // we've now dealt with all lines to this point linesBetweenPrompts.Clear(); // handle the case where we're at the end of the file, waiting for user input if (atFileEnd) { try { // we've already read the prompt, now just read the command when the player enters it command = (await WaitForNewLine(reader, m_tokenSource.Token)).Trim(); } catch (TaskCanceledException) { break; } } // process the next command ProcessPromptCommand(command); Trace("{0}: {1}{2}", FormatTranscriptLineForDisplay(line), m_lastMoveDirection != null ? "GO " : string.Empty, m_lastMoveDirection != null ? m_lastMoveDirection.Value.ToString().ToUpperInvariant() : string.Empty); } else { // this line isn't a prompt; // hang onto it for now in case we meet a prompt shortly. linesBetweenPrompts.Add(line); } } } } catch (IOException ex) { // couldn't read from the file Trace("Automap: Error reading line in file.\nError message: " + ex.Message); MessageBox.Show("Error opening transcript file:\n" + ex.Message + "\n\nAutomapping halted.", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (UnauthorizedAccessException) { MessageBox.Show("Could not gain access to the transcript file. Your interpreter may be restricting access to it. Try again in a few minutes " + "or with scripting off in your interpreter.\n\nAutomapping halted.", "Access Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Trace("Automap: Gentle thread exit."); Status = "Automapping has completed."; }
static void ResetApplicationSettings() { s_dontCareAboutVersion = new Version(0, 0, 0, 0); s_automap = AutomapSettings.Default; s_infiniteScrollBounds = false; s_showMinimap = true; s_recentProjects.Clear(); // TODO: add other application settings here }
internal async void Start(IAutomapCanvas canvas, AutomapSettings settings) { if (this.Running) { this.Stop(); } m_canvas = canvas; m_settings = settings; Debug.Assert(m_settings.AssumeRoomsWithSameNameAreSameRoom || m_settings.VerboseTranscript, "Must assume rooms with same name are same room unless transcript is verbose."); Status = "Automapping has started."; try { using (var stream = File.Open(m_settings.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (StreamReader reader = new StreamReader(stream)) using (m_tokenSource = new CancellationTokenSource()) { string lastline = ""; if (m_settings.ContinueTranscript) { while (!reader.EndOfStream) { lastline = await reader.ReadLineAsync(); } } // keep track of lines we read between here and the next prompt var linesBetweenPrompts = new List <string>(); Status = "Automapping is processing the transcript."; var promptLine = String.Empty; var line = String.Empty; bool atFileEnd = false; // loop until cancelled while (true) { if (m_settings.ContinueTranscript) { line = lastline; m_settings.ContinueTranscript = false; } else { // ...read a line of text try { line = await WaitForNewLine(reader, m_tokenSource.Token); atFileEnd = reader.EndOfStream; // store this now so that it's still valid when we use it below } catch (TaskCanceledException) { break; } } //Trace("[" + line + "]"); string command; if (IsPrompt(line, out command)) { // this is a prompt line // let's process everything leading up to it since the last prompt, but not necessarily this new prompt itself await ProcessTranscriptText(linesBetweenPrompts); // we've now dealt with all lines to this point linesBetweenPrompts.Clear(); // handle the case where we're at the end of the file, waiting for user input if (atFileEnd) { try { // we've already read the prompt, now just read the command when the player enters it command = (await WaitForNewLine(reader, m_tokenSource.Token)).Trim(); } catch (TaskCanceledException) { break; } } // process the next command ProcessPromptCommand(command); Trace("{0}: {1}{2}", FormatTranscriptLineForDisplay(line), m_lastMoveDirection != null ? "GO " : string.Empty, m_lastMoveDirection != null ? m_lastMoveDirection.Value.ToString().ToUpperInvariant() : string.Empty); } else { // this line isn't a prompt; // hang onto it for now in case we meet a prompt shortly. linesBetweenPrompts.Add(line); } } } } catch (IOException ex) { // couldn't read from the file Trace("Automap: Error reading line in file.\nError message: " + ex.Message); MessageBox.Show("Error opening transcript file:\n" + ex.Message + "\n\nAutomapping halted.", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (UnauthorizedAccessException) { MessageBox.Show("Could not gain access to the transcript file. Your interpreter may be restricting access to it. Try again in a few minutes " + "or with scripting off in your interpreter.\n\nAutomapping halted.", "Access Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Trace("Automap: Gentle thread exit."); Status = "Automapping has completed."; }