예제 #1
0
        private void compileTile(FOMap m, Preset p, int tx, int ty)
        {
            Tile tile = tiles[tx, ty];

            if (!tile.Filled)
            {
                compileEmpty(m, p, tx, ty);
            }
            else if (tile.Wide)
            {
                compileWide(m, p, tx, ty);
            }
            else
            {
                bool compilen = false;
                for (int dir = Directions.North; dir <= Directions.West; dir++)
                {
                    if (tile.IsPath(dir) && tile.GetNeighbour(dir).Wide)
                    {
                        compileAdapter(m, p, tx, ty, dir);
                        compilen = true;
                        break;
                    }
                }
                if (!compilen)
                {
                    compileNormalCorridor(m, p, tx, ty);
                }
            }
        }
예제 #2
0
        private static bool precache(string name)
        {
            FOMapParser parser = new FOMapParser(Config.PresetsPath + @"\" + name);

            if (!parser.Parse())
            {
                return(false);
            }

            FOMap map = parser.Map;

            Preset p = new Preset();

            foreach (FOCommon.Maps.Tile tile in map.Tiles)
            {
                BigTile bt = p.GetBigTile(tile.X / (2 * (Config.BigTileEdgeSize + 1)),
                                          (tile.Y / (2 * (Config.BigTileEdgeSize + 1)) + 1), true);
                bt.AddTileClone(tile);
            }

            foreach (MapObject obj in map.Objects)
            {
                BigTile bt = p.GetBigTile(obj.MapX / (2 * (Config.BigTileEdgeSize + 1)),
                                          (obj.MapY / (2 * (Config.BigTileEdgeSize + 1)) + 1), true);
                bt.AddObjectClone(obj);
            }

            cache.Add(name, p);
            return(true);
        }
예제 #3
0
        private void placeBigTile(FOMap m, BigTile bt, int tx, int ty)
        {
            ushort my = (ushort)ty;
            ushort mx = (ushort)(Width - tx - 1);

            m.Objects.AddRange(bt.GetClonedObjects(mx, my));
            m.Tiles.AddRange(bt.GetClonedTiles(mx, my));
        }
예제 #4
0
        internal MapperMap(FOMap map)
        {
            this.Header = map.Header;
            this.Tiles = map.Tiles;
            this.Objects = map.Objects;

            this.InitHexMap();
        }
예제 #5
0
        internal MapperMap(FOMap map)
        {
            this.Header  = map.Header;
            this.Tiles   = map.Tiles;
            this.Objects = map.Objects;

            this.InitHexMap();
        }
예제 #6
0
        private void compileEmpty(FOMap m, Preset p, int tx, int ty)
        {
            Tile    tile = tiles[tx, ty];
            BigTile bt   = p.GetBigTile(0, tile.Variant);

            if (bt == null)
            {
                throw new CompilerException(
                          String.Format("there is no empty tile with variant {0} to place on ({1},{2})", tile.Variant, tx, ty));
            }
            placeBigTile(m, bt, tx, ty);
        }
예제 #7
0
 public ScrollblockersPlacer(Pair <int, int> from, Pair <int, int> to, Map map, FOMap fomap)
 {
     this.fomap = fomap;
     Angle      = 0;
     Dist       = 0;
     MaxHx      = (ushort)(2 * Config.BigTileEdgeSize * map.Width);
     MaxHy      = (ushort)(2 * Config.BigTileEdgeSize * map.Height);
     Hx         = (ushort)((map.Width - from.First - 1) * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Hy         = (ushort)(from.Second * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Tx         = (ushort)((map.Width - to.First - 1) * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Ty         = (ushort)(to.Second * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
 }
예제 #8
0
        public bool Parse(bool onlyHeader)
        {
            if (!File.Exists(FileName))
            {
                Utils.Log(FileName + " doesn't exist. Can't parse data.");
                return(false);
            }

            Map = new FOMap();

            StreamReader r = File.OpenText(FileName);

            mode = ParseMode.Nothing;
            while (!r.EndOfStream && mode != ParseMode.Finished)
            {
                if (mode == ParseMode.Tiles && onlyHeader)
                {
                    break;
                }

                if (mode == ParseMode.Objects)
                {
                    parseObjects(r);
                    break;
                }

                string line = r.ReadLine();
                if (String.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (updateModeLine(line))
                {
                    continue;
                }

                switch (mode)
                {
                case ParseMode.Header:  parseHeaderLine(line); break;

                case ParseMode.Tiles:   parseTileLine(line); break;

                default: break;
                }
            }

            r.Close();
            _IsParsed = true;
            return(true);
        }
예제 #9
0
        /// <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.");
        }
예제 #10
0
 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);
 }
예제 #11
0
        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);
        }
예제 #12
0
        public bool Parse(bool onlyHeader)
        {
            if (!File.Exists(FileName))
            {
                Utils.Log(FileName + " doesn't exist. Can't parse data.");
                return false;
            }

            Map = new FOMap();

            StreamReader r = File.OpenText(FileName);

            mode = ParseMode.Nothing;
            while (!r.EndOfStream && mode != ParseMode.Finished)
            {
                if (mode == ParseMode.Tiles && onlyHeader)
                    break;

                if (mode == ParseMode.Objects)
                {
                    parseObjects(r);
                    break;
                }

                string line = r.ReadLine();
                if (String.IsNullOrEmpty(line))
                    continue;
                if (updateModeLine(line)) continue;

                switch (mode)
                {
                    case ParseMode.Header:  parseHeaderLine(line); break;
                    case ParseMode.Tiles:   parseTileLine(line); break;
                    default: break;
                }
            }

            r.Close();
            _IsParsed = true;
            return true;
        }
예제 #13
0
        /// <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.");
        }
