Example #1
0
        private void resourceLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            this.EditorData.GraphicsPaths.Add("art\\misc");
            this.EditorData.GraphicsPaths.Add("art\\items");
            this.EditorData.GraphicsPaths.Add("art\\tiles");
            this.EditorData.GraphicsPaths.Add("art\\misc");
            this.EditorData.GraphicsPaths.Add("art\\walls");
            this.EditorData.GraphicsPaths.Add("art\\door");
            this.EditorData.GraphicsPaths.Add("art\\scenery");

            Stream stream;
            BinaryFormatter formatter = new BinaryFormatter();

            stream = null;

            this.BeginInvoke((MethodInvoker)delegate
            {
                frmLoading = new frmLoading();
                frmLoading.ShowDialog();

                int count = mapperSettings.Paths.DataFiles.Count;

                if (!File.Exists("./critters.dat")) count++;
                if (!File.Exists("./items.dat")) count++;

                frmLoading.SetFilesNum(count);
            });

            if (File.Exists("./critters.dat"))
            {
                stream = File.OpenRead("./critters.dat");
                critterData = (CritterData)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                List<string> crFiles = new List<string>(Directory.GetFiles(mapperSettings.Paths.CritterProtos));

                this.BeginInvoke((MethodInvoker)delegate
                {
                    frmLoading.SetNextFile(mapperSettings.Paths.CritterProtos);
                    frmLoading.SetResourceNum(crFiles.Count);
                });

                foreach (string file in crFiles)
                {
                    this.BeginInvoke((MethodInvoker)delegate
                    {
                        frmLoading.SetNextResource(file);
                    });

                    int pid = 0;
                    int crType = 0;
                    bool parse = false;
                    foreach (var line in File.ReadAllLines(file))
                    {
                        if (line == "[Critter proto]")
                            if (parse)
                                critterData.crProtos[pid] = crType;
                        parse = true;
                        if (!parse) continue;
                        if (line.StartsWith("Pid="))
                            pid = int.Parse(line.Split('=')[1]);
                        if (line.StartsWith("ST_BASE_CRTYPE="))
                            crType = int.Parse(line.Split('=')[1]);
                    }
                }

                char[] delim = { '\t', ' ' };
                foreach (var line in File.ReadAllLines(mapperSettings.Paths.CritterTypes))
                {
                    if (!line.StartsWith("@")) continue;
                    var toks = line.Split(delim, StringSplitOptions.RemoveEmptyEntries);
                    critterData.crTypeGraphic[int.Parse(toks[1])] = toks[2];
                }
                if (mapperSettings.Performance.CacheResources)
                {
                    stream = File.Create("./critters.dat");
                    formatter.Serialize(stream, critterData);
                }
            }

            if (File.Exists("./items.dat"))
            {
                stream = File.OpenRead("./items.dat");
                items = (List<ItemProto>)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                MSGParser FOObj = new MSGParser(mapperSettings.Paths.FOOBJ);
                FOObj.Parse();

                string itemslst = mapperSettings.Paths.ItemProtos + "\\items.lst";

                if (!File.Exists(itemslst))
                {
                    MessageBox.Show("No " + itemslst + " , unable to load item protos.", "No items.lst", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    List<string> protFiles = new List<string>(File.ReadAllLines(itemslst));

                    this.BeginInvoke((MethodInvoker)delegate
                    {
                        frmLoading.SetNextFile(itemslst);
                        frmLoading.SetResourceNum(protFiles.Count);
                    });

                    foreach (string file in protFiles)
                    {
                        this.BeginInvoke((MethodInvoker)delegate { frmLoading.SetNextResource(file); });
                        protoParser.LoadProtosFromFile(mapperSettings.Paths.ItemProtos + file, "1.0", FOObj, items, null);
                    }
                }
                if (mapperSettings.Performance.CacheResources)
                {
                    stream = File.Create("./items.dat");
                    formatter.Serialize(stream, items);
                }
            }

            foreach (var item in items)
                EditorData.itemsPid[item.ProtoId] = item;

            if (File.Exists("./graphics.dat"))
            {
                stream = File.OpenRead("./graphics.dat");
                Frms = (Dictionary<String, FalloutFRM>)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                if (mapperSettings.Paths.DataFiles == null || mapperSettings.Paths.DataFiles.Count == 0)
                {
                    MessageBox.Show("No datafiles specified, unable to load graphics!");
                    frmPaths.ShowDialog();
                }

                if (mapperSettings.Paths.DataFiles != null || mapperSettings.Paths.DataFiles.Count != 0)
                {

                    List<string> crFiles = new List<string>();
                    foreach (var crType in critterData.crTypeGraphic.Values)
                    {
                        crFiles.Add("art\\critters\\" + crType.ToUpper() + "AA.FRM"); // Idle anim
                        crFiles.Add("art\\critters\\" + crType.ToLower() + "aa.frm");
                    }

                    foreach (string dataFile in mapperSettings.Paths.DataFiles)
                    {
                        string ext = Path.GetExtension(dataFile).ToLower();
                        if (ext != ".dat" && ext != ".zip")
                        {
                            MessageBox.Show("Unknown datafile extension : " + dataFile);
                            continue;
                        }
                        if (ext == ".dat")
                            LoadDat(dataFile, crFiles, transparency);
                        else
                            LoadZip(dataFile, crFiles, transparency);
                    }

                    if (mapperSettings.Performance.CacheResources)
                    {
                        stream = File.Create("./graphics.dat");
                        formatter.Serialize(stream, Frms);
                    }
                }
            }

            showLoadMaps();

            if (stream != null) stream.Close();
        }
Example #2
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));
                }
            }
        }
