Ejemplo n.º 1
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            int x = DrawSurface.GlobalBounds.X;
            int y = DrawSurface.GlobalBounds.Y;
            int w = DrawSurface.GlobalBounds.Width;
            int h = DrawSurface.GlobalBounds.Height;

            for (int i = 0; i < Window; i++)
            {
                int     tick  = (w / (Window + 1)) * (i + 1);
                Vector2 start = new Vector2(x + tick, y + h);
                Vector2 end   = new Vector2(x + tick, y);
                Drawer2D.DrawLine(batch, start, end, TickColor, 1);
            }

            if (SelectedIndustry == "Average")
            {
                RenderAverage(time, batch);
            }
            else
            {
                RenderCompanies(time, batch);
            }

            float midStock = (MaxStock + MinStock) * 0.5f;

            Drawer2D.DrawAlignedText(batch, MinStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y + h - 30, 30, 30));
            Drawer2D.DrawAlignedText(batch, midStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y + (h / 2) - 30, 30, 30));
            Drawer2D.DrawAlignedText(batch, MaxStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y, 30, 30));
            base.Render(time, batch);
        }
Ejemplo n.º 2
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, GUI.Skin.TileHeight);
            Rectangle textRect  = new Rectangle(GlobalBounds.X + 5, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, GUI.Skin.TileHeight);

            GUI.Skin.RenderField(fieldRect, batch);
            string toShow = GetSubstringToShow();

            Carat = MathFunctions.Clamp(Carat, 0, toShow.Length);
            string first = toShow.Substring(0, Carat);
            string last  = toShow.Substring(Carat, toShow.Length - Carat);

            if (!HasKeyboardFocus)
            {
                Drawer2D.DrawAlignedText(batch, " " + toShow, GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
            }
            else
            {
                if (time.TotalGameTime.TotalMilliseconds % 1000 < 500)
                {
                    Drawer2D.DrawAlignedText(batch, " " + first + "|" + last, GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
                }
                else
                {
                    Drawer2D.DrawAlignedText(batch, " " + first + " " + last, GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
                }
            }

            base.Render(time, batch);
        }
Ejemplo n.º 3
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            string text = Text;

            if (WordWrap)
            {
                text = DwarfGUI.WrapLines(Text, LocalBounds, TextFont);
            }

            if (Truncate)
            {
                Vector2 measure  = Datastructures.SafeMeasure(TextFont, text);
                Vector2 wMeasure = Datastructures.SafeMeasure(TextFont, "W");
                if (measure.X > GlobalBounds.Width)
                {
                    int numLetters = GlobalBounds.Width / (int)wMeasure.X;
                    text = Text.Substring(0, Math.Min(numLetters, Text.Length)) + "...";
                }
            }

            if (StrokeColor.A > 0)
            {
                Drawer2D.DrawAlignedStrokedText(batch, text, TextFont, TextColor, StrokeColor, Alignment, GlobalBounds);
            }
            else
            {
                Drawer2D.DrawAlignedText(batch, text, TextFont, TextColor, Alignment, GlobalBounds);
            }
            base.Render(time, batch);
        }
Ejemplo n.º 4
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, GUI.Skin.TileHeight);
            Rectangle textRect  = new Rectangle(GlobalBounds.X + 5, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, GUI.Skin.TileHeight);

            GUI.Skin.RenderField(fieldRect, batch);

            string substring = GetSubstringToShow();

            if (!HasKeyboardFocus)
            {
                Drawer2D.DrawAlignedText(batch, substring, GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
            }
            else
            {
                if (time.TotalGameTime.TotalMilliseconds % 1000 < 500)
                {
                    Drawer2D.DrawAlignedText(batch, substring + "|", GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
                }
                else
                {
                    Drawer2D.DrawAlignedText(batch, substring, GUI.DefaultFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, textRect);
                }
            }

            base.Render(time, batch);
        }
Ejemplo n.º 5
0
        public override void Render(DwarfTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
        {
            Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width - 37, 32);

            GUI.Skin.RenderField(fieldRect, batch);
            Drawer2D.DrawAlignedText(batch, CurrentValue, GUI.DefaultFont, Color.Black, Drawer2D.Alignment.Center, fieldRect);
            GUI.Skin.RenderDownArrow(new Rectangle(GlobalBounds.X + GlobalBounds.Width - 32, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, 32, 32), batch);
            base.Render(time, batch);
        }
Ejemplo n.º 6
0
        public override void Render()
        {
            switch (Mode)
            {
            case IndicatorMode.Indicator2D:
                Drawer2D.DrawAlignedText(DwarfGame.SpriteBatch, Text, PlayState.GUI.DefaultFont, Tint, Drawer2D.Alignment.Center, new Rectangle((int)Position.X, (int)Position.Y, 32, 32));
                break;

            case IndicatorMode.Indicator3D:
                Drawer2D.DrawText(Text, Position, Tint, Color.Transparent);
                break;
            }
        }
Ejemplo n.º 7
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            DwarfGame.SpriteBatch.Begin();
            int      i    = 0;
            Viewport port = GameState.Game.GraphicsDevice.Viewport;

            foreach (CreatureAI creature in Player.SelectedMinions)
            {
                Drawer2D.DrawAlignedText(DwarfGame.SpriteBatch, creature.Stats.FullName, PlayState.GUI.SmallFont, Color.White, Drawer2D.Alignment.Right, new Rectangle(port.Width - 300, i * 24, 300, 24));
                i++;
            }

            DwarfGame.SpriteBatch.End();
        }
