- bugfix in Format80
- fixed heisenburg-endianness in map loader
- THERES A BUG in the mix loading; I need another 4 bytes padding to load temperat.mix and snow.mix (not interior.mix, though)
- ShpViewer can now load and view map files
- Copy TEMPERAT, SNOW, INFERIOR (sic) mixes into $(SolutionDir) for this to work
- Left-click to reload tile-ID file, middle-click scrolls
- the tile-id file has some collisions between tile-sets, be careful about ordering if you change anything
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1081 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -27,14 +27,16 @@ namespace OpenRa.FileFormats
|
|||||||
if( srcIndex >= destIndex )
|
if( srcIndex >= destIndex )
|
||||||
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
|
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
|
||||||
|
|
||||||
for( int i = 0 ; i < Math.Min( count, destIndex - srcIndex ) ; i++ )
|
if( destIndex - srcIndex == 1 )
|
||||||
dest[ destIndex + i ] = dest[ srcIndex + i ];
|
{
|
||||||
|
for( int i = 0 ; i < count ; i++ )
|
||||||
if( srcIndex + count <= destIndex )
|
dest[ destIndex + i ] = dest[ destIndex - 1 ];
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
for( int i = destIndex + destIndex - srcIndex ; i < destIndex + count ; i++ )
|
{
|
||||||
dest[ i ] = dest[ destIndex - 1 ];
|
for( int i = 0 ; i < count ; i++ )
|
||||||
|
dest[ destIndex + i ] = dest[ srcIndex + i ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DecodeInto( MemoryStream input, byte[] dest )
|
public static int DecodeInto( MemoryStream input, byte[] dest )
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Text;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace MapViewer
|
namespace OpenRa.FileFormats
|
||||||
{
|
{
|
||||||
public class IniFile
|
public class IniFile
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MapViewer;
|
|
||||||
|
|
||||||
namespace OpenRa.FileFormats
|
namespace OpenRa.FileFormats
|
||||||
{
|
{
|
||||||
@@ -98,14 +97,14 @@ namespace OpenRa.FileFormats
|
|||||||
{
|
{
|
||||||
for( int j = 0 ; j < 128 ; j++ )
|
for( int j = 0 ; j < 128 ; j++ )
|
||||||
{
|
{
|
||||||
MapTiles[ i, j ].tile = ReadByte( ms );
|
MapTiles[ j, i ].tile = ReadByte( ms );
|
||||||
MapTiles[ i, j ].tile |= (ushort)( ReadByte( ms ) << 8 );
|
MapTiles[ j, i ].tile |= (ushort)( ReadByte( ms ) << 8 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0 ; i < 128 ; i++ )
|
for( int i = 0 ; i < 128 ; i++ )
|
||||||
for( int j = 0 ; j < 128 ; j++ )
|
for( int j = 0 ; j < 128 ; j++ )
|
||||||
MapTiles[ i, j ].image = ReadByte( ms );
|
MapTiles[ j, i ].image = ReadByte( ms );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BitmapBuilder.cs" />
|
<Compile Include="BitmapBuilder.cs" />
|
||||||
@@ -50,6 +49,13 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ShpReader.cs" />
|
<Compile Include="ShpReader.cs" />
|
||||||
<Compile Include="Terrain.cs" />
|
<Compile Include="Terrain.cs" />
|
||||||
|
<Compile Include="TileSet.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenRa.Core\OpenRa.Core.csproj">
|
||||||
|
<Project>{1B60782F-B2DD-43F1-B51D-B798485F317C}</Project>
|
||||||
|
<Name>OpenRa.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using OpenRa.Core;
|
||||||
|
|
||||||
namespace OpenRa.FileFormats
|
namespace OpenRa.FileFormats
|
||||||
{
|
{
|
||||||
@@ -122,11 +123,13 @@ namespace OpenRa.FileFormats
|
|||||||
s.Seek(2 + 4 + (isRmix ? 4 : 0), SeekOrigin.Begin);
|
s.Seek(2 + 4 + (isRmix ? 4 : 0), SeekOrigin.Begin);
|
||||||
|
|
||||||
s.Seek(2, SeekOrigin.Current); //dword align
|
s.Seek(2, SeekOrigin.Current); //dword align
|
||||||
|
s.Seek( 4, SeekOrigin.Current ); //wtf, i dont know why i need this either :(
|
||||||
|
|
||||||
if (isEncrypted)
|
if( isEncrypted )
|
||||||
s.Seek(80, SeekOrigin.Current);
|
s.Seek(80, SeekOrigin.Current);
|
||||||
|
|
||||||
s.Seek(index.Count * PackageEntry.Size + e.Offset, SeekOrigin.Current);
|
s.Seek( index.Count * PackageEntry.Size + e.Offset, SeekOrigin.Current );
|
||||||
|
|
||||||
byte[] data = new byte[ e.Length ];
|
byte[] data = new byte[ e.Length ];
|
||||||
s.Read( data, 0, (int)e.Length );
|
s.Read( data, 0, (int)e.Length );
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
@@ -140,7 +143,6 @@ namespace OpenRa.FileFormats
|
|||||||
{
|
{
|
||||||
return GetContent(PackageEntry.HashFilename(filename));
|
return GetContent(PackageEntry.HashFilename(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRa.FileFormats
|
|||||||
Height = reader.ReadUInt16();
|
Height = reader.ReadUInt16();
|
||||||
|
|
||||||
if( Width != 24 || Height != 24 )
|
if( Width != 24 || Height != 24 )
|
||||||
throw new InvalidDataException();
|
throw new InvalidDataException( string.Format( "{0}x{1}", Width, Height ) );
|
||||||
|
|
||||||
NumTiles = reader.ReadUInt16();
|
NumTiles = reader.ReadUInt16();
|
||||||
reader.ReadUInt16();
|
reader.ReadUInt16();
|
||||||
@@ -58,7 +58,10 @@ namespace OpenRa.FileFormats
|
|||||||
|
|
||||||
public Bitmap GetTile( int index )
|
public Bitmap GetTile( int index )
|
||||||
{
|
{
|
||||||
return TileBitmaps[ index ];
|
if( index < TileBitmaps.Count )
|
||||||
|
return TileBitmaps[ index ];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap[ , ] GetTiles( int tileNum )
|
public Bitmap[ , ] GetTiles( int tileNum )
|
||||||
|
|||||||
49
OpenRa.FileFormats/TileSet.cs
Normal file
49
OpenRa.FileFormats/TileSet.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace OpenRa.FileFormats
|
||||||
|
{
|
||||||
|
public class TileSet
|
||||||
|
{
|
||||||
|
public readonly Dictionary<ushort, Terrain> tiles = new Dictionary<ushort, Terrain>();
|
||||||
|
|
||||||
|
public TileSet( Package mixFile, string suffix, Palette pal )
|
||||||
|
{
|
||||||
|
StreamReader tileIdFile = File.OpenText( "../../../tileSet.til" );
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
string countStr = tileIdFile.ReadLine();
|
||||||
|
string startStr = tileIdFile.ReadLine();
|
||||||
|
string pattern = tileIdFile.ReadLine() + suffix;
|
||||||
|
if( countStr == null || startStr == null || pattern == null )
|
||||||
|
break;
|
||||||
|
|
||||||
|
//try
|
||||||
|
{
|
||||||
|
int count = int.Parse( countStr );
|
||||||
|
int start = int.Parse( startStr, NumberStyles.HexNumber );
|
||||||
|
for( int i = 0 ; i < count ; i++ )
|
||||||
|
{
|
||||||
|
Stream s;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
s = mixFile.GetContent( string.Format( pattern, i + 1 ) );
|
||||||
|
}
|
||||||
|
catch { continue; }
|
||||||
|
Terrain t = new Terrain( s, pal );
|
||||||
|
if( tiles.ContainsKey( (ushort)( start + i ) ) )
|
||||||
|
continue;
|
||||||
|
tiles.Add( (ushort)( start + i ), t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
tileIdFile.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
65
ShpViewer/MapViewControl.cs
Normal file
65
ShpViewer/MapViewControl.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using OpenRa.FileFormats;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace ShpViewer
|
||||||
|
{
|
||||||
|
public class MapViewControl : Control
|
||||||
|
{
|
||||||
|
public int XScroll, YScroll;
|
||||||
|
|
||||||
|
public Map Map;
|
||||||
|
public TileSet TileSet;
|
||||||
|
|
||||||
|
public MapViewControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static Font font = new Font( FontFamily.GenericMonospace, 10 );
|
||||||
|
protected override void OnPaint( PaintEventArgs e )
|
||||||
|
{
|
||||||
|
base.OnPaint( e );
|
||||||
|
if( Map == null || TileSet == null )
|
||||||
|
return;
|
||||||
|
using( Graphics g = e.Graphics )
|
||||||
|
{
|
||||||
|
for( int x = 50 ; x >= 0 ; x-- )
|
||||||
|
{
|
||||||
|
int tX = x + Map.XOffset + XScroll;
|
||||||
|
if( tX < 1 || tX > 127 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for( int y = 50 ; y >= 0 ; y-- )
|
||||||
|
{
|
||||||
|
int tY = y + Map.YOffset + YScroll;
|
||||||
|
if( tY < 1 || tY > 127 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Terrain t;
|
||||||
|
if( TileSet.tiles.TryGetValue( Map.MapTiles[ tX, tY ].tile, out t ) )
|
||||||
|
{
|
||||||
|
Bitmap b = t.GetTile( Map.MapTiles[ tX, tY ].image );
|
||||||
|
if( b == null )
|
||||||
|
{
|
||||||
|
g.FillRectangle( Brushes.Blue, x * 24, y * 24, 24, 24 );
|
||||||
|
g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].image ),
|
||||||
|
font, Brushes.White, x * 24, y * 24 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g.DrawImage( b, x * 24, y * 24 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.FillRectangle( Brushes.Red, x * 24, y * 24, 24, 24 );
|
||||||
|
g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].tile ),
|
||||||
|
font, Brushes.White, x * 24, y * 24 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ namespace ShpViewer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
ofd.Filter = "SHP Files (*.shp)|*.shp|Terrain Files (*.tem; *.sno; *.int)|*.tem;*.sno;*.int|All Files (*.*)|*.*";
|
ofd.Filter = "SHP Files (*.shp)|*.shp|Terrain Files (*.tem; *.sno; *.int)|*.tem;*.sno;*.int|Map Files (*.ini;*.mpr)|*.ini;*.mpr|All Files (*.*)|*.*";
|
||||||
ofd.RestoreDirectory = true;
|
ofd.RestoreDirectory = true;
|
||||||
if( ofd.ShowDialog() == DialogResult.OK )
|
if( ofd.ShowDialog() == DialogResult.OK )
|
||||||
Application.Run( new ShpViewForm( ofd.FileName ) );
|
Application.Run( new ShpViewForm( ofd.FileName ) );
|
||||||
|
|||||||
112
ShpViewer/Properties/Resources.Designer.cs
generated
112
ShpViewer/Properties/Resources.Designer.cs
generated
@@ -8,64 +8,56 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace ShpViewer.Properties
|
namespace ShpViewer.Properties {
|
||||||
{
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute( "System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0" )]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources
|
internal class Resources {
|
||||||
{
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
|
internal Resources() {
|
||||||
internal Resources()
|
}
|
||||||
{
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
/// </summary>
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
|
get {
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
{
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShpViewer.Properties.Resources", typeof(Resources).Assembly);
|
||||||
get
|
resourceMan = temp;
|
||||||
{
|
}
|
||||||
if( ( resourceMan == null ) )
|
return resourceMan;
|
||||||
{
|
}
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager( "ShpViewer.Properties.Resources", typeof( Resources ).Assembly );
|
}
|
||||||
resourceMan = temp;
|
|
||||||
}
|
/// <summary>
|
||||||
return resourceMan;
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
}
|
/// resource lookups using this strongly typed resource class.
|
||||||
}
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
/// <summary>
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
get {
|
||||||
/// resource lookups using this strongly typed resource class.
|
return resourceCulture;
|
||||||
/// </summary>
|
}
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
|
set {
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
resourceCulture = value;
|
||||||
{
|
}
|
||||||
get
|
}
|
||||||
{
|
}
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
34
ShpViewer/Properties/Settings.Designer.cs
generated
34
ShpViewer/Properties/Settings.Designer.cs
generated
@@ -8,23 +8,19 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace ShpViewer.Properties
|
namespace ShpViewer.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute( "Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0" )]
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
|
||||||
{
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
private static Settings defaultInstance = ( (Settings)( global::System.Configuration.ApplicationSettingsBase.Synchronized( new Settings() ) ) );
|
public static Settings Default {
|
||||||
|
get {
|
||||||
public static Settings Default
|
return defaultInstance;
|
||||||
{
|
}
|
||||||
get
|
}
|
||||||
{
|
}
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
22
ShpViewer/ShpViewForm.Designer.cs
generated
22
ShpViewer/ShpViewForm.Designer.cs
generated
@@ -29,21 +29,38 @@ namespace ShpViewer
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
|
this.mapViewControl1 = new ShpViewer.MapViewControl();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// flowLayoutPanel1
|
// flowLayoutPanel1
|
||||||
//
|
//
|
||||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.flowLayoutPanel1.Anchor = ( (System.Windows.Forms.AnchorStyles)( ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom )
|
||||||
this.flowLayoutPanel1.Location = new System.Drawing.Point( 0, 0 );
|
| System.Windows.Forms.AnchorStyles.Left )
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right ) ) );
|
||||||
|
this.flowLayoutPanel1.Location = new System.Drawing.Point( 1, 1 );
|
||||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||||
this.flowLayoutPanel1.Size = new System.Drawing.Size( 292, 273 );
|
this.flowLayoutPanel1.Size = new System.Drawing.Size( 292, 273 );
|
||||||
this.flowLayoutPanel1.TabIndex = 0;
|
this.flowLayoutPanel1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// mapViewControl1
|
||||||
|
//
|
||||||
|
this.mapViewControl1.Anchor = ( (System.Windows.Forms.AnchorStyles)( ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom )
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left )
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right ) ) );
|
||||||
|
this.mapViewControl1.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.mapViewControl1.Location = new System.Drawing.Point( 0, 0 );
|
||||||
|
this.mapViewControl1.Name = "mapViewControl1";
|
||||||
|
this.mapViewControl1.Size = new System.Drawing.Size( 293, 274 );
|
||||||
|
this.mapViewControl1.TabIndex = 1;
|
||||||
|
this.mapViewControl1.Text = "mapViewControl1";
|
||||||
|
this.mapViewControl1.Visible = false;
|
||||||
|
//
|
||||||
// ShpViewForm
|
// ShpViewForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
|
this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size( 292, 273 );
|
this.ClientSize = new System.Drawing.Size( 292, 273 );
|
||||||
|
this.Controls.Add( this.mapViewControl1 );
|
||||||
this.Controls.Add( this.flowLayoutPanel1 );
|
this.Controls.Add( this.flowLayoutPanel1 );
|
||||||
this.Name = "ShpViewForm";
|
this.Name = "ShpViewForm";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
@@ -54,6 +71,7 @@ namespace ShpViewer
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||||
|
private MapViewControl mapViewControl1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace ShpViewer
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
string ext = Path.GetExtension( filename );
|
string ext = Path.GetExtension( filename ).ToLowerInvariant();
|
||||||
if( ext == ".shp" )
|
if( ext == ".shp" )
|
||||||
{
|
{
|
||||||
ShpReader shpReader = new ShpReader( File.OpenRead( filename ) );
|
ShpReader shpReader = new ShpReader( File.OpenRead( filename ) );
|
||||||
@@ -53,6 +53,37 @@ namespace ShpViewer
|
|||||||
}
|
}
|
||||||
bitmaps.Add( bigTile );
|
bitmaps.Add( bigTile );
|
||||||
}
|
}
|
||||||
|
else if( ext == ".ini" || ext == ".mpr" )
|
||||||
|
{
|
||||||
|
IniFile iniFile = new IniFile( File.OpenRead( filename ) );
|
||||||
|
Map map = new Map( iniFile );
|
||||||
|
TileSet tileSet = LoadTileSet( map );
|
||||||
|
|
||||||
|
flowLayoutPanel1.Visible = false;
|
||||||
|
flowLayoutPanel1.BackColor = Color.Blue;
|
||||||
|
mapViewControl1.Visible = true;
|
||||||
|
mapViewControl1.Map = map;
|
||||||
|
mapViewControl1.TileSet = tileSet;
|
||||||
|
mapViewControl1.Invalidate();
|
||||||
|
|
||||||
|
mapViewControl1.MouseClick += delegate( object sender, MouseEventArgs e )
|
||||||
|
{
|
||||||
|
if( e.Button == MouseButtons.Left )
|
||||||
|
{
|
||||||
|
mapViewControl1.Map = new Map( iniFile );
|
||||||
|
mapViewControl1.TileSet = LoadTileSet( map );
|
||||||
|
}
|
||||||
|
else if( e.Button == MouseButtons.Middle )
|
||||||
|
{
|
||||||
|
int dx = ( e.X * 2 - mapViewControl1.Width ) / 24;
|
||||||
|
int dy = ( e.Y * 2 - mapViewControl1.Height ) / 24;
|
||||||
|
|
||||||
|
mapViewControl1.XScroll += dx;
|
||||||
|
mapViewControl1.YScroll += dy;
|
||||||
|
}
|
||||||
|
mapViewControl1.Invalidate();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Bitmap b in bitmaps)
|
foreach (Bitmap b in bitmaps)
|
||||||
{
|
{
|
||||||
@@ -65,5 +96,24 @@ namespace ShpViewer
|
|||||||
Focus();
|
Focus();
|
||||||
BringToFront();
|
BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileSet LoadTileSet( Map currentMap )
|
||||||
|
{
|
||||||
|
Palette pal;
|
||||||
|
switch( currentMap.Theater.ToLowerInvariant() )
|
||||||
|
{
|
||||||
|
case "temperate":
|
||||||
|
pal = new Palette( File.OpenRead( "../../../temperat.pal" ) );
|
||||||
|
return new TileSet( new Package( "../../../temperat.mix" ), ".tem", pal );
|
||||||
|
case "snow":
|
||||||
|
pal = new Palette( File.OpenRead( "../../../snow.pal" ) );
|
||||||
|
return new TileSet( new Package( "../../../snow.mix" ), ".sno", pal );
|
||||||
|
case "interior":
|
||||||
|
pal = new Palette( File.OpenRead( "../../../interior.pal" ) );
|
||||||
|
return new TileSet( new Package( "../../../interior.mix" ), ".int", pal );
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="MapViewControl.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="ShpViewForm.cs">
|
<Compile Include="ShpViewForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -58,6 +61,7 @@
|
|||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
|||||||
148
tileSet.til
Normal file
148
tileSet.til
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
56
|
||||||
|
0003
|
||||||
|
sh{0:00}
|
||||||
|
2
|
||||||
|
0001
|
||||||
|
w{0}
|
||||||
|
38
|
||||||
|
0087
|
||||||
|
s{0:00}
|
||||||
|
38
|
||||||
|
003b
|
||||||
|
wc{0:00}
|
||||||
|
6
|
||||||
|
00f7
|
||||||
|
f{0:00}
|
||||||
|
43
|
||||||
|
00ad
|
||||||
|
d{0:00}
|
||||||
|
4
|
||||||
|
00e7
|
||||||
|
rc{0:00}
|
||||||
|
1
|
||||||
|
00eb
|
||||||
|
br1a
|
||||||
|
1
|
||||||
|
00ee
|
||||||
|
br2a
|
||||||
|
1
|
||||||
|
00f1
|
||||||
|
br3a
|
||||||
|
1
|
||||||
|
017c
|
||||||
|
br1x
|
||||||
|
1
|
||||||
|
017d
|
||||||
|
br2x
|
||||||
|
1
|
||||||
|
00ed
|
||||||
|
br1c
|
||||||
|
1
|
||||||
|
00f0
|
||||||
|
br2c
|
||||||
|
13
|
||||||
|
0070
|
||||||
|
rv{0:00}
|
||||||
|
1
|
||||||
|
0083
|
||||||
|
bridge1
|
||||||
|
1
|
||||||
|
0084
|
||||||
|
bridge1d
|
||||||
|
1
|
||||||
|
017a
|
||||||
|
bridge1h
|
||||||
|
1
|
||||||
|
017e
|
||||||
|
bridge1x
|
||||||
|
1
|
||||||
|
0085
|
||||||
|
bridge2
|
||||||
|
1
|
||||||
|
0086
|
||||||
|
bridge2d
|
||||||
|
1
|
||||||
|
017f
|
||||||
|
bridge2x
|
||||||
|
2
|
||||||
|
0081
|
||||||
|
ford{0}
|
||||||
|
1
|
||||||
|
00e5
|
||||||
|
rv14
|
||||||
|
1
|
||||||
|
00e6
|
||||||
|
rv15
|
||||||
|
1
|
||||||
|
007e
|
||||||
|
falls1a
|
||||||
|
1
|
||||||
|
007f
|
||||||
|
falls2
|
||||||
|
1
|
||||||
|
0080
|
||||||
|
falls2a
|
||||||
|
3
|
||||||
|
0061
|
||||||
|
b{0}
|
||||||
|
1
|
||||||
|
0067
|
||||||
|
p01
|
||||||
|
1
|
||||||
|
0068
|
||||||
|
p02
|
||||||
|
1
|
||||||
|
0069
|
||||||
|
p03
|
||||||
|
1
|
||||||
|
006a
|
||||||
|
p04
|
||||||
|
1
|
||||||
|
006b
|
||||||
|
p07
|
||||||
|
1
|
||||||
|
006c
|
||||||
|
p08
|
||||||
|
1
|
||||||
|
006d
|
||||||
|
p13
|
||||||
|
1
|
||||||
|
006e
|
||||||
|
p14
|
||||||
|
11
|
||||||
|
00d8
|
||||||
|
rf{0:00}
|
||||||
|
1
|
||||||
|
00e3
|
||||||
|
d44
|
||||||
|
1
|
||||||
|
00e4
|
||||||
|
d45
|
||||||
|
49
|
||||||
|
0149
|
||||||
|
wall{0:0000}
|
||||||
|
7
|
||||||
|
010c
|
||||||
|
flor{0:0000}
|
||||||
|
16
|
||||||
|
0180
|
||||||
|
xtra{0:0000}
|
||||||
|
11
|
||||||
|
013e
|
||||||
|
strp{0:0000}
|
||||||
|
15
|
||||||
|
00fd
|
||||||
|
arro{0:0000}
|
||||||
|
5
|
||||||
|
0113
|
||||||
|
gflr{0:0000}
|
||||||
|
11
|
||||||
|
0118
|
||||||
|
gstr{0:0000}
|
||||||
|
1
|
||||||
|
ff
|
||||||
|
clear1
|
||||||
|
1
|
||||||
|
ffff
|
||||||
|
clear1
|
||||||
|
|
||||||
Reference in New Issue
Block a user