Example #3
0
        private void resourceLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            this.EditorData.GraphicsPaths.Add("art\\misc");
            this.EditorData.GraphicsPaths.Add("art\\items");
            this.EditorData.GraphicsPaths.Add("art\\tiles");
            this.EditorData.GraphicsPaths.Add("art\\misc");
            this.EditorData.GraphicsPaths.Add("art\\walls");
            this.EditorData.GraphicsPaths.Add("art\\door");
            this.EditorData.GraphicsPaths.Add("art\\scenery");

            Stream          stream;
            BinaryFormatter formatter = new BinaryFormatter();

            stream = null;

            this.BeginInvoke((MethodInvoker) delegate
            {
                frmLoading = new frmLoading();
                frmLoading.ShowDialog();

                int count = mapperSettings.Paths.DataFiles.Count;

                if (!File.Exists("./critters.dat"))
                {
                    count++;
                }
                if (!File.Exists("./items.dat"))
                {
                    count++;
                }

                frmLoading.SetFilesNum(count);
            });


            if (File.Exists("./critters.dat"))
            {
                stream      = File.OpenRead("./critters.dat");
                critterData = (CritterData)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                List <string> crFiles = new List <string>(Directory.GetFiles(mapperSettings.Paths.CritterProtos));

                this.BeginInvoke((MethodInvoker) delegate
                {
                    frmLoading.SetNextFile(mapperSettings.Paths.CritterProtos);
                    frmLoading.SetResourceNum(crFiles.Count);
                });

                foreach (string file in crFiles)
                {
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        frmLoading.SetNextResource(file);
                    });

                    int  pid    = 0;
                    int  crType = 0;
                    bool parse  = false;
                    foreach (var line in File.ReadAllLines(file))
                    {
                        if (line == "[Critter proto]")
                        {
                            if (parse)
                            {
                                critterData.crProtos[pid] = crType;
                            }
                        }
                        parse = true;
                        if (!parse)
                        {
                            continue;
                        }
                        if (line.StartsWith("Pid="))
                        {
                            pid = int.Parse(line.Split('=')[1]);
                        }
                        if (line.StartsWith("ST_BASE_CRTYPE="))
                        {
                            crType = int.Parse(line.Split('=')[1]);
                        }
                    }
                }

                char[] delim = { '\t', ' ' };
                foreach (var line in File.ReadAllLines(mapperSettings.Paths.CritterTypes))
                {
                    if (!line.StartsWith("@"))
                    {
                        continue;
                    }
                    var toks = line.Split(delim, StringSplitOptions.RemoveEmptyEntries);
                    critterData.crTypeGraphic[int.Parse(toks[1])] = toks[2];
                }
                if (mapperSettings.Performance.CacheResources)
                {
                    stream = File.Create("./critters.dat");
                    formatter.Serialize(stream, critterData);
                }
            }

            if (File.Exists("./items.dat"))
            {
                stream = File.OpenRead("./items.dat");
                items  = (List <ItemProto>)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                MSGParser FOObj = new MSGParser(mapperSettings.Paths.FOOBJ);
                FOObj.Parse();

                string itemslst = mapperSettings.Paths.ItemProtos + "\\items.lst";

                if (!File.Exists(itemslst))
                {
                    MessageBox.Show("No " + itemslst + " , unable to load item protos.", "No items.lst", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    List <string> protFiles = new List <string>(File.ReadAllLines(itemslst));

                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        frmLoading.SetNextFile(itemslst);
                        frmLoading.SetResourceNum(protFiles.Count);
                    });

                    foreach (string file in protFiles)
                    {
                        this.BeginInvoke((MethodInvoker) delegate { frmLoading.SetNextResource(file); });
                        protoParser.LoadProtosFromFile(mapperSettings.Paths.ItemProtos + file, "1.0", FOObj, items, null);
                    }
                }
                if (mapperSettings.Performance.CacheResources)
                {
                    stream = File.Create("./items.dat");
                    formatter.Serialize(stream, items);
                }
            }

            foreach (var item in items)
            {
                EditorData.itemsPid[item.ProtoId] = item;
            }

            if (File.Exists("./graphics.dat"))
            {
                stream = File.OpenRead("./graphics.dat");
                Frms   = (Dictionary <String, FalloutFRM>)formatter.Deserialize(stream);
                stream.Close();
            }
            else
            {
                if (mapperSettings.Paths.DataFiles == null || mapperSettings.Paths.DataFiles.Count == 0)
                {
                    MessageBox.Show("No datafiles specified, unable to load graphics!");
                    frmPaths.ShowDialog();
                }

                if (mapperSettings.Paths.DataFiles != null || mapperSettings.Paths.DataFiles.Count != 0)
                {
                    List <string> crFiles = new List <string>();
                    foreach (var crType in critterData.crTypeGraphic.Values)
                    {
                        crFiles.Add("art\\critters\\" + crType.ToUpper() + "AA.FRM"); // Idle anim
                        crFiles.Add("art\\critters\\" + crType.ToLower() + "aa.frm");
                    }

                    foreach (string dataFile in mapperSettings.Paths.DataFiles)
                    {
                        string ext = Path.GetExtension(dataFile).ToLower();
                        if (ext != ".dat" && ext != ".zip")
                        {
                            MessageBox.Show("Unknown datafile extension : " + dataFile);
                            continue;
                        }
                        if (ext == ".dat")
                        {
                            LoadDat(dataFile, crFiles, transparency);
                        }
                        else
                        {
                            LoadZip(dataFile, crFiles, transparency);
                        }
                    }

                    if (mapperSettings.Performance.CacheResources)
                    {
                        stream = File.Create("./graphics.dat");
                        formatter.Serialize(stream, Frms);
                    }
                }
            }

            showLoadMaps();

            if (stream != null)
            {
                stream.Close();
            }
        }
Example #4
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));
                }
            }
        }