Ejemplo n.º 8
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            if (!IsVisible)
            {
                return;
            }

            if (DrawBounds)
            {
                GUI.Skin.RenderGroup(GlobalBounds, batch);
            }
            Drawer2D.DrawAlignedText(batch, Title, GUI.DefaultFont, Color.Black, Drawer2D.Alignment.Top | Drawer2D.Alignment.Left, GlobalBounds);
            base.Render(time, batch);
        }
Ejemplo n.º 9
0
        public override void Render(DwarfTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
        {
            if (Drawn)
            {
                if (!GUI.DrawAfter.Contains(this))
                {
                    GUI.DrawAfter.Add(this);
                    Drawn = false;
                }
            }
            else
            {
                GUI.Skin.RenderButton(GlobalBounds, batch);


                int x = 0;
                foreach (List <string> column in Columns)
                {
                    if (column.Count == 0)
                    {
                        continue;
                    }

                    float columnMeasure = MeasureColumn(column).Y;
                    PixelsPerValue = (int)columnMeasure / column.Count;
                    int h = 0;

                    foreach (string s in column)
                    {
                        Vector2 measure = Datastructures.SafeMeasure(GUI.DefaultFont, s);

                        Color c = Color.Black;

                        if (s == CurrentValue)
                        {
                            c = Color.DarkRed;
                        }

                        Drawer2D.DrawAlignedText(batch, s, GUI.DefaultFont, c, Drawer2D.Alignment.Left, new Rectangle(GlobalBounds.X + 10 + x, GlobalBounds.Y + h + 5, GlobalBounds.Width, (int)measure.Y + 5));

                        h += PixelsPerValue;
                    }

                    x += ColumnWidth;
                }
                Drawn = true;
                base.Render(time, batch);
            }
        }
Ejemplo n.º 10
0
        public override void Render(DwarfTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
        {
            Rectangle clipBounds = batch.GraphicsDevice.ScissorRectangle;

            Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width - 37, 32);

            GUI.Skin.RenderField(fieldRect, batch);

            batch.GraphicsDevice.ScissorRectangle = MathFunctions.Clamp(fieldRect, batch.GraphicsDevice.Viewport.Bounds);

            Drawer2D.DrawAlignedText(batch, CurrentValue, Font, Color.Black, Drawer2D.Alignment.Center, fieldRect);

            batch.GraphicsDevice.ScissorRectangle = clipBounds;
            GUI.Skin.RenderDownArrow(new Rectangle(GlobalBounds.X + GlobalBounds.Width - 32, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, 32, 32), batch);
            base.Render(time, batch);
        }
Ejemplo n.º 11
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            AutoSize();
            Drawer2D.FillRect(batch, GlobalBounds, BackgroundColor);
            Drawer2D.DrawRect(batch, GlobalBounds, BorderColor, 2);


            int currHeight = 8;

            foreach (var entry in ColorEntries)
            {
                Vector2 measure = Font.MeasureString(entry.Key);
                Drawer2D.DrawAlignedText(batch, entry.Key, Font, TextColor, Drawer2D.Alignment.Right, new Rectangle(GlobalBounds.X + 18, GlobalBounds.Y + currHeight, LocalBounds.Width - 20, (int)measure.Y));
                Drawer2D.FillRect(batch, new Rectangle(GlobalBounds.X + 2, GlobalBounds.Y + currHeight - 5, 10, 10), entry.Value);
                Drawer2D.DrawRect(batch, new Rectangle(GlobalBounds.X + 2, GlobalBounds.Y + currHeight - 5, 10, 10), BorderColor, 1);
                currHeight += (int)(measure.Y + 5);
            }


            base.Render(time, batch);
        }
