static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FOCommon.Utils.InitLog("TiledMapper.log", true); Config.Init(); PresetsManager.Init(); FOCommon.Utils.Log("Tiled Mapper " + Config.AppVersion + " started."); Application.Run(new MainForm(args)); }
/// <summary> /// Compile the map instance. /// </summary> /// <param name="fileName">Output file name</param> /// <param name="header">Map header to be included</param> public void Compile(string fileName, MapHeader header) { FOCommon.Utils.Log("Compiling " + fileName + " using preset '" + Config.CurrentPreset + "'."); Preset p = PresetsManager.GetPreset(Config.CurrentPreset); if (p == null) { FOCommon.Utils.Log("Error: preset '" + Config.CurrentPreset + "' not found."); throw new CompilerException("internal: preset '" + Config.CurrentPreset + "' not found"); } FOMap m = new FOMap(); m.Header = header; header.MaxHexX = (ushort)(2 * Config.BigTileEdgeSize * Width); header.MaxHexY = (ushort)(2 * Config.BigTileEdgeSize * Height); header.Version = 4; header.WorkHexX = (ushort)(header.MaxHexX / 2); header.WorkHexY = (ushort)(header.MaxHexY / 2); // tiles for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { compileTile(m, p, x, y); } } // scrollblockers if (scrollBlockers.Count > 3) { for (int i = 2; i < scrollBlockers.Count; i++) { Pair <int, int> from = scrollBlockers[i - 1]; Pair <int, int> to = scrollBlockers[i]; LineTracer.TraceHex(new ScrollblockersPlacer(from, to, this, m)); } LineTracer.TraceHex(new ScrollblockersPlacer(scrollBlockers[scrollBlockers.Count - 1], scrollBlockers[1], this, m)); } FOMapParser parser = new FOMapParser(fileName); parser.Map = m; parser.Save(); FOCommon.Utils.Log("Compilation successful."); }
private void compileWide(FOMap m, Preset p, int tx, int ty) { Tile tile = tiles[tx, ty]; int hash = GetTileHash(tile); int num = PresetsManager.GetWideNum(hash); if (num == -1) { throw new CompilerException( String.Format("there is no tile for hash W{0,8} to place on ({1},{2})", Utils.HashCode(hash), tx, ty)); } BigTile bt = p.GetBigTile(num, tile.Variant); if (bt == null) { throw new CompilerException( String.Format("there is no tile W{0,8}/{1} to place on ({2},{3})", Utils.HashCode(hash), tile.Variant, tx, ty)); } placeBigTile(m, bt, tx, ty); }
private void compileAdapter(FOMap m, Preset p, int tx, int ty, int dir) { Tile tile = tiles[tx, ty]; int num = PresetsManager.GetAdapterNum(dir); if (num == -1) { throw new CompilerException( String.Format("there is no tile for adapter {0} to place on ({2},{3})", Directions.ToChar(dir), tx, ty)); } BigTile bt = p.GetBigTile(num, tile.Variant); if (bt == null) { throw new CompilerException( String.Format("there is no adapter tile {0}/{1} to place on ({2},{3})", Directions.ToChar(dir), tile.Variant, tx, ty)); } placeBigTile(m, bt, tx, ty); }