git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1330 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
60
OpenRa.BlockCacheVisualizer/Form1.Designer.cs
generated
60
OpenRa.BlockCacheVisualizer/Form1.Designer.cs
generated
@@ -1,60 +0,0 @@
|
||||
namespace OpenRa.BlockCacheVisualizer
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#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.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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
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">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</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 for serialized 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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<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" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</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>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,64 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{127D13D1-3589-4240-A33B-70C3A25536A4}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRa.BlockCacheVisualizer</RootNamespace>
|
||||
<AssemblyName>OpenRa.BlockCacheVisualizer</AssemblyName>
|
||||
</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>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</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>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRa.BlockCacheVisualizer
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
@@ -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<IFolder> mountedFolders = new List<IFolder>();
|
||||
|
||||
20
OpenRa.FileFormats/Folder.cs
Normal file
20
OpenRa.FileFormats/Folder.cs
Normal file
@@ -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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<TreeReference> Trees = new List<TreeReference>();
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Blowfish.cs" />
|
||||
<Compile Include="FileSystem.cs" />
|
||||
<Compile Include="Folder.cs" />
|
||||
<Compile Include="Format40.cs" />
|
||||
<Compile Include="Format80.cs" />
|
||||
<Compile Include="IniFile.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 );
|
||||
viewport = new Viewport(clientSize, map.Size, renderer);
|
||||
|
||||
terrain = new TerrainRenderer( renderer, map, viewport );
|
||||
world = new World( renderer, viewport );
|
||||
treeCache = new TreeCache( renderer.Device, map );
|
||||
terrain = new TerrainRenderer(renderer, map, viewport);
|
||||
world = new World(renderer, viewport);
|
||||
treeCache = new TreeCache(renderer.Device, map);
|
||||
|
||||
foreach( TreeReference treeReference in map.Trees )
|
||||
world.Add( new Tree( treeReference, treeCache, map ) );
|
||||
foreach (TreeReference treeReference in map.Trees)
|
||||
world.Add(new Tree(treeReference, treeCache, map));
|
||||
|
||||
pathFinder = new PathFinder( map, terrain.tileSet );
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<Compile Include="Animation.cs" />
|
||||
<Compile Include="Building.cs" />
|
||||
<Compile Include="Game.cs" />
|
||||
<Compile Include="Sheet.cs" />
|
||||
<Compile Include="Harvester.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Network\Network.cs" />
|
||||
@@ -65,7 +66,6 @@
|
||||
<Compile Include="Refinery.cs" />
|
||||
<Compile Include="Renderer.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Sheet.cs" />
|
||||
<Compile Include="Sidebar.cs" />
|
||||
<Compile Include="Sprite.cs" />
|
||||
<Compile Include="SpriteRenderer.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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 Renderer renderer;
|
||||
protected readonly Bitmap bitmap;
|
||||
|
||||
readonly GraphicsDevice device;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
OpenRa.sln
14
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
|
||||
|
||||
@@ -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<byte> ImageBytes(Bitmap bitmap)
|
||||
|
||||
Reference in New Issue
Block a user