Ejemplo n.º 12
0
        public void RenderTip(GraphicsDevice device, SpriteBatch batch, string tip, Point mouse, TipType tipType)
        {
            Rectangle viewBounds = device.Viewport.Bounds;

            Vector2 stringMeasure = Datastructures.SafeMeasure(GUI.SmallFont, tip);

            Rectangle bounds;

            if (tipType == TipType.BottomRight)
            {
                bounds = new Rectangle(mouse.X + 24, mouse.Y + 24, (int)(stringMeasure.X + 15), (int)(stringMeasure.Y + 15));
            }
            else
            {
                bounds = new Rectangle(mouse.X - (int)stringMeasure.X - 15, mouse.Y - (int)stringMeasure.Y - 15, (int)(stringMeasure.X + 15), (int)(stringMeasure.Y + 15));
            }

            if (bounds.Left < viewBounds.Left)
            {
                bounds.X = viewBounds.X;
            }

            if (bounds.Right > viewBounds.Right)
            {
                bounds.X = viewBounds.Right - bounds.Width;
            }

            if (bounds.Top < viewBounds.Top)
            {
                bounds.Y = viewBounds.Y;
            }

            if (bounds.Bottom > viewBounds.Bottom)
            {
                bounds.Y = viewBounds.Bottom - bounds.Height;
            }

            GUI.Skin.RenderToolTip(bounds, batch, Color.White);
            Drawer2D.DrawAlignedText(batch, tip, GUI.SmallFont, Color.White, Drawer2D.Alignment.Center, bounds);
        }
Ejemplo n.º 13
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            DwarfGame.SpriteBatch.Begin();
            int      i    = 0;
            Viewport port = GameState.Game.GraphicsDevice.Viewport;

            foreach (CreatureAI creature in Player.SelectedMinions)
            {
                Drawer2D.DrawAlignedText(DwarfGame.SpriteBatch, creature.Stats.FullName, PlayState.GUI.SmallFont, Color.White, Drawer2D.Alignment.Right, new Rectangle(port.Width - 300, 68 + i * 24, 300, 24));
                i++;
            }

            foreach (Body body in Player.BodySelector.CurrentBodies)
            {
                if (IsDwarf(body))
                {
                    Drawer2D.DrawRect(DwarfGame.SpriteBatch, body.GetScreenRect(PlayState.Camera), Color.White, 1.0f);
                }
            }


            DwarfGame.SpriteBatch.End();
        }
Ejemplo n.º 14
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            if (!IsVisible)
            {
                return;
            }

            Rectangle globalBounds = GlobalBounds;
            Color     imageColor   = Color.White;
            Color     textColor    = TextColor;
            Color     strokeColor  = GUI.DefaultStrokeColor;

            if (IsLeftPressed)
            {
                imageColor = PressedTint;
                textColor  = PressedTextColor;
            }
            else if (IsMouseOver)
            {
                imageColor = HoverTint;
                textColor  = HoverTextColor;
            }

            if (CanToggle && IsToggled)
            {
                imageColor = ToggleTint;
            }

            imageColor.A = Transparency;

            Rectangle imageBounds = GetImageBounds();

            switch (Mode)
            {
            case ButtonMode.ImageButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButtonFrame(imageBounds, batch);
                }
                Rectangle bounds = imageBounds;
                if (Image != null && Image.Image != null)
                {
                    batch.Draw(Image.Image, bounds, Image.SourceRect, imageColor);
                }

                Drawer2D.DrawAlignedText(batch, Text, TextFont, textColor, Drawer2D.Alignment.Under | Drawer2D.Alignment.Center, new Rectangle(bounds.X + 2, bounds.Y + 4, bounds.Width, bounds.Height), true);
                if (IsToggled)
                {
                    Drawer2D.DrawRect(batch, GetImageBounds(), Color.White, 2);
                }
                break;

            case ButtonMode.PushButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButton(GlobalBounds, batch);
                }
                Drawer2D.DrawAlignedStrokedText(batch, Text,
                                                TextFont,
                                                textColor, strokeColor, Drawer2D.Alignment.Center, GlobalBounds, true);
                break;

            case ButtonMode.ToolButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButton(GlobalBounds, batch);
                }
                if (Image != null && Image.Image != null)
                {
                    Rectangle imageRect   = GetImageBounds();
                    Rectangle alignedRect = Drawer2D.Align(GlobalBounds, imageRect.Width, imageRect.Height, Drawer2D.Alignment.Left);
                    alignedRect.X += 5;
                    batch.Draw(Image.Image, alignedRect, Image.SourceRect, imageColor);
                }
                Drawer2D.DrawAlignedStrokedText(batch, Text, TextFont, textColor, strokeColor, Drawer2D.Alignment.Center, GlobalBounds, true);

                if (IsToggled)
                {
                    Drawer2D.DrawRect(batch, GetImageBounds(), Color.White, 2);
                }

                break;

            case ButtonMode.TabButton:
                GUI.Skin.RenderTab(GlobalBounds, batch, IsToggled ? Color.White : Color.LightGray);
                Drawer2D.DrawAlignedStrokedText(batch, Text,
                                                TextFont,
                                                textColor, strokeColor, Drawer2D.Alignment.Top, new Rectangle(GlobalBounds.X, GlobalBounds.Y + 2, GlobalBounds.Width, GlobalBounds.Height), true);
                break;
            }

            base.Render(time, batch);
        }