예제 #14
0
        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);
        }
예제 #15
0
 public ScrollblockersPlacer(Pair<int, int> from, Pair<int, int> to, Map map, FOMap fomap)
 {
     this.fomap = fomap;
     Angle = 0;
     Dist = 0;
     MaxHx = (ushort)(2 * Config.BigTileEdgeSize * map.Width);
     MaxHy = (ushort)(2 * Config.BigTileEdgeSize * map.Height);
     Hx = (ushort)((map.Width - from.First - 1) * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Hy = (ushort)(from.Second * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Tx = (ushort)((map.Width - to.First - 1) * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
     Ty = (ushort)(to.Second * (2 * Config.BigTileEdgeSize) + Config.BigTileEdgeSize);
 }
예제 #16
0
        public static void OnGraphics(Graphics gdi, FOMap map, FOHexMap hexMap, Dictionary <int, ItemProto> itemsPid, CritterData critterData,
                                      Dictionary <string, FalloutFRM> frms, EditorData editorData, SizeF scale, RectangleF screenArea, MouseSelection mouseSelection)
        {
            Flags flags        = editorData.drawFlags;
            Flags selectFlags  = editorData.selectFlags;
            Flags overlayFlags = editorData.overlayFlags;

            if (!cachedCalls)
            {
                CachedSceneryDraws  = new List <DrawCall>();
                CachedTileDraws     = new List <DrawCall>();
                CachedRoofTileDraws = new List <DrawCall>();
                CachedDrawsLists    = new List <List <DrawCall> >();
                CachedOverlayDraws  = new List <OverlayCall>();
                CachedDrawsLists.Add(CachedTileDraws);
                CachedDrawsLists.Add(CachedSceneryDraws);
                CachedDrawsLists.Add(CachedRoofTileDraws);

                currentClick    = null;
                SelectedObjects = new List <MapObject>();
                SelectedTiles   = new List <Tile>();
                Errors          = new List <string>();

                if (DrawFlag(flags, Flags.Tiles) || DrawFlag(flags, Flags.Roofs))
                {
                    foreach (var tile in map.Tiles)
                    {
                        bool selectable = false;

                        if (!tile.Roof && !DrawFlag(flags, Flags.Tiles))
                        {
                            continue;
                        }
                        if (!tile.Roof && DrawFlag(selectFlags, Flags.Tiles))
                        {
                            selectable = true;
                        }
                        if (tile.Roof && !DrawFlag(flags, Flags.Roofs))
                        {
                            continue;
                        }
                        if (tile.Roof && DrawFlag(selectFlags, Flags.Roofs))
                        {
                            selectable = true;
                        }


                        List <DrawCall> list = null;
                        if (tile.Roof)
                        {
                            list = CachedRoofTileDraws;
                        }
                        else
                        {
                            list = CachedTileDraws;
                        }

                        if (!frms.ContainsKey(tile.Path))
                        {
                            Errors.Add("Tile graphics " + tile.Path + " not loaded.");
                            return;
                        }
                        var    tileCoords = hexMap.GetTileCoords(new Point(tile.X, tile.Y), tile.Roof);
                        Bitmap drawBitmap = frms[tile.Path].Frames[0];
                        if (AddToCache(drawBitmap, tile.Path, list, tileCoords, selectable, mouseSelection, screenArea, tile.colorOverlay))
                        {
                            SelectedTiles.Add(tile);
                        }
                    }
                }

                foreach (var obj in map.Objects.OrderBy(x => x.MapX + x.MapY * 2))
                {
                    bool selectable = false;
                    // skip specific object types
                    if (obj.MapObjType == MapObjectType.Critter && !DrawFlag(flags, Flags.Critters))
                    {
                        continue;
                    }
                    else if (obj.MapObjType == MapObjectType.Item && !DrawFlag(flags, Flags.Items))
                    {
                        continue;
                    }
                    else if (obj.MapObjType == MapObjectType.Scenery && !DrawFlag(flags, Flags.Scenery))
                    {
                        continue;
                    }

                    if (obj.MapObjType == MapObjectType.Critter && DrawFlag(selectFlags, Flags.Critters))
                    {
                        selectable = true;
                    }
                    else if (obj.MapObjType == MapObjectType.Item && DrawFlag(selectFlags, Flags.Items))
                    {
                        selectable = true;
                    }
                    else if (obj.MapObjType == MapObjectType.Scenery && DrawFlag(selectFlags, Flags.Scenery))
                    {
                        selectable = true;
                    }

                    Bitmap drawBitmap;
                    PointF coords;
                    string path;

                    if (obj.MapObjType == MapObjectType.Critter)
                    {
                        string dirS;
                        int    dir = 0;
                        obj.Properties.TryGetValue("Dir", out dirS);
                        int.TryParse(dirS, out dir);

                        string crType = "";
                        critterData.GetCritterType(obj.ProtoId, out crType);

                        FalloutFRM frm;
                        string     cr = "art\\critters\\" + crType + "aa.frm";
                        path = cr;
                        if (!frms.TryGetValue(cr, out frm))
                        {
                            Errors.Add("Critter graphics " + cr + " not loaded.");
                            continue;
                        }
                        if (frm == null)
                        {
                            continue;
                        }

                        coords     = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size, new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(0, 0));
                        drawBitmap = frm.GetAnimFrameByDir(dir, 1);

                        if (DrawFlag(overlayFlags, Flags.Critters))
                        {
                            string text         = editorData.overlayCritterFormat;
                            string preprocessed = PreprocessOverlay(text, obj, new Func <string, string>((string mStr) => {
                                string data = "";
                                if (obj.Properties.ContainsKey(mStr))
                                {
                                    data = obj.Properties[mStr];
                                }
                                if (obj.CritterParams.ContainsKey(mStr))
                                {
                                    data = obj.CritterParams[mStr].ToString();
                                }
                                return(data);
                            }));
                            int lines = text.Count(f => f == '\n');
                            CachedOverlayDraws.Add(new OverlayCall(preprocessed, coords.X, coords.Y - (40 + (15 * (lines - 1)))));
                        }
                    }
                    // Scenery or Item
                    else
                    {
                        ItemProto prot;
                        if (!itemsPid.TryGetValue(obj.ProtoId, out prot))
                        {
                            continue;
                        }
                        if (prot.Type == (int)ItemTypes.ITEM_WALL && !DrawFlag(flags, Flags.SceneryWalls))
                        {
                            continue;
                        }
                        if (!frms.ContainsKey(prot.PicMap))
                        {
                            Errors.Add("Scenery graphics " + prot.PicMap + " not loaded.");
                            continue;
                        }
                        var frm = frms[prot.PicMap];
                        path   = prot.PicMap;
                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size,
                                                        new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(prot.OffsetX, prot.OffsetY));
                        drawBitmap = frm.Frames[0];
                    }

                    if (AddToCache(drawBitmap, path, CachedSceneryDraws, coords, selectable, mouseSelection, screenArea, obj.colorOverlay))
                    {
                        SelectedObjects.Add(obj);
                    }
                }
            }

            // Rendering
            if (currentClick != null)
            {
                ClickToCache(currentClick, false);
            }

            if (scale.Width != 1.0f && gdi != null)
            {
                gdi.ScaleTransform(scale.Width, scale.Height);
            }

            cachedCalls = true;

            if (gdi != null)
            {
                foreach (var call in CachedTileDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }
                foreach (var call in CachedSceneryDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }
                foreach (var call in CachedRoofTileDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }

                foreach (var call in CachedOverlayDraws)
                {
                    DrawOutlinedText(gdi, call.Text, overlayFont, Brushes.GreenYellow, Brushes.Black, new PointF(call.X, call.Y));
                }
            }
        }
예제 #17
0
        public static void OnGraphics( Graphics gdi, FOMap map, FOHexMap hexMap, Dictionary<int, ItemProto> itemsPid, CritterData critterData,
            Dictionary<string, FalloutFRM> frms, EditorData editorData, SizeF scale, RectangleF screenArea, MouseSelection mouseSelection)
        {
            Flags flags = editorData.drawFlags;
            Flags selectFlags = editorData.selectFlags;
            Flags overlayFlags = editorData.overlayFlags;

            if (!cachedCalls)
            {
                CachedSceneryDraws  = new List<DrawCall>();
                CachedTileDraws     = new List<DrawCall>();
                CachedRoofTileDraws = new List<DrawCall>();
                CachedDrawsLists    = new List<List<DrawCall>>();
                CachedOverlayDraws  = new List<OverlayCall>();
                CachedDrawsLists.Add(CachedTileDraws);
                CachedDrawsLists.Add(CachedSceneryDraws);
                CachedDrawsLists.Add(CachedRoofTileDraws);

                currentClick = null;
                SelectedObjects = new List<MapObject>();
                SelectedTiles = new List<Tile>();
                Errors = new List<string>();

                if (DrawFlag(flags, Flags.Tiles) || DrawFlag(flags, Flags.Roofs))
                {
                    foreach (var tile in map.Tiles)
                    {
                        bool selectable = false;

                        if (!tile.Roof && !DrawFlag(flags, Flags.Tiles))
                            continue;
                        if (!tile.Roof && DrawFlag(selectFlags, Flags.Tiles))
                            selectable = true;
                        if (tile.Roof && !DrawFlag(flags, Flags.Roofs))
                            continue;
                        if(tile.Roof && DrawFlag(selectFlags, Flags.Roofs))
                            selectable = true;

                        List<DrawCall> list = null;
                        if (tile.Roof) list = CachedRoofTileDraws;
                        else list = CachedTileDraws;

                        if (!frms.ContainsKey(tile.Path))
                        {
                            Errors.Add("Tile graphics " + tile.Path + " not loaded.");
                            return;
                        }
                        var tileCoords = hexMap.GetTileCoords(new Point(tile.X, tile.Y), tile.Roof);
                        Bitmap drawBitmap = frms[tile.Path].Frames[0];
                        if (AddToCache(drawBitmap, tile.Path, list, tileCoords, selectable, mouseSelection, screenArea, tile.colorOverlay))
                            SelectedTiles.Add(tile);
                    }
                }

                foreach (var obj in map.Objects.OrderBy(x => x.MapX + x.MapY * 2))
                {
                    bool selectable = false;
                    // skip specific object types
                    if (obj.MapObjType == MapObjectType.Critter && !DrawFlag(flags, Flags.Critters))
                        continue;
                    else if (obj.MapObjType == MapObjectType.Item && !DrawFlag(flags, Flags.Items))
                        continue;
                    else if (obj.MapObjType == MapObjectType.Scenery && !DrawFlag(flags, Flags.Scenery))
                        continue;

                    if (obj.MapObjType == MapObjectType.Critter && DrawFlag(selectFlags, Flags.Critters))
                        selectable = true;
                    else if (obj.MapObjType == MapObjectType.Item && DrawFlag(selectFlags, Flags.Items))
                        selectable = true;
                    else if (obj.MapObjType == MapObjectType.Scenery && DrawFlag(selectFlags, Flags.Scenery))
                        selectable = true;

                    Bitmap drawBitmap;
                    PointF coords;
                    string path;

                    if (obj.MapObjType == MapObjectType.Critter)
                    {
                        string dirS;
                        int dir = 0;
                        obj.Properties.TryGetValue("Dir", out dirS);
                        int.TryParse(dirS, out dir);

                        string crType = "";
                        critterData.GetCritterType(obj.ProtoId, out crType);

                        FalloutFRM frm;
                        string cr = "art\\critters\\" + crType + "aa.frm";
                        path = cr;
                        if (!frms.TryGetValue(cr, out frm))
                        {
                            Errors.Add("Critter graphics " + cr + " not loaded.");
                            continue;
                        }
                        if (frm == null)
                            continue;

                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size, new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(0, 0));
                        drawBitmap = frm.GetAnimFrameByDir(dir, 1);

                        if (DrawFlag(overlayFlags, Flags.Critters))
                        {
                            string text = editorData.overlayCritterFormat;
                            string preprocessed = PreprocessOverlay(text, obj, new Func<string, string>((string mStr) => {
                                string data = "";
                                if (obj.Properties.ContainsKey(mStr)) data = obj.Properties[mStr];
                                if (obj.CritterParams.ContainsKey(mStr)) data = obj.CritterParams[mStr].ToString();
                                return data;
                            }));
                            int lines = text.Count(f => f == '\n');
                            CachedOverlayDraws.Add(new OverlayCall(preprocessed, coords.X, coords.Y - (40 + (15 * (lines - 1)))));
                        }
                    }
                    // Scenery or Item
                    else
                    {
                        ItemProto prot;
                        if (!itemsPid.TryGetValue(obj.ProtoId, out prot))
                            continue;
                        if (prot.Type == (int)ItemTypes.ITEM_WALL && !DrawFlag(flags, Flags.SceneryWalls))
                            continue;
                        if (!frms.ContainsKey(prot.PicMap))
                        {
                            Errors.Add("Scenery graphics " + prot.PicMap + " not loaded.");
                            continue;
                        }
                        var frm = frms[prot.PicMap];
                        path = prot.PicMap;
                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size,
                            new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(prot.OffsetX, prot.OffsetY));
                        drawBitmap = frm.Frames[0];
                    }

                    if (AddToCache(drawBitmap, path, CachedSceneryDraws, coords, selectable, mouseSelection, screenArea, obj.colorOverlay))
                        SelectedObjects.Add(obj);
                }
            }

            // Rendering
            if (currentClick != null)
                ClickToCache(currentClick, false);

            if (scale.Width != 1.0f && gdi != null)
                gdi.ScaleTransform(scale.Width, scale.Height);

            cachedCalls = true;

            if (gdi != null)
            {
                foreach (var call in CachedTileDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                foreach (var call in CachedSceneryDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                foreach (var call in CachedRoofTileDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);

                foreach (var call in CachedOverlayDraws)
                {
                    DrawOutlinedText(gdi, call.Text, overlayFont, Brushes.GreenYellow, Brushes.Black, new PointF(call.X, call.Y));
                }
            }
        }
예제 #18
0
        private void compileTile(FOMap m, Preset p, int tx, int ty)
        {
            Tile tile = tiles[tx, ty];

            if (!tile.Filled) compileEmpty(m, p, tx, ty);
            else if (tile.Wide) compileWide(m, p, tx, ty);
            else
            {
                bool compilen = false;
                for (int dir = Directions.North; dir <= Directions.West; dir++)
                {
                    if (tile.IsPath(dir) && tile.GetNeighbour(dir).Wide)
                    {
                        compileAdapter(m, p, tx, ty, dir);
                        compilen = true;
                        break;
                    }
                }
                if (!compilen) compileNormalCorridor(m, p, tx, ty);
            }
        }
예제 #19
0
 private void compileEmpty(FOMap m, Preset p, int tx, int ty)
 {
     Tile tile = tiles[tx, ty];
     BigTile bt = p.GetBigTile(0, tile.Variant);
     if(bt == null) throw new CompilerException(
            String.Format("there is no empty tile with variant {0} to place on ({1},{2})", tile.Variant, tx, ty));
     placeBigTile(m, bt, tx, ty);
 }
예제 #20
0
 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);
 }
예제 #21
0
 private void placeBigTile(FOMap m, BigTile bt, int tx, int ty)
 {
     ushort my = (ushort)ty;
     ushort mx = (ushort)(Width - tx - 1);
     m.Objects.AddRange(bt.GetClonedObjects(mx, my));
     m.Tiles.AddRange(bt.GetClonedTiles(mx, my));
 }