// GfxEd interface // Copyright (C) 2004 Ian Cowburn // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // $Id$ // using System; using System.Collections; using System.Drawing; using System.Windows.Forms; using System.IO; namespace GfxEdInterface { /// /// Defines the interface a plugin must follow /// public interface IPlugin { /// /// The description for this plugin /// string Description {get;} /// /// The short name (for drop down list use) of this plugin /// string ShortName {get;} /// /// The copyright and author information for this plugin /// string Author {get;} /// /// The URL where this plugin can be found /// string URL {get;} /// /// The maximum number of colours for a sprite /// uint MaxColours {get;} /// /// The machines palette. Sprite colours are selected from this. /// /// /// Note that colour zero is considered the transparent/background /// colour and cannot be selected for drawing. On platforms where the /// actual colour could be used, duplicate it and weight your palette /// routines when outputing accordingly. /// Colour[] Palette {get;} /// /// An array indicating that that colour in the sprite can be changed. /// bool[] SprPalEditable {get;} /// /// An array indicating that that colour in the sprite is common to all. /// bool[] SprPalCommon {get;} /// /// The allowable sprite sizes. /// SpriteSize[] AllowedSizes {get;} /// /// The default extension for exports /// string ExportExtension {get;} /// /// Exports the sprites. /// /// The exported filename /// A list of sprites to export /// bool Export(string path, SpriteList sprites); /// /// Get the configuration object for the plugin. /// /// /// If there is no configuration required for the plugin, null can be /// returned. /// IConfig Config {get;} /// /// Get the processing object for the plugin. /// /// /// If there is no processing supplied by the plugin, null can be /// returned. /// IProcess Process {get;} } /// /// Defines the configuration interface for a plugin. /// public interface IConfig { /// /// Shows the configuration dialog. /// void Settings(Form parent); /// /// Outputs the configuration to the suppluied stream. /// /// /// All file operations are done using text files. /// /// The output stream void Output(TextWriter stream); /// /// Inputs the configuration from the suppluied stream. /// /// /// All file operations are done using text files. /// /// The output stream void Input(TextReader stream); } /// /// Defines the processing interface for a plugin. /// public interface IProcess { /// /// Process the sprite. /// void Single(Sprite s); /// /// Process all the sprites. /// void All(SpriteList s); } /// /// Defines the allowable sizes for a sprite and their aspect ratios /// public class SpriteSize { public SpriteSize(uint w, uint h, uint xaspect, uint yaspect) { m_width=w; m_height=h; m_xaspect=xaspect; m_yaspect=yaspect; } public uint Width {get {return m_width;}} public uint Height {get {return m_height;}} public uint XAspect {get {return m_xaspect;}} public uint YAspect {get {return m_yaspect;}} public override string ToString() { return m_width.ToString()+","+m_height.ToString(); } private uint m_width; private uint m_height; private uint m_xaspect; private uint m_yaspect; } /// /// Describes a colour. And yes, a *very* dumb class name. /// public class Colour { public Colour(string name, byte red, byte green, byte blue) { m_name=name; m_red=red; m_blue=blue; m_green=green; } public override string ToString() { return Name; } public string Name { get {return m_name;} set {m_name=value;} } public byte Red { get {return m_red;} set {m_red=value;} } public byte Green { get {return m_green;} set {m_green=value;} } public byte Blue { get {return m_blue;} set {m_blue=value;} } public Color DrawCol { get {return Color.FromArgb(m_red,m_green,m_blue);} } private string m_name; private byte m_red; private byte m_green; private byte m_blue; } /// /// Describes a sprite /// public class Sprite { public Sprite(string name, uint width, uint height, uint maxcol) { m_name=name; m_width=width; m_height=height; m_data=new uint[m_width,m_height]; m_pal=new uint[maxcol]; for(uint f=0;f=0 && nx=0 && ny=0 && nx=0 && ny /// Describes a list of sprites /// public class SpriteList : IEnumerable { public SpriteList() { m_list=new ArrayList(); m_changed=false; } public Sprite this [int i] { get {return (Sprite)m_list[i];} set { m_list[i]=value; m_changed=true; } } public void Add(Sprite s) { m_list.Add(s); m_changed=true; } public void Insert(int i, Sprite s) { m_list.Insert(i,s); m_changed=true; } public void RemoveAt(int i) { m_list.RemoveAt(i); } public int Count { get {return m_list.Count;} } public void Clear() { m_list.Clear(); } public bool Changed { get {return m_changed;} set {m_changed=value;} } public IEnumerator GetEnumerator() { return m_list.GetEnumerator(); } public void Output(TextWriter stream) { stream.WriteLine(m_list.Count); foreach (Sprite s in m_list) { s.Output(stream); } } public static SpriteList Input(TextReader stream) { SpriteList l=new SpriteList(); int count=Convert.ToInt32(stream.ReadLine()); for(int f=0;f