Ejemplo n.º 1
0
        private void DrawGUI(DwarfTime gameTime, float dx)
        {
            GUI.PreRender(gameTime, DwarfGame.SpriteBatch);
            DwarfGame.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp,
                                        null, null);
            Drawer.Render(DwarfGame.SpriteBatch, null, Game.GraphicsDevice.Viewport);
            GUI.Render(gameTime, DwarfGame.SpriteBatch, new Vector2(0, dx));

            Progress.Message = !GenerationComplete ? LoadingMessage : "";

            if (GenerationComplete)
            {
                Rectangle imageBounds      = MapPanel.GetImageBounds();
                float     scaleX           = ((float)imageBounds.Width / (float)PlayState.WorldWidth);
                float     scaleY           = ((float)imageBounds.Height / (float)PlayState.WorldHeight);
                Rectangle spawnRect        = GetSpawnRectangle();
                Rectangle spawnRectOnImage = GetSpawnRectangleOnImage();
                Drawer2D.DrawRect(DwarfGame.SpriteBatch, spawnRectOnImage, Color.Yellow, 3.0f);
                Drawer2D.DrawStrokedText(DwarfGame.SpriteBatch, "Spawn", DefaultFont, new Vector2(spawnRectOnImage.X - 5, spawnRectOnImage.Y - 20), Color.White, Color.Black);

                //ImageMutex.WaitOne();

                /*
                 * DwarfGame.SpriteBatch.Draw(MapPanel.Image.Image,
                 *  new Rectangle(MapPanel.GetImageBounds().Right + 2, MapPanel.GetImageBounds().Top,  spawnRect.Width * 4, spawnRect.Height * 4),
                 * spawnRect, Color.White);
                 */
                //ImageMutex.ReleaseMutex();
                CloseupPanel.Image.Image      = MapPanel.Image.Image;
                CloseupPanel.Image.SourceRect = spawnRect;


                if (ViewSelectionBox.CurrentValue == "Factions")
                {
                    foreach (Faction civ in NativeCivilizations)
                    {
                        Point     start   = civ.Center;
                        Vector2   measure = Datastructures.SafeMeasure(GUI.SmallFont, civ.Name);
                        Rectangle snapped =
                            MathFunctions.SnapRect(
                                new Vector2(start.X * scaleX + imageBounds.X, start.Y * scaleY + imageBounds.Y) -
                                measure * 0.5f, measure, imageBounds);

                        Drawer2D.DrawStrokedText(DwarfGame.SpriteBatch, civ.Name, GUI.SmallFont, new Vector2(snapped.X, snapped.Y), Color.White, Color.Black);
                    }
                }
            }

            GUI.PostRender(gameTime);
            DwarfGame.SpriteBatch.End();
        }