Giter Club home page Giter Club logo

railtools's Introduction

RaiLTools

Quick 'n dirty .NET library for working with Liar-soft's and raiL-soft's projects. Mainly tested with Albatross Log.

Saya meets Albatross

Usage

A few notes for using the library.

Archive Files (.xfl)

var archive = XflArchive.FromFile("archive.xfl");
archive.CreateEntry("newFile.wcg", File.ReadAllBytes("my.wcg"));
archive.Save("archive2.xfl");
archive.ExtractToDirectory("archive_extracted");)

Scenario Files (.gsc)

Scenario files can be loaded like so:

var transFile = TransFile.FromGSC("my_text.gsc");
transFile.Save("my_text.txt");

Edit the stuff and load it back using:

var gscFile = TransFile.FromFile("my_text.txt").ToGSC("my_text.gsc");
gscFile.Save("my_new_text.gsc");

Reading from Scenario Files

It is possible to a certain degree to read the commands in a scenario file using the CommandTranslator or the CommandTokenizer.

var scenario = GscFile.FromFile("my_text.gsc");
var translator = new CommandTranslator(scenario);

foreach(var command in translator.GetCommands()) {
  Console.WriteLine(command);
}

The CommandTranslator will try to map the tokens emitted by the tokenizer to subclasses of ICommand. If it fails, it will simply create UnknownCommand instances. Currently mapped:

  • Sprite images
  • Background images
  • Text
  • Goto, AND, Assign and some more operations
  • Transitions

Image Files (.wcg)

Only 32-Bit files are supported.

To turn WCG files into any sort of file you want:

using (var wcg = WcgImage.FromFile("my_image.wcg"))
using (var img = wcg.ToImage())
{
    img.Save("my_image.png");
}

The images can be turned back in a similar manner:

using (var img = Image.FromFile("my_image.png"))
using (var wcg = WcgImage.FromImage(img))
{
    wcg.Save("my_image.wcg");
}

Note that the generated WCG files are anything but optimized.

Canvas Files (.lwg)

Putting aside whether or not they can be called "canvas" files, they store a list of images (WCG) with a position (x, y).

You can load them like so:

var canvas = LwgCanvas.FromFile("my_canvas.lwg");
foreach(var image in canvas.Entries)
{
    Console.WriteLine("IMG: {0} [x={1}, y={2}]", item.Path, item.X, item.Y);
}

You can also populate a (new) LWG file.

var canvas = new LwgCanvas("my_canvas.lwg");
canvas.ReplaceImage("content_wcg", WcgFile.FromFile("content_wcg.wcg"), 0, 0);
canvas.Save("my_new_canvas.lwg");

The class also has a few helper methods that make it easy to extract and import entire folders.

railtools's People

Contributors

eusthenopteron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.