{"id":27874205,"url":"https://github.com/optimus-code/lcfsharp","last_synced_at":"2025-05-05T01:31:49.324Z","repository":{"id":250485001,"uuid":"830607809","full_name":"optimus-code/LcfSharp","owner":"optimus-code","description":"Read and write RPG Maker 2000/03 LCF files","archived":false,"fork":false,"pushed_at":"2024-09-01T21:15:53.000Z","size":753,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T04:17:30.219Z","etag":null,"topics":["rpgmaker2000","rpgmaker2003"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/optimus-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-18T15:44:40.000Z","updated_at":"2024-09-01T21:15:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e23992fa-cee6-45a0-bd60-7f5209ff9361","html_url":"https://github.com/optimus-code/LcfSharp","commit_stats":null,"previous_names":["optimus-code/lcfsharp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimus-code%2FLcfSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimus-code%2FLcfSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimus-code%2FLcfSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimus-code%2FLcfSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimus-code","download_url":"https://codeload.github.com/optimus-code/LcfSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252423323,"owners_count":21745570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rpgmaker2000","rpgmaker2003"],"created_at":"2025-05-05T01:31:41.535Z","updated_at":"2025-05-05T01:31:49.260Z","avatar_url":"https://github.com/optimus-code.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LcfSharp\n\nLcfSharp is a .NET library for reading and writing RPG Maker 2000/03 Lcf (Ldb, Lmt, Lmu, etc.) files. This library aims to provide a straightforward and efficient way to work with Lcf files in C# applications.\n\n## Features\n\n- **Read Lcf Files**: Parse RPG Maker 2000/03 Lcf files into .NET objects.\n- **Write Lcf Files**: Serialise .NET objects back into RPG Maker 2000/03 Lcf files.\n- **Modeled on System.Text.Json**: Familiar interface for developers who have worked with `System.Text.Json`.\n\n## Installing\n\nTo install LcfSharp from NuGet, use the following command in the NuGet Package Manager Console:\n\n```shell\nInstall-Package LcfSharp\n```\n\n## Usage\n\nTo use existing types provided by LcfSharp, such as `LdbFile`, you can deserialise an Lcf file with the following code snippet:\n\n```csharp\nusing (var stream = File.OpenRead(path))\n{\n    return LcfSerialiser.Deserialise\u003cLdbFile\u003e(stream);\n}\n```\n\n## Implementing Your Own Readers/Writers\n\nEach Lcf file has a header and a collection of chunks. To deserialise a type, you need to use the `ILcfRootChunk` interface for the core class (see `Database.cs`).\n\n### Decorate Classes with Attributes\n\nTo serialize Lcf chunks, use `[LcfChunk\u003cChunkEnumType\u003e]` to decorate your classes. The enum value names need to correspond to properties in the class described by that attribute.\n\n#### Example:\n\n```csharp\n[LcfChunk\u003cRootChunkEnum\u003e]\npublic class MyLcfClass : ILcfRootChunk\n{\n    public List\u003cChildChunk\u003e Children { get; set; }\n}\n```\n\n## Handling Child Chunks with IDs\n\nIn LcfSharp, some chunks are children of other chunks and have unique IDs. These IDs are read and written automatically as long as you use an `int` type decorated with the `[LcfID]` attribute.\n\n### Example\n\nHere's an example of how to define a class with child chunks that include an ID:\n\n```csharp\n[LcfChunk\u003cChildChunkEnum\u003e]\npublic class ChildChunk\n{\n    [LcfID]\n    public int ID { get; set; }\n\n    public string PropertyOne { get; set; }\n\n    public int PropertyTwo { get; set; }\n}\n```\n\n### Enum for Child Chunk Properties\n\nDefine an enum to represent the properties of the child chunk:\n\n```csharp\npublic enum ChildChunkEnum : int\n{\n    /** String */\n    PropertyOne = 0x01,\n    /** Integer */\n    PropertyTwo = 0x02\n}\n```\n\n### Ignoring Properties\n\nFor properties you don't want to be serialized, use `[LcfIgnore]`.\n\n#### Example:\n\n```csharp\npublic class MyLcfClass\n{\n    [LcfIgnore]\n    public string IgnoredProperty { get; set; }\n}\n```\n\n### Always Persist Fields\n\nFor fields that must always be serialised/deserialised, even if they equal the default value, decorate them with `[LcfAlwaysPersist]`.\n\n#### Example:\n\n```csharp\npublic class MyLcfClass\n{\n    [LcfAlwaysPersist]\n    public int AlwaysPersistedProperty { get; set; }\n}\n```\n\n### Version-Specific Properties\n\nYou can decorate properties that correspond to specific versions using `[LcfVersion(LcfEngineVersion.RM2K3)]`.\n\n#### Example:\n\n```csharp\npublic class MyLcfClass\n{\n    [LcfVersion(LcfEngineVersion.RM2K3)]\n    public string VersionSpecificProperty { get; set; }\n}\n```\n\n## Handling Collections in Chunks with List\u003c\u003e\n\nWhen dealing with collections in chunks, the recommended approach is to use the `List\u003c\u003e` type. The length of the list can be determined by one of three methods:\n\n1. **Chunk Length (Default)**: By default, the length of the list is determined by the chunk length.\n2. **Using Another Chunk's Length**:\n   - You can specify the length using another chunk by decorating the list property with the `[LcfSize((int)ActorChunk.AttributeRanksSize)]` attribute.\n3. **Explicit Calculation**:\n   - If properties are decorated with `[LcfCalculateSize]`, the list is read until the next chunk, i.e. length is not available ahead of time.\n\n### Special Case: Classes Without ID Property\n\nIf the list item is a class that does not contain an ID property (i.e., it is not decorated with `[LcfID]`), the length is read automatically from the stream if no length is provided by the parent chunk (if there is one). In this scenario, the Lcf format doesn't provide a byte length value but a direct number of elements.\n\n### Examples\n\n#### Default Length from Chunk\n\n```csharp\npublic List\u003cMyItem\u003e Items { get; set; }\n```\n\n#### Length from Another Chunk\n\n```csharp\n[LcfSize((int)ActorChunk.AttributeRanksSize)]\npublic List\u003cMyItem\u003e Items { get; set; }\n```\n\n#### Automatic based on continuous chunk reading\n\n```csharp\n[LcfCalculateSize]\npublic List\u003cMyItem\u003e Items { get; set; }\n```\n\n## Status\n\nReading is implemented and is mostly working. There may be bugs that need to be ironed out. Writing is not confirmed working yet and needs more time to handle niche scenarios with Lcf writing (like list lengths, etc.).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.\n\n## Acknowledgements\n\nThis project couldn't exist without the great work from [liblcf](https://github.com/EasyRPG/liblcf). Special thanks to the authors of liblcf for their invaluable contributions to understanding the Lcf file format.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\nLcfSharp Copyright (c) 2024 optimus-code\n(A \"loose\" .NET port of liblcf)\nLicensed under the MIT License.\n\nCopyright (c) 2014-2023 liblcf authors\nLicensed under the MIT License.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimus-code%2Flcfsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimus-code%2Flcfsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimus-code%2Flcfsharp/lists"}