public void DrawPreview()
        {
            if (PreviewRenderTarget == null)
            {
                return;
            }
            if (Generator.CurrentState != WorldGenerator.GenerationState.Finished)
            {
                return;
            }

            Root.DrawQuad(PreviewPanel.Rect, PreviewRenderTarget);

            GetSpawnRectangleInScreenSpace(SpawnRectanglePoints);

            try
            {
                DwarfGame.SafeSpriteBatchBegin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, Drawer2D.PointMagLinearMin,
                                               null, null, null, Matrix.Identity);
                Drawer2D.DrawPolygon(DwarfGame.SpriteBatch, Color.Yellow, 1, SpawnRectanglePoints);
                //Drawer2D.DrawStrokedText(DwarfGame.SpriteBatch, "Spawn", DefaultFont, new Vector2(a.X - 5, a.Y - 20),
                //    Color.White, Color.Black);
            }
            finally
            {
                DwarfGame.SpriteBatch.End();
            }


            var font = Root.GetTileSheet("font10");
            var icon = Root.GetTileSheet("map-icons");
            var bkg  = Root.GetTileSheet("basic");
            var rect = PreviewPanel.GetDrawableInterior();

            foreach (var tree in Trees)
            {
                var treeLocation = WorldToScreen(new Vector2(tree.X, tree.Y));
                if (treeLocation.Z > 0.9999f)
                {
                    continue;
                }
                float     scale      = GetIconScale(new Point(tree.X, tree.Y));
                Rectangle nameBounds = new Rectangle(0, 0, (int)(16 * scale), (int)(16 * scale));
                nameBounds.X = (int)treeLocation.X - (nameBounds.Width / 2);
                nameBounds.Y = (int)treeLocation.Y - (nameBounds.Height / 2);
                if (!rect.Contains(nameBounds))
                {
                    continue;
                }
                var mesh = Gui.Mesh.FittedSprite(new Rectangle(nameBounds.Center.X - (int)(8 * scale),
                                                               nameBounds.Center.Y - (int)(8 * scale), (int)(16 * scale), (int)(16 * scale)),
                                                 icon, tree.Z);
                Root.DrawMesh(mesh, Root.RenderData.Texture);
            }

            foreach (var civ in Generator.NativeCivilizations)
            {
                var civLocation = WorldToScreen(new Vector2(civ.Center.X, civ.Center.Y));
                if (civLocation.Z > 0.9999f)
                {
                    continue;
                }
                Rectangle nameBounds;
                var       mesh = Gui.Mesh.CreateStringMesh(civ.Name, font, Vector2.One, out nameBounds);
                nameBounds.X = (int)civLocation.X - (nameBounds.Width / 2);
                nameBounds.Y = (int)civLocation.Y - (nameBounds.Height / 2);
                nameBounds   = MathFunctions.SnapRect(nameBounds, rect);
                mesh.Translate(nameBounds.X, nameBounds.Y);
                if (!rect.Contains(nameBounds))
                {
                    continue;
                }
                if (PreviewSelector.SelectedItem == "Factions") // Draw dots for capitals.
                {
                    var bkgmesh = Gui.Mesh.FittedSprite(nameBounds, bkg, 0)
                                  .Colorize(new Vector4(0.0f, 0.0f, 0.0f, 0.7f));

                    Root.DrawMesh(bkgmesh, Root.RenderData.Texture);
                    Root.DrawMesh(mesh, Root.RenderData.Texture);
                }
                float scale    = GetIconScale(civ.Center);
                var   iconRect = new Rectangle((int)(nameBounds.Center.X - 8 * scale),
                                               (int)(nameBounds.Center.Y + 8 * scale), (int)(16 * scale), (int)(16 * scale));
                if (!rect.Contains(iconRect))
                {
                    continue;
                }
                var iconMesh = Gui.Mesh.FittedSprite(iconRect,
                                                     icon, civ.Race.Icon);
                Root.DrawMesh(iconMesh, Root.RenderData.Texture);
            }

            Rectangle spawnWorld  = Generator.GetSpawnRectangle();
            Vector2   newSpawn    = new Vector2(spawnWorld.Center.X, spawnWorld.Center.Y);
            Vector2   spawnCenter = newSpawn * 0.1f + lastSpawnWorld * 0.9f;
            Vector3   newCenter   = WorldToScreen(newSpawn);
            Vector3   worldCenter = WorldToScreen(spawnCenter);

            if (worldCenter.Z < 0.9999f)
            {
                float     scale       = GetIconScale(new Point((int)spawnCenter.X, (int)spawnCenter.Y));
                Rectangle balloon     = new Rectangle((int)(worldCenter.X - 8 * scale), (int)(worldCenter.Y + 5 * System.Math.Sin(DwarfTime.LastTime.TotalRealTime.TotalSeconds * 2.0f)) - (int)(8 * scale), (int)(16 * scale), (int)(16 * scale));
                var       balloonMesh = Gui.Mesh.FittedSprite(MathFunctions.SnapRect(balloon, PreviewPanel.Rect), icon, 2);
                Root.DrawMesh(balloonMesh, Root.RenderData.Texture);

                Rectangle nameBounds;
                var       mesh = Gui.Mesh.CreateStringMesh("Colony Location", font, Vector2.One, out nameBounds);
                nameBounds.X = (int)newCenter.X - (nameBounds.Width / 2);
                nameBounds.Y = (int)newCenter.Y - (nameBounds.Height / 2) + 16;
                nameBounds   = MathFunctions.SnapRect(nameBounds, PreviewPanel.Rect);
                mesh.Translate(nameBounds.X, nameBounds.Y);
                var bkgmesh = Gui.Mesh.FittedSprite(nameBounds, bkg, 0).Colorize(new Vector4(0.0f, 0.0f, 0.0f, 0.7f));

                Root.DrawMesh(bkgmesh, Root.RenderData.Texture);
                Root.DrawMesh(mesh, Root.RenderData.Texture);
            }

            lastSpawnWorld = spawnCenter;

            if (KeyMesh != null)
            {
                Root.DrawMesh(KeyMesh, Root.RenderData.Texture);
            }
        }