first commit

This commit is contained in:
Jose Caban
2025-06-07 11:39:25 -04:00
commit 3dc33814dd
1035 changed files with 657058 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
package Icarus.Graphics.Animation;
import System.Drawing.*;
/**
* The abstract frame provides some of the functionality common to all frames.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public abstract class AbstractFrame extends AbstractRenderable implements IFrame
{
/**
* This is the anchor point used for the frame.
*/
private Point m_AnchorPoint = new Point(0, 0);
/**
* This is the size of the frame.
*/
private Size m_FrameSize = new Size(0, 0);
/**
* Returns the anchor point of the frame.
*/
public Point getAnchorPoint()
{
return m_AnchorPoint;
}
/**
* Sets up a new anchor point.
*/
public void setAnchorPoint(Point p)
{
m_AnchorPoint = p;
}
/**
* Initializes the frame using the anchor point and bitmap
* passed in, and returns true if the initialization went
* through successfully, and false if it did not.
*/
public boolean initialize(Point anchor, Bitmap image)
{
this.setAnchorPoint(anchor);
this.m_FrameSize.set_Width(image.get_Width());
this.m_FrameSize.set_Height(image.get_Height());
return this.initializeFromBitmap(image);
}
/**
* Will return the size of the frame.
*/
public Size GetSize()
{
return m_FrameSize;
}
/**
* Performs any necessary operations to initialize the frame
* from a bitmap.
*/
protected abstract boolean initializeFromBitmap(Bitmap image);
}

View File

@@ -0,0 +1,19 @@
package Icarus.Graphics.Animation;
import System.Drawing.Point;
import System.Drawing.Rectangle;
import System.Drawing.Size;
/**
* This is just a convenience class providing a default implementation of what originally was a function used by everything and then turned out to just be a helper when more functionality was needed.
*/
public abstract class AbstractRenderable implements IRenderable
{
/**
* Renders the thing.
*/
public void Render(Point coordinates, IRenderParameters parameters)
{
this.Render(new Rectangle(coordinates, Size.Empty), parameters);
}
}

View File

@@ -0,0 +1,81 @@
package Icarus.Graphics.Animation;
import System.Drawing.Graphics;
import System.Drawing.Color;
import System.Drawing.Size;
import System.Drawing.Font;
import System.Drawing.FontFamily;
/**
* The abstract text class, which will allow us to render text in an efficient manner.
*/
public abstract class AbstractText extends AbstractRenderable
{
public static final Graphics DefaultGraphics = Graphics.FromImage(new System.Drawing.Bitmap(1, 1));
private String mText = null;
private Color mColor = Color.get_Black();
private Font mFont = null;
public AbstractText()
{
this("");
}
public AbstractText(String text)
{
this(text, Color.get_Black());
}
public AbstractText(String text, Color c)
{
this(text, c, new Font(FontFamily.get_GenericSansSerif().get_Name(), 12));
}
/**
* Creates a new instance of the abstract text.
*/
public AbstractText(String text, Color c, Font f)
{
mText = text;
mColor = c;
mFont = f;
UpdateText();
}
public String GetText() { return mText; }
public void SetText(String text)
{
mText = text;
UpdateText();
}
public Color GetColor() { return mColor; }
public void SetColor(Color color)
{
mColor = color;
UpdateText();
}
public Font GetFont() { return mFont; }
public void SetFont(Font font)
{
mFont = font;
UpdateText();
}
/**
* Returns the size of the text in pixels.
*/
public Size GetSize()
{
System.Drawing.SizeF fsize = AbstractText.DefaultGraphics.MeasureString(this.GetText(), this.GetFont());
return new Size((int) fsize.get_Width(), (int) fsize.get_Height());
}
/**
* Updates the text. This will be called any time the text itself, or the color or the font is changed.
*/
protected abstract void UpdateText();
}

View File

@@ -0,0 +1,31 @@
package Icarus.Graphics.Animation;
/**
* This thingey allows for context-independent animation handling.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public abstract class AnimationFactory
{
/**
* Singleton Implementation.
*/
private static AnimationFactory mg_Instance = null;
/**
* Singleton Implementation.
*/
public static final AnimationFactory getInstance() { return mg_Instance; }
public static final void setInstance(AnimationFactory factory) { mg_Instance = factory; }
/**
* Returns a blank frame.
*/
public abstract IFrame makeBlankFrame();
/**
* Returns blank text.
*/
public abstract AbstractText makeText(String text, System.Drawing.Color c, System.Drawing.Font f);
}

View File

@@ -0,0 +1,35 @@
package Icarus.Graphics.Animation;
/**
* This class enumerates all the possible looping modes for an animation.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class AnimationType // extends System.Enum //Can't author enums :(
{
/**
* Denotes that the animation is static.
*/
public static AnimationType None = new AnimationType("None");
/**
* The animation loops through once, and freezes at the last frame.
*/
public static AnimationType LoopOnce = new AnimationType("LoopOnce");
/**
* The animation will loop forever.
*/
public static AnimationType LoopForever = new AnimationType("LoopForever");
private String name;
private AnimationType(String n) { name = n; }
public String ToString() { return name; }
public static AnimationType FromString(String v)
{
if (v.equals("LoopOnce")) return AnimationType.LoopOnce;
else if (v.equals("LoopForever")) return AnimationType.LoopForever;
else return AnimationType.None;
}
}

View File

@@ -0,0 +1,63 @@
package Icarus.Graphics.Animation;
import System.Collections.*;
import System.Drawing.*;
/**
* This class provides the functionality of a frameset.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class Frameset
{
/**
* The list of frames in this frameset.
*/
private IList m_FrameList;
/**
* Performs some necessary initialization.
*/
public Frameset()
{
m_FrameList = new ArrayList();
}
/**
* Returns the number of frames in the frameset.
*/
public int getFrameCount()
{
return m_FrameList.get_Count();
}
/**
* Adds a new frame to the frameset and returns the current number of frames in the frameset.
*/
public int addFrame(IFrame frame)
{
m_FrameList.Add(frame);
return this.getFrameCount();
}
/**
* Adds a new frame to the frameset and returns the current number of frames in the frameset.
*/
public int addFrame(Bitmap img, Point anchor)
{
IFrame new_frame = AnimationFactory.getInstance().makeBlankFrame();
new_frame.initialize(anchor, img);
return this.addFrame(new_frame);
}
/**
* Returns the frame at the specified index.
*/
public IFrame getFrameAt(int index)
{
return (IFrame) m_FrameList.get_Item(index);
}
}

View File

@@ -0,0 +1,215 @@
package Icarus.Graphics.Animation;
/**
* This is an animation that uses a frameset as the underlying set of images.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class FramesetAnimation
{
/**
* The path where the animation was loaded from.
*/
private String m_FramesetPath;
/**
* The set of frames used for the animation.
*/
private Frameset m_Frameset;
/**
* The looping type of the animation.
*/
private AnimationType m_AnimationType;
/**
* The delay, in abstract time units, between the frames of the animation.
*/
private long m_AnimationDelay;
/**
* The index of the currently displayed frame in the animation.
*/
private int m_CurrentFrameIndex;
/**
* If we receive an update message and it is not time yet to update the frame, then we can just add to the cumulative delay over here, and check the correct number next time around.
*/
private long m_CumulativeDelay;
/**
* Sets up a blank frameset animation.
*/
public FramesetAnimation()
{
this.set_AnimationDelay(1);
this.set_AnimationType(AnimationType.None);
}
/**
* Sets up the new frameset animation.
*/
public FramesetAnimation(Frameset frames, AnimationType loopMode, long delay)
{
this.set_AnimationType(loopMode);
this.setFrameset(frames);
this.set_AnimationDelay(delay);
}
/**
* This is just a little optimization that makes it so when the animation has only one frame, the update method won't try to do anything funny.
*/
private void processAnimationType()
{
if (m_Frameset != null && m_Frameset.getFrameCount() < 2)
{
//No reason to loop:
m_AnimationType = AnimationType.None;
}
}
/**
* Returns the frameset.
*/
public Frameset getFrameset() { return m_Frameset; }
/**
* Sets up a new frameset.
*/
protected void setFrameset(Frameset frames)
{
m_Frameset = frames;
m_CurrentFrameIndex = 0;
m_CumulativeDelay = 0;
processAnimationType();
}
/**
* Returns the path to the frameset.
*
* @property
*/
public String get_FramesetPath() { return this.m_FramesetPath; }
/**
* Sets the path to the frameset.
*
* @property
*/
public void set_FramesetPath(String value)
{
this.m_FramesetPath = value;
this.setFrameset(FramesetManager.getInstance().getFrameset(value));
}
/**
* Returns the animation type.
*
* @property
* @attribute System.Xml.Serialization.XmlIgnore()
*/
public AnimationType get_AnimationType() { return m_AnimationType; }
/**
* Sets up the new animation type.
*
* @property
*/
public void set_AnimationType(AnimationType type)
{
m_AnimationType = type;
processAnimationType();
}
/**
* This is sort of a hack property for serialization purposes because J# + enums = headache.
*
* @property
*/
public String get_AnimationTypeId() { return this.m_AnimationType.ToString(); }
/**
* This is sort of a hack property for serialization purposes because J# + enums = headache.
*
* @property
*/
public void set_AnimationTypeId(String v)
{
this.set_AnimationType(AnimationType.FromString(v));
}
/**
* Returns the delay, in abstract time units, between the frames of the animation.
*
* @property
*/
public long get_AnimationDelay() { return m_AnimationDelay; }
/**
* Sets the new animation delay.
*
* @property
*/
public void set_AnimationDelay(long delay) { m_AnimationDelay = delay; }
/**
* Returns the index of the current frame.
*
* @property
* @attribute System.Xml.Serialization.XmlIgnore()
*/
public int get_CurrentFrameIndex()
{
return m_CurrentFrameIndex;
}
/**
* Returns the current frame of the animation.
*
* @property
* @attribute System.Xml.Serialization.XmlIgnore()
*/
public IFrame get_CurrentFrame()
{
return m_Frameset.getFrameAt(this.get_CurrentFrameIndex());
}
/**
* Performs an update of the animation given the delay since the previous call in abstract time units.
*/
public void update(long time)
{
if (m_AnimationType == AnimationType.None)
{
//Nothing much to do...
return;
}
m_CumulativeDelay += time;
if (m_CumulativeDelay < this.get_AnimationDelay())
{
//Not time yet...
return;
}
m_CumulativeDelay = 0;
int index = m_CurrentFrameIndex;
if (index >= m_Frameset.getFrameCount() - 1)
{
if (m_AnimationType == AnimationType.LoopForever)
{
index ++;
index %= m_Frameset.getFrameCount();
}
}
else
{
index ++;
}
m_CurrentFrameIndex = index;
}
}

View File

@@ -0,0 +1,102 @@
package Icarus.Graphics.Animation;
import System.Collections.*;
import System.Drawing.Bitmap;
import System.Type;
import System.Reflection.ConstructorInfo;
/**
* The frameset manager singleton class will handle the framesets in memory. It will load each frameset only once, so that we don't waste memory, and it will sometimes unload the framesets that haven't been used for a while.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class FramesetManager
{
/**
* Singleton Implementation.
*/
private static final FramesetManager mg_Instance = new FramesetManager();
/**
* Maps strings to frameset references.
*/
private IDictionary m_Framesets; //TODO: Maybe use soft references here, to provide caching.
/**
* The default frameset provider to use.
*/
private IFramesetProvider m_DefaultFramesetProvider;
/**
* Singleton Implementation.
*/
private FramesetManager()
{
m_Framesets = new Hashtable();
m_DefaultFramesetProvider = new PazeraFramesetProvider();
}
/**
* Singleton Implementation.
*/
public static final FramesetManager getInstance() { return mg_Instance; }
/**
* Sets up the new default frameset provider.
*/
public void setDefaultFramesetProvider(IFramesetProvider provider) { m_DefaultFramesetProvider = provider; }
/**
* Returns the frameset with the specified ID. If the frameset cannot be loaded, will probably throw an exception.
*/
public Frameset getFrameset(String id)
{
if (!m_Framesets.Contains(id))
{
this.loadFramesetFromId(id, null);
}
return (Frameset) m_Framesets.get_Item(id);
}
/**
* Adds the frameset with the specified id. If a frameset with that id already exists, it is overwritten.
*/
public void addFrameset(String id, Frameset frameset)
{
m_Framesets.Add(id, frameset);
}
/**
* Uses the id passed in as the filename to look for the image in the base image folder.
*/
public void loadFramesetFromId(String id, IFramesetProvider provider)
{
this.loadFramesetFromFile(Icarus.Resources.ResourceManager.get_Instance().get_ImagePath() + id, id, provider);
}
/**
* Loads the frameset with the specified id from the full path passed in using the specified frameset provider.
*/
public void loadFramesetFromFile(String filename, String id, IFramesetProvider provider)
{
if (provider == null)
{
provider = m_DefaultFramesetProvider;
}
Frameset new_set = new Frameset();
provider.fillFrameset(new_set, (Bitmap) Bitmap.FromFile(filename));
this.addFrameset(id, new_set);
}
/**
* Given an id of an image, loads it.
*/
public Bitmap loadImageFromId(String id)
{
return (Bitmap) Bitmap.FromFile(Icarus.Resources.ResourceManager.get_Instance().get_ImagePath() + id);
}
}

View File

@@ -0,0 +1,27 @@
package Icarus.Graphics.Animation.GDI;
import Icarus.Graphics.Animation.AnimationFactory;
import Icarus.Graphics.Animation.IFrame;
import Icarus.Graphics.Animation.AbstractText;
/**
* Allows for animation using GDI.
*/
public class GDIAnimationFactory extends AnimationFactory
{
/**
* Returns a blank frame.
*/
public IFrame makeBlankFrame()
{
return new GDIFrame();
}
/**
* Returns blank text.
*/
public AbstractText makeText(String text, System.Drawing.Color c, System.Drawing.Font f)
{
throw new RuntimeException("Text rendering for GDI is not implemented, because it hasn't been needed yet.");
}
}

View File

@@ -0,0 +1,85 @@
package Icarus.Graphics.Animation.GDI;
import Icarus.Graphics.Animation.*;
import System.Drawing.*;
/**
* This is a frame that can be rendered on a GDI control, such as a button, or something like that.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class GDIFrame extends AbstractFrame
{
/**
* The frame image...
*/
private Bitmap m_FrameImage;
/**
* Doesn't do a whole lot...
*/
protected boolean initializeFromBitmap(Bitmap image)
{
m_FrameImage = image;
return (m_FrameImage != null);
}
/**
* Returns a bitmap showing the contents of the frame. This is for saving a frame to a file.
*/
public Bitmap getFrameImage()
{
return m_FrameImage;
}
/**
* Returns the size of the renderable.
*/
public Size GetSize()
{
return m_FrameImage.get_Size();
}
/**
* Returns the width of the frame image.
*/
public int getImageWidth()
{
return m_FrameImage.get_Width();
}
/**
* Returns the height of the frame image.
*/
public int getImageHeight()
{
return m_FrameImage.get_Height();
}
/**
* Will render the frame in the specified context, at the specified coordinates. Note that it is not necessarily the top-left corner of the frame that will be rendered at those coordinates, but rather the anchor point.
*/
public void Render(Rectangle coordinates, IRenderParameters params)
{
GDIRenderParameters p = (GDIRenderParameters) params;
int x = coordinates.get_X() - this.getAnchorPoint().get_X();
int y = coordinates.get_Y() - this.getAnchorPoint().get_Y();
if (coordinates.get_Size() == Size.Empty)
{
p.getGraphics().DrawImageUnscaled(m_FrameImage, x, y);
}
else
{
int width = Math.min(m_FrameImage.get_Width(), coordinates.get_Width());
int height = Math.min(m_FrameImage.get_Height(), coordinates.get_Height());
Rectangle src = new Rectangle(0, 0, width, height);
p.getGraphics().DrawImage(m_FrameImage, x, y, src, GraphicsUnit.Pixel);
}
}
}

View File

@@ -0,0 +1,41 @@
package Icarus.Graphics.Animation.GDI;
import System.Drawing.Point;
import System.Drawing.Graphics;
import Icarus.Graphics.Animation.IRenderParameters;
/**
* The render parameters needed to make render to GDI.
*/
public class GDIRenderParameters implements IRenderParameters
{
/**
* The graphics context in which we want to render the graphics.
*/
private Graphics m_GraphicsContext;
/**
* Initializes the rendering parameters.
*/
public GDIRenderParameters(Graphics context)
{
this.setGraphics(context);
}
/**
* Returns the graphics context.
*/
public Graphics getGraphics()
{
return m_GraphicsContext;
}
/**
* Sets up the new graphics context.
*/
private void setGraphics(Graphics g)
{
m_GraphicsContext = g;
}
}

View File

@@ -0,0 +1,35 @@
package Icarus.Graphics.Animation;
import System.Drawing.*;
/**
* The implementors of this interface are frames that can be rendered
* on screen.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public interface IFrame extends IRenderable
{
/**
* Returns the anchor point of the frame. The anchor point is
* essentially a coordinate in the frame such that when the
* frame is rendered at some point on the screen, the point in
* the frame referenced by the anchor is actually the one put
* in that screen position - not necessarily the top-left
* corner of the frame.
*/
public Point getAnchorPoint();
/**
* Initializes the frame using the anchor point and bitmap
* passed in, and returns true if the initialization went
* through successfully, and false if it did not.
*/
public boolean initialize(Point anchor, Bitmap image);
/**
* Returns a bitmap showing the contents of the frame. This is for saving a frame to a file.
*/
public Bitmap getFrameImage();
}

View File

@@ -0,0 +1,31 @@
package Icarus.Graphics.Animation;
import System.Drawing.*;
/**
* The implementors of this interface will be used to parse a file
* from disk and generate bitmap/point pairs for framesets, as well as
* to export a frameset to a file.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public interface IFramesetProvider
{
/**
* Goes through the image and extracts frames from it.
*/
public void fillFrameset(Frameset frameSet, Bitmap source);
/**
* Will export the frameset passed in to a file, whose name is
* passed in. The export is such that it is guaranteed to be
* loadable by the corresponding fillFrameset function. Other
* than that, nothing should be assumed about the export. This
* function assumes that the filename points to a file that
* can actually be created, and if there are any problems,
* like null filename, or frameset, or premission problems
* with creating the file, an Exception will be thrown.
*/
public void exportFrameset(Frameset frameset, String filename) throws System.Exception;
}

View File

@@ -0,0 +1,8 @@
package Icarus.Graphics.Animation;
/**
* The implementors of this marker interface denote rendering parameters.
*/
public interface IRenderParameters
{
}

View File

@@ -0,0 +1,22 @@
package Icarus.Graphics.Animation;
/**
* The implementors of the renderable interface are things that can be rendered... Duh. ;)
*/
public interface IRenderable
{
/**
* Returns the size of the renderable.
*/
public System.Drawing.Size GetSize();
/**
* Renders the thing.
*/
public void Render(System.Drawing.Point coordinates, IRenderParameters parameters);
/**
* Renders the thing. Note that the destination parameter can be used to specify clipping. The size of the rectangle can be empty, in which case no clipping will be applied.
*/
public void Render(System.Drawing.Rectangle destination, IRenderParameters parameters);
}

View File

@@ -0,0 +1,405 @@
package Icarus.Graphics.Animation;
import System.Drawing.*;
import System.Drawing.Imaging.*;
import System.Collections.*;
/**
* The Pazera frameset provider implements the plain-image frameset format described by Ernest Pazera in the following article originally posted on Gamedev.net: http://www.gamedev.net/reference/articles/article1122.asp
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class PazeraFramesetProvider implements IFramesetProvider
{
/**
* Exports the frameset.
*/
public void exportFrameset(Frameset frameset, String filename)
{
//First, we want to figure out the dimensions of the image in frames:
int frameCount = frameset.getFrameCount();
double dimension = System.Math.Sqrt(frameCount);
int width = (int) System.Math.Ceiling(dimension);
int height = (int) System.Math.Ceiling(((double) frameCount) / ((double) width));
//Generate a matrix of frames to output:
IFrame[][] frameMatrix = new IFrame[height][width];
for (int i = 0; i < frameCount; i++)
{
frameMatrix[i / width][i % width] = frameset.getFrameAt(i);
}
for (int i = frameCount; i < width * height; i++)
{
frameMatrix[i / width][i % width] = null;
}
//Now, precalculate the dimensions of each frame, taking the anchor point into consideration:
Size[][] frameSizes = new Size[height][width];
for (int i = 0; i < frameCount; i++)
{
//Get the frame information:
Point anch = frameset.getFrameAt(i).getAnchorPoint();
Size size = frameset.getFrameAt(i).GetSize();
//Adjust the size by the anchor point:
if (anch.get_X() < 0) { size.set_Width(size.get_Width() - anch.get_X()); }
else if (anch.get_X() >= size.get_Width()) { size.set_Width(anch.get_X() + 1); }
if (anch.get_Y() < 0) { size.set_Height(size.get_Height() - anch.get_Y()); }
else if (anch.get_Y() >= size.get_Height()) { size.set_Height(anch.get_Y() + 1); }
frameSizes[i / width][i % width] = size;
}
for (int i = frameCount; i < width * height; i++)
{
frameSizes[i / width][i % width] = new Size(0, 0);
}
//Compute the widths of each column:
int[] columnWidths = new int[width];
for (int i = 0; i < width; i++)
{
int w = 0;
for (int j = 0; j < height; j++)
{
if (w < frameSizes[j][i].get_Width())
{
w = frameSizes[j][i].get_Width();
}
}
columnWidths[i] = w;
}
//Compute the heights of each row:
int[] rowHeights = new int[height];
for (int i = 0; i < height; i++)
{
int h = 0;
for (int j = 0; j < width; j++)
{
if (h < frameSizes[i][j].get_Height())
{
h = frameSizes[i][j].get_Height();
}
}
rowHeights[i] = h;
}
//Compute the total dimension of the image:
int imageWidth = 1;
for (int i = 0; i < width; i++) { imageWidth += columnWidths[i] + 1; }
int imageHeight = 1;
for (int i = 0; i < height; i++) { imageHeight += rowHeights[i] + 1; }
//Generate the rectangles corresponding to each frame:
Rectangle[] frameRectangles = new Rectangle[frameCount];
for (int i = 0; i < frameCount; i++)
{
int row = i / width;
int col = i % width;
int x = 1;
if (col > 0) { x += frameRectangles[i - 1].get_Right(); }
int y = 1;
if (row > 0) { y += frameRectangles[i - width].get_Bottom(); }
frameRectangles[i] = new Rectangle(x, y, columnWidths[col], rowHeights[row]);
}
//Sahweet, now we can start making the image:
Bitmap output = new Bitmap(imageWidth, imageHeight);
Graphics g = Graphics.FromImage(output);
//Set up control colors:
Color colorBound = Color.FromArgb(255, 0, 255);
Color colorInside = Color.FromArgb(0, 255, 0);
Color colorAnchor = Color.FromArgb(0, 255, 255);
Color colorOutside = Color.FromArgb(255, 255, 255);
//Paint background with the bounds color:
Brush outsideBrush = new SolidBrush(colorOutside);
Brush boundBrush = new SolidBrush(colorBound);
g.FillRectangle(boundBrush, 0, 0, imageWidth, imageHeight);
//Iterate through the rectangles and paint images and their control patterns:
for (int i = 0; i < frameCount; i++)
{
IFrame cf = frameset.getFrameAt(i);
Point anchor = cf.getAnchorPoint();
Bitmap img = cf.getFrameImage();
int x = frameRectangles[i].get_X();
int y = frameRectangles[i].get_Y();
int startx = x;
int starty = y;
int anchx = x;
int anchy = y;
if (anchor.get_X() < 0)
{
startx -= anchor.get_X();
}
else
{
anchx += anchor.get_X();
}
if (anchor.get_Y() < 0)
{
starty -= anchor.get_Y();
}
else
{
anchy += anchor.get_Y();
}
//Paint inside / outside:
//Horizontal:
for (int j = x; j < startx; j++) { output.SetPixel(j, y - 1, colorOutside); }
for (int j = startx; j < startx + img.get_Width(); j++) { output.SetPixel(j, y - 1, colorInside); }
for (int j = startx + img.get_Width(); j < x + columnWidths[i % width]; j++) { output.SetPixel(j, y - 1, colorOutside); }
//Vertical:
for (int j = y; j < starty; j++) { output.SetPixel(x - 1, j, colorOutside); }
for (int j = starty; j < starty + img.get_Height(); j++) { output.SetPixel(x - 1, j, colorInside); }
for (int j = starty + img.get_Height(); j < y + rowHeights[i / width]; j++) { output.SetPixel(x - 1, j, colorOutside); }
//Paint anchor points:
output.SetPixel(anchx, y - 1, colorAnchor);
output.SetPixel(x - 1, anchy, colorAnchor);
//Render actual image:
g.DrawImage(img, startx, starty);
}
//Render the remaining, unfilled frames:
Rectangle previousRect = frameRectangles[frameCount - 1];
for (int i = frameCount; i < width * height; i++)
{
Rectangle curr = new Rectangle(previousRect.get_Right() + 1, previousRect.get_Top(), columnWidths[i % height], previousRect.get_Height());
g.FillRectangle(outsideBrush, curr.get_X() - 1, curr.get_Y(), 1, curr.get_Height());
g.FillRectangle(outsideBrush, curr.get_Left(), curr.get_Y() - 1, curr.get_Width(), 1);
}
//Now we also need to render right-most blank lines:
for (int i = 0; i < width; i++)
{
Rectangle cr = frameRectangles[i];
for (int j = cr.get_X(); j < cr.get_Right(); j++) { output.SetPixel(j, imageHeight - 1, colorOutside); }
}
for (int i = 0; i < height; i++)
{
Rectangle cr = frameRectangles[i * width];
for (int j = cr.get_Y(); j < cr.get_Bottom(); j++) { output.SetPixel(imageWidth - 1, j, colorOutside); }
}
//Also, render the control structure:
output.SetPixel(imageWidth - 1, 1, colorInside);
output.SetPixel(imageWidth - 1, 2, colorAnchor);
//Remove ugly pink:
//output.MakeTransparent(colorBound);
//Save the image:
String[] fileparts = filename.Split(new char[] {'.'});
String extension = fileparts[fileparts.length - 1];
ImageFormat fmt = ImageFormat.get_Bmp();
if (extension.equalsIgnoreCase("gif")) { fmt = ImageFormat.get_Gif(); }
else if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")) { fmt = ImageFormat.get_Jpeg(); }
else if (extension.equalsIgnoreCase("png")) { fmt = ImageFormat.get_Png(); }
output.Save(filename, fmt);
}
/**
* Goes through the image and extracts frames from it.
*/
public void fillFrameset(Frameset frameSet, Bitmap source)
{
//Initialize the control colors:
ControlColors colors = new ControlColors(source);
//Find frame bounds.
IList v_bounds = findVerticalBounds(source, colors);
IList h_bounds = findHorizontalBounds(source, colors);
//Make rectangles that denote the bounds:
IList rectangles = boundsToRectangles(h_bounds, v_bounds);
IEnumerator i = rectangles.GetEnumerator();
while (i.MoveNext())
{
Rectangle r = (Rectangle) i.get_Current();
Rectangle realBounds = findRealBounds(source, colors, r);
//if (realBounds.get_IsEmpty()) { continue; }
if (realBounds.get_Width() < 1 || realBounds.get_Height() < 1) { continue; }
Point anchor = findAnchor(source, colors, r);
//Adjust anchor coordinates to the current frame reference:
anchor.set_X(anchor.get_X() - realBounds.get_X());
anchor.set_Y(anchor.get_Y() - realBounds.get_Y());
Bitmap frame = extractFrame(source, colors, realBounds);
frame.MakeTransparent(colors.bound);
frameSet.addFrame(frame, anchor);
}
}
private IList findVerticalBounds(Bitmap source, ControlColors colors)
{
IList result = new ArrayList();
int width = source.get_Width();
int index = 0;
while (index < width)
{
index = firstHorizontalInstance(source, colors.bound, index, width, 0);
result.Add(new Integer(index));
index++;
}
return result;
}
private IList findHorizontalBounds(Bitmap source, ControlColors colors)
{
IList result = new ArrayList();
int height = source.get_Height();
int index = 0;
while (index < height)
{
index = firstVerticalInstance(source, colors.bound, index, height, 0);
result.Add(new Integer(index));
index++;
}
return result;
}
/**
* Goes through the y-th row of the image, looking at x from start to stop, exclusive, and returns the first instance of color c, or stop if there is no such color in the row in the range.
*/
private int firstHorizontalInstance(Bitmap source, Color c, int start, int stop, int y)
{
int index = 0;
for (index = start; index < stop; index++)
{
if (source.GetPixel(index, y).Equals(c))
{
break;
}
}
return index;
}
/**
* Goes through the x-th column of the image, looking at y from start to stop, exclusive, and returns the first instance of color c, or stop if there is no such color in the column in the range.
*/
private int firstVerticalInstance(Bitmap source, Color c, int start, int stop, int x)
{
int index = 0;
for (index = start; index < stop; index++)
{
if (source.GetPixel(x, index).Equals(c))
{
break;
}
}
return index;
}
private IList boundsToRectangles(IList horizontal, IList vertical)
{
IList result = new ArrayList();
for (int row = 0; row < horizontal.get_Count() - 1; row ++)
{
for (int col = 0; col < vertical.get_Count() - 1; col ++)
{
int left = ((Integer) vertical.get_Item(col)).intValue();
int right = ((Integer) vertical.get_Item(col + 1)).intValue();
int top = ((Integer) horizontal.get_Item(row)).intValue();
int bottom = ((Integer) horizontal.get_Item(row + 1)).intValue();
result.Add(new Rectangle(left, top, right - left, bottom - top));
}
}
return result;
}
private Point findAnchor(Bitmap source, ControlColors colors, Rectangle reference)
{
int x = firstHorizontalInstance(source, colors.anchor, reference.get_Left(), reference.get_Right(), reference.get_Top());
int y = firstVerticalInstance(source, colors.anchor, reference.get_Top(), reference.get_Bottom(), reference.get_Left());
return new Point(x, y);
}
private Bitmap extractFrame(Bitmap source, ControlColors colors, Rectangle reference)
{
//Make new result image:
Bitmap result = new Bitmap(reference.get_Width(), reference.get_Height());
//Make graphics so we can render onto the image:
Graphics g = Graphics.FromImage(result);
//Render:
g.DrawImage(
source,
new Rectangle(0, 0, reference.get_Width(), reference.get_Height()),
reference,
GraphicsUnit.Pixel
);
// g.DrawImage(source, -reference.get_X(), -reference.get_Y(), reference.get_Width(), reference.get_Height());
// DrawImage(source, -reference.get_X(), -reference.get_Y());
return result;
}
private Rectangle findRealBounds(Bitmap source, ControlColors colors, Rectangle reference)
{
int left = firstHorizontalInstance(source, colors.inside, reference.get_Left(), reference.get_Right(), reference.get_Top());
int top = firstVerticalInstance(source, colors.inside, reference.get_Top(), reference.get_Bottom(), reference.get_Left());
int right = firstHorizontalInstance(source, colors.outside, left, reference.get_Right(), reference.get_Top());
int bottom = firstVerticalInstance(source, colors.outside, top, reference.get_Bottom(), reference.get_Left());
return new Rectangle(left, top, right - left, bottom - top);
}
/**
* This is just a little struct-like thing to simplify passing around the control colors.
*/
private class ControlColors
{
public Color bound;
public Color inside;
public Color anchor;
public Color outside;
public ControlColors(Bitmap img)
{
int width = img.get_Width();
bound = img.GetPixel(width - 1, 0);
inside = img.GetPixel(width - 1, 1);
anchor = img.GetPixel(width - 1, 2);
outside = img.GetPixel(width - 1, 3);
}
}
}

