Introduction

RhinoLoader is the parsing engine RhinoXNA uses to import custom project data.

Details

There are several methods in this static class but only two of them are typically needed.
public static List<IRhinoGraphicsComponent> GetGraphics(String propertiesFile, String fileToLoad)

public static List<IMenuItem> GetMenuItems(String propertiesFile, String fileToLoad) 


Each method returns a list of a certain type and takes the same parameters used to load the content. The defined objects are created using the related type defined in the given properties file and dynamically created at runtime (using Reflection). See below for examples of the properties file and the script file.

Properties File Format

The properties file will be supplied by the game implementation using RhinoLoader. A type declaration will be of the style:

TypeName = Package.ClassType

Each declaration should be on a seperate line. An example of the ProjectAmbush implementation properties file:

Sprite=AsteroidsGame.StaticSprite 
2DPlayer=AsteroidsGame.Ship 
Asteroid=AsteroidsGame.Asteroid 
MenuBackground=AsteroidsGame.Menus.MenuBackground 

Script File Format

Once a properties file is created to map the TypeName to the ClassType a script file can be created to load new instances of that type. Parameters are passed to any type class so the script file is dynamic based on how your class is layed out. For example, an instance declaration of a SpriteEntity needs to follow this standard:

TypeName, TextureFile, Handle, ScreenX, ScreenY, Rotation, ScaleX, ScaleY, Layer, Visible, SourceX, SourceY, Width, Height
  • Definitions
    • TypeName - The type to instantiate, defined in the properties file
    • TextureFile - The texture file to load from relative to the Content directory
    • Handle - A unique string handle, used if this item needs to be referenced in the future through code, usually only applicable to displayed items like sprites or models
    • ScreenX - The X-Position of the screen to draw this item (see Screen Positions below)
    • ScreenY - The Y-Position of the screen to draw this item (see Screen Positions below)
    • Rotation - The amount to rotate the sprite (in degrees)
    • ScaleX - The X-Scaling of the sprite (1.0 = 100%)
    • ScaleY - The Y-Scaling of the sprite (1.0 = 100%)
    • Layer - The layer to draw the sprite on (currently doesn't work)
    • Visible - Boolean defining whether or not the sprite is visible by default
    • SourceX - The X-Position of the upper left corner of the rectangle to pull from the texture file
    • SourceY - The Y-Position of the upper left corner of the rectangle to pull from the texture file
    • Width - The width of the rectangle to pull from the texture file (see Texture Dimensions below)
    • Height - The height of the rectangle to pull from the texture file (see Texture Dimensions below)

As with the properties file, each instance of a type should be on it's own line. Comments can be created by starting the line with an apostrophe(').

Screen Positions

Provided in RhinoLoader are some shortcuts to positioning items being loaded (such as sprites). Notice, all sprites are placed, rotated, and scaled by the center of the sprite. Following is a list of these commands:
  • CENTER (X, Y) - Sets the appropriate axis to the center of the title safe area of the screen
  • C## (X, Y) - Sets the appropriate axis ## pixels from the center along that axis (for example, for C100, the sprites will be 100 pixels off center in that axis)
  • L## (X) - Sets the axis ## pixels from the left side of the title safe area of the screen (note: this should only apply to the X-axis; positive amounts travel right)
  • R## (X) - Sets the axis -## pixels from the right side of the title safe area of the screen (note: this should only apply to the X-axis; positive amounts travel left)
  • B## (Y) - Sets the axis -## pixels from the bottom of the title safe area of the screen (note: this should only apply to the Y-axis; positive amounts travel up)
  • T## (Y) - Sets the axis ## pixels from the top of the title safe area of the screen (note: this should only apply to the Y-axis; positive amounts travel down)
  • TBG (Y) - Sets a background so the top of the texture aligns with the top center of the screen (note: this should only apply to the Y-axis; texture object is requred when calling)

Note, all ## can be prefixed with a dash to provide a negative number (for example, C-100 will be negative 100 pixels off center).

Also, simply defining a number will place the object at that pixel location.

Texture Dimensions

Similar to Screen Positions, there are also some shortcuts to quickly grab the entire texture without knowing the dimensions. Following is a list of these commands:
  • WIDTH (Width) - Returns the width of the source file
  • HEIGHT (Height) - Returns the height of the source file

Also, simply defining a number will supply that amount in pixels for width or height.

Format Exceptions

There are a few exceptions available that effect how RhinoLoader will process each line of the script:
  • Apostraphe ( ' ) - When placed as the first character in a line, an apostraphe will define the line as a comment and RhinoLoader will not load the line
  • Quotation Mark ( " ) - RhinoLoader will not remove empty spaces from strings within quotation marks (for example, without quotations the string 'I Love RhinoXNA' would parse as 'ILoveRhinoXNA')

Last edited Oct 7, 2010 at 6:24 PM by MattChristian, version 5

Comments

No comments yet.