There are only a couple of classes from the WinForms project that I need mention, the map renderers. Depending on the renderer chosen, the appropriate values are setup and disposed of by the rendering routine the Image property is always set up. What I also assume you have noticed is that it stores an IntPtr and a Texture2D these are not set by default but are actually set by one of the two rendering options I've made available GDI and XNA. The last class in the MapEditorLib whose main job is to store an image, as well as a name and a unique id as you can see. Public Tileset(Image image, string Name, int ID) It is currently held in the MapEditor WinForms project.
It's worth mentioning that there is no code in the MapEditorLib to render the map. I decided to make an event for this so that all calls to redraw the map would come from one place.
The OnMapChanged event is fired whenever the map is updated, the main form registers for this event so that it knows when the map needs to be redrawn.
Like I said earlier images are not stored in the map itself because they may already be loaded into memory or stored in an archive for a game, etc. We also have the Save functions and the extra SaveTextures function which saves the images stored in each of the Tilesets to disk. These are the tiles that will be placed on the map wherever the user clicks. I will however mention SetSelectedTiles this function takes a 2D array of Tile that are the currently selected tiles from the Tileselect control (which I'll cover later). Most of the functions here are pretty self explanatory, so I shouldn't need to go through them all. A very important property in here is WorkingLayer this is the layer in the map that is currently selected and the one to which any changes will be applied.
This is the class that is used by the WinForms half of the application, it contains a plethora of functions to query and update the map. Public void SaveTextures( string outputFolder) Public void SetLayerZValue( float Z_Value) Public void SetLayerVisible( bool Visible) Public void AddLayer( string Name, float Z_Value, bool Background) Public string GetTilesetName( int X, int Y) Public void SetTiles( int PosX, int PosY) Public void SetSize( int Width, int Height) Public EditableMap( int NumLayers, int Width, int Height, int TileSize) Public class MapChangedEventArgs : EventArgs Public event MapChangedEventHandler OnMapChanged Public delegate void MapChangedEventHandler( object sender, MapChangedEventArgs e) The application should be able to get us the data we need via its name. We use the delegate RequestTexture to get the image data from whatever application is using the Map class. In the case of the Editor, the images are saved in a folder with the map data. Depending if we are in a game or in the Editor, the image data could be in the memory or on disk somewhere.
The map data that is saved to file only includes the name and ID of the Tileset, so we need a way to get the image data. The Map class also has functions for loading a map from file or from a stream. TileSize is the size in pixels of each tile. So we have a few more properties for the width and height of the map, Width and Height are the size in tiles of the map, RealWidth and RealHeight are the size in pixels of the map calculated by using the current tilesize. This one uses a List to store the layers of the map, and adds a little more information that we need to fully describe the map. Here we are, the Map class, this one is fairly important. Public virtual void Load(Stream dataStream, RequestTexture requestTexture) Public void Load( string Path, RequestTexture requestTexture) Public delegate Image RequestTexture( string Name)