public bool ReadFromBuffer(GR.Memory.ByteBuffer DataIn) { if (DataIn == null) { return(false); } GR.IO.MemoryReader memIn = DataIn.MemoryReader(); uint version = memIn.ReadUInt32(); if (version == 1) { TotalNumberOfCharacters = 256; string name = memIn.ReadString(); string charsetFilename = memIn.ReadString(); for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Tile.CustomColor = memIn.ReadInt32(); } bool hasAnyMC = false; for (int i = 0; i < TotalNumberOfCharacters; ++i) { var mode = (TextCharMode)memIn.ReadUInt8(); if ((mode == TextCharMode.COMMODORE_MULTICOLOR) && (Characters[i].Tile.CustomColor < 8)) { mode = TextCharMode.COMMODORE_HIRES; } if (mode == TextCharMode.COMMODORE_MULTICOLOR) { hasAnyMC = true; } } Colors.BackgroundColor = memIn.ReadInt32(); Colors.MultiColor1 = memIn.ReadInt32(); Colors.MultiColor2 = memIn.ReadInt32(); for (int i = 0; i < TotalNumberOfCharacters; ++i) { int tileColor1 = memIn.ReadInt32(); int tileColor2 = memIn.ReadInt32(); int tileColor3 = memIn.ReadInt32(); int tileColor4 = memIn.ReadInt32(); int tileChar1 = memIn.ReadInt32(); int tileChar2 = memIn.ReadInt32(); int tileChar3 = memIn.ReadInt32(); int tileChar4 = memIn.ReadInt32(); } bool genericMulticolor = (memIn.ReadInt32() != 0); GR.Memory.ByteBuffer testbed = new GR.Memory.ByteBuffer(); memIn.ReadBlock(testbed, 64); GR.Memory.ByteBuffer charsetData = new GR.Memory.ByteBuffer(); memIn.ReadBlock(charsetData, (uint)(TotalNumberOfCharacters * 8)); for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Tile.Data = charsetData.SubBuffer(i * 8, 8); } UsedTiles = memIn.ReadUInt32(); ExportFilename = memIn.ReadString(); string exportPathBlockTable = memIn.ReadString(); string exportPathCharset = memIn.ReadString(); string exportPathEditorTiles = memIn.ReadString(); // categories Categories.Clear(); int categoryCount = memIn.ReadInt32(); for (int i = 0; i < categoryCount; ++i) { int catKey = memIn.ReadInt32(); string catName = memIn.ReadString(); Categories.Add(catName); } if (Categories.Count == 0) { // add default category Categories.Add("Uncategorized"); } for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Category = memIn.ReadInt32(); if ((Characters[i].Category < 0) || (Characters[i].Category >= Categories.Count)) { Characters[i].Category = 0; } } ExportNumCharacters = memIn.ReadInt32(); if (ExportNumCharacters < TotalNumberOfCharacters) { ExportNumCharacters = TotalNumberOfCharacters; } ShowGrid = (memIn.ReadInt32() != 0); ExportStartCharacter = memIn.ReadInt32(); Colors.BGColor4 = memIn.ReadInt32(); // playground int w = memIn.ReadInt32(); int h = memIn.ReadInt32(); if (w * h < 256) { w = 16; h = 16; } PlaygroundChars = new List <uint>(w * h); for (int i = 0; i < w * h; ++i) { ushort charInfo = memIn.ReadUInt16(); PlaygroundChars.Add((uint)((charInfo & 0xff) | ((charInfo & 0xff00) << 8))); } Mode = (TextCharMode)memIn.ReadInt32(); if (hasAnyMC) { Mode = TextCharMode.COMMODORE_MULTICOLOR; } } else if (version == 2) { Characters.Clear(); Categories.Clear(); Colors.Palettes.Clear(); TotalNumberOfCharacters = 256; Mode = TextCharMode.COMMODORE_HIRES; var chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memIn)) { if (chunk.Type == FileChunkConstants.CHARSET_PROJECT) { var chunkIn = chunk.MemoryReader(); var subChunk = new GR.IO.FileChunk(); while (subChunk.ReadFromStream(chunkIn)) { var subMemIn = subChunk.MemoryReader(); switch (subChunk.Type) { case FileChunkConstants.CHARSET_INFO: Mode = (TextCharMode)subMemIn.ReadInt32(); TotalNumberOfCharacters = subMemIn.ReadInt32(); ShowGrid = ((subMemIn.ReadInt32() & 1) == 1); break; case FileChunkConstants.CHARSET_COLOR_SETTINGS: Colors.BackgroundColor = subMemIn.ReadInt32(); Colors.MultiColor1 = subMemIn.ReadInt32(); Colors.MultiColor2 = subMemIn.ReadInt32(); Colors.BGColor4 = subMemIn.ReadInt32(); Colors.ActivePalette = subMemIn.ReadInt32(); break; case FileChunkConstants.PALETTE: Colors.Palettes.Add(Palette.Read(subMemIn)); break; case FileChunkConstants.CHARSET_EXPORT: ExportStartCharacter = subMemIn.ReadInt32(); ExportNumCharacters = subMemIn.ReadInt32(); ExportFilename = subMemIn.ReadString(); break; case FileChunkConstants.CHARSET_CHAR: { var charData = new CharData(); subMemIn.ReadInt32(); // was TextCharMode charData.Tile.CustomColor = subMemIn.ReadInt32(); charData.Tile.Mode = Lookup.GraphicTileModeFromTextCharMode(Mode, charData.Tile.CustomColor); charData.Category = subMemIn.ReadInt32(); int dataLength = subMemIn.ReadInt32(); charData.Tile.Data = new GR.Memory.ByteBuffer(); subMemIn.ReadBlock(charData.Tile.Data, (uint)dataLength); Characters.Add(charData); } break; case FileChunkConstants.CHARSET_CATEGORY: Categories.Add(subMemIn.ReadString()); break; case FileChunkConstants.CHARSET_PLAYGROUND: PlaygroundWidth = subMemIn.ReadInt32(); PlaygroundHeight = subMemIn.ReadInt32(); PlaygroundChars = new List <uint>(PlaygroundWidth * PlaygroundHeight); for (int i = 0; i < PlaygroundWidth * PlaygroundHeight; ++i) { // 16 bit index, 16 bit color PlaygroundChars.Add(subMemIn.ReadUInt32()); } break; } } } } if (Colors.Palettes.Count == 0) { Colors.Palettes.Add(PaletteManager.PaletteFromNumColors(Lookup.NumberOfColorsInCharacter(Mode))); } } else { return(false); } return(true); }
public bool Load(byte[] ProjectData) { string currentConfig = "Default"; string activeElement = ""; Node = new System.Windows.Forms.TreeNode(); Node.Tag = this; GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(ProjectData); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); ushort origDebugStartAddress = 2049; while (chunk.ReadFromStream(memIn)) { GR.IO.MemoryReader memChunk = chunk.MemoryReader(); switch (chunk.Type) { case Types.FileChunk.PROJECT: // Project Info // Version memChunk.ReadUInt32(); Settings.Name = memChunk.ReadString(); Settings.Filename = memChunk.ReadString(); Settings.DebugPort = memChunk.ReadUInt16(); origDebugStartAddress = memChunk.ReadUInt16(); Settings.BuildTool = memChunk.ReadString(); Settings.RunTool = memChunk.ReadString(); Settings.MainDocument = memChunk.ReadString(); currentConfig = memChunk.ReadString(); activeElement = memChunk.ReadString(); Node.Text = Settings.Name; break; case Types.FileChunk.PROJECT_ELEMENT: // Element Info { // Version int version = (int)memChunk.ReadUInt32(); ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32(); //System.Windows.Forms.TreeNode nodeParent = NodeFromHierarchy( ProjectElement element = CreateElement(type, Node); element.Name = memChunk.ReadString(); //element.Filename = System.IO.Path.GetFileName( memChunk.ReadString() ); element.Filename = memChunk.ReadString(); if (element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER) { element.Node.Text = element.Name; } else { element.Node.Text = System.IO.Path.GetFileName(element.Filename); } GR.IO.FileChunk subChunk = new GR.IO.FileChunk(); if (!subChunk.ReadFromStream(memChunk)) { return(false); } if (subChunk.Type != Types.FileChunk.PROJECT_ELEMENT_DATA) { return(false); } // Element Data element.DocumentInfo.DocumentFilename = element.Filename; if (element.Document != null) { if (!element.Document.ReadFromReader(subChunk.MemoryReader())) { Elements.Remove(element); element.Document.Dispose(); element = null; } else { element.Document.SetDocumentFilename(element.Filename); } } element.TargetFilename = memChunk.ReadString(); element.TargetType = (Types.CompileTargetType)memChunk.ReadUInt32(); int dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { string dependency = memChunk.ReadString(); element.ForcedDependency.DependentOnFile.Add(new FileDependency.DependencyInfo(dependency, true, false)); } // 3 free strings memChunk.ReadString(); memChunk.ReadString(); memChunk.ReadString(); int perConfigSettingCount = memChunk.ReadInt32(); for (int i = 0; i < perConfigSettingCount; ++i) { GR.IO.FileChunk chunkElementPerConfigSetting = new GR.IO.FileChunk(); chunkElementPerConfigSetting.ReadFromStream(memChunk); if (chunkElementPerConfigSetting.Type == Types.FileChunk.PROJECT_ELEMENT_PER_CONFIG_SETTING) { ProjectElement.PerConfigSettings perConfigSetting = new ProjectElement.PerConfigSettings(); GR.IO.MemoryReader memSubChunk = chunkElementPerConfigSetting.MemoryReader(); string config = memSubChunk.ReadString(); perConfigSetting.PreBuild = memSubChunk.ReadString(); perConfigSetting.CustomBuild = memSubChunk.ReadString(); perConfigSetting.PostBuild = memSubChunk.ReadString(); perConfigSetting.DebugFile = memSubChunk.ReadString(); perConfigSetting.DebugFileType = (C64Studio.Types.CompileTargetType)memSubChunk.ReadInt32(); perConfigSetting.PreBuildChain.Active = (memSubChunk.ReadInt32() == 1); int numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PreBuildChain.Entries.Add(entry); } perConfigSetting.PostBuildChain.Active = (memSubChunk.ReadInt32() == 1); numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PostBuildChain.Entries.Add(entry); } element.Settings[config] = perConfigSetting; } } element.IsShown = (memChunk.ReadInt32() != 0); element.AssemblerType = (C64Studio.Types.AssemblerType)memChunk.ReadUInt32(); int hierarchyPartCount = memChunk.ReadInt32(); for (int i = 0; i < hierarchyPartCount; ++i) { string part = memChunk.ReadString(); element.ProjectHierarchy.Add(part); } if (element.ProjectHierarchy.Count > 0) { // node is sub-node, move accordingly System.Windows.Forms.TreeNode parentNode = NodeFromHierarchy(element.ProjectHierarchy); if ((parentNode != null) && (parentNode != element.Node.Parent)) { element.Node.Remove(); parentNode.Nodes.Add(element.Node); } } // dependency - include symbols dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { element.ForcedDependency.DependentOnFile[i].IncludeSymbols = (memChunk.ReadInt32() != 0); } // code folding entries int numFoldingEntries = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks = new GR.Collections.Set <int>(); for (int i = 0; i < numFoldingEntries; ++i) { int collapsedBlockLine = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks.Add(collapsedBlockLine); //Debug.Log( "Get collapsed blocked for " + element.DocumentInfo.FullPath + ", line " + collapsedBlockLine ); } // TODO - load other stuff if ((element != null) && (element.IsShown)) { ShowDocument(element); if (element.Document != null) { element.Document.ShowHint = DockState.Document; //element.Document.Show( MainForm.panelMain ); } } } break; case Types.FileChunk.PROJECT_ELEMENT_DISPLAY_DATA: { string elementFilename = memChunk.ReadString(); ProjectElement element = GetElementByFilename(elementFilename); if (element != null) { UInt32 numBytes = memChunk.ReadUInt32(); GR.Memory.ByteBuffer displayData = new GR.Memory.ByteBuffer(); memChunk.ReadBlock(displayData, numBytes); if (element.Document != null) { element.Document.ApplyDisplayDetails(displayData); } } } break; case Types.FileChunk.PROJECT_CONFIG: { ProjectConfig config = new ProjectConfig(); config.Load(memChunk); if (string.IsNullOrEmpty(config.DebugStartAddressLabel)) { config.DebugStartAddressLabel = origDebugStartAddress.ToString(); } Settings.Configs.Add(config.Name, config); } break; case Types.FileChunk.PROJECT_WATCH_ENTRY: { WatchEntry watch = new WatchEntry(); watch.Load(memChunk); Core.MainForm.AddWatchEntry(watch); //Debug.Log( "loaded watch entry for " + watch.Name ); } break; } } if (Settings.Configs.Count == 0) { // there must be one config ProjectConfig config = new ProjectConfig(); config.Name = "Default"; Settings.Configs.Add(config.Name, config); Settings.CurrentConfig = config; } else { if (Settings.Configs.ContainsKey(currentConfig)) { Settings.CurrentConfig = Settings.Configs[currentConfig]; } else { foreach (ProjectConfig config in Settings.Configs.Values) { Settings.CurrentConfig = config; break; } } } foreach (ProjectElement element in Elements) { if (element.Settings.Count == 0) { foreach (ProjectConfig config in Settings.Configs.Values) { // needs a default setting! element.Settings[config.Name] = new ProjectElement.PerConfigSettings(); } } if ((!string.IsNullOrEmpty(element.Filename)) && (GR.Path.IsPathEqual(element.Filename, Settings.MainDocument))) { Core.MainForm.m_SolutionExplorer.HighlightNode(element.Node); } Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.DOCUMENT_INFO_CREATED, element.DocumentInfo)); Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.ELEMENT_CREATED, element)); } if (!String.IsNullOrEmpty(activeElement)) { ProjectElement element = GetElementByFilename(activeElement); if ((element != null) && (element.Document != null)) { element.Document.Show(); } } m_Modified = false; return(true); }
public bool ReadFromBuffer(GR.Memory.ByteBuffer ProjectFile) { GR.IO.MemoryReader memReader = new GR.IO.MemoryReader(ProjectFile); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memReader)) { GR.IO.MemoryReader chunkReader = chunk.MemoryReader(); switch (chunk.Type) { case FileChunkConstants.CHARSET_SCREEN_INFO: { int version = chunkReader.ReadInt32(); ScreenWidth = chunkReader.ReadInt32(); ScreenHeight = chunkReader.ReadInt32(); ExternalCharset = chunkReader.ReadString(); _Mode = (TextMode)chunkReader.ReadInt32(); ScreenOffsetX = chunkReader.ReadInt32(); ScreenOffsetY = chunkReader.ReadInt32(); CharOffset = chunkReader.ReadInt32(); Chars = new List <uint>(); for (int i = 0; i < ScreenWidth * ScreenHeight; ++i) { Chars.Add((uint)0x010020); } } break; case FileChunkConstants.MULTICOLOR_DATA: _Mode = (TextMode)chunkReader.ReadUInt8(); CharSet.Colors.BackgroundColor = chunkReader.ReadUInt8(); CharSet.Colors.MultiColor1 = chunkReader.ReadUInt8(); CharSet.Colors.MultiColor2 = chunkReader.ReadUInt8(); break; case FileChunkConstants.SCREEN_CHAR_DATA: for (int i = 0; i < Chars.Count; ++i) { if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 1) { Chars[i] = (uint)((Chars[i] & 0xffff0000) | chunkReader.ReadUInt8()); } else { Chars[i] = (uint)((Chars[i] & 0xffff0000) | chunkReader.ReadUInt16()); } } break; case FileChunkConstants.SCREEN_COLOR_DATA: for (int i = 0; i < Chars.Count; ++i) { if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 1) { Chars[i] = (uint)((Chars[i] & 0xffff) | ((uint)chunkReader.ReadUInt8() << 16)); } else { Chars[i] = (uint)((Chars[i] & 0xffff) | ((uint)chunkReader.ReadUInt16() << 16)); } } break; case FileChunkConstants.CHARSET_DATA: { if (!CharSet.ReadFromBuffer(chunk)) { return(false); } } break; } } memReader.Close(); return(true); }
public bool ReadFromBuffer(GR.Memory.ByteBuffer DataIn) { if (DataIn == null) { return(false); } GR.IO.MemoryReader memIn = DataIn.MemoryReader(); uint version = memIn.ReadUInt32(); string name = memIn.ReadString(); string charsetFilename = memIn.ReadString(); for (int i = 0; i < 256; ++i) { Characters[i].Color = memIn.ReadInt32(); } for (int i = 0; i < 256; ++i) { Characters[i].Mode = (Types.CharsetMode)memIn.ReadUInt8(); } BackgroundColor = memIn.ReadInt32(); MultiColor1 = memIn.ReadInt32(); MultiColor2 = memIn.ReadInt32(); for (int i = 0; i < 256; ++i) { int tileColor1 = memIn.ReadInt32(); int tileColor2 = memIn.ReadInt32(); int tileColor3 = memIn.ReadInt32(); int tileColor4 = memIn.ReadInt32(); int tileChar1 = memIn.ReadInt32(); int tileChar2 = memIn.ReadInt32(); int tileChar3 = memIn.ReadInt32(); int tileChar4 = memIn.ReadInt32(); } bool genericMulticolor = (memIn.ReadInt32() != 0); GR.Memory.ByteBuffer testbed = new GR.Memory.ByteBuffer(); memIn.ReadBlock(testbed, 64); GR.Memory.ByteBuffer charsetData = new GR.Memory.ByteBuffer(); memIn.ReadBlock(charsetData, 2048); for (int i = 0; i < 256; ++i) { Characters[i].Data = charsetData.SubBuffer(i * 8, 8); } UsedTiles = memIn.ReadUInt32(); ExportFilename = memIn.ReadString(); string exportPathBlockTable = memIn.ReadString(); string exportPathCharset = memIn.ReadString(); string exportPathEditorTiles = memIn.ReadString(); // categories Categories.Clear(); int categoryCount = memIn.ReadInt32(); for (int i = 0; i < categoryCount; ++i) { int catKey = memIn.ReadInt32(); string catName = memIn.ReadString(); Categories.Add(catName); } if (Categories.Count == 0) { // add default category Categories.Add("Uncategorized"); } for (int i = 0; i < 256; ++i) { Characters[i].Category = memIn.ReadInt32(); if ((Characters[i].Category < 0) || (Characters[i].Category >= Categories.Count)) { Characters[i].Category = 0; } } NumCharacters = memIn.ReadInt32(); if (NumCharacters == 0) { NumCharacters = 256; } ShowGrid = (memIn.ReadInt32() != 0); StartCharacter = memIn.ReadInt32(); BGColor4 = memIn.ReadInt32(); // playground int w = memIn.ReadInt32(); int h = memIn.ReadInt32(); if (w * h < 256) { w = 16; h = 16; } PlaygroundChars = new List <ushort>(w * h); for (int i = 0; i < w * h; ++i) { PlaygroundChars.Add(memIn.ReadUInt16()); } return(true); }
public bool Load(string Filename) { byte[] projectData = null; try { projectData = System.IO.File.ReadAllBytes(Filename); } catch (System.IO.IOException) { return(false); } Settings.Filename = Filename; Settings.BasePath = System.IO.Path.GetDirectoryName(Settings.Filename); GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(projectData); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memIn)) { GR.IO.MemoryReader memChunk = chunk.MemoryReader(); switch (chunk.Type) { case Types.FileChunk.PROJECT: // Project Info // Version memChunk.ReadUInt32(); Settings.Name = memChunk.ReadString(); Settings.Filename = memChunk.ReadString(); Settings.DebugPort = memChunk.ReadUInt16(); Settings.DebugStartAddress = memChunk.ReadUInt16(); Settings.BuildTool = memChunk.ReadString(); Settings.RunTool = memChunk.ReadString(); Settings.MainDocument = memChunk.ReadString(); break; case Types.FileChunk.PROJECT_ELEMENT: // Element Info { // Version int version = (int)memChunk.ReadUInt32(); ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32(); ProjectElement element = CreateElement(type); element.Name = memChunk.ReadString(); element.Filename = memChunk.ReadString(); ShowDocument(element); GR.IO.FileChunk subChunk = new GR.IO.FileChunk(); if (!subChunk.ReadFromStream(memChunk)) { return(false); } if (subChunk.Type != Types.FileChunk.PROJECT_ELEMENT_DATA) { return(false); } // Element Data if (element.Document != null) { if (!element.Document.ReadFromReader(subChunk.MemoryReader())) { Elements.Remove(element); element.Document.Dispose(); element = null; } } element.TargetFilename = memChunk.ReadString(); element.TargetType = (FileParser.CompileTargetType)memChunk.ReadUInt32(); if ((element != null) && (element.Document != null)) { element.Document.ShowHint = DockState.Document; element.Document.Show(MainForm.panelMain); } } break; } } Settings.Filename = Filename; m_Modified = false; return(true); }
public bool Load(byte[] ProjectData, bool AutoCreateGUIItems) { string currentConfig = "Default"; string activeElement = ""; Node = new System.Windows.Forms.TreeNode(); Node.Tag = this; Node.Collapse(); GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(ProjectData); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); ushort origDebugStartAddress = 0; while (chunk.ReadFromStream(memIn)) { GR.IO.MemoryReader memChunk = chunk.MemoryReader(); switch (chunk.Type) { case FileChunkConstants.PROJECT: // Project Info // Version uint projectVersion = memChunk.ReadUInt32(); Settings.Name = memChunk.ReadString(); Settings.Filename = memChunk.ReadString(); Settings.DebugPort = memChunk.ReadUInt16(); origDebugStartAddress = memChunk.ReadUInt16(); Settings.BuildTool = memChunk.ReadString(); Settings.RunTool = memChunk.ReadString(); Settings.MainDocument = memChunk.ReadString(); currentConfig = memChunk.ReadString(); activeElement = memChunk.ReadString(); memChunk.ReadUInt32(); // flags (all free) if (projectVersion == 1) { if (origDebugStartAddress == 2049) { origDebugStartAddress = 0; } } Node.Text = Settings.Name; break; case FileChunkConstants.PROJECT_ELEMENT: // Element Info { // Version int elementVersion = (int)memChunk.ReadUInt32(); ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32(); ProjectElement element = CreateElement(type, Node); element.Name = memChunk.ReadString(); element.Filename = memChunk.ReadString(); if (element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER) { element.Node.Text = element.Name; } else { element.Node.Text = System.IO.Path.GetFileName(element.Filename); } if (Core.Navigating.Solution.IsNodeExpanded(element)) { element.Node.Expand(); } else { element.Node.Collapse(); } GR.IO.FileChunk subChunk = new GR.IO.FileChunk(); if (!subChunk.ReadFromStream(memChunk)) { return(false); } if (subChunk.Type != FileChunkConstants.PROJECT_ELEMENT_DATA) { return(false); } // Element Data element.DocumentInfo.DocumentFilename = element.Filename; if (element.Document != null) { if (!element.Document.ReadFromReader(subChunk.MemoryReader())) { Elements.Remove(element); element.Document.Dispose(); element = null; } else { element.Document.SetDocumentFilename(element.Filename); } } element.TargetFilename = memChunk.ReadString(); element.TargetType = (Types.CompileTargetType)memChunk.ReadUInt32(); int dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { string dependency = memChunk.ReadString(); element.ForcedDependency.DependentOnFile.Add(new FileDependency.DependencyInfo(Settings.Name, dependency, true, false)); } element.StartAddress = memChunk.ReadString(); // 2 free strings memChunk.ReadString(); memChunk.ReadString(); int perConfigSettingCount = memChunk.ReadInt32(); for (int i = 0; i < perConfigSettingCount; ++i) { GR.IO.FileChunk chunkElementPerConfigSetting = new GR.IO.FileChunk(); chunkElementPerConfigSetting.ReadFromStream(memChunk); if (chunkElementPerConfigSetting.Type == FileChunkConstants.PROJECT_ELEMENT_PER_CONFIG_SETTING) { ProjectElement.PerConfigSettings perConfigSetting = new ProjectElement.PerConfigSettings(); GR.IO.MemoryReader memSubChunk = chunkElementPerConfigSetting.MemoryReader(); string config = memSubChunk.ReadString(); perConfigSetting.PreBuild = memSubChunk.ReadString(); perConfigSetting.CustomBuild = memSubChunk.ReadString(); perConfigSetting.PostBuild = memSubChunk.ReadString(); perConfigSetting.DebugFile = memSubChunk.ReadString(); perConfigSetting.DebugFileType = (RetroDevStudio.Types.CompileTargetType)memSubChunk.ReadInt32(); perConfigSetting.PreBuildChain.Active = (memSubChunk.ReadInt32() == 1); int numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PreBuildChain.Entries.Add(entry); } perConfigSetting.PostBuildChain.Active = (memSubChunk.ReadInt32() == 1); numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PostBuildChain.Entries.Add(entry); } element.Settings[config] = perConfigSetting; } } uint flags = memChunk.ReadUInt32(); element.IsShown = ((flags & 1) != 0); element.AssemblerType = (RetroDevStudio.Types.AssemblerType)memChunk.ReadUInt32(); int hierarchyPartCount = memChunk.ReadInt32(); for (int i = 0; i < hierarchyPartCount; ++i) { string part = memChunk.ReadString(); element.ProjectHierarchy.Add(part); } if (element.ProjectHierarchy.Count > 0) { // node is sub-node, move accordingly System.Windows.Forms.TreeNode parentNode = NodeFromHierarchy(element.ProjectHierarchy); if ((parentNode != null) && (parentNode != element.Node.Parent)) { element.Node.Remove(); parentNode.Nodes.Add(element.Node); } } // dependency - include symbols dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { element.ForcedDependency.DependentOnFile[i].IncludeSymbols = (memChunk.ReadInt32() != 0); } // code folding entries int numFoldingEntries = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks = new GR.Collections.Set <int>(); for (int i = 0; i < numFoldingEntries; ++i) { int collapsedBlockLine = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks.Add(collapsedBlockLine); } // external dependencies int externalDependencyCount = memChunk.ReadInt32(); for (int i = 0; i < externalDependencyCount; ++i) { string dependency = memChunk.ReadString(); element.ExternalDependencies.DependentOnFile.Add(new FileDependency.DependencyInfo("", dependency, true, false)); } var obsoleteBasicVersion = (BasicVersion)memChunk.ReadUInt32(); // dependency - project dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { element.ForcedDependency.DependentOnFile[i].Project = memChunk.ReadString(); } element.BASICDialect = memChunk.ReadString(); if (string.IsNullOrEmpty(element.BASICDialect)) { // old version, find dialect from obsoleteBasicVersion string dialectKey = "BASIC V2"; switch (obsoleteBasicVersion) { case BasicVersion.C64_BASIC_V2: break; case BasicVersion.BASIC_LIGHTNING: dialectKey = "BASIC Lightning"; break; case BasicVersion.LASER_BASIC: dialectKey = "Laser BASIC"; break; case BasicVersion.SIMONS_BASIC: dialectKey = "Simon's BASIC"; break; case BasicVersion.V3_5: dialectKey = "BASIC V3.5"; break; case BasicVersion.V7_0: dialectKey = "BASIC V7.0"; break; } if (Core.Compiling.BASICDialects.ContainsKey(dialectKey)) { element.BASICDialect = dialectKey; } } // TODO - load other stuff if ((element != null) && (element.IsShown) && (AutoCreateGUIItems)) { ShowDocument(element); if (element.Document != null) { element.Document.ShowHint = DockState.Document; } } if (element.Document != null) { element.Document.RefreshDisplayOptions(); } } break; case FileChunkConstants.PROJECT_ELEMENT_DISPLAY_DATA: { string elementFilename = memChunk.ReadString(); ProjectElement element = GetElementByFilename(elementFilename); if (element != null) { UInt32 numBytes = memChunk.ReadUInt32(); GR.Memory.ByteBuffer displayData = new GR.Memory.ByteBuffer(); memChunk.ReadBlock(displayData, numBytes); if (element.Document != null) { element.Document.ApplyDisplayDetails(displayData); } } } break; case FileChunkConstants.PROJECT_CONFIG: { ProjectConfig config = new ProjectConfig(); config.Load(memChunk); if (string.IsNullOrEmpty(config.DebugStartAddressLabel)) { config.DebugStartAddressLabel = origDebugStartAddress.ToString(); } Settings.Configuration(config.Name, config); } break; case FileChunkConstants.PROJECT_WATCH_ENTRY: { WatchEntry watch = new WatchEntry(); watch.Load(memChunk); Settings.WatchEntries.Add(watch); } break; } } if (Settings.GetConfigurationCount() == 0) { // there must be one config ProjectConfig config = new ProjectConfig(); config.Name = "Default"; Settings.Configuration(config.Name, config); Settings.CurrentConfig = config; } else { Settings.CurrentConfig = Settings.Configuration(currentConfig); if (Settings.CurrentConfig == null) { Settings.CurrentConfig = Settings.GetConfigurations().First(); } } foreach (ProjectElement element in Elements) { if (element.Settings.Count == 0) { foreach (var configName in Settings.GetConfigurationNames()) { // needs a default setting! element.Settings[configName] = new ProjectElement.PerConfigSettings(); } } if (AutoCreateGUIItems) { if ((!string.IsNullOrEmpty(element.Filename)) && (GR.Path.IsPathEqual(element.Filename, Settings.MainDocument))) { Core.MainForm.m_SolutionExplorer.HighlightNode(element.Node); } Core.MainForm.RaiseApplicationEvent(new RetroDevStudio.Types.ApplicationEvent(RetroDevStudio.Types.ApplicationEvent.Type.DOCUMENT_INFO_CREATED, element.DocumentInfo)); Core.MainForm.RaiseApplicationEvent(new RetroDevStudio.Types.ApplicationEvent(RetroDevStudio.Types.ApplicationEvent.Type.ELEMENT_CREATED, element)); } } if (!String.IsNullOrEmpty(activeElement)) { ProjectElement element = GetElementByFilename(activeElement); if ((element != null) && (element.Document != null)) { element.Document.Show(); } } m_Modified = false; return(true); }