View File

@@ -0,0 +1,43 @@
package Icarus.Graphics.Animation;
import System.Drawing.*;
import System.Drawing.Imaging.*;
import System.IO.*;
/**
* This frameset provider simply goes through the frames of an animated image and adds them to the frameset. Basically, this one is good for things like animated GIFs.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class SimpleFramesetProvider implements IFramesetProvider
{
/**
* Goes through the image and extracts frames from it.
*/
public void fillFrameset(Frameset frameSet, Bitmap source)
{
//Get frame count:
FrameDimension fd = new FrameDimension(source.get_FrameDimensionsList()[0]);
int frameCount = source.GetFrameCount(fd.get_Time());
//Save the frames:
for (int i = 0; i < frameCount; i++)
{
MemoryStream stream = new MemoryStream();
source.SelectActiveFrame(fd, i);
source.Save(stream, ImageFormat.get_Bmp());
frameSet.addFrame(((Bitmap) Bitmap.FromStream(stream)), new Point(0, 0));
}
}
/**
* Exports the frame as an animated gif.
*/
public void exportFrameset(Frameset frameset, String filename) throws System.Exception
{
throw new System.NotImplementedException("Sorry, but at this point, .NET cannot generate animated GIFs. Please try one of the other Frameset Providers.");
}
}

View File

@@ -0,0 +1,66 @@
package Icarus.Graphics.Animation;
import System.Drawing.Rectangle;
import System.Drawing.Size;
/**
* This thingey will render and grid of child renderables, where the count of the renderables depends on the GridSize property.
*/
public class TiledFrame extends AbstractRenderable
{
/**
* The size of the tiled frame. Basically, this is the number of times the frame will be tiled.
*/
private Size mGridSize;
/**
* This is the renderable that will be tiled.
*/
private IRenderable mChildRenderable;
/** @property */
public Size get_GridSize() { return mGridSize; }
/** @property */
public void set_GridSize(Size v) { mGridSize = v; }
/** @property */
public IRenderable get_ChildRenderable() { return mChildRenderable; }
/** @property */
public void set_ChildRenderable(IRenderable v) { mChildRenderable = v; }
/**
* Returns the size of the renderable.
*/
public Size GetSize()
{
Size result = this.get_ChildRenderable().GetSize();
result.set_Width(result.get_Width() * this.get_GridSize().get_Width());
result.set_Height(result.get_Height() * this.get_GridSize().get_Height());
return result;
}
/**
* Renders the thing. Note that the destination parameter can be used to specify clipping. The size of the rectangle can be empty, in which case no clipping will be applied.
*/
public void Render(Rectangle destination, IRenderParameters parameters)
{
for (int r = 0; r < this.get_GridSize().get_Height(); r++)
{
int yoffset = this.get_ChildRenderable().GetSize().get_Height() * r;
destination.set_Y(destination.get_Y() + yoffset);
for (int c = 0; c < this.get_GridSize().get_Width(); c++)
{
int xoffset = this.get_ChildRenderable().GetSize().get_Width() * c;
destination.set_X(destination.get_X() + xoffset);
this.get_ChildRenderable().Render(destination, parameters);
destination.set_X(destination.get_X() - xoffset);
}
destination.set_Y(destination.get_Y() - yoffset);
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public abstract class AbstractFrame
: AbstractRenderable, IFrame
{
#region IFrame
public abstract Bitmap getFrameImage();
#endregion
#region IRenderable
//public abstract void Render(System.Drawing.Point coordinates, IRenderParameters parameters);
//public abstract void Render(System.Drawing.Rectangle destination, IRenderParameters parameters);
#endregion
/**
* This is the anchor point used for the frame.
*/
private Point m_AnchorPoint = new Point(0, 0);
/**
* This is the size of the frame.
*/
private Size m_FrameSize = new Size(0, 0);
/**
* Returns the anchor point of the frame.
*/
public Point getAnchorPoint()
{
return m_AnchorPoint;
}
/**
* Sets up a new anchor point.
*/
public void setAnchorPoint(Point p)
{
m_AnchorPoint = p;
}
/**
* Initializes the frame using the anchor point and bitmap
* passed in, and returns true if the initialization went
* through successfully, and false if it did not.
*/
public bool initialize(Point anchor, Bitmap image)
{
this.setAnchorPoint(anchor);
this.m_FrameSize.Width = image.Width;
this.m_FrameSize.Height = image.Height;
return this.initializeFromBitmap(image);
}
/**
* Will return the size of the frame.
*/
public override Size GetSize()
{
return m_FrameSize;
}
public abstract bool initializeFromBitmap(Bitmap image);
}
}

View File

@@ -0,0 +1,18 @@
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public abstract class AbstractRenderable
: IRenderable
{
#region IRenderable
public abstract System.Drawing.Size GetSize();
public abstract void Render(System.Drawing.Rectangle destination, IRenderParameters parameters);
#endregion
public void Render(Point coordinates, IRenderParameters parameters)
{
this.Render(new Rectangle(coordinates, Size.Empty), parameters);
}
}
}

View File

@@ -0,0 +1,73 @@
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public abstract class AbstractText
: AbstractRenderable
{
public static System.Drawing.Graphics DefaultGraphics = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1));
private string mText = null;
private Color mColor = Color.Black;
private Font mFont = null;
public AbstractText()
: this("")
{ }
public AbstractText(string text)
: this(text, Color.Black)
{ }
public AbstractText(string text, Color c)
: this(text, c, new Font(FontFamily.GenericSansSerif.Name, 12))
{ }
/**
* Creates a new instance of the abstract text.
*/
public AbstractText(string text, Color c, Font f)
{
mText = text;
mColor = c;
mFont = f;
UpdateText();
}
public string GetText() { return mText; }
public void SetText(string text)
{
mText = text;
UpdateText();
}
public Color GetColor() { return mColor; }
public void SetColor(Color color)
{
mColor = color;
UpdateText();
}
public Font GetFont() { return mFont; }
public void SetFont(Font font)
{
mFont = font;
UpdateText();
}
/**
* Returns the size of the text in pixels.
*/
public override Size GetSize()
{
System.Drawing.SizeF fsize = AbstractText.DefaultGraphics.MeasureString(this.GetText(), this.GetFont());
return new Size((int) fsize.Width, (int) fsize.Height);
}
/**
* Updates the text. This will be called any time the text itself, or the color or the font is changed.
*/
public abstract void UpdateText();
}
}

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{768BFC0C-09DE-479D-8A79-343390A1EB2E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Icarus.Graphics.Animation</RootNamespace>
<AssemblyName>Animation</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractFrame.cs" />
<Compile Include="AbstractRenderable.cs" />
<Compile Include="AbstractText.cs" />
<Compile Include="AnimationFactory.cs" />
<Compile Include="AnimationType.cs" />
<Compile Include="Frameset.cs" />
<Compile Include="FramesetAnimation.cs" />
<Compile Include="FramesetManager.cs" />
<Compile Include="GDI\GDIAnimationFactory.cs" />
<Compile Include="GDI\GDIFrame.cs" />
<Compile Include="GDI\GDIRenderParameters.cs" />
<Compile Include="IFrame.cs" />
<Compile Include="IFramesetProvider.cs" />
<Compile Include="IRenderable.cs" />
<Compile Include="IRenderParameters.cs" />
<Compile Include="PazeraFramesetProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleFramesetProvider.cs" />
<Compile Include="TiledFrame.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\Resources\Resources.csproj">
<Project>{592de8ce-998e-436c-940b-11ee84b2beac}</Project>
<Name>Resources</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,26 @@
namespace Icarus.Graphics.Animation
{
public abstract class AnimationFactory
{
/**
* Singleton Implementation.
*/
private static AnimationFactory mg_Instance = null;
/**
* Singleton Implementation.
*/
public static AnimationFactory getInstance() { return mg_Instance; }
public static void setInstance(AnimationFactory factory) { mg_Instance = factory; }
/**
* Returns a blank frame.
*/
public abstract IFrame makeBlankFrame();
/**
* Returns blank text.
*/
public abstract AbstractText makeText(string text, System.Drawing.Color c, System.Drawing.Font f);
}
}

View File

@@ -0,0 +1,31 @@
namespace Icarus.Graphics.Animation
{
public class AnimationType
{
/**
* Denotes that the animation is static.
*/
public static AnimationType None = new AnimationType("None");
/**
* The animation loops through once, and freezes at the last frame.
*/
public static AnimationType LoopOnce = new AnimationType("LoopOnce");
/**
* The animation will loop forever.
*/
public static AnimationType LoopForever = new AnimationType("LoopForever");
private string name;
private AnimationType(string n) { name = n; }
public override string ToString() { return name; }
public static AnimationType FromString(string v)
{
if (v.Equals("LoopOnce")) return AnimationType.LoopOnce;
else if (v.Equals("LoopForever")) return AnimationType.LoopForever;
else return AnimationType.None;
}
}
}

View File

@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public class Frameset
{
/**
* The list of frames in this frameset.
*/
private List<IFrame> m_FrameList;
/**
* Performs some necessary initialization.
*/
public Frameset()
{
m_FrameList = new List<IFrame>();
}
/**
* Returns the number of frames in the frameset.
*/
public int getFrameCount()
{
return m_FrameList.Count;
}
/**
* Adds a new frame to the frameset and returns the current number of frames in the frameset.
*/
public int addFrame(IFrame frame)
{
m_FrameList.Add(frame);
return this.getFrameCount();
}
/**
* Adds a new frame to the frameset and returns the current number of frames in the frameset.
*/
public int addFrame(Bitmap img, Point anchor)
{
IFrame new_frame = AnimationFactory.getInstance().makeBlankFrame();
new_frame.initialize(anchor, img);
return this.addFrame(new_frame);
}
/**
* Returns the frame at the specified index.
*/
public IFrame getFrameAt(int index)
{
return m_FrameList[index];
}
}
}

View File

@@ -0,0 +1,171 @@
namespace Icarus.Graphics.Animation
{
public class FramesetAnimation
{
/**
* The path where the animation was loaded from.
*/
private string m_FramesetPath;
/**
* The set of frames used for the animation.
*/
private Frameset m_Frameset;
/**
* The looping type of the animation.
*/
private AnimationType m_AnimationType;
/**
* The delay, in abstract time units, between the frames of the animation.
*/
private long m_AnimationDelay;
/**
* The index of the currently displayed frame in the animation.
*/
private int m_CurrentFrameIndex;
/**
* If we receive an update message and it is not time yet to update the frame, then we can just add to the cumulative delay over here, and check the correct number next time around.
*/
private long m_CumulativeDelay;
/**
* Sets up a blank frameset animation.
*/
public FramesetAnimation()
{
this.AnimationDelay = 1;
this.AnimationType = AnimationType.None;
}
/**
* Sets up the new frameset animation.
*/
public FramesetAnimation(Frameset frames, AnimationType loopMode, long delay)
{
this.AnimationType = loopMode;
this.setFrameset(frames);
this.AnimationDelay = delay;
}
/**
* This is just a little optimization that makes it so when the animation has only one frame, the update method won't try to do anything funny.
*/
private void processAnimationType()
{
if (m_Frameset != null && m_Frameset.getFrameCount() < 2)
{
//No reason to loop:
m_AnimationType = AnimationType.None;
}
}
/**
* Returns the frameset.
*/
public Frameset getFrameset() { return m_Frameset; }
/**
* Sets up a new frameset.
*/
protected void setFrameset(Frameset frames)
{
m_Frameset = frames;
m_CurrentFrameIndex = 0;
m_CumulativeDelay = 0;
processAnimationType();
}
public string FramesetPath
{
get { return this.m_FramesetPath; }
set
{
this.m_FramesetPath = value;
this.setFrameset(FramesetManager.getInstance().getFrameset(value));
}
}
public AnimationType AnimationType
{
get { return m_AnimationType; }
set
{
m_AnimationType = value;
processAnimationType();
}
}
public string AnimationTypeId
{
get { return this.m_AnimationType.ToString(); }
set
{
this.AnimationType = AnimationType.FromString(value);
}
}
public long AnimationDelay
{
get { return m_AnimationDelay; }
set
{
m_AnimationDelay = value;
}
}
public int CurrentFrameIndex
{
get { return m_CurrentFrameIndex; }
}
public IFrame CurrentFrame
{
get
{
return m_Frameset.getFrameAt(this.CurrentFrameIndex);
}
}
/**
* Performs an update of the animation given the delay since the previous call in abstract time units.
*/
public void update(long time)
{
if (m_AnimationType == AnimationType.None)
{
//Nothing much to do...
return;
}
m_CumulativeDelay += time;
if (m_CumulativeDelay < this.AnimationDelay)
{
//Not time yet...
return;
}
m_CumulativeDelay = 0;
int index = m_CurrentFrameIndex;
if (index >= m_Frameset.getFrameCount() - 1)
{
if (m_AnimationType == AnimationType.LoopForever)
{
index++;
index %= m_Frameset.getFrameCount();
}
}
else
{
index++;
}
m_CurrentFrameIndex = index;
}
}
}

View File

@@ -0,0 +1,95 @@
using System.Collections;
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public class FramesetManager
{
/**
* Singleton Implementation.
*/
private static FramesetManager mg_Instance = new FramesetManager();
/**
* Maps strings to frameset references.
*/
private IDictionary m_Framesets; //TODO: Maybe use soft references here, to provide caching.
/**
* The default frameset provider to use.
*/
private IFramesetProvider m_DefaultFramesetProvider;
/**
* Singleton Implementation.
*/
private FramesetManager()
{
m_Framesets = new Hashtable();
m_DefaultFramesetProvider = new PazeraFramesetProvider();
}
/**
* Singleton Implementation.
*/
public static FramesetManager getInstance() { return mg_Instance; }
/**
* Sets up the new default frameset provider.
*/
public void setDefaultFramesetProvider(IFramesetProvider provider) { m_DefaultFramesetProvider = provider; }
/**
* Returns the frameset with the specified ID. If the frameset cannot be loaded, will probably throw an exception.
*/
public Frameset getFrameset(string id)
{
if (!m_Framesets.Contains(id))
{
this.loadFramesetFromId(id, null);
}
return (Frameset)m_Framesets[id];
}
/**
* Adds the frameset with the specified id. If a frameset with that id already exists, it is overwritten.
*/
public void addFrameset(string id, Frameset frameset)
{
m_Framesets.Add(id, frameset);
}
/**
* Uses the id passed in as the filename to look for the image in the base image folder.
*/
public void loadFramesetFromId(string id, IFramesetProvider provider)
{
this.loadFramesetFromFile(Icarus.Resources.ResourceManager.Instance.ImagePath + id, id, provider);
}
/**
* Loads the frameset with the specified id from the full path passed in using the specified frameset provider.
*/
public void loadFramesetFromFile(string filename, string id, IFramesetProvider provider)
{
if (provider == null)
{
provider = m_DefaultFramesetProvider;
}
Frameset new_set = new Frameset();
provider.fillFrameset(new_set, (Bitmap)Bitmap.FromFile(filename));
this.addFrameset(id, new_set);
}
/**
* Given an id of an image, loads it.
*/
public Bitmap loadImageFromId(string id)
{
return (Bitmap)Bitmap.FromFile(Icarus.Resources.ResourceManager.Instance.ImagePath + id);
}
}
}

View File

@@ -0,0 +1,29 @@
using Icarus.Graphics.Animation;
using System;
namespace Icarus.Graphics.Animation.GDI
{
/**
* Allows for animation using GDI.
*/
public class GDIAnimationFactory
: AnimationFactory
{
/**
* Returns a blank frame.
*/
public override IFrame makeBlankFrame()
{
return new GDIFrame();
}
/**
* Returns blank text.
*/
public override AbstractText makeText(string text, System.Drawing.Color c, System.Drawing.Font f)
{
throw new Exception("Text rendering for GDI is not implemented, because it hasn't been needed yet.");
}
}
}

View File

