Skip to content

Kontract

onepiecefreak3 edited this page Dec 18, 2018 · 16 revisions

Kontract

  1. Description
  2. Type Interfaces
  3. File Capability

Description

Kontract contains all interfaces that can be inherited by plugins to ensure proper communication between them and Kore. It ensures file operations and format type specific interactions.

Type Interfaces

  1. ITextAdapter
  2. IImageAdapter
  3. IGameAdapter
  4. Future

ITextAdapter

This interface implements an IEnumerable in the plugin, which should hold all text from a text format.

Additionally this interface implements the following:

  • NameFilter; a regular expression that the TextEntry name must match with
  • NameMaxLength; the maximum length of TextEntry names
  • LineEndings; the line ending the format uses to begin a new line

TextEntry

TextEntry is a class that is used in all text format interfaces. It inherits from INotifyPropertyChanged and declares an own even Edited.

It implements the following properties:

  • Name; Virtual; A name or title for the text entry
  • OriginalText; Virtual; The original text of the entry, that shouldn't change even after editing
  • EditedText; Virtual; The edited text, which can get changed over time
  • Notes; Virtual; It's possible to add notes per entry for translation purposes
  • MaxLength; Virtual; The max length of OriginalText and EditedText
  • CanEdit; Virtual; Determines whether the text can be edited

Every property beside MaxLength and CanEdit toggle both events.

IImageAdapter

This interface implements an IList in the plugin, which should hold every image of the image format.

BitmapInfo

BitmapInfo holds information to one image in an image format.

It contains the following properties:

  • Bitmaps; A List, which holds the main image and all its mipmaps
  • MipMapCount; Virtual; Counts the mip maps of this image
  • Name; The name for this image
  • Size; The dimensions of the main image

IGameAdapter

This interface is an addition to text plugins and currently the only non file-based plugin type in Kuriimu2. Those game plugins are meant to create image previews of TextEntry's. They are also meant to handle control codes of the text and change the preview accordingly.

This plugin type is more user- and UI-oriented and therefore less attractive to independant developers. For a programmer of a dedicated translation team though, it will be a helpful addition for their translators to see their work as ingame previews.

The interface implements the following properties:

  • ID; A unique Id for the plugin
  • Name; A name for the plugin; This information can be shown on UIs to select them for example
  • IconPath; An icon for the plugin; Can be shown on UI for better visualization
  • FileName; Name of the file that is opened by the text plugin the Entries come from
  • Entries; The TextEntry's that were loaded into the game plugin

The interface implements a method Loadentries(IEnumerable<TextEntry> entries) which should set Entries and might do stuff like control code interpreting.
It also implements a method SaveEntries() which writes everything back to their respective TextEntry's and returns an IEnumerable.

IGeneratePreview

This interface implements a method GeneratePreview(TextEntry entry) which should generate an image preview out of the given TextEntry.

Future

There are many more type interfaces planned, but not yet implemented or thoroughly developed. Planned are IArchiveAdapter, ILayoutAdapter and IFontAdapter.

While IFontAdapter was the first type interface developed for Kuriimu2s proof-of-concept, it's still considered incomplete and will be documented at a later point. You might want to trial-and-error with it, if you still want to work with it.

File Capability

Those interfaces ensure basic file functionality for the plugin. It isn't specific to any format type and can be used for any file-based plugins.

  1. IIdentifyFiles
  2. ILoadFiles
  3. ISaveFiles
  4. ICreateFiles

IIdentifyFiles

This interface implements a method Identify(string filename). It returns a boolean, indicating if the plugin can handle the given file or not.

If a plugin doesn't inherit from this interface, Kore will handle it as a blind plugin.

ILoadFiles

This interface implements a method Load(string filename). This method should open and interpret the given file.

ISaveFiles

This interface implements a method Save(string filename, int versionIndex = 0). This method is meant to save the interpreted data back into the file format. The versionIndex is meant to differentiate between versions of a file format, but is currently unused by Kore.

ICreateFiles

This interface implements a method Create(). This method is meant to create the format from scratch, without loading a file beforehand.

Clone this wiki locally