public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(); data.Reserve(ScreenHeight * ScreenWidth * 8); GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_SCREEN_INFO); chunkScreenInfo.AppendU32((uint)SelectedCheckType); chunkScreenInfo.AppendI32(ScreenOffsetX); chunkScreenInfo.AppendI32(ScreenOffsetY); chunkScreenInfo.AppendI32(ScreenWidth); chunkScreenInfo.AppendI32(ScreenHeight); data.Append(chunkScreenInfo.ToBuffer()); GR.IO.FileChunk chunkGraphicData = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_DATA); chunkGraphicData.AppendI32(Image.Width); chunkGraphicData.AppendI32(Image.Height); chunkGraphicData.AppendI32((int)Image.PixelFormat); chunkGraphicData.AppendI32(Image.PaletteEntryCount); for (int i = 0; i < Image.PaletteEntryCount; ++i) { chunkGraphicData.AppendU8(Image.PaletteRed(i)); chunkGraphicData.AppendU8(Image.PaletteGreen(i)); chunkGraphicData.AppendU8(Image.PaletteBlue(i)); } GR.Memory.ByteBuffer imageData = Image.GetAsData(); chunkGraphicData.AppendU32(imageData.Length); chunkGraphicData.Append(imageData); data.Append(chunkGraphicData.ToBuffer()); GR.IO.FileChunk chunkScreenMultiColorData = new GR.IO.FileChunk(FileChunkConstants.MULTICOLOR_DATA); chunkScreenMultiColorData.AppendU8((byte)(MultiColor ? 1 : 0)); chunkScreenMultiColorData.AppendU8((byte)Colors.BackgroundColor); chunkScreenMultiColorData.AppendU8((byte)Colors.MultiColor1); chunkScreenMultiColorData.AppendU8((byte)Colors.MultiColor2); chunkScreenMultiColorData.AppendI32(Colors.ActivePalette); data.Append(chunkScreenMultiColorData.ToBuffer()); foreach (var pal in Colors.Palettes) { data.Append(pal.ToBuffer()); } GR.IO.FileChunk chunkColorMapping = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_COLOR_MAPPING); chunkColorMapping.AppendI32(ColorMapping.Count); for (int i = 0; i < ColorMapping.Count; ++i) { var mappings = ColorMapping[i]; chunkColorMapping.AppendI32(mappings.Count); for (int j = 0; j < mappings.Count; ++j) { chunkColorMapping.AppendU8((byte)mappings[j]); } } data.Append(chunkColorMapping.ToBuffer()); return(data); }
public GR.Memory.ByteBuffer Save() { GR.IO.FileChunk chunkWatch = new GR.IO.FileChunk(Types.FileChunk.PROJECT_WATCH_ENTRY); chunkWatch.AppendString(Name); chunkWatch.AppendI32(SizeInBytes); chunkWatch.AppendU32((uint)Type); chunkWatch.AppendU8((byte)(DisplayMemory ? 1 : 0)); chunkWatch.AppendU8((byte)(IndexedX ? 1 : 0)); chunkWatch.AppendU8((byte)(IndexedY ? 1 : 0)); chunkWatch.AppendU8((byte)(LiteralValue ? 1 : 0)); chunkWatch.AppendI32(Address); return(chunkWatch.ToBuffer()); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk(Types.FileChunk.CHARSET_SCREEN_INFO); // version chunkScreenInfo.AppendU32(0); // width chunkScreenInfo.AppendI32(ScreenWidth); // height chunkScreenInfo.AppendI32(ScreenHeight); chunkScreenInfo.AppendString(""); chunkScreenInfo.AppendI32((int)Mode); chunkScreenInfo.AppendI32(ScreenOffsetX); chunkScreenInfo.AppendI32(ScreenOffsetY); projectFile.Append(chunkScreenInfo.ToBuffer()); GR.IO.FileChunk chunkCharSet = new GR.IO.FileChunk(Types.FileChunk.CHARSET_DATA); chunkCharSet.Append(CharSet.SaveToBuffer()); projectFile.Append(chunkCharSet.ToBuffer()); GR.IO.FileChunk chunkScreenMultiColorData = new GR.IO.FileChunk(Types.FileChunk.MULTICOLOR_DATA); chunkScreenMultiColorData.AppendU8((byte)Mode); chunkScreenMultiColorData.AppendU8((byte)BackgroundColor); chunkScreenMultiColorData.AppendU8((byte)MultiColor1); chunkScreenMultiColorData.AppendU8((byte)MultiColor2); projectFile.Append(chunkScreenMultiColorData.ToBuffer()); GR.IO.FileChunk chunkScreenCharData = new GR.IO.FileChunk(Types.FileChunk.SCREEN_CHAR_DATA); for (int i = 0; i < Chars.Count; ++i) { chunkScreenCharData.AppendU8((byte)(Chars[i] & 0xff)); } projectFile.Append(chunkScreenCharData.ToBuffer()); GR.IO.FileChunk chunkScreenColorData = new GR.IO.FileChunk(Types.FileChunk.SCREEN_COLOR_DATA); for (int i = 0; i < Chars.Count; ++i) { chunkScreenColorData.AppendU8((byte)(Chars[i] >> 8)); } projectFile.Append(chunkScreenColorData.ToBuffer()); return(projectFile); }
public GR.IO.FileChunk ToChunk() { GR.IO.FileChunk chunk = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_TOOL); chunk.AppendU32((uint)Type); chunk.AppendString(Name); chunk.AppendString(Filename); chunk.AppendString(PRGArguments); chunk.AppendString(DebugArguments); chunk.AppendString(WorkPath); chunk.AppendString(CartArguments); chunk.AppendString(TrueDriveOnArguments); chunk.AppendString(TrueDriveOffArguments); chunk.AppendU8(PassLabelsToEmulator ? (byte)0 : (byte)1); return(chunk); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); GR.IO.FileChunk chunkProjectInfo = new GR.IO.FileChunk(Types.FileChunk.MAP_PROJECT_INFO); // version chunkProjectInfo.AppendU32(0); chunkProjectInfo.AppendString(ExternalCharset); chunkProjectInfo.AppendI32(ShowGrid ? 1 : 0); projectFile.Append(chunkProjectInfo.ToBuffer()); GR.IO.FileChunk chunkCharset = new GR.IO.FileChunk(Types.FileChunk.MAP_CHARSET); chunkCharset.Append(Charset.SaveToBuffer()); projectFile.Append(chunkCharset.ToBuffer()); GR.IO.FileChunk chunkProjectData = new GR.IO.FileChunk(Types.FileChunk.MAP_PROJECT_DATA); GR.IO.FileChunk chunkMCData = new GR.IO.FileChunk(Types.FileChunk.MULTICOLOR_DATA); chunkMCData.AppendU8((byte)Mode); chunkMCData.AppendU8((byte)BackgroundColor); chunkMCData.AppendU8((byte)MultiColor1); chunkMCData.AppendU8((byte)MultiColor2); chunkMCData.AppendU8((byte)BGColor4); chunkProjectData.Append(chunkMCData.ToBuffer()); foreach (Tile tile in Tiles) { GR.IO.FileChunk chunkTile = new GR.IO.FileChunk(Types.FileChunk.MAP_TILE); chunkTile.AppendString(tile.Name); chunkTile.AppendI32(tile.Chars.Width); chunkTile.AppendI32(tile.Chars.Height); for (int j = 0; j < tile.Chars.Height; ++j) { for (int i = 0; i < tile.Chars.Width; ++i) { TileChar tChar = tile.Chars[i, j]; chunkTile.AppendU8(tChar.Character); chunkTile.AppendU8(tChar.Color); } } chunkProjectData.Append(chunkTile.ToBuffer()); } foreach (Map map in Maps) { GR.IO.FileChunk chunkMap = new GR.IO.FileChunk(Types.FileChunk.MAP); GR.IO.FileChunk chunkMapInfo = new GR.IO.FileChunk(Types.FileChunk.MAP_INFO); chunkMapInfo.AppendString(map.Name); chunkMapInfo.AppendI32(map.TileSpacingX); chunkMapInfo.AppendI32(map.TileSpacingY); chunkMapInfo.AppendI32(map.AlternativeMultiColor1 + 1); chunkMapInfo.AppendI32(map.AlternativeMultiColor2 + 1); chunkMapInfo.AppendI32(map.AlternativeBackgroundColor + 1); chunkMapInfo.AppendI32(map.AlternativeBGColor4 + 1); chunkMapInfo.AppendI32((int)map.AlternativeMode + 1); chunkMap.Append(chunkMapInfo.ToBuffer()); GR.IO.FileChunk chunkMapData = new GR.IO.FileChunk(Types.FileChunk.MAP_DATA); chunkMapData.AppendI32(map.Tiles.Width); chunkMapData.AppendI32(map.Tiles.Height); for (int j = 0; j < map.Tiles.Height; ++j) { for (int i = 0; i < map.Tiles.Width; ++i) { chunkMapData.AppendI32(map.Tiles[i, j]); } } chunkMap.Append(chunkMapData.ToBuffer()); if (map.ExtraDataText.Length > 0) { GR.IO.FileChunk chunkMapExtraData = new GR.IO.FileChunk(Types.FileChunk.MAP_EXTRA_DATA_TEXT); chunkMapExtraData.AppendString(map.ExtraDataText); chunkMap.Append(chunkMapExtraData.ToBuffer()); } if (map.ExtraDataOld.Length > 0) { GR.IO.FileChunk chunkMapExtraData = new GR.IO.FileChunk(Types.FileChunk.MAP_EXTRA_DATA); chunkMapExtraData.AppendU32(map.ExtraDataOld.Length); chunkMapExtraData.Append(map.ExtraDataOld); chunkMap.Append(chunkMapExtraData.ToBuffer()); } chunkProjectData.Append(chunkMap.ToBuffer()); } projectFile.Append(chunkProjectData.ToBuffer()); return(projectFile); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); // version projectFile.AppendU32(1); projectFile.AppendI32(Sprites.Count); // Name projectFile.AppendString(Name); for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendI32(Sprites[i].Color); } for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendU8(Sprites[i].Multicolor ? (byte)1 : (byte)0); } projectFile.AppendI32(BackgroundColor); projectFile.AppendI32(MultiColor1); projectFile.AppendI32(MultiColor2); // generic MC projectFile.AppendU32(0); for (int i = 0; i < Sprites.Count; ++i) { projectFile.Append(Sprites[i].Data); projectFile.AppendU8((byte)Sprites[i].Color); } projectFile.AppendU32(UsedSprites); // export name projectFile.AppendString(ExportFilename); // exportpath projectFile.AppendString(""); // desc for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendString(""); } // testbed (not used anymore, write 0 as number of sprites) projectFile.AppendI32(0); foreach (var layer in SpriteLayers) { GR.IO.FileChunk chunkLayer = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER); GR.IO.FileChunk chunkLayerInfo = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_INFO); chunkLayerInfo.AppendString(layer.Name); chunkLayerInfo.AppendU8((byte)layer.BackgroundColor); chunkLayer.Append(chunkLayerInfo.ToBuffer()); foreach (var sprite in layer.Sprites) { GR.IO.FileChunk chunkLayerSprite = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_ENTRY); chunkLayerSprite.AppendI32(sprite.Index); chunkLayerSprite.AppendU8((byte)sprite.Color); chunkLayerSprite.AppendI32(sprite.X); chunkLayerSprite.AppendI32(sprite.Y); chunkLayerSprite.AppendU8((byte)(sprite.ExpandX ? 1 : 0)); chunkLayerSprite.AppendU8((byte)(sprite.ExpandY ? 1 : 0)); chunkLayer.Append(chunkLayerSprite.ToBuffer()); } projectFile.Append(chunkLayer.ToBuffer()); } /* * int spriteTestCount = memIn.ReadInt32(); * for ( int i = 0; i < spriteTestCount; ++i ) * { * int spriteIndex = memIn.ReadInt32(); * byte spriteColor = memIn.ReadUInt8(); * bool spriteMultiColor = ( memIn.ReadUInt8() != 0 ); * int spriteX = memIn.ReadInt32(); * int spriteY = memIn.ReadInt32(); * }*/ return(projectFile); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk(FileChunkConstants.CHARSET_SCREEN_INFO); // version chunkScreenInfo.AppendI32(0); // width chunkScreenInfo.AppendI32(ScreenWidth); // height chunkScreenInfo.AppendI32(ScreenHeight); chunkScreenInfo.AppendString(""); chunkScreenInfo.AppendI32((int)Mode); chunkScreenInfo.AppendI32(ScreenOffsetX); chunkScreenInfo.AppendI32(ScreenOffsetY); chunkScreenInfo.AppendI32(CharOffset); projectFile.Append(chunkScreenInfo.ToBuffer()); GR.IO.FileChunk chunkCharSet = new GR.IO.FileChunk(FileChunkConstants.CHARSET_DATA); chunkCharSet.Append(CharSet.SaveToBuffer()); projectFile.Append(chunkCharSet.ToBuffer()); GR.IO.FileChunk chunkScreenMultiColorData = new GR.IO.FileChunk(FileChunkConstants.MULTICOLOR_DATA); chunkScreenMultiColorData.AppendU8((byte)Mode); chunkScreenMultiColorData.AppendU8((byte)CharSet.Colors.BackgroundColor); chunkScreenMultiColorData.AppendU8((byte)CharSet.Colors.MultiColor1); chunkScreenMultiColorData.AppendU8((byte)CharSet.Colors.MultiColor2); projectFile.Append(chunkScreenMultiColorData.ToBuffer()); GR.IO.FileChunk chunkScreenCharData = new GR.IO.FileChunk(FileChunkConstants.SCREEN_CHAR_DATA); if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 2) { for (int i = 0; i < Chars.Count; ++i) { chunkScreenCharData.AppendU16((ushort)(Chars[i] & 0xffff)); } } else { for (int i = 0; i < Chars.Count; ++i) { chunkScreenCharData.AppendU8((byte)(Chars[i] & 0xffff)); } } projectFile.Append(chunkScreenCharData.ToBuffer()); GR.IO.FileChunk chunkScreenColorData = new GR.IO.FileChunk(FileChunkConstants.SCREEN_COLOR_DATA); if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 2) { for (int i = 0; i < Chars.Count; ++i) { chunkScreenColorData.AppendU16((ushort)(Chars[i] >> 16)); } } else { for (int i = 0; i < Chars.Count; ++i) { chunkScreenColorData.AppendU8((byte)(Chars[i] >> 16)); } } projectFile.Append(chunkScreenColorData.ToBuffer()); return(projectFile); }
public GR.Memory.ByteBuffer ToBuffer() { GR.Memory.ByteBuffer SettingsData = new GR.Memory.ByteBuffer(); foreach (ToolInfo tool in ToolInfos) { GR.IO.FileChunk chunkTool = tool.ToChunk(); SettingsData.Append(chunkTool.ToBuffer()); } /* * foreach ( C64Studio.LayoutInfo layout in ToolLayout.Values ) * { * layout.StoreLayout(); * SettingsData.Append( layout.ToBuffer() ); * }*/ foreach (AcceleratorKey key in Accelerators.Values) { GR.IO.FileChunk chunkKey = key.ToChunk(); SettingsData.Append(chunkKey.ToBuffer()); } GR.IO.FileChunk chunkSoundSettings = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_SOUND); chunkSoundSettings.AppendU8((byte)(PlaySoundOnSuccessfulBuild ? 1 : 0)); chunkSoundSettings.AppendU8((byte)(PlaySoundOnBuildFailure ? 1 : 0)); chunkSoundSettings.AppendU8((byte)(PlaySoundOnSearchFoundNoItem ? 1 : 0)); SettingsData.Append(chunkSoundSettings.ToBuffer()); GR.IO.FileChunk chunkMainWindowPlacement = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_WINDOW); chunkMainWindowPlacement.AppendString(MainWindowPlacement); SettingsData.Append(chunkMainWindowPlacement.ToBuffer()); GR.IO.FileChunk chunkTabs = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_TABS); chunkTabs.AppendI32(TabSize); chunkTabs.AppendU8((byte)(AllowTabs ? 1 : 0)); chunkTabs.AppendU8((byte)(TabConvertToSpaces ? 1 : 0)); SettingsData.Append(chunkTabs.ToBuffer()); GR.IO.FileChunk chunkFont = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_FONT); chunkFont.AppendString(SourceFontFamily); chunkFont.AppendI32((int)SourceFontSize); chunkFont.AppendU8((byte)(BASICUseNonC64Font ? 1 : 0)); chunkFont.AppendString(BASICSourceFontFamily); chunkFont.AppendI32((int)BASICSourceFontSize); SettingsData.Append(chunkFont.ToBuffer()); foreach (Types.SyntaxElement element in SyntaxColoring.Keys) { GR.IO.FileChunk chunkSyntaxColor = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_SYNTAX_COLORING); chunkSyntaxColor.AppendU32((uint)element); chunkSyntaxColor.AppendU32(SyntaxColoring[element].FGColor); chunkSyntaxColor.AppendU32(SyntaxColoring[element].BGColor); chunkSyntaxColor.AppendI32(SyntaxColoring[element].BGColorAuto ? 1 : 0); SettingsData.Append(chunkSyntaxColor.ToBuffer()); } GR.IO.FileChunk chunkUI = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_UI); chunkUI.AppendU8((byte)(ToolbarActiveMain ? 1 : 0)); chunkUI.AppendU8((byte)(ToolbarActiveDebugger ? 1 : 0)); SettingsData.Append(chunkUI.ToBuffer()); GR.IO.FileChunk chunkRunEmu = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_RUN_EMULATOR); chunkRunEmu.AppendU8((byte)(TrueDriveEnabled ? 1 : 0)); SettingsData.Append(chunkRunEmu.ToBuffer()); GR.IO.FileChunk chunkDefaults = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_DEFAULTS); chunkDefaults.AppendString(DefaultProjectBasePath); SettingsData.Append(chunkDefaults.ToBuffer()); // dockpanel layout GR.IO.FileChunk chunkLayout = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_DPS_LAYOUT); System.IO.MemoryStream memOut = new System.IO.MemoryStream(); PanelMain.SaveAsXml(memOut, Encoding.UTF8); byte[] layoutData = memOut.ToArray(); string xmlOutText = System.Text.Encoding.UTF8.GetString(layoutData); // remove dummy elements (layout of non-tool windows) GR.Strings.XMLParser parser = new GR.Strings.XMLParser(); if (!parser.Parse(xmlOutText)) { Debug.Log("Could not parse XML"); } else { EnumElements(parser); xmlOutText = parser.ToText(); } //Debug.Log( xmlOutText ); chunkLayout.AppendU32((uint)layoutData.Length); chunkLayout.Append(layoutData); SettingsData.Append(chunkLayout.ToBuffer()); memOut.Close(); memOut.Dispose(); GR.IO.FileChunk chunkFindReplace = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_FIND_REPLACE); chunkFindReplace.AppendU8((byte)(LastFindIgnoreCase ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindWholeWord ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindRegexp ? 1 : 0)); chunkFindReplace.AppendU8((byte)(LastFindWrap ? 1 : 0)); chunkFindReplace.AppendU8((byte)LastFindTarget); chunkFindReplace.AppendI32(FindArguments.Count); foreach (var findArg in FindArguments) { chunkFindReplace.AppendString(findArg); } chunkFindReplace.AppendI32(ReplaceArguments.Count); foreach (var replaceArg in ReplaceArguments) { chunkFindReplace.AppendString(replaceArg); } SettingsData.Append(chunkFindReplace.ToBuffer()); GR.IO.FileChunk chunkIgnoredWarnings = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_IGNORED_WARNINGS); chunkIgnoredWarnings.AppendI32(IgnoredWarnings.Count); foreach (Types.ErrorCode ignoredWarning in IgnoredWarnings) { chunkIgnoredWarnings.AppendI32((int)ignoredWarning); } SettingsData.Append(chunkIgnoredWarnings.ToBuffer()); foreach (var pair in GenericTools) { GR.Memory.ByteBuffer data = pair.Value.DisplayDetails(); if (data != null) { GR.IO.FileChunk chunkPanelDisplayDetails = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_PANEL_DISPLAY_DETAILS); chunkPanelDisplayDetails.AppendString(pair.Key); chunkPanelDisplayDetails.AppendU32(data.Length); chunkPanelDisplayDetails.Append(data); SettingsData.Append(chunkPanelDisplayDetails.ToBuffer()); } } // ASM editor settings GR.IO.FileChunk chunkASMEditor = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_ASSEMBLER_EDITOR); chunkASMEditor.AppendU8((byte)(ASMHideLineNumbers ? 1 : 0)); SettingsData.Append(chunkASMEditor.ToBuffer()); // BASIC settings GR.IO.FileChunk chunkBASICParser = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_BASIC_PARSER); chunkBASICParser.AppendU8((byte)(BASICStripSpaces ? 1 : 0)); SettingsData.Append(chunkBASICParser.ToBuffer()); // BASIC key map GR.IO.FileChunk chunkBASICKeyMap = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_BASIC_KEYMAP); chunkBASICKeyMap.AppendI32(BASICKeyMap.Keymap.Count); foreach (var entry in BASICKeyMap.Keymap) { chunkBASICKeyMap.AppendU32((uint)entry.Key); chunkBASICKeyMap.AppendI32((int)entry.Value.KeyboardKey); } SettingsData.Append(chunkBASICKeyMap.ToBuffer()); // environment behaviour settings GR.IO.FileChunk chunkEnvironment = new GR.IO.FileChunk(Types.FileChunk.SETTINGS_ENVIRONMENT); chunkEnvironment.AppendU8((byte)(AutoOpenLastSolution ? 1 : 0)); SettingsData.Append(chunkEnvironment.ToBuffer()); return(SettingsData); }
public bool SaveToFile(string Filename) { GR.Memory.ByteBuffer resultingFile = new GR.Memory.ByteBuffer(); GR.IO.FileChunk chunkGeneral = new GR.IO.FileChunk((ushort)ChunkType.GENERAL); chunkGeneral.AppendString(OldCharsetProjectFilename); chunkGeneral.AppendString(ExportFilename); chunkGeneral.AppendString(ExportPrefix); chunkGeneral.AppendI32(ExportConstantOffset); chunkGeneral.AppendString(SpriteProjectFilename); chunkGeneral.AppendString(ProjectType); chunkGeneral.AppendU8(EmptyChar); chunkGeneral.AppendU8(EmptyColor); resultingFile.Append(chunkGeneral.ToBuffer()); int charSetIndex = 0; foreach (Types.CharsetProjectInfo info in CharsetProjects) { GR.IO.FileChunk chunkCharset = new GR.IO.FileChunk((ushort)ChunkType.CHARSET_INFO); chunkCharset.AppendString(info.Filename); chunkCharset.AppendU8((byte)(info.Multicolor ? 1 : 0)); resultingFile.Append(chunkCharset.ToBuffer()); ++charSetIndex; } foreach (Element element in Elements) { GR.IO.FileChunk chunkElement = new GR.IO.FileChunk((ushort)ChunkType.ELEMENT); chunkElement.AppendString(element.Name); chunkElement.AppendI32(element.Index); chunkElement.AppendI32(element.Characters.Width); chunkElement.AppendI32(element.Characters.Height); for (int i = 0; i < element.Characters.Width; ++i) { for (int j = 0; j < element.Characters.Height; ++j) { chunkElement.AppendU8(element.Characters[i, j].Char); chunkElement.AppendU8(element.Characters[i, j].Color); } } chunkElement.AppendI32(element.CharsetIndex); resultingFile.Append(chunkElement.ToBuffer()); } foreach (ObjectTemplate obj in ObjectTemplates) { GR.IO.FileChunk chunkObj = new GR.IO.FileChunk((ushort)ChunkType.OBJECT_TEMPLATE); chunkObj.AppendString(obj.Name); chunkObj.AppendI32(obj.StartSprite); chunkObj.AppendI32(obj.Behaviours.Count); foreach (KeyValuePair <int, Behaviour> behaviourPair in obj.Behaviours) { chunkObj.AppendI32(behaviourPair.Value.Value); chunkObj.AppendString(behaviourPair.Value.Name); } resultingFile.Append(chunkObj.ToBuffer()); } foreach (Screen screen in Screens) { GR.IO.FileChunk chunkScreen = new GR.IO.FileChunk((ushort)ChunkType.SCREEN); GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk((ushort)ChunkType.SCREEN_INFO); chunkScreenInfo.AppendString(screen.Name); chunkScreenInfo.AppendI32(screen.Width); chunkScreenInfo.AppendI32(screen.Height); chunkScreenInfo.AppendU8(screen.ConfigByte); chunkScreenInfo.AppendI32(screen.CharsetIndex); chunkScreenInfo.AppendU8(screen.WLConfigByte); chunkScreenInfo.AppendString(screen.ExtraData); chunkScreenInfo.AppendI32(screen.OverrideMC1 + 1); chunkScreenInfo.AppendI32(screen.OverrideMC2 + 1); chunkScreen.Append(chunkScreenInfo.ToBuffer()); foreach (ScreenElement element in screen.DisplayedElements) { GR.IO.FileChunk chunkScreenElement = new GR.IO.FileChunk((ushort)ChunkType.SCREEN_ELEMENT); chunkScreenElement.AppendI32((int)element.Type); chunkScreenElement.AppendI32(element.Index); chunkScreenElement.AppendI32(element.X); chunkScreenElement.AppendI32(element.Y); chunkScreenElement.AppendI32(element.Repeats); chunkScreenElement.AppendI32(element.Repeats2); chunkScreenElement.AppendI32(element.Char); chunkScreenElement.AppendI32(element.Color); chunkScreenElement.AppendI32(element.SearchObjectIndex); chunkScreenElement.AppendI32(element.TargetX); chunkScreenElement.AppendI32(element.TargetY); chunkScreenElement.AppendI32(element.TargetLevel); chunkScreenElement.AppendI32(element.Flags); chunkScreen.Append(chunkScreenElement.ToBuffer()); } // save extra object data int screenElementIndex = 0; foreach (ScreenElement element in screen.DisplayedElements) { if (element.Type == ScreenElementType.LD_OBJECT) { GR.IO.FileChunk chunkObject = new GR.IO.FileChunk((ushort)ChunkType.ELEMENT_OBJECT_DATA); chunkObject.AppendI32(screenElementIndex); chunkObject.AppendI32(element.Object.TemplateIndex); chunkObject.AppendI32(element.Object.X); chunkObject.AppendI32(element.Object.Y); chunkObject.AppendI32(element.Object.Color); chunkObject.AppendI32(element.Object.Speed); chunkObject.AppendI32(element.Object.Behaviour); chunkObject.AppendI32(element.Object.MoveBorderLeft); chunkObject.AppendI32(element.Object.MoveBorderTop); chunkObject.AppendI32(element.Object.MoveBorderRight); chunkObject.AppendI32(element.Object.MoveBorderBottom); chunkObject.AppendI32(element.Object.Data); chunkObject.AppendI32(element.Object.OptionalValue); chunkObject.AppendI32((int)element.Object.Optional); chunkScreen.Append(chunkObject.ToBuffer()); } else if (element.Type == ScreenElementType.LD_SPAWN_SPOT) { GR.IO.FileChunk chunkSpawnSpot = new GR.IO.FileChunk((ushort)ChunkType.ELEMENT_SPAWN_SPOT_DATA); chunkSpawnSpot.AppendI32(screenElementIndex); chunkSpawnSpot.AppendI32(element.Object.TemplateIndex); chunkSpawnSpot.AppendI32(element.Object.X); chunkSpawnSpot.AppendI32(element.Object.Y); chunkSpawnSpot.AppendI32(element.Repeats); chunkScreen.Append(chunkSpawnSpot.ToBuffer()); } ++screenElementIndex; } /* * GR.IO.FileChunk chunkScreen = new GR.IO.FileChunk( (ushort)ChunkType.OLD_SCREEN ); * * chunkScreen.AppendString( screen.Name ); * chunkScreen.AppendI32( screen.DisplayedElements.Count ); * foreach ( ScreenElement element in screen.DisplayedElements ) * { * chunkScreen.AppendI32( (int)element.Type ); * chunkScreen.AppendI32( element.Index ); * chunkScreen.AppendI32( element.X ); * chunkScreen.AppendI32( element.Y ); * chunkScreen.AppendI32( element.Repeats ); * chunkScreen.AppendI32( element.Char ); * chunkScreen.AppendI32( element.Color ); * chunkScreen.AppendI32( element.SearchObjectIndex ); * } * // save extra object data * foreach ( ScreenElement element in screen.DisplayedElements ) * { * if ( element.Type == ScreenElementType.LD_OBJECT ) * { * GR.IO.FileChunk chunkObject = new GR.IO.FileChunk( (ushort)ChunkType.ELEMENT_OBJECT_DATA ); * chunkObject.AppendI32( element.Object.TemplateIndex ); * chunkObject.AppendI32( element.Object.X ); * chunkObject.AppendI32( element.Object.Y ); * chunkObject.AppendI32( element.Object.Color ); * chunkObject.AppendI32( element.Object.Speed ); * chunkObject.AppendI32( element.Object.Behaviour ); * chunkObject.AppendI32( element.Object.MoveBorderLeft ); * chunkObject.AppendI32( element.Object.MoveBorderTop ); * chunkObject.AppendI32( element.Object.MoveBorderRight ); * chunkObject.AppendI32( element.Object.MoveBorderBottom ); * * chunkScreen.Append( chunkObject.ToBuffer() ); * } * else if ( element.Type == ScreenElementType.LD_SPAWN_SPOT ) * { * GR.IO.FileChunk chunkSpawnSpot = new GR.IO.FileChunk( (ushort)ChunkType.ELEMENT_SPAWN_SPOT_DATA ); * chunkSpawnSpot.AppendI32( element.Object.TemplateIndex ); * chunkSpawnSpot.AppendI32( element.Object.X ); * chunkSpawnSpot.AppendI32( element.Object.Y ); * chunkSpawnSpot.AppendI32( element.Repeats ); * * chunkScreen.Append( chunkSpawnSpot.ToBuffer() ); * } * } * GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk( (ushort)ChunkType.OLD_SCREEN_MORE_DATA ); * chunkScreenInfo.AppendI32( screen.Width ); * chunkScreen.Append( chunkScreenInfo.ToBuffer() ); */ resultingFile.Append(chunkScreen.ToBuffer()); } foreach (Region region in Regions) { GR.IO.FileChunk chunkRegion = new GR.IO.FileChunk((ushort)ChunkType.MAP_REGION); GR.IO.FileChunk chunkRegionInfo = new GR.IO.FileChunk((ushort)ChunkType.MAP_REGION_INFO); chunkRegionInfo.AppendI32(region.DisplayX); chunkRegionInfo.AppendI32(region.DisplayY); chunkRegionInfo.AppendI32(region.Vertical ? 1 : 0); chunkRegionInfo.AppendU32(region.ExtraData.Length); chunkRegionInfo.Append(region.ExtraData); chunkRegion.Append(chunkRegionInfo.ToBuffer()); foreach (RegionScreenInfo screenInfo in region.Screens) { GR.IO.FileChunk chunkRegionScreenInfo = new GR.IO.FileChunk((ushort)ChunkType.MAP_REGION_SCREEN); chunkRegionScreenInfo.AppendI32(screenInfo.ScreenIndex); chunkRegionScreenInfo.AppendI32(screenInfo.ExitN ? 1 : 0); chunkRegionScreenInfo.AppendI32(screenInfo.ExitS ? 1 : 0); chunkRegionScreenInfo.AppendI32(screenInfo.ExitW ? 1 : 0); chunkRegionScreenInfo.AppendI32(screenInfo.ExitE ? 1 : 0); chunkRegion.Append(chunkRegionScreenInfo.ToBuffer()); } resultingFile.Append(chunkRegion.ToBuffer()); } return(GR.IO.File.WriteAllBytes(Filename, resultingFile)); }