git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1183 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -104,8 +104,14 @@ namespace OpenRa.FileFormats
|
||||
}
|
||||
|
||||
for( int i = 0 ; i < 128 ; i++ )
|
||||
{
|
||||
for( int j = 0 ; j < 128 ; j++ )
|
||||
{
|
||||
MapTiles[ j, i ].image = ReadByte( ms );
|
||||
if( MapTiles[ j, i ].tile == 0xff || MapTiles[ j, i ].tile == 0xffff )
|
||||
MapTiles[ j, i ].image = (byte)( i % 4 + ( j % 4 ) * 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadTrees( IniFile file )
|
||||
|
||||
@@ -8,9 +8,9 @@ using System.Windows.Forms;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Actor
|
||||
abstract class Actor
|
||||
{
|
||||
public PointF location;
|
||||
public SheetRectangle<Sheet>[] currentImages;
|
||||
public abstract SheetRectangle<Sheet>[] CurrentImages { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace OpenRa.Game
|
||||
|
||||
foreach (TreeReference treeReference in map.Trees)
|
||||
world.Add(new Tree(treeReference, treeCache, map));
|
||||
|
||||
UnitSheetBuilder.AddUnit( "mcv", renderer.Device, pal );
|
||||
world.Add( new Mcv( new PointF( 24 * 5, 24 * 5 ) ) );
|
||||
}
|
||||
|
||||
void LoadVertexBuffer()
|
||||
|
||||
@@ -2,18 +2,22 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenRa.FileFormats;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Mcv : Actor
|
||||
{
|
||||
int facing;
|
||||
//int facing; // not currently used
|
||||
|
||||
static Package unitsPackage = new Package("../../../conquer.mix");
|
||||
|
||||
public Mcv()
|
||||
public Mcv( PointF location )
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public override SheetRectangle<Sheet>[] CurrentImages
|
||||
{
|
||||
get { return new SheetRectangle<Sheet>[] { UnitSheetBuilder.McvSheet[ 0 ] }; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
<Compile Include="Sheet.cs" />
|
||||
<Compile Include="Tree.cs" />
|
||||
<Compile Include="TreeCache.cs" />
|
||||
<Compile Include="UnitSheetBuilder.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="Vertex.cs" />
|
||||
<Compile Include="World.cs" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -8,11 +9,19 @@ namespace OpenRa.Game
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.SetCompatibleTextRenderingDefault( false );
|
||||
|
||||
new MainWindow().Run();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
File.WriteAllText( "error.log", e.ToString() );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,11 @@ namespace OpenRa.Game
|
||||
location = new PointF(24 * (r.X - map.XOffset), 24 * (r.Y - map.YOffset));
|
||||
currentImages = new SheetRectangle<Sheet>[] { renderer.GetImage(r.Image) };
|
||||
}
|
||||
|
||||
SheetRectangle<Sheet>[] currentImages;
|
||||
public override SheetRectangle<Sheet>[] CurrentImages
|
||||
{
|
||||
get { return currentImages; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
OpenRa.Game/UnitSheetBuilder.cs
Normal file
45
OpenRa.Game/UnitSheetBuilder.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenRa.FileFormats;
|
||||
using System.Drawing;
|
||||
using BluntDirectX.Direct3D;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
static class UnitSheetBuilder
|
||||
{
|
||||
static readonly Package unitsPackage = new Package( "../../../conquer.mix" );
|
||||
public static readonly List<SheetRectangle<Sheet>> McvSheet = new List<SheetRectangle<Sheet>>();
|
||||
|
||||
public static void AddUnit( string name, GraphicsDevice device, Palette pal )
|
||||
{
|
||||
List<Sheet> sheets = new List<Sheet>();
|
||||
Size pageSize = new Size( 1024, 512 );
|
||||
|
||||
Provider<Sheet> sheetProvider = delegate
|
||||
{
|
||||
Sheet sheet = new Sheet( new Bitmap( pageSize.Width, pageSize.Height ) );
|
||||
sheets.Add( sheet );
|
||||
return sheet;
|
||||
};
|
||||
|
||||
TileSheetBuilder<Sheet> builder = new TileSheetBuilder<Sheet>( pageSize, sheetProvider );
|
||||
|
||||
ShpReader reader = new ShpReader( unitsPackage.GetContent( name + ".shp" ) );
|
||||
foreach( ImageHeader h in reader )
|
||||
{
|
||||
Bitmap bitmap = BitmapBuilder.FromBytes( h.Image, reader.Width, reader.Height, pal );
|
||||
|
||||
SheetRectangle<Sheet> rect = builder.AddImage( bitmap.Size );
|
||||
using( Graphics g = Graphics.FromImage( rect.sheet.bitmap ) )
|
||||
g.DrawImage( bitmap, rect.origin );
|
||||
|
||||
McvSheet.Add( rect );
|
||||
}
|
||||
|
||||
foreach( Sheet sheet in sheets )
|
||||
sheet.LoadTexture( device );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,20 @@ namespace OpenRa.Game
|
||||
|
||||
foreach (Actor a in actors)
|
||||
{
|
||||
if (a.currentImages == null)
|
||||
if (a.CurrentImages == null)
|
||||
continue;
|
||||
|
||||
foreach (SheetRectangle<Sheet> image in a.currentImages)
|
||||
foreach (SheetRectangle<Sheet> image in a.CurrentImages)
|
||||
{
|
||||
if( image.sheet != sheet && sprites > 0 && sheet != null )
|
||||
{
|
||||
DrawBatch( vertices, indices, renderer, sheet );
|
||||
|
||||
vertices = new List<Vertex>();
|
||||
indices = new List<ushort>();
|
||||
sprites = 0;
|
||||
}
|
||||
|
||||
sheet = image.sheet;
|
||||
Util.CreateQuad(vertices, indices, a.location, image);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user