mostly fixes openra startup time
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1928 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -22,7 +22,7 @@ namespace OpenRa.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
Regex sectionPattern = new Regex( @"\[([^]]*)\]" );
|
||||
Regex sectionPattern = new Regex( @"^\[([^]]*)\]" );
|
||||
Regex entryPattern = new Regex( @"([^=;]+)=([^;]*)" );
|
||||
|
||||
bool ProcessSection( string line )
|
||||
@@ -40,6 +40,9 @@ namespace OpenRa.FileFormats
|
||||
|
||||
bool ProcessEntry( string line )
|
||||
{
|
||||
if (string.IsNullOrEmpty(line) || line.StartsWith(";"))
|
||||
return false;
|
||||
|
||||
Match m = entryPattern.Match( line );
|
||||
if( m == null || !m.Success )
|
||||
return false;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
@@ -14,6 +14,21 @@
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -24,6 +39,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -109,6 +125,23 @@
|
||||
<Name>OpenRa.TechTree</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</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.
|
||||
|
||||
@@ -48,5 +48,7 @@ namespace OpenRa.Game
|
||||
get { return bitmap.GetPixel(p.X, p.Y); }
|
||||
set { bitmap.SetPixel(p.X, p.Y, value); }
|
||||
}
|
||||
|
||||
public Bitmap Bitmap { get { return bitmap; } } // for perf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace OpenRa.Game
|
||||
public static Sprite Add(byte[] src, Size size)
|
||||
{
|
||||
Sprite rect = AddImage(size);
|
||||
Util.CopyIntoChannel(rect, src);
|
||||
//Util.CopyIntoChannel(rect, src);
|
||||
Util.FastCopyIntoChannel(rect, src);
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,30 +10,23 @@ namespace OpenRa.Game
|
||||
public readonly Rectangle bounds;
|
||||
public readonly Sheet sheet;
|
||||
public readonly TextureChannel channel;
|
||||
public readonly RectangleF uv;
|
||||
|
||||
internal Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
||||
{
|
||||
this.bounds = bounds;
|
||||
this.sheet = sheet;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
RectangleF TextureCoords
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RectangleF(
|
||||
uv = new RectangleF(
|
||||
(float)(bounds.Left + 0.5f) / sheet.Size.Width,
|
||||
(float)(bounds.Top + 0.5f) / sheet.Size.Height,
|
||||
(float)(bounds.Width) / sheet.Size.Width,
|
||||
(float)(bounds.Height) / sheet.Size.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public float2 MapTextureCoords(float2 p)
|
||||
{
|
||||
RectangleF uv = TextureCoords;
|
||||
|
||||
return new float2(
|
||||
p.X > 0 ? uv.Right : uv.Left,
|
||||
p.Y > 0 ? uv.Bottom : uv.Top);
|
||||
@@ -42,9 +35,9 @@ namespace OpenRa.Game
|
||||
|
||||
public enum TextureChannel
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
Red = 0,
|
||||
Green = 1,
|
||||
Blue = 2,
|
||||
Alpha = 3,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using OpenRa.FileFormats;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -83,29 +84,47 @@ namespace OpenRa.Game
|
||||
indices.Add((ushort)(offset + 2));
|
||||
}
|
||||
|
||||
public static void CopyIntoChannel(Sprite dest, byte[] src)
|
||||
public static void FastCopyIntoChannel(Sprite dest, byte[] src)
|
||||
{
|
||||
for (int i = 0; i < dest.bounds.Width; i++)
|
||||
for (int j = 0; j < dest.bounds.Height; j++)
|
||||
var bitmap = dest.sheet.Bitmap;
|
||||
BitmapData bits = null;
|
||||
uint[] channelMasks = { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
||||
uint mask = channelMasks[(int)dest.channel];
|
||||
|
||||
try
|
||||
{
|
||||
bits = bitmap.LockBits(dest.bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
|
||||
int width = dest.bounds.Width;
|
||||
int height = dest.bounds.Height;
|
||||
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
Point p = new Point(dest.bounds.Left + i, dest.bounds.Top + j);
|
||||
byte b = src[i + dest.bounds.Width * j];
|
||||
dest.sheet[p] = ReplaceChannel(dest.sheet[p], dest.channel, b);
|
||||
unsafe
|
||||
{
|
||||
uint* p = (uint*)(bits.Scan0.ToInt32() + j * bits.Stride);
|
||||
for (int i = 0; i < width; i++, p++)
|
||||
*p = ReplaceChannel(*p, mask, src[i + width * j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
bitmap.UnlockBits(bits);
|
||||
}
|
||||
}
|
||||
|
||||
static Color ReplaceChannel(Color o, TextureChannel channel, byte p)
|
||||
static uint ReplaceChannel(uint o, uint mask, byte p)
|
||||
{
|
||||
switch (channel)
|
||||
{
|
||||
case TextureChannel.Red: return Color.FromArgb(o.A, p, o.G, o.B);
|
||||
case TextureChannel.Green: return Color.FromArgb(o.A, o.R, p, o.B);
|
||||
case TextureChannel.Blue: return Color.FromArgb(o.A, o.R, o.G, p);
|
||||
case TextureChannel.Alpha: return Color.FromArgb(p, o.R, o.G, o.B);
|
||||
uint pp = (uint)p;
|
||||
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
pp |= pp << 8; // copy into all channels
|
||||
pp |= pp << 16;
|
||||
|
||||
o &= ~mask;
|
||||
o |= (mask & pp);
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user