FanTranslatorsInternational / Kuriimu2

Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
GNU General Public License v3.0
315 stars 58 forks source link

Documentation | Wiki out of date for Plugin #195

Closed caleb-mabry closed 2 years ago

caleb-mabry commented 3 years ago

Description

Very small: while reading some documentation, I noticed that the example code snippet it out of date. I'm hoping to have some of that wiki documentation updated. Here is the reference. https://github.com/FanTranslatorsInternational/Kuriimu2/wiki/Plugins#plugin-class

Change

Before

public class ExamplePlugin : IFilePlugin, IIdentifyFiles
{
    // This is the unique plugin id, with which a plugin can be identified in the framework
    public Guid PluginId => Guid.Parse("a-valid-Guid-here");

    // These file extensions allow for an additional identification of the format
    public string[] FileExtensions => new[] { "*.ext" };

    // Additional plugin meta data
    public PluginMetadata Metadata => new PluginMetadata("Format name", "Plugin author", "Short description");

    // Allows an identification of one or more files of the parent file system to identify
    // if the given file is the supported file format.
    public async Task<bool> IdentifyAsync(IFileSystem fileSystem, UPath filePath, IdentifyContext context)
    {
        var fileStream = await fileSystem.OpenFileAsync(filePath);
        using var br = new BinaryReaderX(fileStream);

        return br.ReadString(4) == "MGCK";
    }

    // Creates the plugin state, which implements all the format specific actions and properties
    public IPluginState CreatePluginState(IPluginManager pluginManager)
    {
        return new ExampleState();
    }
}

After

    public class ExamplePlugin : IFilePlugin, IIdentifyFiles
    {
        // This is the unique plugin id, with which a plugin can be identified in the framework
        public Guid PluginId => Guid.Parse("a-valid-Guid-here");

        // These file extensions allow for an additional identification of the format
        public string[] FileExtensions => new[] { "*.ext" };

        // Additional plugin meta data
        public PluginMetadata Metadata => new PluginMetadata("Format name", "Plugin author", "Short description");

        public PluginType PluginType => PluginType.Archive;

        // Allows an identification of one or more files of the parent file system to identify
        // if the given file is the supported file format.
        public async Task<bool> IdentifyAsync(IFileSystem fileSystem, UPath filePath, IdentifyContext context)
        {
            var fileStream = await fileSystem.OpenFileAsync(filePath);
            using var br = new BinaryReaderX(fileStream);

            return br.ReadString(4) == "MGCK";
        }

        public IPluginState CreatePluginState(IBaseFileManager fileManager)
        {
            return new ExampleState();
        }
    }
onepiecefreak3 commented 2 years ago

Updated in the wiki. Thanks for reporting.