internal static Blorb ReadBlorbFile(byte[] StoryData) { _blorb = new Blorb(); _chunks = new Dictionary <int, Chunk>(); _resources = new Dictionary <int, Resource>(); // _stream = new FileStream(FileName, FileMode.Open); _stream = new MemoryStream(StoryData); String id = ReadString(); if (id == "FORM") { } else { throw new Exception("Not a FORM"); } int len = ReadInt(); String type = ReadString(); if (type != "IFRS") { throw new Exception("Not an IFRS FORM"); } handleForm((int)_stream.Position - 4, len); // Backup over the Form ID so that handle form can read it if (_blorb.MetaData != null) { try { //XDocument doc = XDocument.Parse(_blorb.MetaData); //var r = doc.Root; //XName n = XName.Get("title", r.Name.NamespaceName); //var desc = doc.Descendants(n); //foreach (var e in desc) //{ // _blorb.StoryName = e.Value; //} throw new Exception("Parsing blorb metadata not yet working"); } catch (Exception ex) { #if !SILVERLIGHT //System.Windows.Forms.MessageBox.Show("Exception reading metadata:" + ex); #endif _blorb.MetaData = null; } } _stream.Close(); return(_blorb); }
/* * os_path_open * * Open a file in the current directory. * -- Szurgot: Changed this to return a Memory stream, and also has Blorb Logic.. May need to refine * -- Changed this again to take a byte[] to allow the data to be loaded further up the chain */ public static MemoryStream path_open(byte[] story_data) { // System.IO.FileInfo fi = new System.IO.FileInfo(FileName); if (story_data.Length < 4) { throw new ArgumentException("story_data isn't long enough"); } else { if (story_data[0] == (char)'F' && story_data[1] == (byte)'O' && story_data[2] == (byte)'R' && story_data[3] == (byte)'M') { _blorbFile = Blorb.BlorbReader.ReadBlorbFile(story_data); return(new System.IO.MemoryStream(_blorbFile.ZCode)); } else { //FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); //byte[] buffer = new byte[fs.Length]; //fs.Read(buffer, 0, buffer.Length); //fs.Close(); #if !SILVERLIGHT String temp = Path.ChangeExtension(main.story_name, "blb"); _blorbFile = null; if (File.Exists(temp)) { var s = File.OpenRead(temp); byte[] buffer = new zbyte[s.Length]; s.Read(buffer, 0, buffer.Length); s.Close(); var tempB = Blorb.BlorbReader.ReadBlorbFile(buffer); _blorbFile = tempB; } #endif return(new MemoryStream(story_data)); } } }
public void StoryStarted(string StoryName, Blorb BlorbFile) { Console.WriteLine("Starting " + StoryName); }
public void StoryStarted(string StoryFileName, Blorb BlorbFile) { invoke(() => { if (os_._blorbFile != null) { _parent.Title = String.Format("FrotzNET - {0}", os_._blorbFile.StoryName); } else { _parent.Title = String.Format("FrotzNET - {0}", StoryFileName); } OnStoryStarted(new GameSelectedEventArgs(StoryFileName, BlorbFile)); _scrollback.Reset(); }); }
public void StoryStarted(string StoryName, Blorb BlorbFile) { throw new NotImplementedException(); }
internal static Blorb ReadBlorbFile(byte[] StoryData) { _blorb = new Blorb(); _chunks = new Dictionary<int, Chunk>(); _resources = new Dictionary<int, Resource>(); // _stream = new FileStream(FileName, FileMode.Open); _stream = new MemoryStream(StoryData); String id = ReadString(); if (id == "FORM") { } else { throw new Exception("Not a FORM"); } int len = ReadInt(); String type = ReadString(); if (type != "IFRS") { throw new Exception("Not an IFRS FORM"); } handleForm((int)_stream.Position - 4, len); // Backup over the Form ID so that handle form can read it if (_blorb.MetaData != null) { try { XDocument doc = XDocument.Parse(_blorb.MetaData); var r = doc.Root; XName n = XName.Get("title", r.Name.NamespaceName); var desc = doc.Descendants(n); foreach (var e in desc) { _blorb.StoryName = e.Value; } } catch (Exception ex) { #if !SILVERLIGHT System.Windows.Forms.MessageBox.Show("Exception reading metadata:" + ex); #endif _blorb.MetaData = null; } } _stream.Close(); return _blorb; }
/* * os_path_open * * Open a file in the current directory. * -- Szurgot: Changed this to return a Memory stream, and also has Blorb Logic.. May need to refine * -- Changed this again to take a byte[] to allow the data to be loaded further up the chain */ public static MemoryStream path_open(byte[] story_data) { // System.IO.FileInfo fi = new System.IO.FileInfo(FileName); if (story_data.Length < 4) { throw new ArgumentException("story_data isn't long enough"); } else { if (story_data[0] == (char)'F' && story_data[1] == (byte)'O' && story_data[2] == (byte)'R' && story_data[3] == (byte)'M') { _blorbFile = Blorb.BlorbReader.ReadBlorbFile(story_data); return new System.IO.MemoryStream(_blorbFile.ZCode); } else { //FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); //byte[] buffer = new byte[fs.Length]; //fs.Read(buffer, 0, buffer.Length); //fs.Close(); #if !SILVERLIGHT String temp = Path.ChangeExtension(main.story_name, "blb"); _blorbFile = null; if (File.Exists(temp)) { var s = File.OpenRead(temp); byte[] buffer = new zbyte[s.Length]; s.Read(buffer, 0, buffer.Length); s.Close(); var tempB = Blorb.BlorbReader.ReadBlorbFile(buffer); _blorbFile = tempB; } #endif return new MemoryStream(story_data); } } }
public void StoryStarted(string StoryName, Blorb BlorbFile) { Log.DebugFormat("StoryStarted: [{0},{1}]", StoryName, BlorbFile); }
public void StoryStarted(string StoryFileName, Blorb BlorbFile) { Dispatcher.Invoke(new Action(delegate { if (os_._blorbFile != null) { _parent.Title = String.Format("FrotzNET - {0}", os_._blorbFile.StoryName); } else { _parent.Title = String.Format("FrotzNET - {0}", StoryFileName); } if (GameSelected != null) GameSelected(this, new GameSelectedEventArgs(StoryFileName, BlorbFile)); })); }