@@ -0,0 +1,88 @@
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.Graphics.Animation.GDI
{
/**
* This is a frame that can be rendered on a GDI control, such as a button, or something like that.
*
* @author $Author: asskoala $
* @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
*/
public class GDIFrame
: AbstractFrame
{
/**
* The frame image...
*/
private Bitmap m_FrameImage;
/**
* Doesn't do a whole lot...
*/
public override bool initializeFromBitmap(Bitmap image)
{
m_FrameImage = image;
return (m_FrameImage != null);
}
/**
* Returns a bitmap showing the contents of the frame. This is for saving a frame to a file.
*/
public override Bitmap getFrameImage()
{
return m_FrameImage;
}
/**
* Returns the size of the renderable.
*/
public override Size GetSize()
{
return m_FrameImage.Size;
}
/**
* Returns the width of the frame image.
*/
public int getImageWidth()
{
return m_FrameImage.Width;
}
/**
* Returns the height of the frame image.
*/
public int getImageHeight()
{
return m_FrameImage.Height;
}
/**
* Will render the frame in the specified context, at the specified coordinates. Note that it is not necessarily the top-left corner of the frame that will be rendered at those coordinates, but rather the anchor point.
*/
public override void Render(Rectangle coordinates, IRenderParameters iparams)
{
GDIRenderParameters p = (GDIRenderParameters) iparams;
int x = coordinates.X - this.getAnchorPoint().X;
int y = coordinates.Y - this.getAnchorPoint().Y;
if (coordinates.Size == Size.Empty)
{
p.getGraphics().DrawImageUnscaled(m_FrameImage, x, y);
}
else
{
int width = Math.Min(m_FrameImage.Width, coordinates.Width);
int height = Math.Min(m_FrameImage.Height, coordinates.Height);
Rectangle src = new Rectangle(0, 0, width, height);
p.getGraphics().DrawImage(m_FrameImage, x, y, src, GraphicsUnit.Pixel);
}
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.Graphics.Animation.GDI
{
/**
* The render parameters needed to make render to GDI.
*/
public class GDIRenderParameters
: IRenderParameters
{
/**
* The graphics context in which we want to render the graphics.
*/
private System.Drawing.Graphics m_GraphicsContext;
/**
* Initializes the rendering parameters.
*/
public GDIRenderParameters(System.Drawing.Graphics context)
{
this.setGraphics(context);
}
/**
* Returns the graphics context.
*/
public System.Drawing.Graphics getGraphics()
{
return m_GraphicsContext;
}
/**
* Sets up the new graphics context.
*/
private void setGraphics(System.Drawing.Graphics g)
{
m_GraphicsContext = g;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace Icarus.Graphics.Animation
{
public interface IFrame
: IRenderable
{
/**
* Returns the anchor point of the frame. The anchor point is
* essentially a coordinate in the frame such that when the
* frame is rendered at some point on the screen, the point in
* the frame referenced by the anchor is actually the one put
* in that screen position - not necessarily the top-left
* corner of the frame.
*/
Point getAnchorPoint();
/**
* Initializes the frame using the anchor point and bitmap
* passed in, and returns true if the initialization went
* through successfully, and false if it did not.
*/
bool initialize(Point anchor, Bitmap image);
/**
* Returns a bitmap showing the contents of the frame. This is for saving a frame to a file.
*/
Bitmap getFrameImage();
}
}

View File

@@ -0,0 +1,25 @@
using System.Drawing;
namespace Icarus.Graphics.Animation
{
public interface IFramesetProvider
{
/**
* Goes through the image and extracts frames from it.
*/
void fillFrameset(Frameset frameSet, Bitmap source);
/**
* Will export the frameset passed in to a file, whose name is
* passed in. The export is such that it is guaranteed to be
* loadable by the corresponding fillFrameset function. Other
* than that, nothing should be assumed about the export. This
* function assumes that the filename points to a file that
* can actually be created, and if there are any problems,
* like null filename, or frameset, or premission problems
* with creating the file, an Exception will be thrown.
*/
void exportFrameset(Frameset frameset, string filename);
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Icarus.Graphics.Animation
{
public interface IRenderParameters
{
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Icarus.Graphics.Animation
{
public interface IRenderable
{
/**
* Returns the size of the renderable.
*/
System.Drawing.Size GetSize();
/**
* Renders the thing.
*/
void Render(System.Drawing.Point coordinates, IRenderParameters parameters);
/**
* Renders the thing. Note that the destination parameter can be used to specify clipping. The size of the rectangle can be empty, in which case no clipping will be applied.
*/
void Render(System.Drawing.Rectangle destination, IRenderParameters parameters);
}
}

View File

@@ -0,0 +1,401 @@
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Collections;
namespace Icarus.Graphics.Animation
{
public class PazeraFramesetProvider
: IFramesetProvider
{
/**
* Exports the frameset.
*/
public void exportFrameset(Frameset frameset, string filename)
{
//First, we want to figure out the dimensions of the image in frames:
int frameCount = frameset.getFrameCount();
double dimension = System.Math.Sqrt(frameCount);
int width = (int) System.Math.Ceiling(dimension);
int height = (int) System.Math.Ceiling(((double) frameCount) / ((double) width));
//Generate a matrix of frames to output:
IFrame[,] frameMatrix = new IFrame[height,width];
for (int i = 0; i < frameCount; i++)
{
frameMatrix[i / width,i % width] = frameset.getFrameAt(i);
}
for (int i = frameCount; i < width * height; i++)
{
frameMatrix[i / width,i % width] = null;
}
//Now, precalculate the dimensions of each frame, taking the anchor point into consideration:
Size[,] frameSizes = new Size[height,width];
for (int i = 0; i < frameCount; i++)
{
//Get the frame information:
Point anch = frameset.getFrameAt(i).getAnchorPoint();
Size size = frameset.getFrameAt(i).GetSize();
//Adjust the size by the anchor point:
if (anch.X < 0) { size.Width = size.Width - anch.X; }
else if (anch.X >= size.Width) { size.Width = anch.X + 1; }
if (anch.Y < 0) { size.Height = size.Height - anch.Y; }
else if (anch.Y >= size.Height) { size.Height = anch.Y + 1; }
frameSizes[i / width,i % width] = size;
}
for (int i = frameCount; i < width * height; i++)
{
frameSizes[i / width,i % width] = new Size(0, 0);
}
//Compute the widths of each column:
int[] columnWidths = new int[width];
for (int i = 0; i < width; i++)
{
int w = 0;
for (int j = 0; j < height; j++)
{
if (w < frameSizes[j,i].Width)
{
w = frameSizes[j,i].Width;
}
}
columnWidths[i] = w;
}
//Compute the heights of each row:
int[] rowHeights = new int[height];
for (int i = 0; i < height; i++)
{
int h = 0;
for (int j = 0; j < width; j++)
{
if (h < frameSizes[i,j].Height)
{
h = frameSizes[i,j].Height;
}
}
rowHeights[i] = h;
}
//Compute the total dimension of the image:
int imageWidth = 1;
for (int i = 0; i < width; i++) { imageWidth += columnWidths[i] + 1; }
int imageHeight = 1;
for (int i = 0; i < height; i++) { imageHeight += rowHeights[i] + 1; }
//Generate the rectangles corresponding to each frame:
Rectangle[] frameRectangles = new Rectangle[frameCount];
for (int i = 0; i < frameCount; i++)
{
int row = i / width;
int col = i % width;
int x = 1;
if (col > 0) { x += frameRectangles[i - 1].Right; }
int y = 1;
if (row > 0) { y += frameRectangles[i - width].Bottom; }
frameRectangles[i] = new Rectangle(x, y, columnWidths[col], rowHeights[row]);
}
//Sahweet, now we can start making the image:
Bitmap output = new Bitmap(imageWidth, imageHeight);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(output);
//Set up control colors:
Color colorBound = Color.FromArgb(255, 0, 255);
Color colorInside = Color.FromArgb(0, 255, 0);
Color colorAnchor = Color.FromArgb(0, 255, 255);
Color colorOutside = Color.FromArgb(255, 255, 255);
//Paint background with the bounds color:
Brush outsideBrush = new SolidBrush(colorOutside);
Brush boundBrush = new SolidBrush(colorBound);
g.FillRectangle(boundBrush, 0, 0, imageWidth, imageHeight);
//Iterate through the rectangles and paint images and their control patterns:
for (int i = 0; i < frameCount; i++)
{
IFrame cf = frameset.getFrameAt(i);
Point anchor = cf.getAnchorPoint();
Bitmap img = cf.getFrameImage();
int x = frameRectangles[i].X;
int y = frameRectangles[i].Y;
int startx = x;
int starty = y;
int anchx = x;
int anchy = y;
if (anchor.X < 0)
{
startx -= anchor.X;
}
else
{
anchx += anchor.X;
}
if (anchor.Y < 0)
{
starty -= anchor.Y;
}
else
{
anchy += anchor.Y;
}
//Paint inside / outside:
//Horizontal:
for (int j = x; j < startx; j++) { output.SetPixel(j, y - 1, colorOutside); }
for (int j = startx; j < startx + img.Width; j++) { output.SetPixel(j, y - 1, colorInside); }
for (int j = startx + img.Width; j < x + columnWidths[i % width]; j++) { output.SetPixel(j, y - 1, colorOutside); }
//Vertical:
for (int j = y; j < starty; j++) { output.SetPixel(x - 1, j, colorOutside); }
for (int j = starty; j < starty + img.Height; j++) { output.SetPixel(x - 1, j, colorInside); }
for (int j = starty + img.Height; j < y + rowHeights[i / width]; j++) { output.SetPixel(x - 1, j, colorOutside); }
//Paint anchor points:
output.SetPixel(anchx, y - 1, colorAnchor);
output.SetPixel(x - 1, anchy, colorAnchor);
//Render actual image:
g.DrawImage(img, startx, starty);
}
//Render the remaining, unfilled frames:
Rectangle previousRect = frameRectangles[frameCount - 1];
for (int i = frameCount; i < width * height; i++)
{
Rectangle curr = new Rectangle(previousRect.Right + 1, previousRect.Top, columnWidths[i % height], previousRect.Height);
g.FillRectangle(outsideBrush, curr.X - 1, curr.Y, 1, curr.Height);
g.FillRectangle(outsideBrush, curr.Left, curr.Y - 1, curr.Width, 1);
}
//Now we also need to render right-most blank lines:
for (int i = 0; i < width; i++)
{
Rectangle cr = frameRectangles[i];
for (int j = cr.X; j < cr.Right; j++) { output.SetPixel(j, imageHeight - 1, colorOutside); }
}
for (int i = 0; i < height; i++)
{
Rectangle cr = frameRectangles[i * width];
for (int j = cr.Y; j < cr.Bottom; j++) { output.SetPixel(imageWidth - 1, j, colorOutside); }
}
//Also, render the control structure:
output.SetPixel(imageWidth - 1, 1, colorInside);
output.SetPixel(imageWidth - 1, 2, colorAnchor);
//Remove ugly pink:
//output.MakeTransparent(colorBound);
//Save the image:
string[] fileparts = filename.Split(new char[] {'.'});
string extension = fileparts[fileparts.Length - 1];
ImageFormat fmt = ImageFormat.Bmp;
if (extension.Equals("gif", System.StringComparison.CurrentCultureIgnoreCase)) { fmt = ImageFormat.Gif; }
else if (extension.Equals("jpg", System.StringComparison.CurrentCultureIgnoreCase) || extension.Equals("jpeg", System.StringComparison.CurrentCultureIgnoreCase)) { fmt = ImageFormat.Jpeg; }
else if (extension.Equals("png", System.StringComparison.CurrentCultureIgnoreCase)) { fmt = ImageFormat.Png; }
output.Save(filename, fmt);
}
/**
* Goes through the image and extracts frames from it.
*/
public void fillFrameset(Frameset frameSet, Bitmap source)
{
//Initialize the control colors:
ControlColors colors = new ControlColors(source);
//Find frame bounds.
var v_bounds = findVerticalBounds(source, colors);
var h_bounds = findHorizontalBounds(source, colors);
//Make rectangles that denote the bounds:
var rectangles = boundsToRectangles(h_bounds, v_bounds);
var i = rectangles.GetEnumerator();
while (i.MoveNext())
{
Rectangle r = (Rectangle) i.Current;
Rectangle realBounds = findRealBounds(source, colors, r);
if (realBounds.Width < 1 || realBounds.Height < 1) { continue; }
Point anchor = findAnchor(source, colors, r);
//Adjust anchor coordinates to the current frame reference:
anchor.X = anchor.X - realBounds.X;
anchor.Y = anchor.Y - realBounds.Y;
Bitmap frame = extractFrame(source, colors, realBounds);
frame.MakeTransparent(colors.bound);
frameSet.addFrame(frame, anchor);
}
}
private IList findVerticalBounds(Bitmap source, ControlColors colors)
{
IList result = new ArrayList();
int width = source.Width;
int index = 0;
while (index < width)
{
index = firstHorizontalInstance(source, colors.bound, index, width, 0);
result.Add(index);
index++;
}
return result;
}
private IList findHorizontalBounds(Bitmap source, ControlColors colors)
{
IList result = new ArrayList();
int height = source.Height;
int index = 0;
while (index < height)
{
index = firstVerticalInstance(source, colors.bound, index, height, 0);
result.Add(index);
index++;
}
return result;
}
/**
* Goes through the y-th row of the image, looking at x from start to stop, exclusive, and returns the first instance of color c, or stop if there is no such color in the row in the range.
*/
private int firstHorizontalInstance(Bitmap source, Color c, int start, int stop, int y)
{
int index = 0;
for (index = start; index < stop; index++)
{
if (source.GetPixel(index, y).Equals(c))
{
break;
}
}
return index;
}
/**
* Goes through the x-th column of the image, looking at y from start to stop, exclusive, and returns the first instance of color c, or stop if there is no such color in the column in the range.
*/
private int firstVerticalInstance(Bitmap source, Color c, int start, int stop, int x)
{
int index = 0;
for (index = start; index < stop; index++)
{
if (source.GetPixel(x, index).Equals(c))
{
break;
}
}
return index;
}
private IList boundsToRectangles(IList horizontal, IList vertical)
{
IList result = new ArrayList();
for (int row = 0; row < horizontal.Count - 1; row ++)
{
for (int col = 0; col < vertical.Count - 1; col ++)
{
int left = (int) vertical[col];
int right = (int) vertical[col + 1];
int top = (int)horizontal[row];
int bottom = (int)horizontal[row + 1];
result.Add(new Rectangle(left, top, right - left, bottom - top));
}
}
return result;
}
private Point findAnchor(Bitmap source, ControlColors colors, Rectangle reference)
{
int x = firstHorizontalInstance(source, colors.anchor, reference.Left, reference.Right, reference.Top);
int y = firstVerticalInstance(source, colors.anchor, reference.Top, reference.Bottom, reference.Left);
return new Point(x, y);
}
private Bitmap extractFrame(Bitmap source, ControlColors colors, Rectangle reference)
{
//Make new result image:
Bitmap result = new Bitmap(reference.Width, reference.Height);
//Make graphics so we can render onto the image:
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(result);
//Render:
g.DrawImage(
source,
new Rectangle(0, 0, reference.Width, reference.Height),
reference,
GraphicsUnit.Pixel
);
// g.DrawImage(source, -reference.X, -reference.Y, reference.Width, reference.Height);
// DrawImage(source, -reference.X, -reference.Y);
return result;
}
private Rectangle findRealBounds(Bitmap source, ControlColors colors, Rectangle reference)
{
int left = firstHorizontalInstance(source, colors.inside, reference.Left, reference.Right, reference.Top);
int top = firstVerticalInstance(source, colors.inside, reference.Top, reference.Bottom, reference.Left);
int right = firstHorizontalInstance(source, colors.outside, left, reference.Right, reference.Top);
int bottom = firstVerticalInstance(source, colors.outside, top, reference.Bottom, reference.Left);
return new Rectangle(left, top, right - left, bottom - top);
}
/**
* This is just a little struct-like thing to simplify passing around the control colors.
*/
private class ControlColors
{
public Color bound;
public Color inside;
public Color anchor;
public Color outside;
public ControlColors(Bitmap img)
{
int width = img.Width;
bound = img.GetPixel(width - 1, 0);
inside = img.GetPixel(width - 1, 1);
anchor = img.GetPixel(width - 1, 2);
outside = img.GetPixel(width - 1, 3);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Animation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Animation")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("768bfc0c-09de-479d-8a79-343390a1eb2e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,36 @@
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
namespace Icarus.Graphics.Animation
{
public class SimpleFramesetProvider
: IFramesetProvider
{
public void fillFrameset(Frameset frameSet, Bitmap source)
{
//Get frame count:
FrameDimension fd = new FrameDimension(source.FrameDimensionsList[0]);
int frameCount = source.GetFrameCount(FrameDimension.Time);
//Save the frames:
for (int i = 0; i < frameCount; i++)
{
MemoryStream stream = new MemoryStream();
source.SelectActiveFrame(fd, i);
source.Save(stream, ImageFormat.Bmp);
frameSet.addFrame(((Bitmap) Bitmap.FromStream(stream)), new Point(0, 0));
}
}
/**
* Exports the frame as an animated gif.
*/
public void exportFrameset(Frameset frameset, string filename)
{
throw new System.NotImplementedException("Sorry, but at this point, .NET cannot generate animated GIFs. Please try one of the other Frameset Providers.");
}
}
}

View File

@@ -0,0 +1,71 @@
using System.Drawing;
namespace Icarus.Graphics.Animation
{
/**
* This thingey will render and grid of child renderables, where the count of the renderables depends on the GridSize property.
*/
public class TiledFrame
: AbstractRenderable
{
/**
* The size of the tiled frame. Basically, this is the number of times the frame will be tiled.
*/
private Size mGridSize;
/**
* This is the renderable that will be tiled.
*/
private IRenderable mChildRenderable;
/** @property */
public Size GridSize
{
get { return mGridSize; }
set { mGridSize = value; }
}
/** @property */
public IRenderable ChildRenderable
{
get { return mChildRenderable; }
set { mChildRenderable = value; }
}
/**
* Returns the size of the renderable.
*/
public override Size GetSize()
{
Size result = this.ChildRenderable.GetSize();
result.Width = result.Width * this.GridSize.Width;
result.Height = result.Height * this.GridSize.Height;
return result;
}
/**
* Renders the thing. Note that the destination parameter can be used to specify clipping. The size of the rectangle can be empty, in which case no clipping will be applied.
*/
public override void Render(Rectangle destination, IRenderParameters parameters)
{
for (int r = 0; r < this.GridSize.Height; r++)
{
int yoffset = this.ChildRenderable.GetSize().Height * r;
destination.Y = destination.Y + yoffset;
for (int c = 0; c < this.GridSize.Width; c++)
{
int xoffset = this.ChildRenderable.GetSize().Width * c;
destination.X = destination.X + xoffset;
this.ChildRenderable.Render(destination, parameters);
destination.X = destination.X - xoffset;
}
destination.Y = destination.Y - yoffset;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,49 @@
using System;
namespace Icarus.Input {
/// <summary>
/// BoundAction is an action associated with a given
/// key or button on an input device.
/// </summary>
public class BoundAction {
#region Instance Variables
/// <summary>
/// Name of the button or key this bound action will be applied to.
/// </summary>
private string keyname = null;
/// <summary>
/// The action to be done when the button or key is pressed.
/// </summary>
private string action = null;
#endregion
#region Initialization
/// <summary>
/// Constructor for a BoundAction.
/// </summary>
/// <param name="name">Name of the button or key to be mapped.</param>
/// <param name="boundAction">Action to be assigned to the given key.</param>
public BoundAction(string name, string boundAction) {
keyname = name;
action = boundAction;
}
#endregion
#region Accessors/Modifiers
/// <summary>
/// Accessor for keyname.
/// </summary>
public string gs_keyname {
get { return keyname; }
}
/// <summary>
/// Accessor/Modifer for action.
/// </summary>
public string gs_action {
get { return action; }
set { action = value; }
}
#endregion
}
}

View File

@@ -0,0 +1,84 @@
using System;
namespace Icarus.Input.ButtonEvents {
/// <summary>
/// Stores event information for when a button is pressed on a device.
/// </summary>
public class ButtonPressEvent {
#region Instance Variables
/// <summary>
/// Name of the button or key that was pressed.
/// </summary>
private string buttonName = string.Empty;
/// <summary>
/// Initial button state for when a button or key has been pressed.
/// </summary>
private bool buttonPressed = false;
/// <summary>
/// Button state for when a button has been depressed and held down.
/// </summary>
private bool buttonDown = false;
/// <summary>
/// Final button state for when a button has been released.
/// </summary>
private bool buttonReleased = false;
#endregion
#region Accessors and Modifiers
/// <summary>
/// The name of the button or key that was pressed.
/// </summary>
public string Name {
get { return buttonName; }
set { buttonName = value; }
}
/// <summary>
/// Whether or not the button or key was just pressed.
/// </summary>
public bool Pressed {
get { return buttonPressed; }
set { buttonPressed = value; }
}
/// <summary>
/// Whether or not the button or key is being held down.
/// </summary>
public bool Down {
get { return buttonDown; }
set { buttonDown = value; }
}
/// <summary>
/// Whether or not the button or key was just released.
/// </summary>
public bool Released {
get { return buttonReleased; }
set { buttonReleased = value; }
}
#endregion
#region General Use
/// <summary>
/// Overridden string representation of this object.
/// </summary>
/// <returns>String representation of this object.</returns>
public override string ToString() {
string state = string.Empty;
if (buttonPressed) {
state = "Pressed";
} else if (buttonDown) {
state = "Down";
} else if (buttonReleased) {
state = "Released";
}
return buttonName + " " + state;
}
#endregion
}
}

View File

@@ -0,0 +1,25 @@
using System;
namespace Icarus.Input.ButtonEvents {
/// <summary>
/// Stores event information for when a button is pressed on a joystick.
/// </summary>
public class JoystickButtonPressEvent : ButtonPressEvent {
/// <summary>
/// Creates a new JoystickButtonPressEvent.
/// </summary>
/// <param name="name">Name of the joystick button that was pressed.</param>
/// <param name="pressed">Whether or not this button was just pressed.</param>
/// <param name="down">Whether or not this button is being held down.</param>
/// <param name="released">Whether or not this button was just released.</param>
public JoystickButtonPressEvent(string name, bool pressed, bool down, bool released) {
this.Name = name;
this.Pressed = pressed;
this.Down = down;
this.Released = released;
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
namespace Icarus.Input.ButtonEvents {
/// <summary>
/// Stores event information for when a key is pressed on a keyboard.
/// </summary>
public class KeyboardButtonPressEvent : ButtonPressEvent {
/// <summary>
/// Creates a new KeyboardButtonPressEvent.
/// </summary>
/// <param name="name">Name of the keyboard key that was pressed.</param>
/// <param name="pressed">Whether or not this key was just pressed.</param>
/// <param name="down">Whether or not this key is being held down.</param>
/// <param name="released">Whether or not this key was just released.</param>
public KeyboardButtonPressEvent(string name, bool pressed, bool down, bool released) {
this.Name = name;
this.Pressed = pressed;
this.Down = down;
this.Released = released;
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
namespace Icarus.Input.ButtonEvents {
/// <summary>
/// Stores event information for when a button is pressed on a mouse.
/// </summary>
public class MouseButtonPressEvent : ButtonPressEvent {
/// <summary>
/// Creates a new MouseButtonPressEvent.
/// </summary>
/// <param name="name">Name of the mouse button that was pressed.</param>
/// <param name="pressed">Whether or not this button was just pressed.</param>
/// <param name="down">Whether or not this button is being held down.</param>
/// <param name="released">Whether or not this button was just released.</param>
public MouseButtonPressEvent(string name, bool pressed, bool down, bool released) {
this.Name = name;
this.Pressed = pressed;
this.Down = down;
this.Released = released;
}
}
}

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>7.10.3077</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7BAAA06F-5B67-417E-9A36-26C5C6EB931C}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>App.ico</ApplicationIcon>
<AssemblyKeyContainerName />
<AssemblyName>Icarus.Input</AssemblyName>
<AssemblyOriginatorKeyFile />
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>Input</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE;DEBUG;DISABLE_JOYSTICK</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE;DISABLE_JOYSTICK</DefineConstants>
<DocumentationFile>Input.xml</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.4.2.0\lib\net40\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DirectInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.DirectInput.4.2.0\lib\net40\SharpDX.DirectInput.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BoundAction.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ButtonEvents\ButtonPressEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ButtonEvents\JoystickButtonPressEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ButtonEvents\KeyboardButtonPressEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ButtonEvents\MouseButtonPressEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="InputEngine.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="InputSettings.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="InputTester.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MovementEvents\JoystickMovementEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MovementEvents\MouseMovementEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MovementEvents\MovementEvent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="QueueEventSorter.cs">
<SubType>Code</SubType>
</Compile>
<Content Include="App.ico" />
<EmbeddedResource Include="InputTester.resx">
<DependentUpon>InputTester.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,632 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Icarus.Input</name>
</assembly>
<members>
<member name="T:Icarus.Input.ButtonEvents.ButtonPressEvent">
<summary>
Stores event information for when a button is pressed on a device.
</summary>
</member>
<member name="F:Icarus.Input.ButtonEvents.ButtonPressEvent.buttonName">
<summary>
Name of the button or key that was pressed.
</summary>
</member>
<member name="F:Icarus.Input.ButtonEvents.ButtonPressEvent.buttonPressed">
<summary>
Initial button state for when a button or key has been pressed.
</summary>
</member>
<member name="F:Icarus.Input.ButtonEvents.ButtonPressEvent.buttonDown">
<summary>
Button state for when a button has been depressed and held down.
</summary>
</member>
<member name="F:Icarus.Input.ButtonEvents.ButtonPressEvent.buttonReleased">
<summary>
Final button state for when a button has been released.
</summary>
</member>
<member name="M:Icarus.Input.ButtonEvents.ButtonPressEvent.ToString">
<summary>
Overridden string representation of this object.
</summary>
<returns>String representation of this object.</returns>
</member>
<member name="P:Icarus.Input.ButtonEvents.ButtonPressEvent.Name">
<summary>
The name of the button or key that was pressed.
</summary>
</member>
<member name="P:Icarus.Input.ButtonEvents.ButtonPressEvent.Pressed">
<summary>
Whether or not the button or key was just pressed.
</summary>
</member>
<member name="P:Icarus.Input.ButtonEvents.ButtonPressEvent.Down">
<summary>
Whether or not the button or key is being held down.
</summary>
</member>
<member name="P:Icarus.Input.ButtonEvents.ButtonPressEvent.Released">
<summary>
Whether or not the button or key was just released.
</summary>
</member>
<member name="T:Icarus.Input.ButtonEvents.JoystickButtonPressEvent">
<summary>
Stores event information for when a button is pressed on a joystick.
</summary>
</member>
<member name="M:Icarus.Input.ButtonEvents.JoystickButtonPressEvent.#ctor(System.String,System.Boolean,System.Boolean,System.Boolean)">
<summary>
Creates a new JoystickButtonPressEvent.
</summary>
<param name="name">Name of the joystick button that was pressed.</param>
<param name="pressed">Whether or not this button was just pressed.</param>
<param name="down">Whether or not this button is being held down.</param>
<param name="released">Whether or not this button was just released.</param>
</member>
<member name="T:Icarus.Input.ButtonEvents.KeyboardButtonPressEvent">
<summary>
Stores event information for when a key is pressed on a keyboard.
</summary>
</member>
<member name="M:Icarus.Input.ButtonEvents.KeyboardButtonPressEvent.#ctor(System.String,System.Boolean,System.Boolean,System.Boolean)">
<summary>
Creates a new KeyboardButtonPressEvent.
</summary>
<param name="name">Name of the keyboard key that was pressed.</param>
<param name="pressed">Whether or not this key was just pressed.</param>
<param name="down">Whether or not this key is being held down.</param>
<param name="released">Whether or not this key was just released.</param>
</member>
<member name="T:Icarus.Input.ButtonEvents.MouseButtonPressEvent">
<summary>
Stores event information for when a button is pressed on a mouse.
</summary>
</member>
<member name="M:Icarus.Input.ButtonEvents.MouseButtonPressEvent.#ctor(System.String,System.Boolean,System.Boolean,System.Boolean)">
<summary>
Creates a new MouseButtonPressEvent.
</summary>
<param name="name">Name of the mouse button that was pressed.</param>
<param name="pressed">Whether or not this button was just pressed.</param>
<param name="down">Whether or not this button is being held down.</param>
<param name="released">Whether or not this button was just released.</param>
</member>
<member name="T:Icarus.Input.MovementEvents.JoystickMovementEvent">
<summary>
Stores event information for when a joystick is moved.
</summary>
</member>
<member name="T:Icarus.Input.MovementEvents.MovementEvent">
<summary>
Stores event information for when a device is moved.
</summary>
</member>
<member name="F:Icarus.Input.MovementEvents.MovementEvent.deltaX">
<summary>
The change incurred in the x-direction by the device.
</summary>
</member>
<member name="F:Icarus.Input.MovementEvents.MovementEvent.deltaY">
<summary>
The change incurred in the y-direction by the device.
</summary>
</member>
<member name="F:Icarus.Input.MovementEvents.MovementEvent.deltaZ">
<summary>
The change incurred in the z-direction by the device.
</summary>
</member>
<member name="M:Icarus.Input.MovementEvents.MovementEvent.ToString">
<summary>
Overridden string representation of this object.
</summary>
<returns>String representation of this object.</returns>
</member>
<member name="P:Icarus.Input.MovementEvents.MovementEvent.DX">
<summary>
Delta X. The change in the x-coordinate of the device.
</summary>
</member>
<member name="P:Icarus.Input.MovementEvents.MovementEvent.DY">
<summary>
Delta Y. The change in the y-coordinate of the device.
</summary>
</member>
<member name="P:Icarus.Input.MovementEvents.MovementEvent.DZ">
<summary>
Delta Z. The change in the z-coordinate of the device.
</summary>
</member>
<member name="M:Icarus.Input.MovementEvents.JoystickMovementEvent.#ctor(System.Int32,System.Int32,System.Int32)">
<summary>
Creates a new JoystickMovementEvent.
</summary>
<param name="dx">Change in the x-coordinate.</param>
<param name="dy">Change in the y-coordinate.</param>
<param name="dz">Change in the z-coordinate.</param>
</member>
<member name="T:Icarus.Input.MovementEvents.MouseMovementEvent">
<summary>
Stores event information for when the mouse is moved.
</summary>
</member>
<member name="M:Icarus.Input.MovementEvents.MouseMovementEvent.#ctor(System.Int32,System.Int32,System.Int32)">
<summary>
Creates a new MouseMovementEvent.
</summary>
<param name="dx">Change in the x-coordinate.</param>
<param name="dy">Change in the y-coordinate.</param>
<param name="dz">Change in the z-coordinate.</param>
</member>
<member name="T:Icarus.Input.BoundAction">
<summary>
BoundAction is an action associated with a given
key or button on an input device.
</summary>
</member>
<member name="F:Icarus.Input.BoundAction.keyname">
<summary>
Name of the button or key this bound action will be applied to.
</summary>
</member>
<member name="F:Icarus.Input.BoundAction.action">
<summary>
The action to be done when the button or key is pressed.
</summary>
</member>
<member name="M:Icarus.Input.BoundAction.#ctor(System.String,System.String)">
<summary>
Constructor for a BoundAction.
</summary>
<param name="name">Name of the button or key to be mapped.</param>
<param name="boundAction">Action to be assigned to the given key.</param>
</member>
<member name="P:Icarus.Input.BoundAction.gs_keyname">
<summary>
Accessor for keyname.
</summary>
</member>
<member name="P:Icarus.Input.BoundAction.gs_action">
<summary>
Accessor/Modifer for action.
</summary>
</member>
<member name="T:Icarus.Input.InputEngine">
<summary>
Summary description for UserInputEngine.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.settings">
<summary>
General settings for the Input Engine.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.controller">
<summary>
Control Form for devices to be attached to.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.keyboard">
<summary>
Keyboard input device.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.mouse">
<summary>
Mouse input device.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.joystick">
<summary>
Joystick Input device.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.keyboardEventQueue">
<summary>
Queue of keyboard events that have yet been processed by the system.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.mouseEventQueue">
<summary>
Queue of mouse events that have yet been processed by the system.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.joystickEventQueue">
<summary>
Queue of joystick events that have yet been processed by the system.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.boundKeys">
<summary>
Array list of all key bindings for the keyboard.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.boundMouseButtons">
<summary>
Array list of all button bindings for the mouse.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.boundJoystickButtons">
<summary>
Array list of all button bindings for the joystick.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.listenLoopThread">
<summary>
Thread that constantly polls for input received.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.sorter">
<summary>
Sorts and creates button and movement events and stores them in a queue.
</summary>
</member>
<member name="F:Icarus.Input.InputEngine.instance">
<summary>
The singleton class instance of this class.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.#ctor">
<summary>
Private singleton constructor.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.Initialize(System.Windows.Forms.Control)">
<summary>
Initializes and configures the devices, based on the given Controller.
</summary>
<param name="owner">The Controller Form that owns these devices.</param>
</member>
<member name="M:Icarus.Input.InputEngine.InitDevices">
<summary>
Initializes the devices from the system.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.ConfigureDevices">
<summary>
Configures and acquires the devices for use.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.UpdateDevices">
<summary>
Updates all devices.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.UpdateKeyboard">
<summary>
Updates the keyboard event queue based on the actual input to the keyboard.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.UpdateMouse">
<summary>
Updates the mouse event queue based on the actual input to the mouse.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.UpdateJoystick">
<summary>
Updates the joystick event queue based on the actual input to the joystick.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.bindKey(System.String,System.String)">
<summary>
Binds an action to a keyboard key.
</summary>
<param name="name">Name of the key.</param>
<param name="action">Name of the action.</param>
</member>
<member name="M:Icarus.Input.InputEngine.bindMouseButton(System.String,System.String)">
<summary>
Binds an action to a mouse button.
</summary>
<param name="name">Name of the button.</param>
<param name="action">Name of the action.</param>
</member>
<member name="M:Icarus.Input.InputEngine.bindJoystickButton(System.String,System.String)">
<summary>
Binds an action to a joystick button.
</summary>
<param name="name">Name of the button.</param>
<param name="action">Name of the action.</param>
</member>
<member name="M:Icarus.Input.InputEngine.makeBinding(System.String,System.String,System.Collections.ArrayList)">
<summary>
Adds a BoundAction of the given name and action to the given bindingList.
</summary>
<param name="name">Name of the key/button.</param>
<param name="action">Name of the action.</param>
<param name="bindingList">List of BoundActions to be added to.</param>
</member>
<member name="M:Icarus.Input.InputEngine.getKeyAction(System.String)">
<summary>
Gets the action bound to the specified keyboard key.
</summary>
<param name="name">Key to get action for.</param>
<returns>The action for the key.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getKeyAction">
<summary>
Gets the action bound to the specified keyboard key.
</summary>
<returns>The action for the key.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getMouseButtonAction(System.String)">
<summary>
Gets the action bound to the specified mouse button.
</summary>
<param name="name">Button to get action for.</param>
<returns>The action for the button.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getMouseButtonAction">
<summary>
Gets the action bound to the specified mouse button.
</summary>
<returns>The action for the button.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getJoystickButtonAction(System.String)">
<summary>
Gets the action bound to the specified joystick button.
</summary>
<param name="name">Button to get action for.</param>
<returns>The action for the button.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getJoystickButtonAction">
<summary>
Gets the action bound to the specified joystick button.
</summary>
<returns>The action for the button.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getCurrentButtonAction">
<summary>
Returns the current action.
If several input devices are invoked at the same time,
first joystick will be chosen, then mouse, then keyboard.
</summary>
<returns>String value of the action to be performed.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.getAction(System.String,System.Collections.ArrayList)">
<summary>
Gets the action bound to the key/button in the given list of BoundActions.
</summary>
<param name="name">The key/button to get the action for.</param>
<param name="bindingList">List of BoundActions to search in.</param>
<returns>The action for the key/button.</returns>
</member>
<member name="M:Icarus.Input.InputEngine.StartListening">
<summary>
Starts the thread looping and polling for new input on devices.
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.StopListening">
<summary>
Stops the thread from looping and polling for new input on devices
</summary>
</member>
<member name="M:Icarus.Input.InputEngine.LoopAndListen">
<summary>
Continually updates input information from all devices.
</summary>
</member>
<member name="P:Icarus.Input.InputEngine.Instance">
<summary>
Accessor/Modifier for the singleton class instance.
</summary>
</member>
<member name="P:Icarus.Input.InputEngine.KeyboardEventQueue">
<summary>
The current queue of inputs from the keyboard.
</summary>
</member>
<member name="P:Icarus.Input.InputEngine.MouseEventQueue">
<summary>
The current queue of inputs from the mouse.
</summary>
</member>
<member name="P:Icarus.Input.InputEngine.JoystickEventQueue">
<summary>
The current queue of inputs from the joystick.
</summary>
</member>
<member name="T:Icarus.Input.InputSettings">
<summary>
I am a singleton which can be used to retrieve Input Engine settings.
Members are straightforward to access.
</summary>
</member>
<member name="F:Icarus.Input.InputSettings.instance">
<summary>
Singleton instance.
</summary>
</member>
<member name="F:Icarus.Input.InputSettings.maxKeyboardEvents">
<summary>
Maximum length of keyboard event queue before input loss is incurred.
</summary>
</member>
<member name="F:Icarus.Input.InputSettings.maxMouseEvents">
<summary>
Maximum length of mouse event queue before input loss is incurred.
</summary>
</member>
<member name="F:Icarus.Input.InputSettings.maxJoystickEvents">
<summary>
Maximum length of joystick event queue before input loss is incurred.
</summary>
</member>
<member name="F:Icarus.Input.InputSettings.loopIntervalTime">
<summary>
Time the thread takes between each update of devices.
Missed input can occur if value is set too high, Performance is lowered if value is too low.
</summary>
</member>
<member name="M:Icarus.Input.InputSettings.#ctor">
<summary>
Initializes the Input Settings to the default values for the Game Engine.
</summary>
</member>
<member name="M:Icarus.Input.InputSettings.#ctor(System.String)">
<summary>
Load the Input Settings from fileName.
Loads defaults then overwrites them with values in File.
</summary>
<param name="fileName">Name of File to load</param>
</member>
<member name="P:Icarus.Input.InputSettings.Instance">
<summary>
Accessor/Modifier for singleton instance.
</summary>
</member>
<member name="P:Icarus.Input.InputSettings.MaxKeyboardEvents">
<summary>
This sets and accesses the GLOBAL maximum number of keyboard events that are queued.
</summary>
</member>
<member name="P:Icarus.Input.InputSettings.MaxMouseEvents">
<summary>
This sets and accesses the GLOBAL maximum number of mouse events that are queued.
</summary>
</member>
<member name="P:Icarus.Input.InputSettings.MaxJoystickEvents">
<summary>
This sets and accesses the GLOBAL maximum number of joystick events that are queued.
</summary>
</member>
<member name="P:Icarus.Input.InputSettings.LoopIntervalTime">
<summary>
This sets and accesses the GLOBAL time interval between input intervals.
</summary>
</member>
<member name="T:Icarus.Input.InputTester">
<summary>
Summary description for InputTester.
</summary>
</member>
<member name="F:Icarus.Input.InputTester.engine">
<summary>
The singleton input engine.
</summary>
</member>
<member name="F:Icarus.Input.InputTester.listenLoopThread">
<summary>
Thread that constantly polls for input received.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.Main">
<summary>
Executes this tester form.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.#ctor">
<summary>
Constructor for this Tester Form.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.fillComboBox(System.Windows.Forms.ComboBox)">
<summary>
Adds various test commands to be bound for testing.
</summary>
<param name="cBox">The comboBox to add these commands to.</param>
</member>
<member name="M:Icarus.Input.InputTester.Dispose(System.Boolean)">
<summary>
Clean up any resources being used.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.InitializeComponent">
<summary>
Required method for Designer support - do not modify
the contents of this method with the code editor.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.LoopAndListen">
<summary>
Method executed by the thread, that loops forever
polling the InputEngine for any input received.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.stopListening">
<summary>
Stop the thread from looping and polling the InputEngine.
</summary>
</member>
<member name="M:Icarus.Input.InputTester.startListening">
<summary>
Starts the thread looping and polling the InputEngine.
</summary>
</member>
<member name="T:Icarus.Input.QueueEventSorter">
<summary>
Sorts and adds button and movement events to event queues.
</summary>
</member>
<member name="F:Icarus.Input.QueueEventSorter.currentKeyboardDownList">
<summary>
List of current keyboard keys that are being held down.
</summary>
</member>
<member name="F:Icarus.Input.QueueEventSorter.currentMouseDownList">
<summary>
List of current mouse buttons that are being held down.
</summary>
</member>
<member name="F:Icarus.Input.QueueEventSorter.currentJoystickDownList">
<summary>
List of current joystick buttons that are being held down.
</summary>
</member>
<member name="M:Icarus.Input.QueueEventSorter.AddKeyboardEvents(System.Collections.ArrayList,Microsoft.DirectX.DirectInput.Key[])">
<summary>
Takes in a list of new events and determines the current states of each
and adds them to the current queue.
</summary>
<param name="queue">Current keyboard queue to add new events to.</param>
<param name="events">List of new events to sort and add.</param>
<returns>The updated current keyboard event queue.</returns>
</member>
<member name="M:Icarus.Input.QueueEventSorter.AddMouseEvents(System.Collections.ArrayList,System.Byte[])">
<summary>
Takes in a list of new events and determines the current states of each
and adds them to the current queue.
</summary>
<param name="queue">Current mouse queue to add new events to.</param>
<param name="events">List of new events to sort and add.</param>
<returns>The updated current mouse event queue.</returns>
</member>
<member name="M:Icarus.Input.QueueEventSorter.AddJoystickEvents(System.Collections.ArrayList,System.Byte[])">
<summary>
Takes in a list of new events and determines the current states of each
and adds them to the current queue.
</summary>
<param name="queue">Current joystick queue to add new events to.</param>
<param name="events">List of new events to sort and add.</param>
<returns>The updated current joystick event queue.</returns>
</member>
<member name="M:Icarus.Input.QueueEventSorter.AddMouseMovementEvent(System.Collections.ArrayList,System.Int32,System.Int32,System.Int32)">
<summary>
Takes in assorted movement readings from the mouse to create a new event
and add it to the current queue.
</summary>
<param name="queue">Current mouse queue to add new event to.</param>
<param name="dx">Change in x-coordinate.</param>
<param name="dy">Change in y-coordinate.</param>
<param name="dz">Change in z-coordinate.</param>
<returns>The updated current mouse event queue.</returns>
</member>
<member name="M:Icarus.Input.QueueEventSorter.AddJoystickMovementEvent(System.Collections.ArrayList,System.Int32,System.Int32,System.Int32)">
<summary>
Takes in assorted movement readings from the joystick to create a new event
and add it to the current queue.
</summary>
<param name="queue">Current joystick queue to add new event to.</param>
<param name="dx">Change in x-coordinate.</param>
<param name="dy">Change in y-coordinate.</param>
<param name="dz">Change in z-coordinate.</param>
<returns>The updated current joystick event queue.</returns>
</member>
</members>
</doc>

View File

@@ -0,0 +1,503 @@
using System;
using System.Threading;
using System.Collections;
using System.Windows.Forms;
using SharpDX.DirectInput;
using Icarus.Input.ButtonEvents;
using Icarus.Input.MovementEvents;
namespace Icarus.Input {
/// <summary>
/// Summary description for UserInputEngine.
/// </summary>
public class InputEngine {
#region Static Upgrade Helpers
private static byte[] SDX_GET_MOUSEBUTTONS(SharpDX.DirectInput.Mouse mouse)
{
var state = mouse.GetCurrentState();
byte[] events = new byte[state.Buttons.Length];
for (int i = 0; i < state.Buttons.Length; i++)
{
events[i] = (byte)(state.Buttons[i] ? 1 : 0);
}
return events;
}
#endregion
#region Instance Variables
/// <summary>
/// General settings for the Input Engine.
/// </summary>
private InputSettings settings = InputSettings.Instance;
/// <summary>
/// Control Form for devices to be attached to.
/// </summary>
private Control controller = null;
/// <summary>
/// DirectInput instance object
/// </summary>
private SharpDX.DirectInput.DirectInput directInputInstance = null;
/// <summary>
/// Keyboard input device.
/// </summary>
private SharpDX.DirectInput.Keyboard keyboard = null;
/// <summary>
/// Mouse input device.
/// </summary>
private SharpDX.DirectInput.Mouse mouse = null;
/// <summary>
/// Joystick Input device.
/// </summary>
private Device joystick = null;
/// <summary>
/// Queue of keyboard events that have yet been processed by the system.
/// </summary>
private ArrayList keyboardEventQueue = new ArrayList();
/// <summary>
/// Queue of mouse events that have yet been processed by the system.
/// </summary>
private ArrayList mouseEventQueue = new ArrayList();
/// <summary>
/// Queue of joystick events that have yet been processed by the system.
/// </summary>
private ArrayList joystickEventQueue = new ArrayList();
/// <summary>
/// Array list of all key bindings for the keyboard.
/// </summary>
private ArrayList boundKeys = new ArrayList();
/// <summary>
/// Array list of all button bindings for the mouse.
/// </summary>
private ArrayList boundMouseButtons = new ArrayList();
/// <summary>
/// Array list of all button bindings for the joystick.
/// </summary>
private ArrayList boundJoystickButtons = new ArrayList();
/// <summary>
/// Thread that constantly polls for input received.
/// </summary>
private Thread listenLoopThread = null;
/// <summary>
/// Sorts and creates button and movement events and stores them in a queue.
/// </summary>
private QueueEventSorter sorter = new QueueEventSorter();
#endregion
#region Singleton Stuff
/// <summary>
/// The singleton class instance of this class.
/// </summary>
private static InputEngine instance = new InputEngine();
/// <summary>
/// Private singleton constructor.
/// </summary>
private InputEngine() {
boundKeys = new ArrayList();
boundMouseButtons = new ArrayList();
boundJoystickButtons = new ArrayList();
}
/// <summary>
/// Accessor/Modifier for the singleton class instance.
/// </summary>
public static InputEngine Instance {
get { return instance; }
}
#endregion
#region Initialization
/// <summary>
/// Initializes and configures the devices, based on the given Controller.
/// </summary>
/// <param name="owner">The Controller Form that owns these devices.</param>
public void Initialize(Control owner) {
controller = owner;
directInputInstance = new DirectInput();
InitDevices();
ConfigureDevices();
}
/// <summary>
/// Initializes the devices from the system.
/// </summary>
private void InitDevices() {
keyboard = new SharpDX.DirectInput.Keyboard(directInputInstance);
if (keyboard == null) {
Console.WriteLine(" -- No keyboard found.");
}
mouse = new SharpDX.DirectInput.Mouse(directInputInstance);
if(mouse == null) {
Console.WriteLine(" -- No mouse found.");
}
#if !DISABLE_JOYSTICK
foreach (var di in directInputInstance.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly)) {
joystick = new SharpDX.DirectInput.Joystick(directInputInstance, di.InstanceGuid);
break;
}
#endif
if(joystick == null) {
Console.WriteLine(" -- No joystick found.");
}
}
/// <summary>
/// Configures and acquires the devices for use.
/// </summary>
private void ConfigureDevices() {
if (keyboard != null) {
//keyboard.SetCooperativeLevel(controller, CooperativeLevelFlags.Foreground);
keyboard.Acquire();
}
if (mouse != null) {
//mouse.Properties.AxisModeAbsolute = true;
//mouse.SetCooperativeLevel(controller, CooperativeLevelFlags.Foreground);
mouse.Acquire();
}
if (joystick != null) {
#if !DISABLE_JOYSTICK
//Set joystick axis ranges.
foreach (DeviceObjectInstance doi in joystick.Objects) {
if ((doi.ObjectId & (int) DeviceObjectTypeFlags.Axis) != 0) {
joystick.Properties.SetRange(ParameterHow.ById, doi.ObjectId, new InputRange(-5000,5000));
}
}
//joystick.Properties.AxisModeAbsolute = true;
//joystick.SetCooperativeLevel(controller, CooperativeLevelFlags.Foreground);
joystick.Acquire();
#endif
}
}
#endregion
#region Accessors/Modifiers
/// <summary>
/// The current queue of inputs from the keyboard.
/// </summary>
public ArrayList KeyboardEventQueue {
get {
ArrayList eventQueue = (ArrayList) keyboardEventQueue.Clone();
keyboardEventQueue.Clear();
return eventQueue;
}
}
/// <summary>
/// The current queue of inputs from the mouse.
/// </summary>
public ArrayList MouseEventQueue {
get {
ArrayList eventQueue = (ArrayList) mouseEventQueue.Clone();
mouseEventQueue.Clear();
return eventQueue;
}
}
/// <summary>
/// The current queue of inputs from the joystick.
/// </summary>
public ArrayList JoystickEventQueue {
get {
ArrayList eventQueue = (ArrayList) joystickEventQueue.Clone();
joystickEventQueue.Clear();
return eventQueue;
}
}
#endregion
#region Device Capturing
/// <summary>
/// Updates all devices.
/// </summary>
private void UpdateDevices() {
UpdateKeyboard();
UpdateMouse();
UpdateJoystick();
int MAXSIZE;
MAXSIZE = settings.MaxKeyboardEvents;
if (keyboardEventQueue.Count >= MAXSIZE) {
keyboardEventQueue = keyboardEventQueue.GetRange(0, MAXSIZE);
}
MAXSIZE = settings.MaxMouseEvents;
if (mouseEventQueue.Count >= MAXSIZE) {
mouseEventQueue = mouseEventQueue.GetRange(0, MAXSIZE);
}
MAXSIZE = settings.MaxJoystickEvents;
if (joystickEventQueue.Count >= MAXSIZE) {
joystickEventQueue = joystickEventQueue.GetRange(0, MAXSIZE);
}
}
/// <summary>
/// Updates the keyboard event queue based on the actual input to the keyboard.
/// </summary>
private void UpdateKeyboard() {
if (keyboard != null)
{
try
{
var pressed = keyboard.GetCurrentState().PressedKeys;
if (pressed != null)
{
var keyEvents = pressed.ToArray();
keyboardEventQueue = sorter.AddKeyboardEvents(keyboardEventQueue, keyEvents);
}
else
{
throw new Exception("Failed to get key state");
}
}
catch (Exception) {
}
}
}
/// <summary>
/// Updates the mouse event queue based on the actual input to the mouse.
/// </summary>
private void UpdateMouse() {
if (mouse != null)
{
try
{
var state = mouse.GetCurrentState();
mouseEventQueue = sorter.AddMouseMovementEvent(mouseEventQueue, state.X, state.Y, state.Z);
mouseEventQueue = sorter.AddMouseEvents(mouseEventQueue, SDX_GET_MOUSEBUTTONS(mouse));
}
catch (Exception) {
}
}
}
/// <summary>
/// Updates the joystick event queue based on the actual input to the joystick.
/// </summary>
private void UpdateJoystick() {
if (joystick != null) {
#if !DISABLE_JOYSTICK
try {
JoystickState state = joystick.CurrentJoystickState;
joystickEventQueue = sorter.AddJoystickMovementEvent(joystickEventQueue, state.X, state.Y, state.Z);
joystickEventQueue = sorter.AddJoystickEvents(joystickEventQueue, state.GetButtons());
} catch (NotAcquiredException) {
}
#endif
}
}
#endregion
#region Key/Button Binding
/// <summary>
/// Binds an action to a keyboard key.
/// </summary>
/// <param name="name">Name of the key.</param>
/// <param name="action">Name of the action.</param>
public void bindKey (string name, string action) {
makeBinding(name, action, boundKeys);
}
/// <summary>
/// Binds an action to a mouse button.
/// </summary>
/// <param name="name">Name of the button.</param>
/// <param name="action">Name of the action.</param>
public void bindMouseButton (string name, string action) {
makeBinding(name, action, boundMouseButtons);
}
/// <summary>
/// Binds an action to a joystick button.
/// </summary>
/// <param name="name">Name of the button.</param>
/// <param name="action">Name of the action.</param>
public void bindJoystickButton (string name, string action) {
makeBinding(name, action, boundJoystickButtons);
}
/// <summary>
/// Adds a BoundAction of the given name and action to the given bindingList.
/// </summary>
/// <param name="name">Name of the key/button.</param>
/// <param name="action">Name of the action.</param>
/// <param name="bindingList">List of BoundActions to be added to.</param>
private void makeBinding(string name, string action, ArrayList bindingList) {
foreach (BoundAction ba in bindingList) {
if (ba.gs_keyname == name) {
if (action != null) {
ba.gs_action = action;
} else {
bindingList.Remove(ba);
}
return;
}
}
if (action != null) {
bindingList.Add(new BoundAction(name, action));
}
}
#endregion
#region Bound Key/Button Action Requests
/// <summary>
/// Gets the action bound to the specified keyboard key.
/// </summary>
/// <param name="name">Key to get action for.</param>
/// <returns>The action for the key.</returns>
public string getKeyAction (string name) {
return getAction(name, boundKeys);
}
/// <summary>
/// Gets the action bound to the specified keyboard key.
/// </summary>
/// <returns>The action for the key.</returns>
public string getKeyAction () {
if (keyboard == null) {
return null;
}
Key[] keys = keyboard.GetCurrentState().PressedKeys.ToArray();
if (keys.Length < 1) {
return null;
}
else return getKeyAction(keys[0].ToString());
}
/// <summary>
/// Gets the action bound to the specified mouse button.
/// </summary>
/// <param name="name">Button to get action for.</param>
/// <returns>The action for the button.</returns>
public string getMouseButtonAction (string name) {
return getAction(name, boundMouseButtons);
}
/// <summary>
/// Gets the action bound to the specified mouse button.
/// </summary>
/// <returns>The action for the button.</returns>
public string getMouseButtonAction () {
if (mouse == null) return null;
byte[] buttons = SDX_GET_MOUSEBUTTONS(mouse);
if (buttons.Length < 1) return null;
else return getMouseButtonAction(buttons[0].ToString());
}
/// <summary>
/// Gets the action bound to the specified joystick button.
/// </summary>
/// <param name="name">Button to get action for.</param>
/// <returns>The action for the button.</returns>
public string getJoystickButtonAction (string name) {
return getAction(name, boundJoystickButtons);
}
/// <summary>
/// Gets the action bound to the specified joystick button.
/// </summary>
/// <returns>The action for the button.</returns>
public string getJoystickButtonAction () {
#if !DISABLE_JOYSTICK
if (joystick == null) return null;
byte[] keys = joystick.CurrentJoystickState.GetButtons();
if (keys.Length < 1) {
return null;
}
else {
for (int i = 0; i < keys.Length; i++) {
if (keys[i] != 0)
return getJoystickButtonAction(i.ToString());
}
}
#endif
return null;
}
/// <summary>
/// Returns the current action.
/// If several input devices are invoked at the same time,
/// first joystick will be chosen, then mouse, then keyboard.
/// </summary>
/// <returns>String value of the action to be performed.</returns>
public string getCurrentButtonAction() {
string action = null;
action = getJoystickButtonAction();
if (action != null) {
return action;
}
action = getMouseButtonAction();
if (action != null) {
return action;
}
action = getKeyAction();
if (action != null) {
return action;
}
return null;
}
/// <summary>
/// Gets the action bound to the key/button in the given list of BoundActions.
/// </summary>
/// <param name="name">The key/button to get the action for.</param>
/// <param name="bindingList">List of BoundActions to search in.</param>
/// <returns>The action for the key/button.</returns>
private string getAction(string name, ArrayList bindingList) {
foreach (BoundAction ba in bindingList) {
if (ba.gs_keyname == name) {
return ba.gs_action;
}
}
return null;
}
#endregion
#region Listening Thread Logic
/// <summary>
/// Starts the thread looping and polling for new input on devices.
/// </summary>
public void StartListening() {
if (listenLoopThread == null) {
listenLoopThread = new Thread(new ThreadStart(LoopAndListen));
listenLoopThread.Start();
}
}
/// <summary>
/// Stops the thread from looping and polling for new input on devices
/// </summary>
public void StopListening() {
if (listenLoopThread != null) {
listenLoopThread.Abort();
listenLoopThread = null;
}
}
/// <summary>
/// Continually updates input information from all devices.
/// </summary>
private void LoopAndListen() {
while (true) {
UpdateDevices();
Thread.Sleep(settings.LoopIntervalTime);
}
}
#endregion
}
}

View File

@@ -0,0 +1,97 @@
using System;
namespace Icarus.Input {
/// <summary>
/// I am a singleton which can be used to retrieve Input Engine settings.
/// Members are straightforward to access.
/// </summary>
public class InputSettings {
#region Singleton Stuff
/// <summary>
/// Singleton instance.
/// </summary>
private static InputSettings instance = new InputSettings();
/// <summary>
/// Accessor/Modifier for singleton instance.
/// </summary>
public static InputSettings Instance {
get { return instance; }
set { instance = value;}
}
#endregion
#region Instance Variables
/// <summary>
/// Maximum length of keyboard event queue before input loss is incurred.
/// </summary>
private int maxKeyboardEvents;
/// <summary>
/// Maximum length of mouse event queue before input loss is incurred.
/// </summary>
private int maxMouseEvents;
/// <summary>
/// Maximum length of joystick event queue before input loss is incurred.
/// </summary>
private int maxJoystickEvents;
/// <summary>
/// Time the thread takes between each update of devices.
/// Missed input can occur if value is set too high, Performance is lowered if value is too low.
/// </summary>
private int loopIntervalTime;
#endregion
#region Accessors/Modifiers
/// <summary>
/// This sets and accesses the GLOBAL maximum number of keyboard events that are queued.
/// </summary>
public int MaxKeyboardEvents {
get { return maxKeyboardEvents; }
set { maxKeyboardEvents = value;}
}
/// <summary>
/// This sets and accesses the GLOBAL maximum number of mouse events that are queued.
/// </summary>
public int MaxMouseEvents {
get { return maxMouseEvents; }
set { maxMouseEvents = value;}
}
/// <summary>
/// This sets and accesses the GLOBAL maximum number of joystick events that are queued.
/// </summary>
public int MaxJoystickEvents {
get { return maxJoystickEvents; }
set { maxJoystickEvents = value;}
}
/// <summary>
/// This sets and accesses the GLOBAL time interval between input intervals.
/// </summary>
public int LoopIntervalTime {
get { return loopIntervalTime; }
set { loopIntervalTime = value; }
}
#endregion
#region Initialization
/// <summary>
/// Initializes the Input Settings to the default values for the Game Engine.
/// </summary>
private InputSettings() {
maxKeyboardEvents = 100000;
maxMouseEvents = 100000;
maxJoystickEvents = 100000;
loopIntervalTime = 25;
}
/// <summary>
/// Load the Input Settings from fileName.
/// Loads defaults then overwrites them with values in File.
/// </summary>
/// <param name="fileName">Name of File to load</param>
private InputSettings(string fileName) : this() {
}
#endregion
}
}

View File

@@ -0,0 +1,441 @@
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
using Icarus.Input.ButtonEvents;
namespace Icarus.Input {
/// <summary>
/// Summary description for InputTester.
/// </summary>
public class InputTester : System.Windows.Forms.Form {
#region GUI Components
private System.Windows.Forms.TextBox keyboardDisplay;
private System.Windows.Forms.TextBox mouseDisplay;
private System.Windows.Forms.TextBox joystickDisplay;
private System.Windows.Forms.Label keyboardLabel;
private System.Windows.Forms.Label mouseLabel;
private System.Windows.Forms.Label joystickLabel;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.TextBox keyTextBox;
private System.Windows.Forms.ComboBox keyComboBox;
private System.Windows.Forms.Button keyButton;
private System.Windows.Forms.Button mouseButton;
private System.Windows.Forms.ComboBox mouseComboBox;
private System.Windows.Forms.TextBox mouseTextBox;
private System.Windows.Forms.Button joystickButton;
private System.Windows.Forms.ComboBox joystickComboBox;
private System.Windows.Forms.TextBox joystickTextBox;
private System.ComponentModel.Container components = null;
#endregion
#region Instance Variables
/// <summary>
/// The singleton input engine.
/// </summary>
private InputEngine engine = null;
/// <summary>
/// Thread that constantly polls for input received.
/// </summary>
private Thread listenLoopThread = null;
#endregion
#region Execution
/// <summary>
/// Executes this tester form.
/// </summary>
public static void Main() {
Console.WriteLine("You are now running the tester program for the InputEngine of the Icarus Game Engine");
new InputTester().Show();
}
/// <summary>
/// Constructor for this Tester Form.
/// </summary>
public InputTester() {
// Required for Windows Form Designer support
InitializeComponent();
fillComboBox(keyComboBox);
fillComboBox(mouseComboBox);
fillComboBox(joystickComboBox);
engine = InputEngine.Instance;
engine.Initialize(this);
}
/// <summary>
/// Adds various test commands to be bound for testing.
/// </summary>
/// <param name="cBox">The comboBox to add these commands to.</param>
private void fillComboBox(ComboBox cBox) {
cBox.Items.Add("<DO NOTHING>");
cBox.Items.Add("Red");
cBox.Items.Add("Blue");
cBox.Items.Add("Green");
cBox.Items.Add("Yellow");
cBox.Items.Add("Magenta");
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing ) {
if( disposing ) {
if(components != null) {
components.Dispose();
}
}
base.Dispose( disposing );
stopListening();
Console.WriteLine("You have exited the tester program for the InputEngine of the Icarus Game Engine.");
Console.WriteLine("Have A Nice Day!");
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.keyboardDisplay = new System.Windows.Forms.TextBox();
this.mouseDisplay = new System.Windows.Forms.TextBox();
this.joystickDisplay = new System.Windows.Forms.TextBox();
this.keyboardLabel = new System.Windows.Forms.Label();
this.mouseLabel = new System.Windows.Forms.Label();
this.joystickLabel = new System.Windows.Forms.Label();
this.startButton = new System.Windows.Forms.Button();
this.stopButton = new System.Windows.Forms.Button();
this.keyTextBox = new System.Windows.Forms.TextBox();
this.keyComboBox = new System.Windows.Forms.ComboBox();
this.keyButton = new System.Windows.Forms.Button();
this.mouseButton = new System.Windows.Forms.Button();
this.mouseComboBox = new System.Windows.Forms.ComboBox();
this.mouseTextBox = new System.Windows.Forms.TextBox();
this.joystickButton = new System.Windows.Forms.Button();
this.joystickComboBox = new System.Windows.Forms.ComboBox();
this.joystickTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// keyboardDisplay
//
this.keyboardDisplay.Location = new System.Drawing.Point(32, 40);
this.keyboardDisplay.Multiline = true;
this.keyboardDisplay.Name = "keyboardDisplay";
this.keyboardDisplay.ReadOnly = true;
this.keyboardDisplay.Size = new System.Drawing.Size(272, 80);
this.keyboardDisplay.TabIndex = 0;
this.keyboardDisplay.Text = "";
//
// mouseDisplay
//
this.mouseDisplay.Location = new System.Drawing.Point(32, 168);
this.mouseDisplay.Multiline = true;
this.mouseDisplay.Name = "mouseDisplay";
this.mouseDisplay.ReadOnly = true;
this.mouseDisplay.Size = new System.Drawing.Size(272, 80);
this.mouseDisplay.TabIndex = 1;
this.mouseDisplay.Text = "";
//
// joystickDisplay
//
this.joystickDisplay.Location = new System.Drawing.Point(32, 296);
this.joystickDisplay.Multiline = true;
this.joystickDisplay.Name = "joystickDisplay";
this.joystickDisplay.ReadOnly = true;
this.joystickDisplay.Size = new System.Drawing.Size(272, 80);
this.joystickDisplay.TabIndex = 2;
this.joystickDisplay.Text = "";
//
// keyboardLabel
//
this.keyboardLabel.Location = new System.Drawing.Point(32, 16);
this.keyboardLabel.Name = "keyboardLabel";
this.keyboardLabel.Size = new System.Drawing.Size(88, 23);
this.keyboardLabel.TabIndex = 3;
this.keyboardLabel.Text = "Keyboard Input:";
this.keyboardLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// mouseLabel
//
this.mouseLabel.Location = new System.Drawing.Point(32, 144);
this.mouseLabel.Name = "mouseLabel";
this.mouseLabel.Size = new System.Drawing.Size(72, 23);
this.mouseLabel.TabIndex = 4;
this.mouseLabel.Text = "Mouse Input:";
this.mouseLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// joystickLabel
//
this.joystickLabel.Location = new System.Drawing.Point(32, 272);
this.joystickLabel.Name = "joystickLabel";
this.joystickLabel.Size = new System.Drawing.Size(80, 23);
this.joystickLabel.TabIndex = 5;
this.joystickLabel.Text = "Joystick Input:";
this.joystickLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// startButton
//
this.startButton.Location = new System.Drawing.Point(72, 400);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(88, 23);
this.startButton.TabIndex = 6;
this.startButton.Text = "Start Listening";
this.startButton.Click += new System.EventHandler(this.startButton_Click);
//
// stopButton
//
this.stopButton.Location = new System.Drawing.Point(176, 400);
this.stopButton.Name = "stopButton";
this.stopButton.Size = new System.Drawing.Size(88, 23);
this.stopButton.TabIndex = 7;
this.stopButton.Text = "Stop Listening";
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// keyTextBox
//
this.keyTextBox.Location = new System.Drawing.Point(320, 40);
this.keyTextBox.Name = "keyTextBox";
this.keyTextBox.TabIndex = 8;
this.keyTextBox.Text = "<Key Name>";
//
// keyComboBox
//
this.keyComboBox.Location = new System.Drawing.Point(320, 72);
this.keyComboBox.Name = "keyComboBox";
this.keyComboBox.Size = new System.Drawing.Size(104, 21);
this.keyComboBox.TabIndex = 9;
this.keyComboBox.Text = "<Action>";
//
// keyButton
//
this.keyButton.Location = new System.Drawing.Point(328, 104);
this.keyButton.Name = "keyButton";
this.keyButton.TabIndex = 10;
this.keyButton.Text = "Bind Key";
this.keyButton.Click += new System.EventHandler(this.keyButton_Click);
//
// mouseButton
//
this.mouseButton.Location = new System.Drawing.Point(328, 232);
this.mouseButton.Name = "mouseButton";
this.mouseButton.TabIndex = 13;
this.mouseButton.Text = "Bind Button";
this.mouseButton.Click += new System.EventHandler(this.mouseButton_Click);
//
// mouseComboBox
//
this.mouseComboBox.Location = new System.Drawing.Point(320, 200);
this.mouseComboBox.Name = "mouseComboBox";
this.mouseComboBox.Size = new System.Drawing.Size(104, 21);
this.mouseComboBox.TabIndex = 12;
this.mouseComboBox.Text = "<Action>";
//
// mouseTextBox
//
this.mouseTextBox.Location = new System.Drawing.Point(320, 168);
this.mouseTextBox.Name = "mouseTextBox";
this.mouseTextBox.TabIndex = 11;
this.mouseTextBox.Text = "<Button Name>";
//
// joystickButton
//
this.joystickButton.Location = new System.Drawing.Point(328, 360);
this.joystickButton.Name = "joystickButton";
this.joystickButton.TabIndex = 16;
this.joystickButton.Text = "Bind Button";
this.joystickButton.Click += new System.EventHandler(this.joystickButton_Click);
//
// joystickComboBox
//
this.joystickComboBox.Location = new System.Drawing.Point(320, 328);
this.joystickComboBox.Name = "joystickComboBox";
this.joystickComboBox.Size = new System.Drawing.Size(104, 21);
this.joystickComboBox.TabIndex = 15;
this.joystickComboBox.Text = "<Action>";
//
// joystickTextBox
//
this.joystickTextBox.Location = new System.Drawing.Point(320, 296);
this.joystickTextBox.Name = "joystickTextBox";
this.joystickTextBox.TabIndex = 14;
this.joystickTextBox.Text = "<Button Name>";
//
// InputTester
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(440, 446);
this.Controls.Add(this.joystickButton);
this.Controls.Add(this.joystickComboBox);
this.Controls.Add(this.joystickTextBox);
this.Controls.Add(this.mouseButton);
this.Controls.Add(this.mouseComboBox);
this.Controls.Add(this.mouseTextBox);
this.Controls.Add(this.keyButton);
this.Controls.Add(this.keyComboBox);
this.Controls.Add(this.keyTextBox);
this.Controls.Add(this.stopButton);
this.Controls.Add(this.startButton);
this.Controls.Add(this.joystickLabel);
this.Controls.Add(this.mouseLabel);
this.Controls.Add(this.keyboardLabel);
this.Controls.Add(this.joystickDisplay);
this.Controls.Add(this.mouseDisplay);
this.Controls.Add(this.keyboardDisplay);
this.Name = "InputTester";
this.Text = "InputTester";
this.ResumeLayout(false);
}
#endregion
#region Input Listening Thread Operations
/// <summary>
/// Method executed by the thread, that loops forever
/// polling the InputEngine for any input received.
/// </summary>
private void LoopAndListen() {
string key = null;
string action = null;
engine.StartListening();
while (true) {
ArrayList keyboardQueue = engine.KeyboardEventQueue;
foreach (object keyEvent in keyboardQueue) {
keyboardDisplay.AppendText(keyEvent.ToString() + " ");
if (keyEvent is KeyboardButtonPressEvent) {
key = ((KeyboardButtonPressEvent) keyEvent).Name;
action = engine.getKeyAction(key);
performAction(action, keyboardDisplay);
}
}
ArrayList mouseQueue = engine.MouseEventQueue;
foreach (object mouseEvent in mouseQueue) {
mouseDisplay.AppendText(mouseEvent.ToString() + " ");
if (mouseEvent is MouseButtonPressEvent) {
key = ((MouseButtonPressEvent) mouseEvent).Name;
action = engine.getMouseButtonAction(key);
performAction(action, mouseDisplay);
}
}
ArrayList joystickQueue = engine.JoystickEventQueue;
foreach (object joystickEvent in joystickQueue) {
joystickDisplay.AppendText(joystickEvent.ToString() + " ");
if (joystickEvent is JoystickButtonPressEvent) {
key = ((JoystickButtonPressEvent) joystickEvent).Name;
action = engine.getJoystickButtonAction(key);
performAction(action, joystickDisplay);
}
}
Thread.Sleep(1000);
keyboardDisplay.Text = "";
mouseDisplay.Text = "";
joystickDisplay.Text = "";
}
}
private void performAction(string action, TextBox display) {
if(action == "Red") {
display.BackColor = Color.Red;
} else if(action == "Blue") {
display.BackColor = Color.Blue;
} else if(action == "Green") {
display.BackColor = Color.Lime;
} else if(action == "Yellow") {
display.BackColor = Color.Yellow;
} else if(action == "Magenta") {
display.BackColor = Color.Magenta;
} else {
display.BackColor = Color.White;
}
}
private string getFirstKeyInput(string input) {
input = input.Substring("Keyboard:".Length, input.Length - ("Keyboard:".Length));
input = input.TrimStart(' ');
if (input.IndexOf(" ") > 0) {
input = input.Substring(0, input.IndexOf(" "));
return input;
} else {
return null;
}
}
private string getFirstButtonInput(string input) {
int start = input.IndexOf("Button:");
if (start > 0) {
start += "Button:".Length;
input = input.Substring(start, input.Length - start);
if (input.IndexOf("Button:") > 0) {
input = input.Substring(0, input.IndexOf("Button:"));
}
input = input.Trim();
return input;
} else {
return null;
}
}
/// <summary>
/// Stop the thread from looping and polling the InputEngine.
/// </summary>
public void stopListening() {
if (listenLoopThread != null) {
engine.StopListening();
listenLoopThread.Abort();
listenLoopThread = null;
}
}
/// <summary>
/// Starts the thread looping and polling the InputEngine.
/// </summary>
public void startListening() {
if (listenLoopThread == null) {
listenLoopThread = new Thread(new ThreadStart(LoopAndListen));
listenLoopThread.Start();
}
}
#endregion
#region Button Click Methods
private void startButton_Click(object sender, System.EventArgs e) {
startListening();
}
private void stopButton_Click(object sender, System.EventArgs e) {
stopListening();
}
private void keyButton_Click(object sender, System.EventArgs e) {
string action = (string) keyComboBox.SelectedItem;
if (action == "<DO NOTHING>") {
action = null;
}
engine.bindKey(keyTextBox.Text, action);
}
private void mouseButton_Click(object sender, System.EventArgs e) {
string action = (string) mouseComboBox.SelectedItem;
if (action == "<DO NOTHING>") {
action = null;
}
engine.bindMouseButton(mouseTextBox.Text, action);
}
private void joystickButton_Click(object sender, System.EventArgs e) {
string action = (string) joystickComboBox.SelectedItem;
if (action == "<DO NOTHING>") {
action = null;
}
engine.bindJoystickButton(joystickTextBox.Text, action);
}
#endregion
}
}

View File

@@ -0,0 +1,283 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used forserialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="keyboardDisplay.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyboardDisplay.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyboardDisplay.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseDisplay.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseDisplay.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseDisplay.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickDisplay.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickDisplay.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="joystickDisplay.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyboardLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="keyboardLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyboardLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="joystickLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="startButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="startButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="startButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="stopButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="stopButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="stopButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="keyTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyComboBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyComboBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="keyComboBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="keyButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="keyButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseComboBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseComboBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseComboBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="mouseTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="mouseTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="joystickButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickComboBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickComboBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="joystickComboBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="joystickTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="joystickTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>(Default)</value>
</data>
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value>
</data>
<data name="$this.Name">
<value>InputTester</value>
</data>
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>80</value>
</data>
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
</root>

View File

@@ -0,0 +1,23 @@
using System;
namespace Icarus.Input.MovementEvents {
/// <summary>
/// Stores event information for when a joystick is moved.
/// </summary>
public class JoystickMovementEvent : MovementEvent {
/// <summary>
/// Creates a new JoystickMovementEvent.
/// </summary>
/// <param name="dx">Change in the x-coordinate.</param>
/// <param name="dy">Change in the y-coordinate.</param>
/// <param name="dz">Change in the z-coordinate.</param>
public JoystickMovementEvent(int dx, int dy, int dz) {
this.DX = dx;
this.DY = dy;
this.DZ = dz;
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
namespace Icarus.Input.MovementEvents {
/// <summary>
/// Stores event information for when the mouse is moved.
/// </summary>
public class MouseMovementEvent : MovementEvent {
/// <summary>
/// Creates a new MouseMovementEvent.
/// </summary>
/// <param name="dx">Change in the x-coordinate.</param>
/// <param name="dy">Change in the y-coordinate.</param>
/// <param name="dz">Change in the z-coordinate.</param>
public MouseMovementEvent(int dx, int dy, int dz) {
this.DX = dx;
this.DY = dy;
this.DZ = dz;
}
}
}

View File

@@ -0,0 +1,62 @@
using System;
namespace Icarus.Input.MovementEvents {
/// <summary>
/// Stores event information for when a device is moved.
/// </summary>
public class MovementEvent {
#region Instance Variables
/// <summary>
/// The change incurred in the x-direction by the device.
/// </summary>
private int deltaX = 0;
/// <summary>
/// The change incurred in the y-direction by the device.
/// </summary>
private int deltaY = 0;
/// <summary>
/// The change incurred in the z-direction by the device.
/// </summary>
private int deltaZ = 0;
#endregion
#region Accessors and Modifiers
/// <summary>
/// Delta X. The change in the x-coordinate of the device.
/// </summary>
public int DX {
get { return deltaX; }
set { deltaX = value; }
}
/// <summary>
/// Delta Y. The change in the y-coordinate of the device.
/// </summary>
public int DY {
get { return deltaY; }
set { deltaY = value; }
}
/// <summary>
/// Delta Z. The change in the z-coordinate of the device.
/// </summary>
public int DZ {
get { return deltaZ; }
set { deltaZ = value; }
}
#endregion
#region General Use
/// <summary>
/// Overridden string representation of this object.
/// </summary>
/// <returns>String representation of this object.</returns>
public override string ToString() {
return "DX=" + deltaX + ", DY=" + deltaY + ", DZ=" + deltaZ;
}
#endregion
}
}

View File

@@ -0,0 +1,162 @@
using System;
using System.Collections;
using SharpDX.DirectInput;
using Icarus.Input.ButtonEvents;
using Icarus.Input.MovementEvents;
namespace Icarus.Input {
/// <summary>
/// Sorts and adds button and movement events to event queues.
/// </summary>
public class QueueEventSorter {
#region Instance Variables
/// <summary>
/// List of current keyboard keys that are being held down.
/// </summary>
private ArrayList currentKeyboardDownList = new ArrayList();
/// <summary>
/// List of current mouse buttons that are being held down.
/// </summary>
private ArrayList currentMouseDownList = new ArrayList();
/// <summary>
/// List of current joystick buttons that are being held down.
/// </summary>
private ArrayList currentJoystickDownList = new ArrayList();
#endregion
#region Key and Button Event Adding
/// <summary>
/// Takes in a list of new events and determines the current states of each
/// and adds them to the current queue.
/// </summary>
/// <param name="queue">Current keyboard queue to add new events to.</param>
/// <param name="events">List of new events to sort and add.</param>
/// <returns>The updated current keyboard event queue.</returns>
public ArrayList AddKeyboardEvents(ArrayList queue, Key[] events) {
ArrayList newDownList = new ArrayList();
foreach(Key k in events) {
newDownList.Add(k.ToString());
if (currentKeyboardDownList.Contains(k.ToString())) {
queue.Add(new KeyboardButtonPressEvent(k.ToString(), false, true, false));
} else {
currentKeyboardDownList.Add(k.ToString());
queue.Add(new KeyboardButtonPressEvent(k.ToString(), true, false, false));
}
}
foreach (string key in currentKeyboardDownList) {
if (!newDownList.Contains(key)) {
queue.Add(new KeyboardButtonPressEvent(key, false, false, true));
}
}
currentKeyboardDownList = newDownList;
return queue;
}
/// <summary>
/// Takes in a list of new events and determines the current states of each
/// and adds them to the current queue.
/// </summary>
/// <param name="queue">Current mouse queue to add new events to.</param>
/// <param name="events">List of new events to sort and add.</param>
/// <returns>The updated current mouse event queue.</returns>
public ArrayList AddMouseEvents(ArrayList queue, byte[] events) {
ArrayList newDownList = new ArrayList();
for (int i = 0; i < events.Length; i++) {
string name = "Button:" + i;
if (events[i] != 0) {
newDownList.Add(name);
if (currentMouseDownList.Contains(name)) {
queue.Add(new MouseButtonPressEvent(name, false, true, false));
} else {
currentMouseDownList.Add(name);
queue.Add(new MouseButtonPressEvent(name, true, false, false));
}
}
}
foreach (string buttonName in currentMouseDownList) {
if (!newDownList.Contains(buttonName)) {
queue.Add(new MouseButtonPressEvent(buttonName, false, false, true));
}
}
currentMouseDownList = newDownList;
return queue;
}
/// <summary>
/// Takes in a list of new events and determines the current states of each
/// and adds them to the current queue.
/// </summary>
/// <param name="queue">Current joystick queue to add new events to.</param>
/// <param name="events">List of new events to sort and add.</param>
/// <returns>The updated current joystick event queue.</returns>
public ArrayList AddJoystickEvents(ArrayList queue, byte[] events) {
ArrayList newDownList = new ArrayList();
for (int i = 0; i < events.Length; i++) {
string name = "Button:" + i;
if (events[i] != 0) {
newDownList.Add(name);
if (currentJoystickDownList.Contains(name)) {
queue.Add(new JoystickButtonPressEvent(name, false, true, false));
} else {
currentJoystickDownList.Add(name);
queue.Add(new JoystickButtonPressEvent(name, true, false, false));
}
}
}
foreach (string buttonName in currentJoystickDownList) {
if (!newDownList.Contains(buttonName)) {
queue.Add(new JoystickButtonPressEvent(buttonName, false, false, true));
}
}
currentJoystickDownList = newDownList;
return queue;
}
#endregion
#region Movement Event Adding
/// <summary>
/// Takes in assorted movement readings from the mouse to create a new event
/// and add it to the current queue.
/// </summary>
/// <param name="queue">Current mouse queue to add new event to.</param>
/// <param name="dx">Change in x-coordinate.</param>
/// <param name="dy">Change in y-coordinate.</param>
/// <param name="dz">Change in z-coordinate.</param>
/// <returns>The updated current mouse event queue.</returns>
public ArrayList AddMouseMovementEvent(ArrayList queue, int dx, int dy, int dz) {
if (dx != 0 || dy != 0 || dz != 0) {
queue.Add(new MouseMovementEvent(dx, dy, dz));
}
return queue;
}
/// <summary>
/// Takes in assorted movement readings from the joystick to create a new event
/// and add it to the current queue.
/// </summary>
/// <param name="queue">Current joystick queue to add new event to.</param>
/// <param name="dx">Change in x-coordinate.</param>
/// <param name="dy">Change in y-coordinate.</param>
/// <param name="dz">Change in z-coordinate.</param>
/// <returns>The updated current joystick event queue.</returns>
public ArrayList AddJoystickMovementEvent(ArrayList queue, int dx, int dy, int dz) {
if (dx != 0 || dy != 0 || dz != 0) {
queue.Add(new JoystickMovementEvent(dx, dy, dz));
}
return queue;
}
#endregion
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpDX" version="4.2.0" targetFramework="net40" />
<package id="SharpDX.DirectInput" version="4.2.0" targetFramework="net40" />
</packages>

View File

@@ -0,0 +1,273 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Collections;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.LUCIE
{
/// <summary>
/// Delegate for receiving information about clicks on LUCIE components.
/// </summary>
public delegate void ClickCallback(AbstractComponent sender);
/// <summary>
/// Delegate for receiving information about child additions and removals in LUCIE.
/// </summary>
public delegate void ChildCallback(AbstractComponent sender, AbstractComponent child);
/// <summary>
/// Delegate for receiving information about resizing a component.
/// </summary>
public delegate void ResizedCallback(AbstractComponent sender, Size oldSize);
/// <summary>
/// The base component class, from which all of the more specific controls, such as buttons and labels, will be derived.
/// </summary>
public abstract class AbstractComponent : AbstractRenderable
{
#region Private Members
/// <summary>
/// The bounds of the component relative to the parent component.
/// </summary>
private Rectangle mBounds;
/// <summary>
/// Whether or not this component is visible.
/// </summary>
private bool mIsVisible;
/// <summary>
/// The list of child components.
/// </summary>
private IList mChildren;
#endregion
#region Events
/// <summary>
/// Triggered whenever the component is clicked.
/// </summary>
public event ClickCallback Click;
/// <summary>
/// Triggers the click event.
/// </summary>
public void OnClick()
{
//Notify self:
Clicked();
//Notify others:
if (Click != null)
{
Click(this);
}
}
/// <summary>
/// Triggered whenever a child is added to or removed from this component.
/// </summary>
public event ChildCallback ChildrenChanged;
/// <summary>
/// Triggers the ChildrenChanged event.
/// </summary>
/// <param name="child"></param>
public void OnChildrenChanged(AbstractComponent child)
{
if (ChildrenChanged != null)
{
ChildrenChanged(this, child);
}
}
/// <summary>
/// Triggered whenever the component's Size property is changed.
/// </summary>
public event ResizedCallback Resized;
/// <summary>
/// Triggers the Resized event.
/// </summary>
/// <param name="oldSize"></param>
public void OnResized(Size oldSize)
{
if (Resized != null)
{
Resized(this, oldSize);
}
}
#endregion
#region Initialization and Cleanup
/// <summary>
/// Default constructor that creates a new component of zero size, at the origin, which is invisible.
/// </summary>
public AbstractComponent()
{
mBounds = new Rectangle(0, 0, 0, 0);
mIsVisible = false;
mChildren = new ArrayList();
}
#endregion
#region Properties
/// <summary>
/// Whether or not this component is visible.
/// </summary>
public bool IsVisible
{
get { return mIsVisible; }
set { mIsVisible = value; }
}
/// <summary>
/// The location of the component.
/// </summary>
public Point Location
{
get { return mBounds.Location; }
set { mBounds.Location = value; }
}
/// <summary>
/// The size of the component. This will be set automagically. So get your grubby paws away from the setter.
/// </summary>
public Size Size
{
get { return mBounds.Size; }
//TODO: Now, you know, .NET 2.0 supports this. We should swtich. We TOTALLY should.
//protected//
set
{
Size oldSize = mBounds.Size;
mBounds.Size = value;
this.OnResized(oldSize);
}
}
/// <summary>
/// Gets the bounds of the control.
/// </summary>
public Rectangle Bounds
{
get { return mBounds; }
}
/// <summary>
/// The children of this component.
/// </summary>
public IList Children
{
get { return mChildren; }
}
#endregion
#region Parents and Children
/// <summary>
/// Adds a child to this component.
/// </summary>
/// <param name="child"></param>
public void AddChild(AbstractComponent child)
{
if (!mChildren.Contains(child))
{
mChildren.Add(child);
this.OnChildrenChanged(child);
}
}
/// <summary>
/// Removes the child from this component, if such child exists.
/// </summary>
/// <param name="child"></param>
public void RemoveChild(AbstractComponent child)
{
if (mChildren.Contains(child))
{
mChildren.Remove(child);
this.OnChildrenChanged(child);
}
}
/// <summary>
/// Returns the component at the specified coordinates, or null if no such component exists.
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public AbstractComponent FindChildAt(Point position)
{
AbstractComponent theChild = null;
if (!this.mBounds.Contains(position))
{
//The position is out of my bounds, so no component there.
return null;
}
position.Offset(-this.Location.X, -this.Location.Y);
//We want to check the top components first, so we must iterate the list in reverse:
for (int i = this.Children.Count - 1; i >= 0; i--)
{
AbstractComponent c = (AbstractComponent) this.Children[i];
theChild = c.FindChildAt(position);
if (theChild != null) break;
}
position.Offset(this.Location.X, this.Location.Y);
if (theChild == null)
{
if (this.IsVisible)
return this;
else
return null;
}
else
{
return theChild;
}
}
#endregion
#region IRenderable Members
public override Size GetSize()
{
return this.Size;
}
public override void Render(Rectangle coordinates, IRenderParameters parameters)
{
if (this.IsVisible)
{
coordinates.Offset(this.Location.X, this.Location.Y);
RenderSelf(coordinates, parameters);
//Render children:
foreach (AbstractComponent c in mChildren)
{
c.Render(coordinates, parameters);
}
coordinates.Offset(-this.Location.X, -this.Location.Y);
}
}
protected abstract void RenderSelf(Rectangle coordinates, IRenderParameters parameters);
#endregion
#region Virtual Functions
/// <summary>
/// Gets called when the control is clicked.
/// </summary>
public virtual void Clicked() { }
#endregion
}
}

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,107 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Drawing;
namespace Icarus.LUCIE
{
/// <summary>
/// Specifies how the components in the grid will be laid out.
/// </summary>
public enum Layout
{
Row,
Column
}
/// <summary>
/// This is a grid of components.
/// </summary>
/// Basically, we can add a bunch of components to this control and they will be nicely laid out in a row or column.
public class ComponentGrid : AbstractComponent
{
/// <summary>
/// The layout of the grid.
/// </summary>
private Layout mLayout;
/// <summary>
/// Initializes the component grid.
/// </summary>
/// <param name="l">How will the components be laid out?</param>
public ComponentGrid(Layout l)
{
this.Layout = l;
//Register to listen for child changes:
this.ChildrenChanged += new ChildCallback(ComponentGrid_ChildrenChanged);
}
/// <summary>
/// Gets or sets how the components are laid out.
/// </summary>
public Layout Layout
{
get { return mLayout; }
set
{
this.mLayout = value;
this.LayOutComponents();
}
}
/// <summary>
/// This function lays out the components and updates my own dimensions.
/// </summary>
private void LayOutComponents()
{
//The position for the next component:
Point position = new Point(0, 0);
//The maximum dimension in the direction perpendicular to the one being laid out in:
int maximumDimension = 0;
foreach (AbstractComponent child in this.Children)
{
child.Location = position;
switch (this.Layout)
{
case Layout.Column:
maximumDimension = Math.Max(maximumDimension, child.Size.Width);
position.Y += child.Size.Height;
break;
case Layout.Row:
maximumDimension = Math.Max(maximumDimension, child.Size.Height);
position.X += child.Size.Width;
break;
}
}
switch (this.Layout)
{
case Layout.Column:
this.Size = new Size(maximumDimension, position.Y);
break;
case Layout.Row:
this.Size = new Size(position.X, maximumDimension);
break;
}
}
protected override void RenderSelf(System.Drawing.Rectangle coordinates, Icarus.Graphics.Animation.IRenderParameters parameters)
{
//Nothing special to do. The rendering of children is done on a higher level.
}
private void ComponentGrid_ChildrenChanged(AbstractComponent sender, AbstractComponent child)
{
//Update layout:
this.LayOutComponents();
}
}
}

View File

@@ -0,0 +1,100 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.LUCIE
{
/// <summary>
/// This is just like a component grid, except it also can highlight an item with a special image.
/// </summary>
public class HighlightGrid : ComponentGrid
{
/// <summary>
/// The animation used to highlight the selected component.
/// </summary>
private FramesetAnimation mHighlightAnimation;
/// <summary>
/// Which component is highlighted.
/// </summary>
private AbstractComponent mHighlightedComponent;
/// <summary>
/// The position of the highlight animation.
/// </summary>
private Point mHighlightPosition = new Point(0, 0);
/// <summary>
/// Initializes the highlight grid.
/// </summary>
/// <param name="l">The layout of the components.</param>
/// <param name="highlightAnimation">The animation used to highlight the selected item.</param>
public HighlightGrid(Layout l, FramesetAnimation highlightAnimation) : base(l)
{
this.HighlightAnimation = highlightAnimation;
}
/// <summary>
/// The animation used to highlight the selected component.
/// </summary>
public FramesetAnimation HighlightAnimation
{
get { return this.mHighlightAnimation; }
set { this.mHighlightAnimation = value; }
}
/// <summary>
/// Which child should be highlighted?
/// </summary>
public AbstractComponent HighlightedComponent
{
get { return this.mHighlightedComponent; }
set
{
this.mHighlightedComponent = value;
this.UpdateHighlight();
}
}
/// <summary>
/// Updates the position of the highlight depending on which component is currently selected.
/// </summary>
private void UpdateHighlight()
{
if (this.HighlightedComponent != null)
{
//Find the center of the component:
switch (this.Layout)
{
case Layout.Column:
mHighlightPosition.X = this.Size.Width / 2;
mHighlightPosition.Y = this.HighlightedComponent.Location.Y + this.HighlightedComponent.Size.Height / 2;
break;
case Layout.Row:
mHighlightPosition.X = this.HighlightedComponent.Location.X + this.HighlightedComponent.Size.Width / 2;
mHighlightPosition.Y = this.Size.Height / 2;
break;
}
}
}
protected override void RenderSelf(Rectangle coordinates, IRenderParameters parameters)
{
base.RenderSelf(coordinates, parameters);
if (this.HighlightAnimation != null && this.HighlightedComponent != null)
{
coordinates.Offset(mHighlightPosition);
this.HighlightAnimation.CurrentFrame.Render(coordinates, parameters);
this.HighlightAnimation.update(1);
coordinates.Offset(-mHighlightPosition.X, -mHighlightPosition.Y);
}
}
}
}

View File

@@ -0,0 +1,35 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.LUCIE
{
/// <summary>
/// This is a simple component that just displays a static image.
/// </summary>
public class ImageComponent : AbstractComponent
{
private Frameset mFrameset;
/// <summary>
/// Creates a new image component. Note that the image will be automagically sized to the proper dimensions.
/// </summary>
/// <param name="image">The image to display. Note that it doesn't have to have the fancy frameset markup. Any old image will do.</param>
public ImageComponent(Bitmap image)
{
this.mFrameset = new Frameset();
mFrameset.addFrame(image, new Point(0, 0));
this.Size = image.Size;
}
protected override void RenderSelf(Rectangle coordinates, Icarus.Graphics.Animation.IRenderParameters parameters)
{
mFrameset.getFrameAt(0).Render(coordinates, parameters);
}
}
}

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>7.10.3077</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8532E9F7-4E6A-4CD8-A3E5-FC5E8811635C}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon />
<AssemblyKeyContainerName />
<AssemblyName>Icarus.LUCIE</AssemblyName>
<AssemblyOriginatorKeyFile />
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>Icarus.LUCIE</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile />
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractComponent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ComponentGrid.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="HighlightGrid.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ImageComponent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Label.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RootComponent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="StatusBar.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Graphics\Animation\Animation.csproj">
<Project>{768bfc0c-09de-479d-8a79-343390a1eb2e}</Project>
<Name>Animation</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,69 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.LUCIE
{
/// <summary>
/// This is a simple label that can be used to... well, label things.
/// </summary>
/// For those of you that have lived under a rock since before Windows 1.0 came out, a label
/// is a piece of text that can be displayed at an arbitrary location on screen.
/// For instance, it could be displayed next to this big red button and say something
/// like: don't push this button!
public class Label : AbstractComponent
{
/// <summary>
/// The context used to render the label.
/// </summary>
private AbstractText mText;
/// <summary>
/// Creates a new label with black color and default font.
/// </summary>
/// <param name="text">The text of the label</param>
public Label(string text) : this(text, Color.Black) { }
/// <summary>
/// Creates a new label with the specified color and default font.
/// </summary>
/// <param name="text"></param>
/// <param name="c"></param>
public Label(string text, Color c) : this(text, c, new Font(FontFamily.GenericSerif.Name, 12)) { }
/// <summary>
/// Creates a new label with the specified text, color and font. Note that the size of the label
/// will be automagically set to fit the text. However, you still need to explicitly
/// set the position, and make it visible and such.
/// </summary>
/// <param name="text">The text of the label</param>
/// <param name="c">The color of the label</param>
/// <param name="f">The font of the label</param>
public Label(string text, Color c, Font f)
{
mText = AnimationFactory.getInstance().makeText(text, c, f);
this.Size = mText.GetSize();
}
/// <summary>
/// The text string of the label.
/// </summary>
public string Text
{
get
{
return mText.GetText();
}
}
protected override void RenderSelf(Rectangle coordinates, IRenderParameters parameters)
{
mText.Render(coordinates, parameters);
}
}
}

View File

@@ -0,0 +1,117 @@
// $Author: asskoala $
// $Date: 2005/12/11 21:07:21 $
// $Revision: 1.1 $
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Icarus.LUCIE
{
/// <summary>
/// The root component is the invisible container that will have all of the components in a single interface in it. It is told who our parent .NET control is and uses it for things like getting mouse input, if necessary. Note that this component will always resize itself to match the dimensions of the parent control.
/// </summary>
public class RootComponent: AbstractComponent
{
/// <summary>
/// The parent control of the UI tree.
/// </summary>
private Control mParentControl;
private bool mListeningForEvents = false;
/// <summary>
/// Initializes the root component.
/// </summary>
/// <param name="parent">Which control do we use for user events and such?</param>
public RootComponent(Control parent)
{
this.mParentControl = parent;
UpdateBounds();
}
/// <summary>
/// Sets whether or not this control should listen for events.
/// </summary>
public bool IsListeningForEvents
{
get { return mListeningForEvents; }
set
{
if (value)
{
if (!IsListeningForEvents)
{
//Update variable:
mListeningForEvents = true;
//Attach handlers:
this.mParentControl.SizeChanged += new EventHandler(mParentControl_SizeChanged);
this.mParentControl.MouseUp += new MouseEventHandler(mParentControl_MouseUp);
}
}
else
{
if (IsListeningForEvents)
{
//Update variable:
mListeningForEvents = false;
//Detach the events:
this.mParentControl.SizeChanged -= new EventHandler(mParentControl_SizeChanged);
this.mParentControl.MouseUp -= new MouseEventHandler(mParentControl_MouseUp);
}
}
}
}
/// <summary>
/// The parent .NET control of the UI tree.
/// </summary>
public Control ParentControl
{
get { return mParentControl; }
}
/// <summary>
/// This function will set the bounds of the root component to match the bounds of the parent control.
/// </summary>
private void UpdateBounds()
{
this.Location = new Point(0, 0);
this.Size = this.mParentControl.Size;
}
/// <summary>
/// Gets called whenever the size of the parent control changes.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mParentControl_SizeChanged(object sender, EventArgs e)
{
this.UpdateBounds();
}
/// <summary>
/// Gets called whenever the mouse button goes up over the control, which is our cue for a click.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mParentControl_MouseUp(object sender, MouseEventArgs e)
{
AbstractComponent c = this.FindChildAt(new Point(e.X, e.Y));
if (c != null)
{
//We've been clickzorred!
c.OnClick();
}
}
protected override void RenderSelf(Rectangle coordinates, Icarus.Graphics.Animation.IRenderParameters parameters)
{
//I'm invisible.
}
}
}

View File

@@ -0,0 +1,150 @@
using System;
using System.Drawing;
using Icarus.Graphics.Animation;
namespace Icarus.LUCIE
{
/// <summary>
/// This is a status bar, which can be used to display the value of something out of a maximum. So, for examples, such things as health of the player, or the progress of loading a level can all be displayed using a bar.
/// </summary>
public class StatusBar : AbstractComponent
{
private int mMaximumValue;
private int mCurrentValue;
private int mLeftOffset;
private AbstractComponent mRightEnd;
private TiledFrame mBar;
/// <summary>
/// Creates a new status bar.
/// </summary>
/// <param name="leftEnd">The image to use on the left end of the bar. Can be null to have no left end.</param>
/// <param name="barFiller">The image to use for the filler for the bar itself. Must be provided.</param>
/// <param name="rightEnd">The image to use on the right end of the bar. Can be null to have no right end.</param>
public StatusBar(Bitmap leftEnd, Bitmap barFiller, Bitmap rightEnd)
{
int height = 0;
if (leftEnd == null)
{
mLeftOffset = 0;
}
else
{
mLeftOffset = leftEnd.Width;
ImageComponent left = new ImageComponent(leftEnd);
left.Location = new Point(0, 0);
left.IsVisible = true;
this.AddChild(left);
height = Math.Max(height, left.Size.Height);
}
if (rightEnd == null)
{
mRightEnd = null;
}
else
{
mRightEnd = new ImageComponent(rightEnd);
mRightEnd.Location = new Point(mLeftOffset, 0);
mRightEnd.IsVisible = true;
this.AddChild(mRightEnd);
height = Math.Max(height, mRightEnd.Size.Height);
}
mBar = new TiledFrame();
IFrame barFrame = AnimationFactory.getInstance().makeBlankFrame();
barFrame.initialize(new Point(0, 0), barFiller);
mBar.ChildRenderable = barFrame;
mBar.GridSize = new Size(0, 1);
height = Math.Max(height, mBar.GetSize().Height);
//Set my own size, at least we know the height:
Size s = this.Size;
s.Height = height;
this.Size = s;
}
/// <summary>
/// The maximum value the bar can display.
/// </summary>
public int MaximumValue
{
get { return mMaximumValue; }
set
{
// Set the value:
mMaximumValue = value;
// Enforce current value constraints and update as needed:
CurrentValue = CurrentValue;
}
}
/// <summary>
/// The current value the bar is displaying.
/// </summary>
public int CurrentValue
{
get { return mCurrentValue; }
set
{
if (mCurrentValue == value) return;
mCurrentValue = Math.Min(value, MaximumValue);
ProcessValueUpdate();
}
}
/// <summary>
/// Updates the visual representation of the bar as needed.
/// </summary>
private void ProcessValueUpdate()
{
// Compute the length of the bar for 100%:
double length = this.Size.Width - mLeftOffset - mRightEnd.Size.Width;
// Compute the percent fill of the bar:
double percent = ((double) CurrentValue) / ((double) MaximumValue);
if (percent <= 0.001)
{
this.IsVisible = false;
}
else
{
this.IsVisible = true;
// Compute the length of the bar:
length *= percent;
// Now, find the number of units of filler we need:
int fillerCount = (int) Math.Floor(length / ((double) mBar.ChildRenderable.GetSize().Width));
// Now we can set the size of the tiled grid:
Size s = mBar.GridSize;
s.Width = fillerCount;
mBar.GridSize = s;
// Finally, offset right end appropriately:
Point l = mRightEnd.Location;
l.X = mLeftOffset + mBar.GetSize().Width;
mRightEnd.Location = l;
}
}
protected override void RenderSelf(Rectangle coordinates, IRenderParameters parameters)
{
coordinates.X += mLeftOffset;
mBar.Render(coordinates, parameters);
coordinates.X -= mLeftOffset;
}
}
}

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,68 @@
using System;
using Icarus.Logic.Physics;
using Icarus.Graphics.Animation;
namespace Icarus.Logic
{
/// <summary>
/// This is a child object. Basically, it means it's a subcomponent of another object. For instance, suppose we have the Merc world object. He could have a "whip" child object.
/// </summary>
public class ChildObject: WorldObject
{
#region Data
/// <summary>
/// The anchor point for the child.
/// </summary>
private Point mAnchorPoint;
/// <summary>
/// The parent world object.
/// </summary>
private WorldObject mParent;
#endregion
#region Fields
/// <summary>
/// Anchor Point. The anchor point is the coordinate of the parent object where the top-left corner of the child goes.
/// </summary>
public Point AnchorPoint
{
get { return mAnchorPoint; }
set { mAnchorPoint = value; }
}
/// <summary>
/// The parent of the child object.
/// </summary>
[System.Xml.Serialization.XmlIgnore]
public WorldObject Parent
{
get { return mParent; }
set { mParent = value; }
}
/// <summary>
/// The location of the child component.
/// </summary>
public override Point Location
{
get
{
return this.Parent.Location.Add(this.AnchorPoint);
}
}
/// <summary>
/// Velocity of the child component.
/// </summary>
public override Vector Velocity
{
get
{
return this.Parent.Velocity;
}
}
#endregion
}
}

View File

@@ -0,0 +1,129 @@
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Specialized;
namespace Icarus.Logic.Controllers
{
/// <summary>
/// This guy provides us with controllers.
/// </summary>
public sealed class ControllerFactory
{
#region Singleton Stuff
/// <summary>
/// Singleton Implementation.
/// </summary>
private static ControllerFactory mgInstance = new ControllerFactory();
/// <summary>
/// Singleton Implementation.
/// </summary>
public static ControllerFactory Instance
{
get { return ControllerFactory.mgInstance; }
}
#endregion
#region Private Parts
/// <summary>
/// The default controller.
/// </summary>
private IController mDefaultController = new DefaultController();
/// <summary>
/// The dictionary of registered controllers. This is so that we don't have to look up the type through reflection every time.
/// </summary>
private IDictionary mControllerTypes;
/// <summary>
/// Initializes the controller factory.
/// </summary>
private ControllerFactory()
{
// Initialize the dictinary of controllers:
mControllerTypes = new ListDictionary();
// Register the default controller:
this.RegisterControllerType(mDefaultController.GetType().FullName);
}
/// <summary>
/// Registers the controller type with the dictionary.
/// </summary>
/// <param name="fullName"></param>
private void RegisterControllerType(string fullName)
{
// First, we need to actually find this type they speak of:
Type controllerType = GetTypeForName(fullName);
//TODO: Check that controllerType implements IController.
// Add this to the list:
mControllerTypes.Add(controllerType.FullName, controllerType);
}
/// <summary>
/// Returns the type corresponding to the name passed in, or null if the type is undefined.
/// </summary>
/// <param name="fullName"></param>
/// <returns></returns>
private Type GetTypeForName(string fullName)
{
// Get the main executable assembly:
Assembly entryAssembly = Assembly.GetEntryAssembly();
// See if the type is defined in that assembly:
Type result = entryAssembly.GetType(fullName, false, false);
if (result != null) { return result; }
// Get the list of referenced assemblies:
AssemblyName[] referencedAssemblies = entryAssembly.GetReferencedAssemblies();
// Check each referenced assembly for the type:
foreach (AssemblyName aName in referencedAssemblies)
{
Assembly a = Assembly.Load(aName);
result = a.GetType(fullName, false, false);
if (result != null) { return result; }
}
return null;
}
/// <summary>
/// Returns a controller for the specified type.
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
private IController GetControllerForType(Type t)
{
return (IController) t.GetConstructor(Type.EmptyTypes).Invoke(null);
}
#endregion
/// <summary>
/// Returns the default controller for objects.
/// </summary>
public IController DefaultController
{
get { return this.mDefaultController; }
}
/// <summary>
/// Returns a controller for the type whose fully qualified name is supplied. Of course, note that if the specified type is not actually a controller, then bad things will happen (exceptions).
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public IController GetControllerForType(string type)
{
if (!mControllerTypes.Contains(type))
{
this.RegisterControllerType(type);
}
return this.GetControllerForType(mControllerTypes[type] as Type);
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Icarus.Logic.Controllers
{
/// <summary>
/// This is the default controller that doesn't really do anything.
/// </summary>
public class DefaultController: IController
{
public void UpdateObject(PhysicsObject obj)
{
//Nothing to do...
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace Icarus.Logic.Controllers
{
/// <summary>
/// The implementors of this interface are controllers that can control a world object.
/// </summary>
public interface IController
{
/// <summary>
/// Updates the world object passed in.
/// </summary>
/// <param name="obj"></param>
void UpdateObject(PhysicsObject obj);
}
}

View File

@@ -0,0 +1,167 @@
using System;
using System.Collections;
using System.Threading;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// I am the heart of the Icarus Game Engine
/// I basically cause everything to start moving, sort of like a Spark Plug.
/// I am a Singleton and I get started when the user turns the key by
/// executing the executable created by the Runner project.
/// </summary>
public class GameEngine
{
#region Instance Variables
/// <summary>
/// This is the stack of game states we have running.
/// </summary>
private Stack mGameStates;
/// <summary>
/// This tells us if we are running, paused or stopped.
/// </summary>
private int iDoRun = -1;
#endregion
#region Singleton Stuff
private static GameEngine instance = new GameEngine();
/// <summary>
/// Private Constructor for the Game Engine
/// It is a Singleton so noone should ever touch the Constructor
/// </summary>
private GameEngine()
{
this.mGameStates = new Stack();
//We need to do this instead of using PushState function, because now the stack is empty.
this.mGameStates.Push(new RootState());
}
/// <summary>
/// The Singleton GameEngine instance
/// </summary>
public static GameEngine Instance
{
get { return instance; }
}
#endregion
#region Game State Controls
//TODO: When pushing and popping the states, should we check the state of the engine?
// Like, suppose we are paused and push a state. Should we call pause on it so it doesn't do anything silly?
/// <summary>
/// The current state of the game engine.
/// </summary>
public IGameState CurrentState
{
get { return (IGameState) this.mGameStates.Peek(); }
}
/// <summary>
/// Pushes a game state onto the game state stack. The state on top of the stack is always the active one.
/// </summary>
/// <param name="state">The new active state.</param>
public void PushState(IGameState state)
{
//Pause the current state:
this.CurrentState.Pause();
//Enter the new state:
state.Enter();
//Push the new state on the stack:
this.mGameStates.Push(state);
this.CurrentState.Unpause();
}
/// <summary>
/// Pops the current state off the state stack. The previous active state will become active once again.
/// </summary>
public void PopState()
{
//Exit current state:
this.CurrentState.Exit();
//Pop state:
this.mGameStates.Pop();
//Unpause the next state:
this.CurrentState.Unpause();
}
/// <summary>
/// Renders the current state.
/// </summary>
/// <param name="parameters">Render parameters</param>
public void RenderCurrentState(Icarus.Graphics.Animation.IRenderParameters parameters)
{
this.CurrentState.RenderState(parameters);
}
#endregion
#region Run Controls
/// <summary>
/// Start the game engine.
/// </summary>
public void Play()
{
this.CurrentState.Unpause();
this.iDoRun = 1;
}
/// <summary>
/// Pause the game engine.
/// </summary>
public void Pause()
{
this.iDoRun = -1;
this.CurrentState.Pause();
}
/// <summary>
/// Stop the game engine. Note that this will pop all the states, so we stop cleanly.
/// </summary>
public void Stop()
{
//Pop all the states so we stop cleanly:
while (!this.CurrentState.GetType().Equals(typeof(RootState)))
{
this.PopState();
}
this.iDoRun = 0;
}
#endregion
#region Main Game Engine Loop
/// <summary>
/// The function that needs to be run in its own thread. This controls the game engine.
/// </summary>
public void RunThread()
{
while (this.iDoRun != 0)
{
DateTime start = DateTime.Now;
int delay = (int) ((float)GameSettings.Instance.sv_updateRate / GameSettings.Instance.sv_timescale);
if (this.iDoRun > 0)
{
this.CurrentState.Step(delay);
}
int millis = DateTime.Now.Subtract(start).Milliseconds;
if (millis < delay)
{
Thread.Sleep(delay - millis);
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,37 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// I am a combination of Relations that define who
/// my enemies and friends are.
///
/// A Relation is composed of a friend and an enemy
/// and is loaded as a script.
///
/// </summary>
public class GameFaction
{
//private Relation[] arrRelations;
private string strFactionName;
/// <summary>
/// The faction Name
///
/// Just a string
/// </summary>
public string Name {
get { return this.strFactionName; }
set { this.strFactionName = value;}
}
/// <summary>
/// Initialize the GameFaction object to default values
/// </summary>
public GameFaction()
{
strFactionName = null;
}
}
}

View File

@@ -0,0 +1,49 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// I contain the Vital information necessary for a great game.
///
/// I, personally, love value types.
/// </summary>
public class GameProperties
{
private float fHealth;
private float fCollisionDamage;
/// <summary>
/// This should hold the health of the current Game Object.
/// </summary>
public float Health {
get { return this.fHealth; }
set { this.fHealth = value;}
}
/// <summary>
/// This should contain the damage inflicted by the object
/// upon unfriendly objects during a collision
/// </summary>
public float CollisionDamage {
get { return this.fCollisionDamage; }
set { this.fCollisionDamage = value;}
}
/// <summary>
/// Print the properties of the object
/// </summary>
public void PrintGameProperties() {
Console.WriteLine(this.ToString());
}
/// <summary>
/// Convert the GameProperties into a string Representation
/// </summary>
/// <returns>GameProperties string representation</returns>
public override string ToString() {
return ("GameProperties:\n" +
" Health: " + fHealth +
" CollisionDamage: " + fCollisionDamage);
}
}
}

View File

@@ -0,0 +1,358 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// I am a singleton which can be used to retrieve Game Engine settings.
/// Members are straightforward to access.
/// </summary>
public class GameSettings
{
#region Instance Variables
/// <summary>
/// Defines the game difficulty, changes the AI, and is used by Game Calculations.
/// </summary>
private int iDifficulty;
/// <summary>
/// The timescale is used to define the number of times per
/// second that the GameEngine executes to update the world.
/// </summary>
private float iTimeScale;
/// <summary>
/// Defines whether cheats are on or off.
/// </summary>
private bool bCheatsEnabled;
/// <summary>
/// Defines how many particles are pre-allocated when a level loads.
/// </summary>
private uint uiMaxParticles;
/// <summary>
/// Defines the number of particles to dynamically load at a time
/// when the max number of particles is infinite.
/// </summary>
private uint uiParticleLoadRate;
/// <summary>
/// Defines how many items are pre-allocated when a level loads.
/// </summary>
private uint uiMaxItems;
/// <summary>
/// Defines the number of items to dynamically load at a time
/// when the max number of items is infinite.
/// </summary>
private uint uiItemLoadRate;
/// <summary>
/// Defines how many actors are pre-allocated when a level loads.
/// </summary>
private uint uiMaxActors;
/// <summary>
/// Defines the number of actors to dynamically load at a time
/// when the max number of actors is infinite.
/// </summary>
private uint uiActorLoadRate;
/// <summary>
/// Defines how many terrain world objects are pre-allocated when a level loads.
/// </summary>
private uint uiMaxTerrainObjects;
/// <summary>
/// Defines the number of terrain ojects to dynamically load at a time
/// when the max number of terrain objects is infinite.
/// </summary>
private uint uiTerrainObjectLoadRate;
/// <summary>
/// Defines how detailed the Physics calculations are.
/// </summary>
private int iPhysicsDetail;
/// <summary>
/// Defines the maximum number of collision boxes in a level
/// </summary>
private uint uiMaxCollisionBoxes;
/// <summary>
/// The maximum internal collision rectangles a collision box can hold
/// </summary>
private uint uiMaxInternalRects;
/// <summary>
/// The maximum internal collision triangles a collision box can hold
/// </summary>
private uint uiMaxInternalTris;
/// <summary>
/// This defines the time between updates in milliseconds, default is 22 (45fps)
/// </summary>
private uint uiUpdateRate;
/// <summary>
/// The maximum number of stages per level
/// </summary>
private uint uiMaxStages;
#endregion
#region Singleton Stuff
private static GameSettings instance = new GameSettings();
/// <summary>
/// Returns the instance of the GameSettings object
/// </summary>
public static GameSettings Instance
{
get { return instance; }
}
#endregion
#region Accessors/Modifiers
/* ------------------- */
/* Accessors/Modifiers */
/* ------------------- */
/// <summary>
/// Defines the maximum number of collision boxes in a level
/// </summary>
public uint sv_maxCollisionBoxes
{
get { return this.uiMaxCollisionBoxes; }
set { this.uiMaxCollisionBoxes = value; }
}
/// <summary>
/// Defines the maximum number of internal collision rectangles
/// a collision box can hold
/// </summary>
public uint sv_maxInternalRects
{
get { return this.uiMaxInternalRects; }
set { this.uiMaxInternalRects = value; }
}
/// <summary>
/// Defines the maximum number of internal collision triangles
/// a collision box can hold
/// </summary>
public uint sv_maxInternalTris
{
get { return this.uiMaxInternalTris; }
set { this.uiMaxInternalTris = value; }
}
/// <summary>
/// A Negative difficulty should cause all enemies to freeze in place
/// (allowing debugging to take place).
/// A Positive difficulty becomes more difficult with increasing values.
/// Lowest difficulty is 0.
/// </summary>
public int sv_difficulty
{
get { return this.iDifficulty; }
set { this.iDifficulty = value;}
}
/// <summary>
/// This sets the game's TimeScale.
/// The timescale values can range from FLOAT_MIN to FLOAT_MAX.
/// Whether the full range is supported, doesn't matter.
/// Negatives don't matter, only the magnitude is used.
/// A higher number than 1.0f will result in more updates occuring per second.
/// Numbers between 0 and 1.0, exclusive, result in fewer
/// updates and, thus, the game moves "slower".
/// </summary>
public float sv_timescale
{
get { return this.iTimeScale; }
set { this.iTimeScale = value;}
}
/// <summary>
/// Activating cheats can turn on things like God Mode, which negate damage
/// effects to the player, as well as various other nifty debugging tools.
/// </summary>
public bool sv_cheats
{
get { return this.bCheatsEnabled; }
set { this.bCheatsEnabled = value;}
}
/// <summary>
/// A value of 0 means that infinite particles are allowed.
/// In the case of infinite particles, particles will be loaded dynamically
/// sv_particleLoadRate at a time.
/// Dynamic loading is much slower, but requires much less memory.
/// </summary>
public uint sv_maxParticles
{
get { return this.uiMaxParticles; }
set { this.uiMaxParticles = value;}
}
/// <summary>
/// This defines the number of particles to dynamically load at a time
/// when the max number of particles is infinite.
/// </summary>
public uint sv_particleLoadRate
{
get { return this.uiParticleLoadRate; }
set { this.uiParticleLoadRate = value;}
}
/// <summary>
/// A value of 0 means that infinite items are allowed.
/// In the case of infinite items, items will be loaded dynamically
/// sv_itemLoadRate at a time.
/// Dynamic loading is much slower, but requires much less memory.
/// </summary>
public uint sv_maxItems
{
get { return this.uiMaxItems; }
set { this.uiMaxItems = value;}
}
/// <summary>
/// This defines the number of items to dynamically load at a time
/// when the max number of items is infinite.
/// </summary>
public uint sv_itemLoadRate
{
get { return this.uiItemLoadRate; }
set { this.uiItemLoadRate = value;}
}
/// <summary>
/// A value of 0 means that infinite actors are allowed.
/// In the case of infinite actors, actors will be loaded dynamically
/// sv_actorLoadRate at a time.
/// Dynamic loading is much slower, but requires much less memory.
/// </summary>
public uint sv_maxActors
{
get { return this.uiMaxActors; }
set { this.uiMaxActors = value;}
}
/// <summary>
/// This defines the number of actors to dynamically load at a time
/// when the max number of actors is infinite.
/// </summary>
public uint sv_actorLoadRate
{
get { return this.uiActorLoadRate; }
set { this.uiActorLoadRate = value;}
}
/// <summary>
/// A value of 0 means that infinite terrain objects are allowed.
/// In the case of infinite terrain objects, terrain objects will be
/// loaded dynamically sv_terrainObjectLoadRate at a time.
/// Dynamic loading is much slower, but requires much less memory.
/// </summary>
public uint sv_maxTerrainObjects
{
get { return this.uiMaxTerrainObjects; }
set { this.uiMaxTerrainObjects = value;}
}
/// <summary>
/// This defines the number of terrain objects to dynamically load at a time
/// when the max number of terrain objects is infinite.
/// </summary>
public uint sv_TerrainObjectLoadRate
{
get { return this.uiTerrainObjectLoadRate; }
set { this.uiTerrainObjectLoadRate = value;}
}
/// <summary>
/// This may cause faster algorithms to be used in place of slower,
/// more precise algorithms.
/// This varies on Physics Engine implementation/mode.
/// Default value is 0 (Full Detail), negative values lower
/// detail and positive values (may) increase detail.
/// </summary>
public int sv_physicsDetail
{
get { return this.iPhysicsDetail; }
set { this.iPhysicsDetail = value;}
}
/// <summary>
/// This stores the time between updates in milliseconds.
///
/// Note that the variable sv_timescale speeds up or slows down the
/// game itself, this variable will affect the magnitude of vectors in
/// the Physics Engine and alter the Physics themselves
/// </summary>
public uint sv_updateRate
{
get { return this.uiUpdateRate; }
set { this.uiUpdateRate = value;}
}
/// <summary>
/// The maximum number of stages per level
/// </summary>
public uint sv_maxStages
{
get { return this.uiMaxStages; }
set { this.uiMaxStages = value; }
}
#endregion
#region Initialization
/* -------------- */
/* Initialization */
/* -------------- */
/// <summary>
/// Uses Icarus preset Game settings as defined in the variable comments.
/// </summary>
private GameSettings()
{
this.iDifficulty = 3;
this.iPhysicsDetail = 0;
this.iTimeScale = 1.0f;
this.bCheatsEnabled = false;
this.uiParticleLoadRate = 25;
this.uiMaxParticles = 1000;
this.uiItemLoadRate = 25;
this.uiMaxItems = 100;
this.uiActorLoadRate = 25;
this.uiMaxActors = 100;
this.uiTerrainObjectLoadRate = 25;
this.uiMaxTerrainObjects = 1000;
this.uiMaxCollisionBoxes = 100;
this.sv_maxInternalRects = 15;
this.sv_maxInternalTris = 15;
this.uiUpdateRate = 22; //45fps
this.uiMaxStages = 10;
}
/// <summary>
/// Load GameSettings from a File.
/// Sets the settings to the Icarus Defaults then loads the settings from
/// fileName and replaces the settings specified.
/// </summary>
/// <param name="fileName">The fileName of settings to replace defaults.</param>
private GameSettings(string fileName) : this()
{
// TODO: Implement me
}
#endregion
}
}

View File

@@ -0,0 +1,26 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// This is an adapter of the IGameState stuff, so that we don't have to implement all the functions.
/// </summary>
public class GameStateAdapter : IGameState
{
#region IGameState Members
public virtual void Enter() { }
public virtual void Step(int millis) { }
public virtual void RenderState(Icarus.Graphics.Animation.IRenderParameters parameters) { }
public virtual void Pause() { }
public virtual void Unpause() { }
public virtual void Exit() { }
#endregion
}
}

View File

@@ -0,0 +1,42 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// The interface that all game states must implement.
/// </summary>
public interface IGameState
{
/// <summary>
/// Called when we enter the state.
/// </summary>
void Enter();
/// <summary>
/// Called at every iteration of the game engine loop.
/// </summary>
/// <param name="millis">The numbher of milliseconds since the function was last called.</param>
void Step(int millis);
/// <summary>
/// Gets called when the state needs to be rendered.
/// </summary>
/// <param name="parameters"></param>
void RenderState(Icarus.Graphics.Animation.IRenderParameters parameters);
/// <summary>
/// This function will be called when the state needs to be paused to be revived later on.
/// </summary>
void Pause();
/// <summary>
/// This function will be called when the state is revived after a previous pause.
/// </summary>
void Unpause();
/// <summary>
/// Called when we exit the state.
/// </summary>
void Exit();
}
}

View File

@@ -0,0 +1,455 @@
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// Form for creating and editng levels.
/// Provides for saving and loading levels.
/// </summary>
public class LevelBuilder : System.Windows.Forms.Form
{
#region GUI Components
private System.Windows.Forms.TextBox levelNameTextBox;
private System.Windows.Forms.Label levelNameLabel;
private System.Windows.Forms.Label physicsScaleLabel;
private System.Windows.Forms.TextBox physicsScaleTextBox;
private System.Windows.Forms.Label bgImageLabel;
private System.Windows.Forms.TextBox bgImageTextBox;
private System.Windows.Forms.Button bgImageButton;
private System.Windows.Forms.Button itemButton;
private System.Windows.Forms.Button actorButton;
private System.Windows.Forms.Button terrainButton;
private System.Windows.Forms.Button particleButton;
private System.Windows.Forms.ListBox itemList;
private System.Windows.Forms.ListBox actorList;
private System.Windows.Forms.ListBox terrainList;
private System.Windows.Forms.ListBox particleList;
private System.Windows.Forms.Button loadButton;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.Button itemEditButton;
private System.Windows.Forms.Button itemRemoveButton;
private System.Windows.Forms.Button actorRemoveButton;
private System.Windows.Forms.Button actorEditButton;
private System.Windows.Forms.Button terrainRemoveButton;
private System.Windows.Forms.Button terrainEditButton;
private System.Windows.Forms.Button particleRemoveButton;
private System.Windows.Forms.Button particleEditButton;
private System.ComponentModel.Container components = null;
#endregion
#region Execution And Initialization
/// <summary>
/// Executes the Level Builder
/// </summary>
public static void Main()
{
new LevelBuilder().Show();
Console.WriteLine("You are now running the level builder program for the Icarus Game Engine.");
}
/// <summary>
/// Initialize the LevelBuilder object
/// </summary>
public LevelBuilder()
{
// Required for Windows Form Designer support
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
Console.WriteLine("You have exited the level builder program for the Icarus Game Engine.");
Console.WriteLine("Have A Nice Day!");
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.levelNameTextBox = new System.Windows.Forms.TextBox();
this.levelNameLabel = new System.Windows.Forms.Label();
this.physicsScaleLabel = new System.Windows.Forms.Label();
this.physicsScaleTextBox = new System.Windows.Forms.TextBox();
this.bgImageLabel = new System.Windows.Forms.Label();
this.bgImageTextBox = new System.Windows.Forms.TextBox();
this.bgImageButton = new System.Windows.Forms.Button();
this.itemButton = new System.Windows.Forms.Button();
this.actorButton = new System.Windows.Forms.Button();
this.terrainButton = new System.Windows.Forms.Button();
this.particleButton = new System.Windows.Forms.Button();
this.itemList = new System.Windows.Forms.ListBox();
this.actorList = new System.Windows.Forms.ListBox();
this.terrainList = new System.Windows.Forms.ListBox();
this.particleList = new System.Windows.Forms.ListBox();
this.loadButton = new System.Windows.Forms.Button();
this.saveButton = new System.Windows.Forms.Button();
this.itemEditButton = new System.Windows.Forms.Button();
this.itemRemoveButton = new System.Windows.Forms.Button();
this.actorRemoveButton = new System.Windows.Forms.Button();
this.actorEditButton = new System.Windows.Forms.Button();
this.terrainRemoveButton = new System.Windows.Forms.Button();
this.terrainEditButton = new System.Windows.Forms.Button();
this.particleRemoveButton = new System.Windows.Forms.Button();
this.particleEditButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// levelNameTextBox
//
this.levelNameTextBox.Location = new System.Drawing.Point(112, 48);
this.levelNameTextBox.Name = "levelNameTextBox";
this.levelNameTextBox.Size = new System.Drawing.Size(416, 20);
this.levelNameTextBox.TabIndex = 0;
this.levelNameTextBox.Text = "Level";
//
// levelNameLabel
//
this.levelNameLabel.Location = new System.Drawing.Point(40, 48);
this.levelNameLabel.Name = "levelNameLabel";
this.levelNameLabel.Size = new System.Drawing.Size(72, 23);
this.levelNameLabel.TabIndex = 1;
this.levelNameLabel.Text = "Level Name:";
this.levelNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// physicsScaleLabel
//
this.physicsScaleLabel.Location = new System.Drawing.Point(32, 112);
this.physicsScaleLabel.Name = "physicsScaleLabel";
this.physicsScaleLabel.Size = new System.Drawing.Size(80, 23);
this.physicsScaleLabel.TabIndex = 2;
this.physicsScaleLabel.Text = "Physics Scale:";
this.physicsScaleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// physicsScaleTextBox
//
this.physicsScaleTextBox.Location = new System.Drawing.Point(112, 112);
this.physicsScaleTextBox.Name = "physicsScaleTextBox";
this.physicsScaleTextBox.Size = new System.Drawing.Size(48, 20);
this.physicsScaleTextBox.TabIndex = 3;
this.physicsScaleTextBox.Text = "1";
//
// bgImageLabel
//
this.bgImageLabel.Location = new System.Drawing.Point(8, 80);
this.bgImageLabel.Name = "bgImageLabel";
this.bgImageLabel.Size = new System.Drawing.Size(104, 23);
this.bgImageLabel.TabIndex = 4;
this.bgImageLabel.Text = "Background Image:";
this.bgImageLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// bgImageTextBox
//
this.bgImageTextBox.Location = new System.Drawing.Point(112, 80);
this.bgImageTextBox.Name = "bgImageTextBox";
this.bgImageTextBox.ReadOnly = true;
this.bgImageTextBox.Size = new System.Drawing.Size(416, 20);
this.bgImageTextBox.TabIndex = 5;
this.bgImageTextBox.Text = "[None]";
//
// bgImageButton
//
this.bgImageButton.Location = new System.Drawing.Point(536, 80);
this.bgImageButton.Name = "bgImageButton";
this.bgImageButton.TabIndex = 6;
this.bgImageButton.Text = "Browse...";
this.bgImageButton.Click += new System.EventHandler(this.bgImageButton_Click);
//
// itemButton
//
this.itemButton.Location = new System.Drawing.Point(32, 152);
this.itemButton.Name = "itemButton";
this.itemButton.Size = new System.Drawing.Size(104, 23);
this.itemButton.TabIndex = 7;
this.itemButton.Text = "Add New Item";
this.itemButton.Click += new System.EventHandler(this.itemButton_Click);
//
// actorButton
//
this.actorButton.Location = new System.Drawing.Point(184, 152);
this.actorButton.Name = "actorButton";
this.actorButton.Size = new System.Drawing.Size(104, 23);
this.actorButton.TabIndex = 8;
this.actorButton.Text = "Add New Actor";
this.actorButton.Click += new System.EventHandler(this.actorButton_Click);
//
// terrainButton
//
this.terrainButton.Location = new System.Drawing.Point(336, 152);
this.terrainButton.Name = "terrainButton";
this.terrainButton.Size = new System.Drawing.Size(104, 23);
this.terrainButton.TabIndex = 9;
this.terrainButton.Text = "Add New Terrain";
this.terrainButton.Click += new System.EventHandler(this.terrainButton_Click);
//
// particleButton
//
this.particleButton.Location = new System.Drawing.Point(488, 152);
this.particleButton.Name = "particleButton";
this.particleButton.Size = new System.Drawing.Size(104, 23);
this.particleButton.TabIndex = 10;
this.particleButton.Text = "Add New Particle";
this.particleButton.Click += new System.EventHandler(this.particleButton_Click);
//
// itemList
//
this.itemList.Location = new System.Drawing.Point(16, 184);
this.itemList.Name = "itemList";
this.itemList.ScrollAlwaysVisible = true;
this.itemList.Size = new System.Drawing.Size(136, 238);
this.itemList.TabIndex = 11;
//
// actorList
//
this.actorList.Location = new System.Drawing.Point(168, 184);
this.actorList.Name = "actorList";
this.actorList.ScrollAlwaysVisible = true;
this.actorList.Size = new System.Drawing.Size(136, 238);
this.actorList.TabIndex = 12;
//
// terrainList
//
this.terrainList.Location = new System.Drawing.Point(320, 184);
this.terrainList.Name = "terrainList";
this.terrainList.ScrollAlwaysVisible = true;
this.terrainList.Size = new System.Drawing.Size(136, 238);
this.terrainList.TabIndex = 13;
//
// particleList
//
this.particleList.Location = new System.Drawing.Point(472, 184);
this.particleList.Name = "particleList";
this.particleList.ScrollAlwaysVisible = true;
this.particleList.Size = new System.Drawing.Size(136, 238);
this.particleList.TabIndex = 14;
//
// loadButton
//
this.loadButton.Location = new System.Drawing.Point(8, 8);
this.loadButton.Name = "loadButton";
this.loadButton.Size = new System.Drawing.Size(120, 23);
this.loadButton.TabIndex = 15;
this.loadButton.Text = "Load Level From File";
this.loadButton.Click += new System.EventHandler(this.loadButton_Click);
//
// saveButton
//
this.saveButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.saveButton.Location = new System.Drawing.Point(216, 472);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(200, 32);
this.saveButton.TabIndex = 16;
this.saveButton.Text = "Save Level";
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// itemEditButton
//
this.itemEditButton.Location = new System.Drawing.Point(24, 432);
this.itemEditButton.Name = "itemEditButton";
this.itemEditButton.Size = new System.Drawing.Size(56, 23);
this.itemEditButton.TabIndex = 17;
this.itemEditButton.Text = "Edit";
this.itemEditButton.Click += new System.EventHandler(this.itemEditButton_Click);
//
// itemRemoveButton
//
this.itemRemoveButton.Location = new System.Drawing.Point(88, 432);
this.itemRemoveButton.Name = "itemRemoveButton";
this.itemRemoveButton.Size = new System.Drawing.Size(56, 23);
this.itemRemoveButton.TabIndex = 18;
this.itemRemoveButton.Text = "Remove";
this.itemRemoveButton.Click += new System.EventHandler(this.itemRemoveButton_Click);
//
// actorRemoveButton
//
this.actorRemoveButton.Location = new System.Drawing.Point(240, 432);
this.actorRemoveButton.Name = "actorRemoveButton";
this.actorRemoveButton.Size = new System.Drawing.Size(56, 23);
this.actorRemoveButton.TabIndex = 20;
this.actorRemoveButton.Text = "Remove";
this.actorRemoveButton.Click += new System.EventHandler(this.actorRemoveButton_Click);
//
// actorEditButton
//
this.actorEditButton.Location = new System.Drawing.Point(176, 432);
this.actorEditButton.Name = "actorEditButton";
this.actorEditButton.Size = new System.Drawing.Size(56, 23);
this.actorEditButton.TabIndex = 19;
this.actorEditButton.Text = "Edit";
this.actorEditButton.Click += new System.EventHandler(this.actorEditButton_Click);
//
// terrainRemoveButton
//
this.terrainRemoveButton.Location = new System.Drawing.Point(392, 432);
this.terrainRemoveButton.Name = "terrainRemoveButton";
this.terrainRemoveButton.Size = new System.Drawing.Size(56, 23);
this.terrainRemoveButton.TabIndex = 22;
this.terrainRemoveButton.Text = "Remove";
this.terrainRemoveButton.Click += new System.EventHandler(this.terrainRemoveButton_Click);
//
// terrainEditButton
//
this.terrainEditButton.Location = new System.Drawing.Point(328, 432);
this.terrainEditButton.Name = "terrainEditButton";
this.terrainEditButton.Size = new System.Drawing.Size(56, 23);
this.terrainEditButton.TabIndex = 21;
this.terrainEditButton.Text = "Edit";
this.terrainEditButton.Click += new System.EventHandler(this.terrainEditButton_Click);
//
// particleRemoveButton
//
this.particleRemoveButton.Location = new System.Drawing.Point(544, 432);
this.particleRemoveButton.Name = "particleRemoveButton";
this.particleRemoveButton.Size = new System.Drawing.Size(56, 23);
this.particleRemoveButton.TabIndex = 24;
this.particleRemoveButton.Text = "Remove";
this.particleRemoveButton.Click += new System.EventHandler(this.particleRemoveButton_Click);
//
// particleEditButton
//
this.particleEditButton.Location = new System.Drawing.Point(480, 432);
this.particleEditButton.Name = "particleEditButton";
this.particleEditButton.Size = new System.Drawing.Size(56, 23);
this.particleEditButton.TabIndex = 23;
this.particleEditButton.Text = "Edit";
this.particleEditButton.Click += new System.EventHandler(this.particleEditButton_Click);
//
// LevelBuilder
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(624, 518);
this.Controls.Add(this.particleRemoveButton);
this.Controls.Add(this.particleEditButton);
this.Controls.Add(this.terrainRemoveButton);
this.Controls.Add(this.terrainEditButton);
this.Controls.Add(this.actorRemoveButton);
this.Controls.Add(this.actorEditButton);
this.Controls.Add(this.itemRemoveButton);
this.Controls.Add(this.itemEditButton);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.loadButton);
this.Controls.Add(this.particleList);
this.Controls.Add(this.terrainList);
this.Controls.Add(this.actorList);
this.Controls.Add(this.itemList);
this.Controls.Add(this.particleButton);
this.Controls.Add(this.terrainButton);
this.Controls.Add(this.actorButton);
this.Controls.Add(this.itemButton);
this.Controls.Add(this.bgImageButton);
this.Controls.Add(this.bgImageTextBox);
this.Controls.Add(this.bgImageLabel);
this.Controls.Add(this.physicsScaleTextBox);
this.Controls.Add(this.physicsScaleLabel);
this.Controls.Add(this.levelNameLabel);
this.Controls.Add(this.levelNameTextBox);
this.Name = "LevelBuilder";
this.Text = "LevelBuilder";
this.ResumeLayout(false);
}
#endregion
#region File System Buttons
private void loadButton_Click(object sender, System.EventArgs e)
{
}
private void saveButton_Click(object sender, System.EventArgs e)
{
}
private void bgImageButton_Click(object sender, System.EventArgs e)
{
}
#endregion
#region WorldObject Creation
private void itemButton_Click(object sender, System.EventArgs e)
{
}
private void actorButton_Click(object sender, System.EventArgs e)
{
}
private void terrainButton_Click(object sender, System.EventArgs e)
{
}
private void particleButton_Click(object sender, System.EventArgs e)
{
}
#endregion
#region WorldObject Editing
private void itemEditButton_Click(object sender, System.EventArgs e)
{
}
private void actorEditButton_Click(object sender, System.EventArgs e)
{
}
private void terrainEditButton_Click(object sender, System.EventArgs e)
{
}
private void particleEditButton_Click(object sender, System.EventArgs e)
{
}
#endregion
#region WorldObject Removal
private void itemRemoveButton_Click(object sender, System.EventArgs e)
{
}
private void actorRemoveButton_Click(object sender, System.EventArgs e)
{
}
private void terrainRemoveButton_Click(object sender, System.EventArgs e)
{
}
private void particleRemoveButton_Click(object sender, System.EventArgs e)
{
}
#endregion
}
}

View File

@@ -0,0 +1,355 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used forserialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="levelNameTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="levelNameTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="levelNameTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="levelNameLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="levelNameLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="levelNameLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="physicsScaleLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="physicsScaleLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="physicsScaleLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="physicsScaleTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="physicsScaleTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="physicsScaleTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageLabel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="bgImageLabel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageLabel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageTextBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageTextBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="bgImageTextBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="bgImageButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="bgImageButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="itemButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="actorButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="terrainButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="particleButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemList.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemList.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="itemList.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorList.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorList.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="actorList.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainList.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainList.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="terrainList.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleList.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleList.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="particleList.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="loadButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="loadButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="loadButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="saveButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="saveButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="saveButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemEditButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="itemEditButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemEditButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemRemoveButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="itemRemoveButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="itemRemoveButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorRemoveButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="actorRemoveButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorRemoveButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorEditButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="actorEditButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="actorEditButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainRemoveButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="terrainRemoveButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainRemoveButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainEditButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="terrainEditButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="terrainEditButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleRemoveButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="particleRemoveButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleRemoveButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleEditButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="particleEditButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="particleEditButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>(Default)</value>
</data>
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value>
</data>
<data name="$this.Name">
<value>LevelBuilder</value>
</data>
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>80</value>
</data>
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
</root>

View File

@@ -0,0 +1,98 @@
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using Icarus.Resources;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// This class provides the functionality of being able to
/// save and load levels. The levels are saved as xml files
/// on the harddrive.
/// </summary>
public class LevelLoader
{
#region Singleton access
/// <summary>
/// The instance of this loader
/// </summary>
private static LevelLoader instance = new LevelLoader();
/// <summary>
/// The Singleton LevelLoader instance
/// </summary>
public static LevelLoader Instance
{
get { return instance; }
}
#endregion
#region Methods
/// <summary>
/// Loads a level from an XML file.
/// </summary>
/// <param name="fileName">The filename of the level XML file.</param>
/// <returns>The loaded level or null if no level could be loaded.</returns>
public Level LoadLevelXML(string fileName)
{
//Set the type of Object for deserialization
Level level = new Level();
XmlSerializer xmls = new XmlSerializer(level.GetType());
//Open level XML file
if (!File.Exists(fileName)) return null;
FileStream fs = new FileStream(fileName, FileMode.Open);
if(fs == null) return null;
//read level file and create level
XmlReader reader = new XmlTextReader(fs);
level = (Level) xmls.Deserialize(reader);
//Close file
fs.Close();
return level;
}
/// <summary>
/// Saves a level to an XML file.
/// </summary>
/// <param name="fileName">The filename used to save the level XML file.</param>
/// <returns>True for success, False for failure.</returns>
public bool SaveLevelXML(string fileName, Level level)
{
//Setup serializer:
XmlSerializer xmls = new XmlSerializer(level.GetType());
//Create filestream to save level
FileStream fs = new FileStream(fileName, FileMode.Create);
//Save level
xmls.Serialize(fs, level);
//Close file
fs.Close();
//return success;
return true;
}
/// <summary>
/// Returns the list of ids of available levels.
/// </summary>
/// <returns></returns>
public string[] GetLevelIDList()
{
return Directory.GetFiles(ResourceManager.Instance.LevelPath, "*.xml");
}
#endregion
}
}

View File

@@ -0,0 +1,6 @@
/*
* This contains the specs for relations defined in the game
* Note that Relations themselves are all scripted!
*/

View File

@@ -0,0 +1,15 @@
using System;
namespace Icarus.Logic.GameEngine
{
/// <summary>
/// This is the root state for the game engine. Basically, it makes sure that everything dies when we quit.
/// </summary>
public class RootState : GameStateAdapter
{
public override void Exit()
{
System.Windows.Forms.Application.Exit();
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using Icarus.Graphics.Animation;
namespace Icarus.Logic
{
/// <summary>
/// The implementors of this interface can be viewed on screen.
/// </summary>
public interface IViewable
{
/// <summary>
/// Gets the location of the viewable in world coordinates.
/// </summary>
Icarus.Logic.Physics.Point Location { get; }
/// <summary>
/// Gets the id of the animation to use for the viewable.
/// </summary>
FramesetAnimation Animation { get; }
}
}

View File

@@ -0,0 +1,110 @@
using System;
using System.IO;
using System.Drawing;
using System.Xml.Serialization;
using System.Collections;
using Icarus.Graphics.Animation;
using Icarus.Logic.GameEngine;
using Icarus.Logic.Physics;
namespace Icarus.Logic {
/// <summary>
/// Contains the necessary items used to describe a Game level.
/// Holds the information about the current list of WorldObjects,
/// the view background, the view terrain collision mask, and
/// other necessary information used to play the game level.
/// </summary>
public class Level
{
#region Instance Variables
/// <summary>
/// An array of all the stages this level contains.
/// </summary>
private Stage[] stages = null;
/// <summary>
/// The index of the current stage
/// </summary>
private int iCurrStageIndex = 0;
#endregion
#region Initialization
/* -------------- */
/* Initialization */
/* -------------- */
/// <summary>
/// Makes a new level.
/// </summary>
public Level()
{
stages = new Stage[GameSettings.Instance.sv_maxStages];
}
#endregion
#region Acessing/Modifying
/// <summary>
/// The array of stages that belong to this level
/// </summary>
public Stage[] Stages
{
get { return this.stages; }
set { this.stages = value; }
}
/// <summary>
/// The current stage of this level
/// </summary>
[XmlIgnore]
public Stage CurrStage
{
get { return this.stages[this.iCurrStageIndex]; }
set
{
for(int i = 0; i < GameSettings.Instance.sv_maxStages; i++)
{
if(value.Equals(this.stages[i]))
{
//set the index for the stage that was passed in
this.CurrentStageIndex = i;
break;
}
}
}
}
/// <summary>
/// The index of the current stage in the stages array
/// </summary>
public int CurrentStageIndex
{
get { return this.iCurrStageIndex; }
set { this.iCurrStageIndex = value; }
}
#endregion
}
}

View File

@@ -0,0 +1,167 @@
using System;
using Icarus.Graphics.Animation;
namespace Icarus.Logic
{
/// <summary>
/// This is the representation of a single layer of background for the level. It's all fancy and parallax, and stuff.
/// </summary>
public class LevelBackground: IComparable
{
/// <summary>
/// The actual background animation.
/// </summary>
private FramesetAnimation mBackgroundAnimation;
/// <summary>
/// Teh Parallax factor!!1! Read the documentation for the corresponding property.
/// </summary>
private double mParallaxFactor;
/// <summary>
/// The actual renderable used to display the background. See BackgroundRenderable property documentation for more information.
/// </summary>
private IRenderable mActualRenderable;
private int mRows = 1;
private int mColumns = 1;
/// <summary>
/// Gets the background animation.
/// </summary>
public FramesetAnimation Animation
{
get { return mBackgroundAnimation; }
set
{
mBackgroundAnimation = value;
UpdateActualRenderable();
}
}
/// <summary>
/// Gets or sets how many times we need to tile the background vertically.
/// </summary>
public int Rows
{
get { return mRows; }
set
{
mRows = value;
UpdateActualRenderable();
}
}
/// <summary>
/// Gets or sets how many times we need to tile the background horizontally.
/// </summary>
public int Columns
{
get { return mColumns; }
set
{
mColumns = value;
UpdateActualRenderable();
}
}
/// <summary>
/// Gets or sets the parallax factor. The value of 0 means the background will be stationary. The value of 1 means it will be moving the same as the character. Stuff in between is stuff in between. Stuff outside the range... Hell, I don't know what will happen, but probably nothing good.
/// </summary>
public double ParallaxFactor
{
get { return mParallaxFactor; }
set { mParallaxFactor = value; }
}
/// <summary>
/// Gets the center of the background.
/// </summary>
[System.Xml.Serialization.XmlIgnore]
public Icarus.Logic.Physics.Point BackgroundCenter
{
get
{
return new Icarus.Logic.Physics.Point(this.BackgroundRenderable.GetSize().Width / 2,
this.BackgroundRenderable.GetSize().Height / 2,
0);
}
}
/// <summary>
/// Gets the renderable thing that we acutally need to make the background. This needs to be used instead of the Animation property, because the background will sometimes need to be tiled.
/// </summary>
[System.Xml.Serialization.XmlIgnore]
public IRenderable BackgroundRenderable
{
get { return mActualRenderable; }
}
/// <summary>
/// Sets the animation with the specified parameters.
/// </summary>
/// <param name="id"></param>
/// <param name="t"></param>
/// <param name="delay"></param>
public void SetAnimation(string id, AnimationType t, int delay)
{
FramesetAnimation anim = new FramesetAnimation();
anim.FramesetPath = id;
anim.AnimationType = t;
anim.AnimationDelay = delay;
this.Animation = anim;
UpdateActualRenderable();
}
#region IComparable Members
/// <summary>
/// Allows is to sort level backgrounds by parallax factor.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public int CompareTo(object obj)
{
if (obj is LevelBackground)
{
LevelBackground lb = (LevelBackground) obj;
return this.ParallaxFactor.CompareTo(lb.ParallaxFactor);
}
throw new ArgumentException("obj is not a LevelBackground", "obj");
}
#endregion
public void UpdateAnimation(long time)
{
int oldFrame = mBackgroundAnimation.CurrentFrameIndex;
mBackgroundAnimation.update(time);
if (mBackgroundAnimation.CurrentFrameIndex != oldFrame)
{
UpdateActualRenderable();
}
}
private void UpdateActualRenderable()
{
if (this.Rows < 2 && this.Columns < 2)
{
this.mActualRenderable = this.Animation.CurrentFrame;
}
else
{
TiledFrame result = new TiledFrame();
result.GridSize = new System.Drawing.Size(Columns, Rows);
result.ChildRenderable = this.Animation.CurrentFrame;
this.mActualRenderable = result;
}
}
}
}

View File

@@ -0,0 +1,306 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>7.10.3077</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{45F11B0F-760F-40A1-B7EB-ED2D164C5845}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon />
<AssemblyKeyContainerName />
<AssemblyName>Icarus.Logic</AssemblyName>
<AssemblyOriginatorKeyFile />
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>Icarus.Logic</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>Logic.xml</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Graphics\Animation\Animation.csproj">
<Project>{768bfc0c-09de-479d-8a79-343390a1eb2e}</Project>
<Name>Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Input\Input.csproj">
<Name>Input</Name>
<Project>{7BAAA06F-5B67-417E-9A36-26C5C6EB931C}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\Resources\Resources.csproj">
<Name>Resources</Name>
<Project>{592DE8CE-998E-436C-940B-11EE84B2BEAC}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\SoundEngine\SoundEngine.csproj">
<Name>SoundEngine</Name>
<Project>{34137FAB-56F2-4242-B48E-F8EB169A16DF}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.4.2.0\lib\net40\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DirectSound, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.DirectSound.4.2.0\lib\net40\SharpDX.DirectSound.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ChildObject.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Controllers\ControllerFactory.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Controllers\DefaultController.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Controllers\IController.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\GameEngine.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\GameFaction.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\GameProperties.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\GameSettings.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\GameStateAdapter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\IGameState.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\LevelBuilder.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GameEngine\LevelLoader.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\Relations.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameEngine\RootState.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IViewable.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Level.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LevelBackground.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PhysicsObject.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBox.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxCD.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxEnemyDefault.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxFloor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxMobile.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxRobotTuxHand.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxSlopeBL.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxSlopeBR.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxSlopeTL.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxSlopeTR.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxTransition.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxWall.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxWhip.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\CollisionBoxZoom.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\MovingPlatform.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\MovingPlatformHorizontal.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\MovingPlatformVertical.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsEngine.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsGeek.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsGNURobot.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsMerc.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsParticle.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsPlayer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsRectangle.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsSettings.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsShortLife.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsTuxHand.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsTuxHead.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsTuxRobot.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\PhysicsWhip.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\Point.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\RectangleFloor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\RectangleWall.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\Triangle.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\TriangleBL.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\TriangleBR.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\TriangleTL.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\TriangleTR.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\Vector.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Physics\ZoomTrigger.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Stage.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="WorldObject.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="GameEngine\LevelBuilder.resx">
<DependentUpon>LevelBuilder.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,232 @@
using System;
using System.Drawing;
using System.Xml.Serialization;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBox.
/// </summary>
// Instruct the XmlSerializer to accept other types of boxes as well.
[XmlInclude(typeof(Physics.CollisionBoxFloor))]
[XmlInclude(typeof(Physics.CollisionBoxWall))]
[XmlInclude(typeof(Physics.CollisionBoxSlopeTL))]
[XmlInclude(typeof(Physics.CollisionBoxSlopeTR))]
[XmlInclude(typeof(Physics.CollisionBoxSlopeBR))]
[XmlInclude(typeof(Physics.CollisionBoxSlopeBL))]
[XmlInclude(typeof(Physics.CollisionBoxTransition))]
[XmlInclude(typeof(Physics.CollisionBoxMobile))]
[XmlInclude(typeof(Physics.CollisionBoxRobotTuxHand))]
[XmlInclude(typeof(Physics.CollisionBoxEnemyDefault))]
[XmlInclude(typeof(Physics.CollisionBoxWhip))]
[XmlInclude(typeof(Physics.CollisionBoxZoom))]
public class CollisionBox
{
#region Declarations
/// <summary>
/// The amount of damage this collisionbox does.
/// </summary>
private int iDamage;
/// <summary>
/// Rectangular bounding box of this collision box
/// </summary>
private PhysicsRectangle rectBoundingBox;
/// <summary>
/// Array of rectangles for more precise collisions within
/// this collision box
/// </summary>
private PhysicsRectangle[] rectArray = null;
/// <summary>
/// Array of triangles for more precise collisions within
/// this collision box
/// </summary>
private Triangle[] triArray = null;
/// <summary>
/// Original width of bounding box that does not change
/// </summary>
private int iBoundingBoxWidth;
/// <summary>
/// Orgiginal height of bounding box that does not change
/// </summary>
private int iBoundingBoxHeight;
/// <summary>
/// Text Description of this object for level editing
/// </summary>
private string strDescription = "";
#endregion
#region Properties/Feilds
/// <summary>
/// Gets or sets the damage this collision box does to merc
/// </summary>
public int Damage
{
get { return this.iDamage; }
set { this.iDamage = value; }
}
/// <summary>
/// Rectangular bounding box of this collision box
/// </summary>
public PhysicsRectangle BoundingBox
{
get {return this.rectBoundingBox; }
set {this.rectBoundingBox = value; }
}
/// <summary>
/// Array of rectangles for more precise collisions within
/// this collision box
/// </summary>
public PhysicsRectangle[] RectArray
{
//TODO: These need to be recalculated when needed so they up to date
// and represent the current velocity, etc.
get { return this.rectArray; }
set {this.rectArray = value;}
}
/// <summary>
/// Array of triangles for more precise collisions within
/// this collision box
/// </summary>
public Triangle[] TriArray
{
//TODO: These need to be recalculated when needed so they up to date
// and represent the current velocity, etc.
get { return this.triArray; }
set { this.triArray = value; }
}
/// <summary>
/// Original width of bounding box that does not change with vel
/// </summary>
public int BoundingBoxHeight
{
get { return this.iBoundingBoxHeight; }
set { this.iBoundingBoxHeight = value;}
}
/// <summary>
/// Original height of bounding box that does not change with vel
/// </summary>
public int BoundingBoxWidth
{
get {return this.iBoundingBoxWidth; }
set {this.iBoundingBoxWidth = value;}
}
/// <summary>
/// A text Description of this object for level editing
/// </summary>
public string Description
{
get { return this.strDescription; }
set { this.strDescription = value; }
}
#endregion
#region Contruction
public CollisionBox()
{
this.rectBoundingBox = new PhysicsRectangle();
this.RectArray = new PhysicsRectangle[Icarus.Logic.GameEngine.GameSettings.Instance.sv_maxInternalRects];
this.TriArray = new Triangle[Icarus.Logic.GameEngine.GameSettings.Instance.sv_maxInternalTris];
this.strDescription = "Collision Box";
}
#endregion
#region Methods
public int checkAndCollide(PhysicsObject po)
{
//Check for collision with this box
if(po.CollisionBox.BoundingBox.IntersectsWith(this.BoundingBox))
{
if(this.RectArray[0] == null && this.TriArray[0] == null)
{
//Collided but had no interal rectangles or triangles to collide with
return this.handleRectCollision(this.BoundingBox, po);
}
//Check for internal, more precise collisions
//Check Rectangles
foreach (PhysicsRectangle pr in this.RectArray)
{
if(pr == null) break;
if(pr.IntersectsWith(po.CollisionBox.BoundingBox))
{
return this.handleRectCollision(pr, po);
}
}
//Check Triangles
foreach (Triangle tri in this.TriArray)
{
if (tri == null) break;
if(tri.IntersectsWith(po.CollisionBox.BoundingBox))
{
return this.handleTriCollision(tri, po);
}
}
}
return (int)PhysicsSettings.enumActions.DoNothing;
}
/// <summary>
/// -Performs actions on a PO/WO specific to this collision box.
/// -Basic functionality only stops the PO/WO where the collision
/// took place.
/// -This function should be overridden for specific collision boxes
/// such as teleporters, jump pads, ice...
/// </summary>
/// <param name="rect">The collision rect that was hit</param>
/// <param name="po">The PO/WO that hit the rect</param>
/// <returns>An action represented in PhysicsSettings.enumActions</returns>
public virtual int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
return rect.intersectionAction(po);
//Vector.ScalarMultVector(po.Velocity, po.Velocity, 0.0f);
//return (int)PhysicsSettings.enumActions.DoNothing;
}
public virtual int handleTriCollision(Triangle tri, PhysicsObject po)
{
return tri.intersectionAction(po);
//Vector.ScalarMultVector(po.Velocity, po.Velocity, 0.0f);
//return (int)PhysicsSettings.enumActions.DoNothing;
}
/// <summary>
/// This can be called to set properties specifically when making
/// a prefab collision box. i.e: CollisionBoxFloor, CollisionBoxWall, etc
/// </summary>
public virtual void setSpecial()
{
}
#endregion
}
}

View File

@@ -0,0 +1,82 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxCD.
/// </summary>
public class CollisionBoxCD : CollisionBox
{
/// <summary>
/// The spark that happens after a CD hits something
/// </summary>
private PhysicsShortLife pslHitSpark;
public CollisionBoxCD()
{
this.Damage = 5;
pslHitSpark = new PhysicsShortLife();
pslHitSpark.FlickerTime = 0;
pslHitSpark.IterationsToLive = 15;
pslHitSpark.SetAnimation(@"\hit\hit.png", Icarus.Graphics.Animation.AnimationType.LoopOnce, 3);
}
/// <summary>
/// Handles collisions for CDs
/// </summary>
/// <param name="rect">the cd bounding box</param>
/// <param name="po">the po that the cd hit</param>
/// <returns></returns>
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
if(po is PhysicsMerc || po is PhysicsShortLife) return (int)PhysicsSettings.enumActions.DoNothing;
//Special case for fighting tux robot
if(po is PhysicsTuxHead)
{
PhysicsTuxRobot tux = (PhysicsTuxRobot)(((ChildObject)po).Parent);
if(tux.Vulnerable)
{
tux.GameStats.Health -= this.Damage;
tux.Vulnerable = false;
}
}
if(po is PhysicsPlayer)
{
if(((PhysicsPlayer)po).Vulnerable)
{
//Damage code
((PhysicsPlayer)po).GameStats.Health -= this.Damage;
((PhysicsPlayer)po).Vulnerable = false;
}
}
//Add spark then tell physics engine to remove CD object
int i;
for(i = 0; i < Logic.GameEngine.GameSettings.Instance.sv_maxActors; i++)
{
if(PhysicsEngine.Instance.currentLevel.CurrStage.actorList[i] == null) break;
}
//is there room?
if((Logic.GameEngine.GameSettings.Instance.sv_maxActors - 1) > i)
{
Vector vec = new Vector();
vec.j = 0;
pslHitSpark.po_gravity = vec;
pslHitSpark.Location.x = rect.X;
pslHitSpark.Location.y = rect.Y;
pslHitSpark.IterationCount = 0;
pslHitSpark.SetAnimation(@"\hit\hit.png", Icarus.Graphics.Animation.AnimationType.LoopOnce, 3);
PhysicsEngine.Instance.currentLevel.CurrStage.actorList[i] = pslHitSpark;
}
return (int)PhysicsSettings.enumActions.Remove;
}
}
}

View File

@@ -0,0 +1,117 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxEnemyDefault.
/// </summary>
public class CollisionBoxEnemyDefault : CollisionBox
{
/// <summary>
/// The direction to throw merc on collision
/// Defined in PhysicsSetting.enumDirection
/// Left
/// Right
/// Center - throws left or right, which ever is closer
/// </summary>
private int iThrowDirection;
/// <summary>
/// Contructor
/// </summary>
public CollisionBoxEnemyDefault()
{
iThrowDirection = (int)PhysicsSettings.enumDirection.Center;
}
/// <summary>
/// Gets or sets the direction this collision box throws merc
/// </summary>
public int ThrowDirection
{
get { return this.iThrowDirection; }
set { this.iThrowDirection = value; }
}
/// <summary>
/// Handles collisions with all types of objects and enemy default.
/// </summary>
/// <param name="rect">colliding rectangle</param>
/// <param name="po">po to be affected</param>
/// <returns></returns>
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
//TODO: Do Damage if needed
//Is it merc?
if(po is PhysicsMerc)
{
//Do Damage to merc
((WorldObject)po).GameStats.Health -= this.Damage;
((PhysicsMerc)po).Vulnerable = false;
po.Velocity.j = .35f * PhysicsSettings.Instance.JumpVelocity;
switch (this.iThrowDirection)
{
case (int)PhysicsSettings.enumDirection.Center:
//Knock player back
if(rect.X > po.CollisionBox.BoundingBox.X)
{
//Move away from collision
po.Location.x = rect.X - po.CollisionBox.BoundingBoxWidth;
//set velocity
po.Velocity.i = .4f * PhysicsSettings.Instance.JumpVelocity;
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.JumpingLeft;
}
else
{
//Move away from collision
po.Location.x = rect.X + rect.Width + po.CBXoffset;
//set velocity
po.Velocity.i = -.4f * PhysicsSettings.Instance.JumpVelocity;
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.JumpingRight;
}
break;
case (int)PhysicsSettings.enumDirection.Left:
//Move away from collision
po.Location.x = rect.X - po.CollisionBox.BoundingBoxWidth;
//set velocity
po.Velocity.i = .4f * PhysicsSettings.Instance.JumpVelocity;
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.JumpingLeft;
break;
case (int)PhysicsSettings.enumDirection.Right:
//Move away from collision
po.Location.x = rect.X + rect.Width + po.CBXoffset;
//set velocity
po.Velocity.i = -.4f * PhysicsSettings.Instance.JumpVelocity;
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.JumpingRight;
break;
}
}
return (int)Icarus.Logic.Physics.PhysicsSettings.enumActions.DoNothing;
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxFloor.
/// </summary>
[Serializable]
public class CollisionBoxFloor : CollisionBox
{
public CollisionBoxFloor()
{
this.Description = "CB-Floor";
this.RectArray[0] = new RectangleFloor();
}
/// <summary>
/// Sets the internal FloorRectangle's location
/// </summary>
public override void setSpecial()
{
this.RectArray[0].X = this.BoundingBox.X;
this.RectArray[0].Y = this.BoundingBox.Y;
this.RectArray[0].Width = this.BoundingBox.Width;
this.RectArray[0].Height = this.BoundingBox.Height;
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using System.Xml.Serialization;
namespace Icarus.Logic.Physics
{
/// <summary>
/// This moving box needs access to the world object that is holding it
/// </summary>
public class CollisionBoxMobile : CollisionBox
{
/// <summary>
/// This particular box needs to know things about the world obj holding it
/// </summary>
private WorldObject wo;
/// <summary>
/// Allowing the world obj to set a ref to itself
/// </summary>
[XmlIgnore]
public WorldObject WO
{
set { this.wo = value;}
}
/// <summary>
/// Constructionering
/// </summary>
public CollisionBoxMobile()
{
this.Description = "CB-Mobile";
}
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
if(!(po is PhysicsPlayer)) return (int)PhysicsSettings.enumActions.DoNothing;
//Stop a person from moving(walking) once they hit the floor
if(po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.FallingLeft)
{
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.StandingLeft;
po.Velocity.i = 0.0f;
}
else if(po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.FallingRight)
{
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.StandingRight;
po.Velocity.i = 0.0f;
}
//Prevent the player from colliding when jumping up hill
if(po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.JumpingRight||
po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.JumpingLeft)
{
return (int)PhysicsSettings.enumActions.DoNothing;
}
//Move the PO with the velocity of itself plus this WO
po.Velocity.i = wo.Velocity.i;
if((po.CollisionBox.BoundingBox.Y + po.CollisionBox.BoundingBoxHeight/2) > (this.BoundingBox.Y+this.BoundingBoxHeight/2))//Move PO up
{
//po.Location.y = this.BoundingBox.Y + this.BoundingBoxHeight + po.CBYoffset;
}
else //Move PO down
{
po.Location.y = this.BoundingBox.Y - po.CollisionBox.BoundingBoxHeight + po.CBYoffset;
po.Velocity.j = 0.0f;
}
//po.Velocity.j = 0.0f; Moved inside if else statement
return (int)Icarus.Logic.Physics.PhysicsSettings.enumActions.DoNothing;
}
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Xml.Serialization;
namespace Icarus.Logic.Physics
{
/// <summary>
/// This is specially made for the tux robot hand. It should only
/// be put in a MovingPlatform worldobject.
/// </summary>
public class CollisionBoxRobotTuxHand : CollisionBox
{
/// <summary>
/// This particular box needs to know things about the world obj holding it
/// </summary>
private PhysicsObject poParent;
/// <summary>
/// Allowing the world obj to set a ref to itself
/// </summary>
[XmlIgnore]
public PhysicsObject PO
{
set { this.poParent = value;}
}
/// <summary>
/// Construction
/// </summary>
public CollisionBoxRobotTuxHand()
{
this.Description = "Tux's Robot Hand";
this.Damage = 20;
}
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
if(po is PhysicsPlayer)
{
//Stop a person from moving(walking) once they hit the floor(hand)
if(po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.FallingLeft)
{
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.StandingLeft;
po.Velocity.i = 0.0f;
}
else if(po.ActionState == (int)PhysicsSettings.enumPlayerActionStates.FallingRight)
{
po.LastActionState = po.ActionState;
po.ActionState = (int)PhysicsSettings.enumPlayerActionStates.StandingRight;
po.Velocity.i = 0.0f;
}
//Move the PO with the velocity of itself plus this WO
po.Velocity.i = poParent.Velocity.i;
if((po.CollisionBox.BoundingBox.Y + po.CollisionBox.BoundingBoxHeight/2) > (this.BoundingBox.Y+this.BoundingBoxHeight/2))//Move PO up
{
//DAMAGE CODE
((WorldObject)po).GameStats.Health -= this.Damage;
((PhysicsPlayer)po).Vulnerable = false;
po.Location.x = this.BoundingBox.X - po.CollisionBox.BoundingBoxWidth + po.CBXoffset;
po.Location.y -= 10;//Just move him up a bit above the floor
po.Velocity.i = -3.0f * PhysicsSettings.Instance.WalkVelocity;
po.Velocity.j += 1.5f * PhysicsSettings.Instance.JumpVelocity;
}
else //Move PO down
{
po.Location.y = this.BoundingBox.Y - po.CollisionBox.BoundingBoxHeight + po.CBYoffset;
}
po.Velocity.j = 0.0f;
}
return (int)Icarus.Logic.Physics.PhysicsSettings.enumActions.DoNothing;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxSlopeBL.
/// </summary>
public class CollisionBoxSlopeBL : CollisionBox
{
public CollisionBoxSlopeBL()
{
this.Description = "CB-Tri-Floor-NegSlope";
this.TriArray[0] = new TriangleBL();
}
/// <summary>
/// Sets the internal TriangleBL location
/// </summary>
public override void setSpecial()
{
Icarus.Logic.Physics.Point P1 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y, 0.0f);
Icarus.Logic.Physics.Point P2 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
Icarus.Logic.Physics.Point P3 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
this.TriArray[0].P1 = P1;
this.TriArray[0].P2 = P2;
this.TriArray[0].P3 = P3;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxSlopeBR.
/// </summary>
public class CollisionBoxSlopeBR : CollisionBox
{
public CollisionBoxSlopeBR()
{
this.Description = "CB-Tri-Floor-PosSlope";
this.TriArray[0] = new TriangleBR();
}
/// <summary>
/// Sets the internal TriangleBR location
/// </summary>
public override void setSpecial()
{
Icarus.Logic.Physics.Point P1 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y, 0.0f);
Icarus.Logic.Physics.Point P2 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
Icarus.Logic.Physics.Point P3 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
this.TriArray[0].P1 = P1;
this.TriArray[0].P2 = P2;
this.TriArray[0].P3 = P3;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxSlopeTL.
/// </summary>
public class CollisionBoxSlopeTL : CollisionBox
{
public CollisionBoxSlopeTL()
{
this.Description = "CB-Tri-Ceiling-PosSlope";
this.TriArray[0] = new TriangleTL();
}
/// <summary>
/// Sets the internal TriangleTL location
/// </summary>
public override void setSpecial()
{
Icarus.Logic.Physics.Point P1 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y, 0.0f);
Icarus.Logic.Physics.Point P2 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
Icarus.Logic.Physics.Point P3 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y, 0.0f);
this.TriArray[0].P1 = P1;
this.TriArray[0].P2 = P2;
this.TriArray[0].P3 = P3;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxSlopeTR.
/// </summary>
public class CollisionBoxSlopeTR : CollisionBox
{
public CollisionBoxSlopeTR()
{
this.Description = "CB-Tri-Ceiling-NegSlope";
this.TriArray[0] = new TriangleTR();
}
/// <summary>
/// Sets the internal TriangleTR location
/// </summary>
public override void setSpecial()
{
Icarus.Logic.Physics.Point P1 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X, this.BoundingBox.Y, 0.0f);
Icarus.Logic.Physics.Point P2 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y, 0.0f);
Icarus.Logic.Physics.Point P3 =
new Icarus.Logic.Physics.Point(this.BoundingBox.X + this.BoundingBox.Width, this.BoundingBox.Y + this.BoundingBox.Height, 0.0f);
this.TriArray[0].P1 = P1;
this.TriArray[0].P2 = P2;
this.TriArray[0].P3 = P3;
}
}
}

View File

@@ -0,0 +1,161 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxTransition.
/// </summary>
public class CollisionBoxTransition : CollisionBox
{
#region Declarations
/// <summary>
/// The health that this transition will set to the player
/// </summary>
private int iHealth;
/// <summary>
/// The index of the next stage to be displayed
/// </summary>
private int iNextStage;
/// <summary>
/// The x coordinate to place merc in the next stage
/// </summary>
private int iX;
/// <summary>
/// The y coordinate to place merc in the next stage
/// </summary>
private int iY;
/// <summary>
/// The x coord of the new place to center the stage
/// </summary>
private int iXviewCenter;
/// <summary>
/// The y coord of the new place to center the stage
/// </summary>
private int iYviewCenter;
#endregion
#region Construction
/// <summary>
/// Construction
/// </summary>
public CollisionBoxTransition()
{
this.Description = "Transition Obj";
}
#endregion
#region Properties
/// <summary>
/// gets or sets the amount of health this transition gives the player
/// </summary>
public int Health
{
get { return this.iHealth; }
set { this.iHealth = value; }
}
/// <summary>
/// The index of the next level
/// </summary>
public int NextStage
{
get { return this.iNextStage; }
set { this.iNextStage = value; }
}
/// <summary>
/// X location of merc after transition
/// </summary>
public int X
{
get { return this.iX; }
set { this.iX = value; }
}
/// <summary>
/// Y location of merc after transition
/// </summary>
public int Y
{
get { return this.iY; }
set { this.iY = value; }
}
/// <summary>
/// X location to set screen center to after transition
/// </summary>
public int XViewCenter
{
get { return this.iXviewCenter; }
set { this.iXviewCenter = value; }
}
/// <summary>
/// Y location to set screen center to after transition
/// </summary>
public int YViewCenter
{
get { return this.iYviewCenter; }
set { this.iYviewCenter = value; }
}
#endregion
#region Collision Override
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
if(po.GetType().Equals(typeof(Physics.PhysicsMerc)))
{
//Set the next stage to the current.
Physics.PhysicsEngine.Instance.currentLevel.CurrentStageIndex = this.iNextStage;
//Move Player to new actor list
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.actorList[Physics.PhysicsEngine.Instance.currentLevel.CurrStage.PlayerActorIndex] = (Physics.PhysicsMerc)po;
//Set Player's location in the new stage.
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.actorList[Physics.PhysicsEngine.Instance.currentLevel.CurrStage.PlayerActorIndex].Location.x = this.X;
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.actorList[Physics.PhysicsEngine.Instance.currentLevel.CurrStage.PlayerActorIndex].Location.y = this.Y;
//If a health value has been set, give it to player
if(this.Health > 0)
{
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.actorList[Physics.PhysicsEngine.Instance.currentLevel.CurrStage.PlayerActorIndex].GameStats.Health = this.Health;
}
//Set new screen centering location
if(this.iXviewCenter == 0 || this.iYviewCenter == 0)
{
//Center on merc if center position not set
this.iXviewCenter = this.iX;
this.iYviewCenter = this.iY;
}
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.ViewCenter.x = this.iXviewCenter;
Physics.PhysicsEngine.Instance.currentLevel.CurrStage.ViewCenter.y = this.iYviewCenter;
}
//Do what ever we need... Nothing.
return (int)PhysicsSettings.enumActions.DoNothing;
}
#endregion
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxWall.
/// </summary>
[Serializable]
public class CollisionBoxWall : CollisionBox
{
public CollisionBoxWall()
{
this.Description = "CB-Wall";
this.RectArray[0] = new RectangleWall();
this.RectArray[0].X = this.BoundingBox.X;
this.RectArray[0].Y = this.BoundingBox.Y;
this.RectArray[0].Width = this.BoundingBox.Width;
this.RectArray[0].Height = this.BoundingBox.Height;
}
/// <summary>
/// Sets the internal WallRectangle's location
/// </summary>
public override void setSpecial()
{
this.RectArray[0].X = this.BoundingBox.X;
this.RectArray[0].Y = this.BoundingBox.Y;
this.RectArray[0].Width = this.BoundingBox.Width;
this.RectArray[0].Height = this.BoundingBox.Height;
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Xml.Serialization;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxWhip.
/// </summary>
public class CollisionBoxWhip : CollisionBox
{
/// <summary>
/// whether or not to show spark on whip
/// </summary>
private bool bShowSpark;
/// <summary>
/// This particular box needs to know things about the world obj holding it
/// </summary>
private WorldObject wo;
/// <summary>
/// Allowing the world obj to set a ref to itself
/// </summary>
[XmlIgnore]
public WorldObject WO
{
set { this.wo = value;}
}
/// <summary>
/// Gets or sets whether a spark should be shown or not
/// </summary>
public bool ShowSpark
{
get { return this.bShowSpark; }
set { this.bShowSpark = value;}
}
public CollisionBoxWhip()
{
//Amound of Damage the whip does
this.Damage = 10;
this.bShowSpark = false;
}
/// <summary>
/// Handles collisions with a whip
/// </summary>
/// <param name="rect">Rect that is being collided with</param>
/// <param name="po">PO to be affected</param>
/// <returns></returns>
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
//Special case for fighting tux robot
if(po is PhysicsTuxHead)
{
PhysicsTuxRobot tux = (PhysicsTuxRobot)(((ChildObject)po).Parent);
if(tux.Vulnerable)
{
tux.GameStats.Health -= this.Damage;
tux.Vulnerable = false;
this.ShowSpark = true;
}
return (int)Icarus.Logic.Physics.PhysicsSettings.enumActions.DoNothing;
}
//Is it a Player?
if(po is PhysicsPlayer)
{
//Can we hurt it?
if(((PhysicsPlayer)po).Vulnerable)
{
//Pow
((WorldObject)po).GameStats.Health -= this.Damage;
//Give it a rest for a bit
((PhysicsPlayer)po).Vulnerable = false;
this.ShowSpark = true;
}
}
return (int)Icarus.Logic.Physics.PhysicsSettings.enumActions.DoNothing;
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
namespace Icarus.Logic.Physics
{
/// <summary>
/// Summary description for CollisionBoxZoom.
/// </summary>
public class CollisionBoxZoom : CollisionBox
{
/// <summary>
/// Whether or not to zoom
/// </summary>
private bool bZoom;
public CollisionBoxZoom()
{
this.bZoom = false;
}
/// <summary>
/// gets or sets whether or not to zoom
/// </summary>
public bool Zoom
{
get { return this.bZoom; }
set { this.bZoom = value; }
}
/// <summary>
/// Turns on zooming when merc collides with this box
/// </summary>
/// <param name="rect"></param>
/// <param name="po"></param>
/// <returns></returns>
public override int handleRectCollision(PhysicsRectangle rect, PhysicsObject po)
{
if(po is PhysicsMerc)
{
this.bZoom = true;
}
return (int)PhysicsSettings.enumActions.DoNothing;
}
}
}

Some files were not shown because too many files have changed in this diff Show More