From 74b4d5d455e45e8dd90d16bbcc9edcef29b1bae3 Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@993157c7-ee19-0410-b2c4-bb4e9862e678>
Date: Mon, 23 Jul 2007 15:55:06 +0000
Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1330
993157c7-ee19-0410-b2c4-bb4e9862e678
---
OpenRa.BlockCacheVisualizer/Form1.Designer.cs | 60 ---------
OpenRa.BlockCacheVisualizer/Form1.cs | 103 ---------------
OpenRa.BlockCacheVisualizer/Form1.resx | 120 ------------------
.../OpenRa.BlockCacheVisualizer.csproj | 64 ----------
OpenRa.BlockCacheVisualizer/Program.cs | 20 ---
.../Properties/AssemblyInfo.cs | 33 -----
OpenRa.FileFormats/FileSystem.cs | 13 --
OpenRa.FileFormats/Folder.cs | 20 +++
OpenRa.FileFormats/Map.cs | 3 +-
OpenRa.FileFormats/OpenRa.FileFormats.csproj | 1 +
OpenRa.Game/Game.cs | 26 ++--
OpenRa.Game/HardwarePalette.cs | 38 +-----
OpenRa.Game/MainWindow.cs | 4 +-
OpenRa.Game/OpenRa.Game.csproj | 2 +-
OpenRa.Game/PathFinder.cs | 9 --
OpenRa.Game/Renderer.cs | 2 +-
OpenRa.Game/Sheet.cs | 43 ++++---
OpenRa.Game/SheetBuilder.cs | 11 +-
OpenRa.Game/Unit.cs | 17 +--
OpenRa.Game/Util.cs | 3 +-
OpenRa.sln | 14 +-
PaletteUsage/Program.cs | 10 +-
22 files changed, 80 insertions(+), 536 deletions(-)
delete mode 100644 OpenRa.BlockCacheVisualizer/Form1.Designer.cs
delete mode 100644 OpenRa.BlockCacheVisualizer/Form1.cs
delete mode 100644 OpenRa.BlockCacheVisualizer/Form1.resx
delete mode 100644 OpenRa.BlockCacheVisualizer/OpenRa.BlockCacheVisualizer.csproj
delete mode 100644 OpenRa.BlockCacheVisualizer/Program.cs
delete mode 100644 OpenRa.BlockCacheVisualizer/Properties/AssemblyInfo.cs
create mode 100644 OpenRa.FileFormats/Folder.cs
diff --git a/OpenRa.BlockCacheVisualizer/Form1.Designer.cs b/OpenRa.BlockCacheVisualizer/Form1.Designer.cs
deleted file mode 100644
index 19af6ba754..0000000000
--- a/OpenRa.BlockCacheVisualizer/Form1.Designer.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-namespace OpenRa.BlockCacheVisualizer
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
- this.SuspendLayout();
- //
- // flowLayoutPanel1
- //
- this.flowLayoutPanel1.BackColor = System.Drawing.SystemColors.MenuHighlight;
- this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
- this.flowLayoutPanel1.Name = "flowLayoutPanel1";
- this.flowLayoutPanel1.Size = new System.Drawing.Size(748, 528);
- this.flowLayoutPanel1.TabIndex = 0;
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(748, 528);
- this.Controls.Add(this.flowLayoutPanel1);
- this.Name = "Form1";
- this.Text = "Form1";
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
- }
-}
-
diff --git a/OpenRa.BlockCacheVisualizer/Form1.cs b/OpenRa.BlockCacheVisualizer/Form1.cs
deleted file mode 100644
index fb60afd397..0000000000
--- a/OpenRa.BlockCacheVisualizer/Form1.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-using System.IO;
-using System.Drawing.Imaging;
-
-namespace OpenRa.BlockCacheVisualizer
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- ClientSize = new Size(525,525);
- FormBorderStyle = FormBorderStyle.FixedSingle;
- MaximizeBox = false;
- Text = "PNG Block Cache Visualizer";
- Visible = true;
-
- OpenFileDialog d = new OpenFileDialog();
- d.RestoreDirectory = true;
- d.Filter = "OpenRA PNG Block Cache (*.png)|*.png";
-
- if (DialogResult.OK != d.ShowDialog())
- return;
-
-
-
- string filename = d.FileName;
- string palname = Path.GetDirectoryName(filename) + "\\palette-cache.png";
-
- Bitmap palette = new Bitmap(palname);
- Bitmap block = new Bitmap(filename);
-
- uint[] masks = { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
-
- foreach (uint c in masks)
- {
- Bitmap b = ExtractChannelToBitmap(block, palette, c);
- PictureBox pb = new PictureBox();
-
- pb.SizeMode = PictureBoxSizeMode.AutoSize;
- pb.Image = b;
- pb.BackColor = Color.White;
-
- flowLayoutPanel1.Controls.Add(pb);
- }
- }
-
- uint MaskColor(uint c, uint mask)
- {
- uint hax = c & mask;
-
- hax = (hax & 0xffff) | (hax >> 16);
- return (hax & 0xff) | (hax >> 8);
- }
-
- static BitmapData Lock(Bitmap b, ImageLockMode mode)
- {
- return b.LockBits(new Rectangle(new Point(), b.Size), mode, b.PixelFormat);
- }
-
- Bitmap ExtractChannelToBitmap(Bitmap src, Bitmap pal, uint mask)
- {
- Bitmap dest = new Bitmap(src.Width / 2, src.Height / 2, pal.PixelFormat);
-
- BitmapData destData = Lock(dest, ImageLockMode.WriteOnly);
- BitmapData paletteData = Lock(pal, ImageLockMode.ReadOnly);
- BitmapData srcData = Lock(src, ImageLockMode.ReadOnly);
-
- int destStride = destData.Stride/4;
- int srcStride = srcData.Stride/4;
-
- unsafe
- {
- uint* pdest = (uint*)destData.Scan0.ToPointer();
- uint* ppal = (uint*)paletteData.Scan0.ToPointer();
- uint* psrc = (uint*)srcData.Scan0.ToPointer();
-
- int h = dest.Height; int w = dest.Width;
-
- for (int j = 0; j < h; j++)
- for (int i = 0; i < w; i++)
- {
- uint srcc = psrc[2 * j * srcStride + 2 * i];
- uint index = MaskColor(srcc, mask);
- uint data = ppal[index];
- pdest[j * destStride + i] = data;
- }
- }
-
- dest.UnlockBits(destData);
- pal.UnlockBits(paletteData);
- src.UnlockBits(srcData);
-
- return dest;
- }
- }
-}
\ No newline at end of file
diff --git a/OpenRa.BlockCacheVisualizer/Form1.resx b/OpenRa.BlockCacheVisualizer/Form1.resx
deleted file mode 100644
index ff31a6db56..0000000000
--- a/OpenRa.BlockCacheVisualizer/Form1.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/OpenRa.BlockCacheVisualizer/OpenRa.BlockCacheVisualizer.csproj b/OpenRa.BlockCacheVisualizer/OpenRa.BlockCacheVisualizer.csproj
deleted file mode 100644
index 7bcfeef9bb..0000000000
--- a/OpenRa.BlockCacheVisualizer/OpenRa.BlockCacheVisualizer.csproj
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
- Debug
- AnyCPU
- 8.0.50727
- 2.0
- {127D13D1-3589-4240-A33B-70C3A25536A4}
- WinExe
- Properties
- OpenRa.BlockCacheVisualizer
- OpenRa.BlockCacheVisualizer
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- true
- false
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- Form1.cs
-
-
-
-
- Designer
- Form1.cs
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRa.BlockCacheVisualizer/Program.cs b/OpenRa.BlockCacheVisualizer/Program.cs
deleted file mode 100644
index 1fd48c145d..0000000000
--- a/OpenRa.BlockCacheVisualizer/Program.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Windows.Forms;
-
-namespace OpenRa.BlockCacheVisualizer
-{
- static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- }
- }
-}
\ No newline at end of file
diff --git a/OpenRa.BlockCacheVisualizer/Properties/AssemblyInfo.cs b/OpenRa.BlockCacheVisualizer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 0948e9b23f..0000000000
--- a/OpenRa.BlockCacheVisualizer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-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("OpenRa.BlockCacheVisualizer")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("OpenRa.BlockCacheVisualizer")]
-[assembly: AssemblyCopyright("Copyright © 2007")]
-[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("db73d0ce-dd5f-4143-92ed-3c8e8b98f380")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenRa.FileFormats/FileSystem.cs b/OpenRa.FileFormats/FileSystem.cs
index 1640289cd4..91faad27f8 100644
--- a/OpenRa.FileFormats/FileSystem.cs
+++ b/OpenRa.FileFormats/FileSystem.cs
@@ -6,19 +6,6 @@ using OpenRa.FileFormats;
namespace OpenRa.FileFormats
{
- public class Folder : IFolder
- {
- readonly string path;
-
- public Folder(string path) { this.path = path; }
-
- public Stream GetContent(string filename)
- {
- try { return File.OpenRead(path + filename); }
- catch { throw new FileNotFoundException("File not found", filename); }
- }
- }
-
public static class FileSystem
{
static List mountedFolders = new List();
diff --git a/OpenRa.FileFormats/Folder.cs b/OpenRa.FileFormats/Folder.cs
new file mode 100644
index 0000000000..e43f9b3a47
--- /dev/null
+++ b/OpenRa.FileFormats/Folder.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace OpenRa.FileFormats
+{
+ public class Folder : IFolder
+ {
+ readonly string path;
+
+ public Folder(string path) { this.path = path; }
+
+ public Stream GetContent(string filename)
+ {
+ try { return File.OpenRead(path + filename); }
+ catch { throw new FileNotFoundException("File not found", filename); }
+ }
+ }
+}
diff --git a/OpenRa.FileFormats/Map.cs b/OpenRa.FileFormats/Map.cs
index 1ae6c1508f..35273bd443 100644
--- a/OpenRa.FileFormats/Map.cs
+++ b/OpenRa.FileFormats/Map.cs
@@ -17,8 +17,7 @@ namespace OpenRa.FileFormats
public readonly int Width;
public readonly int Height;
-
- public PointF Size { get { return new PointF(Width, Height); } }
+ public int2 Size { get { return new int2(Width, Height); } }
public readonly TileReference[ , ] MapTiles = new TileReference[ 128, 128 ];
public readonly List Trees = new List();
diff --git a/OpenRa.FileFormats/OpenRa.FileFormats.csproj b/OpenRa.FileFormats/OpenRa.FileFormats.csproj
index 838abf985c..7c692e4383 100644
--- a/OpenRa.FileFormats/OpenRa.FileFormats.csproj
+++ b/OpenRa.FileFormats/OpenRa.FileFormats.csproj
@@ -41,6 +41,7 @@
+
diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs
index cdd5477194..5090bf0f6e 100644
--- a/OpenRa.Game/Game.cs
+++ b/OpenRa.Game/Game.cs
@@ -15,31 +15,31 @@ namespace OpenRa.Game
public readonly PathFinder pathFinder;
public readonly Network network;
- public Game( string mapName, Renderer renderer, int2 clientSize )
+ public Game(string mapName, Renderer renderer, int2 clientSize)
{
- map = new Map( new IniFile( FileSystem.Open( mapName ) ) );
- FileSystem.Mount( new Package( "../../../" + map.Theater + ".mix" ) );
+ map = new Map(new IniFile(FileSystem.Open(mapName)));
+ FileSystem.Mount(new Package("../../../" + map.Theater + ".mix"));
- viewport = new Viewport( clientSize, new float2( map.Size ), renderer );
-
- terrain = new TerrainRenderer( renderer, map, viewport );
- world = new World( renderer, viewport );
- treeCache = new TreeCache( renderer.Device, map );
+ viewport = new Viewport(clientSize, map.Size, renderer);
- foreach( TreeReference treeReference in map.Trees )
- world.Add( new Tree( treeReference, treeCache, map ) );
+ terrain = new TerrainRenderer(renderer, map, viewport);
+ world = new World(renderer, viewport);
+ treeCache = new TreeCache(renderer.Device, map);
- pathFinder = new PathFinder( map, terrain.tileSet );
+ foreach (TreeReference treeReference in map.Trees)
+ world.Add(new Tree(treeReference, treeCache, map));
+
+ pathFinder = new PathFinder(map, terrain.tileSet);
network = new Network();
}
public void Tick()
{
- viewport.DrawRegions( this );
+ viewport.DrawRegions(this);
}
- public void Issue( IOrder order )
+ public void Issue(IOrder order)
{
order.Apply();
}
diff --git a/OpenRa.Game/HardwarePalette.cs b/OpenRa.Game/HardwarePalette.cs
index a249cc4bd8..662b95b80e 100644
--- a/OpenRa.Game/HardwarePalette.cs
+++ b/OpenRa.Game/HardwarePalette.cs
@@ -8,22 +8,14 @@ using OpenRa.FileFormats;
namespace OpenRa.Game
{
- // todo: synthesize selection color, and generate duplicate palette block!
- public class HardwarePalette
+ class HardwarePalette : Sheet
{
- const int maxEntries = 16; // dont need anything like this many,
- // but the hardware likes square textures better
-
- Bitmap bitmap = new Bitmap(256, maxEntries);
- GraphicsDevice device;
+ const int maxEntries = 16;
int allocated = 0;
- Texture paletteTexture;
-
- public HardwarePalette(GraphicsDevice device, Map map)
+ public HardwarePalette(Renderer renderer, Map map)
+ : base(renderer,new Size(256, maxEntries))
{
- this.device = device;
-
Palette pal = new Palette(FileSystem.Open(map.Theater + ".pal"));
AddPalette(pal);
@@ -31,30 +23,10 @@ namespace OpenRa.Game
AddPalette(new Palette(pal, new PaletteRemap(FileSystem.Open(remap + ".rem"))));
}
- void Resolve()
- {
- const string filename = "../../../palette-cache.png";
- bitmap.Save(filename);
-
- using (Stream s = File.OpenRead(filename))
- paletteTexture = Texture.Create(s, device);
- }
-
- public Texture PaletteTexture
- {
- get
- {
- if (paletteTexture == null)
- Resolve();
-
- return paletteTexture;
- }
- }
-
int AddPalette(Palette p)
{
for (int i = 0; i < 256; i++)
- bitmap.SetPixel(i, allocated, p.GetColor(i));
+ this[new Point(i, allocated)] = p.GetColor(i);
return allocated++;
}
diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs
index 1859bc80aa..972b0954f1 100644
--- a/OpenRa.Game/MainWindow.cs
+++ b/OpenRa.Game/MainWindow.cs
@@ -39,7 +39,7 @@ namespace OpenRa.Game
bool windowed = !settings.GetValue("fullscreeen", false);
renderer = new Renderer(this, GetResolution(settings), windowed);
- SheetBuilder.Initialize( renderer.Device );
+ SheetBuilder.Initialize( renderer );
game = new Game( settings.GetValue( "map", "scm12ea.ini" ), renderer, new int2( ClientSize ) );
@@ -54,7 +54,7 @@ namespace OpenRa.Game
sidebar = new Sidebar(Race.Soviet, renderer, game.viewport);
- renderer.SetPalette( new HardwarePalette( renderer.Device, game.map ) );
+ renderer.SetPalette( new HardwarePalette( renderer, game.map ) );
}
internal void Run()
diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index 58c67e3232..14fae2e4a9 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -44,6 +44,7 @@
+
@@ -65,7 +66,6 @@
-
diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs
index d6bb36df76..a4962abf50 100644
--- a/OpenRa.Game/PathFinder.cs
+++ b/OpenRa.Game/PathFinder.cs
@@ -46,9 +46,6 @@ namespace OpenRa.Game
queue.Add( new PathDistance( estimator( startLocation - offset ), startLocation ) );
cellInfo[ startLocation.X, startLocation.Y ].MinCost = 0;
- int seenCount = 0;
- int impassableCount = 0;
-
while( !queue.Empty )
{
PathDistance p = queue.Pop();
@@ -63,15 +60,9 @@ namespace OpenRa.Game
int2 newHere = here + d;
if( cellInfo[ newHere.X, newHere.Y ].Seen )
- {
- ++seenCount;
continue;
- }
if( passableCost[ newHere.X, newHere.Y ] == double.PositiveInfinity )
- {
- ++impassableCount;
continue;
- }
double cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563 : 1.0 ) * passableCost[ newHere.X, newHere.Y ];
double newCost = cellInfo[ here.X, here.Y ].MinCost + cellCost;
diff --git a/OpenRa.Game/Renderer.cs b/OpenRa.Game/Renderer.cs
index 035fb5802e..774fb277d0 100644
--- a/OpenRa.Game/Renderer.cs
+++ b/OpenRa.Game/Renderer.cs
@@ -20,7 +20,7 @@ namespace OpenRa.Game
public void SetPalette(HardwarePalette hp)
{
- shader.SetTexture(paletteHandle, hp.PaletteTexture);
+ shader.SetTexture(paletteHandle, hp.Texture);
}
public Renderer(Control host, Size resolution, bool windowed)
diff --git a/OpenRa.Game/Sheet.cs b/OpenRa.Game/Sheet.cs
index 22fd1c1449..e1892c7f16 100644
--- a/OpenRa.Game/Sheet.cs
+++ b/OpenRa.Game/Sheet.cs
@@ -1,28 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
-using System.Drawing;
using BluntDirectX.Direct3D;
+using System.Drawing;
using System.IO;
-using System.Drawing.Imaging;
namespace OpenRa.Game
{
class Sheet
{
- public readonly Bitmap bitmap;
-
- readonly GraphicsDevice device;
+ readonly Renderer renderer;
+ protected readonly Bitmap bitmap;
+
Texture texture;
+ static int suffix = 0;
- string filename = string.Format("../../../block-cache-{0}.png", suffix++);
-
- public Size Size { get { return bitmap.Size; } }
-
- public Sheet(Size size, GraphicsDevice d)
+ public Sheet(Renderer renderer, Size size)
{
- bitmap = new Bitmap(size.Width, size.Height);
- device = d;
+ this.renderer = renderer;
+ this.bitmap = new Bitmap(size.Width, size.Height);
+ }
+
+ void Resolve()
+ {
+ string filename = string.Format("../../../sheet-{0}.png", suffix++);
+ bitmap.Save(filename);
+
+ using (Stream s = File.OpenRead(filename))
+ texture = Texture.Create(s, renderer.Device);
}
public Texture Texture
@@ -30,20 +35,18 @@ namespace OpenRa.Game
get
{
if (texture == null)
- LoadTexture();
+ Resolve();
return texture;
}
}
- void LoadTexture()
+ public Size Size { get { return bitmap.Size; } }
+
+ public Color this[Point p]
{
- bitmap.Save(filename);
-
- using( Stream s = File.OpenRead(filename) )
- texture = Texture.Create(s, device);
+ get { return bitmap.GetPixel(p.X, p.Y); }
+ set { bitmap.SetPixel(p.X, p.Y, value); }
}
-
- static int suffix = 0;
}
}
diff --git a/OpenRa.Game/SheetBuilder.cs b/OpenRa.Game/SheetBuilder.cs
index 08d5cb8110..28579288cd 100644
--- a/OpenRa.Game/SheetBuilder.cs
+++ b/OpenRa.Game/SheetBuilder.cs
@@ -9,9 +9,9 @@ namespace OpenRa.Game
{
static class SheetBuilder
{
- public static void Initialize(GraphicsDevice d)
+ public static void Initialize(Renderer r)
{
- device = d;
+ renderer = r;
}
public static Sprite Add(byte[] src, Size size)
@@ -30,12 +30,9 @@ namespace OpenRa.Game
return Add(data, size);
}
- static Sheet NewSheet()
- {
- return new Sheet(new Size(512, 512), device);
- }
+ static Sheet NewSheet() { return new Sheet(renderer, new Size(512, 512)); }
- static GraphicsDevice device;
+ static Renderer renderer;
static Sheet current = null;
static int rowHeight = 0;
static Point p;
diff --git a/OpenRa.Game/Unit.cs b/OpenRa.Game/Unit.cs
index 5789f11435..96fcc5a6e1 100644
--- a/OpenRa.Game/Unit.cs
+++ b/OpenRa.Game/Unit.cs
@@ -114,16 +114,6 @@ namespace OpenRa.Game
return true;
}
- public virtual IOrder Order( int2 xy )
- {
- return new MoveOrder( this, xy );
- }
-
- public int2 Location
- {
- get { return toCell; }
- }
-
public override float2 RenderLocation
{
get
@@ -135,9 +125,8 @@ namespace OpenRa.Game
}
}
- public override Sprite[] CurrentImages
- {
- get { return animation.Images; }
- }
+ public int2 Location { get { return toCell; } }
+ public virtual IOrder Order(int2 xy) { return new MoveOrder(this, xy); }
+ public override Sprite[] CurrentImages { get { return animation.Images; } }
}
}
diff --git a/OpenRa.Game/Util.cs b/OpenRa.Game/Util.cs
index 6f1e5ff2f4..e574840476 100644
--- a/OpenRa.Game/Util.cs
+++ b/OpenRa.Game/Util.cs
@@ -91,8 +91,7 @@ namespace OpenRa.Game
{
Point p = new Point(dest.bounds.Left + i, dest.bounds.Top + j);
byte b = src[i + dest.bounds.Width * j];
- Color original = dest.sheet.bitmap.GetPixel(p.X, p.Y);
- dest.sheet.bitmap.SetPixel(p.X, p.Y, ReplaceChannel(original, dest.channel, b));
+ dest.sheet[p] = ReplaceChannel(dest.sheet[p], dest.channel, b);
}
}
diff --git a/OpenRa.sln b/OpenRa.sln
index 3afa9061a9..d0e7cffbb4 100644
--- a/OpenRa.sln
+++ b/OpenRa.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C# Express 2005
+# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixDecrypt", "MixDecrypt\MixDecrypt.vcproj", "{6F5D4280-3D23-41FF-AE2A-511B5553E377}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.FileFormats", "OpenRa.FileFormats\OpenRa.FileFormats.csproj", "{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}"
@@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BluntDx", "BluntDx\BluntDx.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.TechTree", "OpenRa.TechTree\OpenRa.TechTree.csproj", "{2BFC3861-E90E-4F77-B254-8FB8285E43AC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.BlockCacheVisualizer", "OpenRa.BlockCacheVisualizer\OpenRa.BlockCacheVisualizer.csproj", "{127D13D1-3589-4240-A33B-70C3A25536A4}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.DataStructures", "OpenRa.DataStructures\OpenRa.DataStructures.csproj", "{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteUsage", "PaletteUsage\PaletteUsage.csproj", "{54577061-E2D2-4336-90A2-A9A7106A30CD}"
@@ -83,16 +81,6 @@ Global
{2BFC3861-E90E-4F77-B254-8FB8285E43AC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2BFC3861-E90E-4F77-B254-8FB8285E43AC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2BFC3861-E90E-4F77-B254-8FB8285E43AC}.Release|Win32.ActiveCfg = Release|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Any CPU.Build.0 = Release|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Win32.ActiveCfg = Release|Any CPU
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
diff --git a/PaletteUsage/Program.cs b/PaletteUsage/Program.cs
index 09100e0f80..ccc00752ea 100644
--- a/PaletteUsage/Program.cs
+++ b/PaletteUsage/Program.cs
@@ -23,13 +23,11 @@ namespace PaletteUsage
foreach (byte b in ImageBytes(bitmap))
++f[b];
- for (int i = 0; i < 256; i++)
- {
- if (i % 8 == 0)
- Console.WriteLine();
+ Console.WriteLine("Unused palette entries:");
- Console.Write("{0} -> {1}", i.ToString().PadLeft(3), f[i].ToString().PadRight(8));
- }
+ for (int i = 0; i < 256; i++)
+ if (f[i] == 0)
+ Console.WriteLine("0x{0:x}\t\t{0}", i);
}
static IEnumerable ImageBytes(Bitmap bitmap)