public CSVBasedList( EU2.Install install, string csvHeaderLine, System.Type itemType, System.Collections.Specialized.HybridDictionary list ) : base(install) { this.list = new System.Collections.Specialized.HybridDictionary(); this.csvHeaderLine = csvHeaderLine; this.itemType = itemType; }
public ProvinceList( EU2.Install install ) : base(install) { loaded = false; boundbox = null; idtable = null; adjacencies = null; }
public Provinces( EU2.Install install ) : base(install, CSVHEADER, typeof( Province )) { loaded = false; boundbox = null; idtable = null; adjacencies = null; }
public IDTable( EU2.Install install ) : base(install) { // Get the mapsize from the boundbox table this.mapsize = install.Map.MapSize; OpenStream(); }
public Map( EU2.Install install ) : base(install) { lightmaps = new Lightmap[5]; lightmaps[0] = new Lightmap( 0, install.GetMapFile("lightmap1.tbl"), install ); lightmaps[1] = new Lightmap( 1, install.GetMapFile("lightmap2.tbl"), install ); lightmaps[2] = new Lightmap( 2, install.GetMapFile("lightmap3.tbl"), install ); lightmaps[3] = new Lightmap( 4, install.GetMapFile("lightmap4.tbl"), install ); }
public TerrainList( EU2.Install install ) { CSVReader reader = new CSVReader( install.GetMapFile( "terrain types.csv" ) ); try { ReadFromCSV( reader ); } finally { reader.Close(); } }
public ReligionList( EU2.Install install ) { CSVReader reader = new CSVReader( install.GetDBFile( "religion.csv" ) ); try { ReadFromCSV( reader ); } finally { reader.Close(); } }
private static void EU2File_WriteFileItemSave( IFile file, EU2.Edit.FileProcessingEventArgs e ) { switch ( e.Action ) { case FileProcessingAction.Write: Console.WriteLine( "Saving {0}...", e.Item ); break; case FileProcessingAction.Generate: Console.WriteLine( "Generating {0}...", e.Item ); break; case FileProcessingAction.Regenerate: Console.WriteLine( "Regenerating {0}...", e.Item ); break; default: Console.WriteLine( "{1} {0}...", e.Item, e.Action.ToString() ); break; } }
public short[] Shade16( EU2.Map.Codec.RawImage image ) { short[] buffer = new short[image.PixelCount]; int bufidx = 0; Pixel[,] memory = image.Memory; int height = image.Size.Height; int width = image.Size.Width; for ( int y=0; y<height; ++y ) { for ( int x=0; x<width; ++x ) { byte color = (byte)(0x1F-(memory[x,y].Color>>2)); buffer[bufidx++] = (short)((color << 10) | (color << 5) | color); } } Bitmap canvas = new Bitmap( image.Width, image.Height, PixelFormat.Format16bppRgb555 ); Graphics g = Graphics.FromImage( canvas ); g.DrawImageUnscaled( Visualiser.CreateImage16( buffer, image.Size ), 0, 0 ); Font f = new Font( "Small Fonts", 5 ); for ( int y=0; y<image.Height; y += Lightmap.BlockSize ) { for ( int x=0; x<image.Width; x += Lightmap.BlockSize ) { int ix = image.X + x; int iy = image.Y + y; IncognitaGridItem data = incognita[ix >> Lightmap.BlockFactor, iy >> Lightmap.BlockFactor]; int id = idgrid.RealID( ix, iy, data[0].ID ); g.DrawString( id.ToString() + "/" + data[0].Weight.ToString( "X2" ), f, Brushes.Black, x+2, y+2 ); id = idgrid.RealID( ix, iy, data[1].ID ); g.DrawString( id.ToString() + "/" + data[1].Weight.ToString( "X2" ), f, Brushes.Black, x+2, y+8 ); id = idgrid.RealID( ix, iy, data[2].ID ); g.DrawString( id.ToString() + "/" + data[2].Weight.ToString( "X2" ), f, Brushes.Black, x+2, y+14 ); id = idgrid.RealID( ix, iy, data[3].ID ); g.DrawString( id.ToString() + "/" + data[3].Weight.ToString( "X2" ), f, Brushes.Black, x+2, y+20 ); } } f.Dispose(); g.Dispose(); return Visualiser.CreateBuffer16( canvas ); }
private static void WriteRegions(EU2.Map.IDGrid idgrid, EU2.Data.ProvinceList provinces, IDMap idmap, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("IDGrid"); for(int y=0; y<idgrid.Height; ++y ) { for(int x=0; x<idgrid.Width; ++x ) { writer.WriteStartElement("Region"); writer.WriteAttributeString("index-x", x.ToString()); writer.WriteAttributeString("index-y", y.ToString()); writer.WriteAttributeString("offset-x", (x*EU2.Map.IDGrid.RegionWidth).ToString()); writer.WriteAttributeString("offset-y", (y*EU2.Map.IDGrid.RegionHeight).ToString()); ushort[] list = idgrid.GetIDs(x,y); int cnt=0; for(; cnt<list.Length; ++cnt) { if ( list[cnt] == 0 && cnt>0 ) break; } if ( cnt <= 1 ) { writer.WriteAttributeString("provinceCount", "0"); Rectangle rect = Rectangle.Empty; if ( !EU2.Map.IDGrid.CheckAreaForOverflow(idmap, EU2.Map.IDGrid.GetRegionRect(x,y), out rect) ) { writer.WriteStartElement("Overflow"); writer.WriteAttributeString("x", rect.X.ToString()); writer.WriteAttributeString("y", rect.Y.ToString()); writer.WriteAttributeString("width", rect.Width.ToString()); writer.WriteAttributeString("height", rect.Height.ToString()); writer.WriteEndElement(); } } else { writer.WriteAttributeString("provinceCount", cnt.ToString()); for(int i=0; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; writer.WriteStartElement("Province"); writer.WriteAttributeString("index", i.ToString()); writer.WriteAttributeString("id", list[i].ToString()); writer.WriteAttributeString("name", provinces[list[i]].Name); writer.WriteEndElement(); } } writer.WriteEndElement(); } } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
private static void WriteBoxes(EU2.Map.ProvinceBoundBox[] boxes, EU2.IO.CSVWriter writer) { writer.EndRow( "ProvinceId;Left;Top;Right;Bottom;" ); foreach(EU2.Map.ProvinceBoundBox box in boxes) { writer.Write(box.ProvinceID); writer.Write(box.Left); writer.Write(box.Top); writer.Write(box.Right); writer.Write(box.Bottom); writer.EndRow(); } writer.Flush(); }
private static void WriteBoxes(EU2.Map.ProvinceBoundBox[] boxes, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("BoundBoxes"); foreach(EU2.Map.ProvinceBoundBox box in boxes) { writer.WriteStartElement("Box"); writer.WriteAttributeString("provinceId", box.ProvinceID.ToString()); writer.WriteAttributeString("left", box.Left.ToString()); writer.WriteAttributeString("top", box.Top.ToString()); writer.WriteAttributeString("right", box.Right.ToString()); writer.WriteAttributeString("bottom", box.Bottom.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
private static void WriteAdjacencies(EU2.Map.AdjacencyTable adjtable, EU2.Data.ProvinceList provinces, EU2.IO.CSVWriter writer) { writer.EndRow( "fromProvinceId;fromProvinceName;toProvinceId;toProvinceName;type" ); for(int i=Province.MinID; i<=Province.MaxID; ++i) { EU2.Map.Adjacent[] adj = adjtable[i]; for(int t=0; t<adj.Length; ++t) { writer.Write(i); writer.Write(provinces[i].Name); writer.Write(adj[t].ID); writer.Write(provinces[adj[t].ID].Name); writer.Write(adj[t].Type.ToString().ToLower()); writer.EndRow(); } } writer.Flush(); }
private static void WriteAdjacencies(EU2.Map.AdjacencyTable adjtable, EU2.Data.ProvinceList provinces, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("Adjacencies"); for(int i=Province.MinID; i<=Province.MaxID; ++i) { EU2.Map.Adjacent[] adj = adjtable[i]; writer.WriteStartElement("From"); writer.WriteAttributeString("id", i.ToString()); writer.WriteAttributeString("name", provinces[i].Name); for(int t=0; t<adj.Length; ++t) { writer.WriteStartElement("To"); writer.WriteAttributeString("id", adj[t].ID.ToString()); writer.WriteAttributeString("name", provinces[adj[t].ID].Name); writer.WriteAttributeString("type", adj[t].Type.ToString().ToLower()); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
public CSVBasedItem( EU2.Install install, System.IO.StreamReader reader ) : base(install) { if ( !ReadFrom( reader ) ) throw new AtEndOfStreamException(); }
public override void QuickPaint(System.Drawing.Graphics g, EU2.Map.ILightmapDimensions m, System.Drawing.Rectangle area) { Paint( g, m, area ); }
public Goods( EU2.Install install ) : base(install, CSVHEADER, typeof( EU2.Data.Good )) { ReadFrom( Install.DBPath + "\\goods.csv" ); }
public void QuickPaint(System.Drawing.Graphics g, EU2.Map.ILightmapDimensions m, System.Drawing.Rectangle area) { g.FillRectangle( Brushes.Red, new Rectangle( Point.Empty, m.CoordMap.BlocksToActual( area.Size ) ) ); }
public BoundBox( EU2.Install install ) { this.install = install; cache = new Hashtable(); OpenStream(); }
public Province( EU2.Install install, System.IO.StreamReader reader ) : base(install, reader) { }
public Province( EU2.Install install, ushort id ) : base(install) { this.id = id; }
private static void WriteRegions(EU2.Map.IDGrid idgrid, EU2.Data.ProvinceList provinces, IDMap idmap, EU2.IO.CSVWriter writer) { writer.EndRow( "region-index-x;region-index-y;region-offset-x;region-offset-x;region-provinceCount;index;provinceId;name" ); for(int y=0; y<idgrid.Height; ++y ) { for(int x=0; x<idgrid.Width; ++x ) { ushort[] list = idgrid.GetIDs(x,y); if ( list.Length == 0 ) { writer.Write(x); writer.Write(y); writer.Write(x*EU2.Map.IDGrid.RegionWidth); writer.Write(y*EU2.Map.IDGrid.RegionHeight); writer.Write(0); Rectangle rect = Rectangle.Empty; if ( !EU2.Map.IDGrid.CheckAreaForOverflow(idmap, EU2.Map.IDGrid.GetRegionRect(x,y), out rect) ) { writer.Write("Overflow"); writer.Write(rect.X); writer.Write(rect.Y); writer.Write(rect.Width); writer.Write(rect.Height); } writer.EndRow(); } else { int i=0; for(; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; } int cnt = i; for(i=0; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; writer.Write(x); writer.Write(y); writer.Write(x*EU2.Map.IDGrid.RegionWidth); writer.Write(y*EU2.Map.IDGrid.RegionHeight); writer.Write(cnt); writer.Write(i); writer.Write(list[i]); writer.Write(provinces[list[i]].Name); writer.EndRow(); } } } } writer.Flush(); }
public override void Paint(System.Drawing.Graphics g, EU2.Map.ILightmapDimensions m, System.Drawing.Rectangle area) { if ( sources[srcindex] == null || shaderproxy == null ) return; Rectangle actualarea = m.CoordMap.BlocksToActual( area ); bool decomp = sources[srcindex].VolatileDecompression; sources[srcindex].VolatileDecompression = true; RawImage raw = sources[srcindex].DecodeImage( actualarea ); Bitmap canvas = new Bitmap( raw.Bounds.Width, raw.Bounds.Height, PixelFormat.Format32bppRgb ); BitmapData cdata = canvas.LockBits( new Rectangle( new Point( 0, 0 ), canvas.Size ), ImageLockMode.WriteOnly, canvas.PixelFormat ); int[] lightbuf = shaderproxy.Shade32( raw ); System.Runtime.InteropServices.Marshal.Copy( lightbuf, 0, cdata.Scan0, lightbuf.Length ); canvas.UnlockBits( cdata ); g.DrawImageUnscaled( canvas, 0, 0 ); sources[srcindex].VolatileDecompression = decomp; }
public AdjacencyTable( EU2.Install install ) : base(install) { OpenStream(); }
public CSVBasedItem( EU2.Install install ) : base(install) { }