Пример #1
0
        public override void Display()
        {
            if (r == null || loadTimer.Elapsed.TotalSeconds < 0.25)
            {
                return;
            }

            loadTimer.Restart();

            loadTick = ++loadTick % 8;
            r.BeginFrame(int2.Zero, 1f);
            r.RgbaSpriteRenderer.DrawSprite(gdiLogo, gdiPos);
            r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
            r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);

            WidgetUtils.DrawPanelPartial(bounds, PanelSides.Edges,
                                         borderTop, borderBottom, borderLeft, borderRight,
                                         cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight,
                                         null);
            var barY = bounds.Height - 78;

            if (!setup && r.Fonts != null)
            {
                loadingFont = r.Fonts["BigBold"];
                loadingText = loadInfo["Text"];
                loadingPos  = new float2((bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);

                versionFont = r.Fonts["Regular"];
                var versionSize = versionFont.Measure(versionText);
                versionPos = new float2(bounds.Width - 107 - versionSize.X / 2, 115 - versionSize.Y / 2);

                setup = true;
            }

            if (loadingFont != null)
            {
                loadingFont.DrawText(loadingText, loadingPos, Color.Gray);
            }
            if (versionFont != null)
            {
                versionFont.DrawTextWithContrast(versionText, versionPos, Color.White, Color.Black, 2);
            }

            for (var i = 0; i <= 8; i++)
            {
                var block = loadTick == i ? brightBlock : dimBlock;
                r.RgbaSpriteRenderer.DrawSprite(block,
                                                new float2(bounds.Width / 2 - 114 - i * 32, barY));
                r.RgbaSpriteRenderer.DrawSprite(block,
                                                new float2(bounds.Width / 2 + 114 + i * 32 - 16, barY));
            }

            r.EndFrame(nih);
        }
Пример #2
0
        public void Display()
        {
            if (r == null || loadTimer.ElapsedTime() < 0.25)
            {
                return;
            }

            loadTimer.Reset();

            loadTick = ++loadTick % 8;
            r.BeginFrame(float2.Zero, 1f);
            r.RgbaSpriteRenderer.DrawSprite(gdiLogo, gdiPos);
            r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
            r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);

            WidgetUtils.DrawPanelPartial(ss, Bounds, PanelSides.Edges);
            var barY = Bounds.Height - 78;

            if (!setup && r.Fonts != null)
            {
                loadingFont = r.Fonts["BigBold"];
                loadingText = "Loading";
                loadingPos  = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);

                versionFont = r.Fonts["Regular"];
                versionText = WidgetUtils.ActiveModVersion();
                var versionSize = versionFont.Measure(versionText);
                versionPos = new float2(Bounds.Width - 107 - versionSize.X / 2, 115 - versionSize.Y / 2);

                setup = true;
            }

            if (loadingFont != null)
            {
                loadingFont.DrawText(loadingText, loadingPos, Color.Gray);
            }
            if (versionFont != null)
            {
                versionFont.DrawTextWithContrast(versionText, versionPos, Color.White, Color.Black, 2);
            }

            for (var i = 0; i <= 8; i++)
            {
                var block = loadTick == i ? brightBlock : dimBlock;
                r.RgbaSpriteRenderer.DrawSprite(block,
                                                new float2(Bounds.Width / 2 - 114 - i * 32, barY));
                r.RgbaSpriteRenderer.DrawSprite(block,
                                                new float2(Bounds.Width / 2 + 114 + i * 32 - 16, barY));
            }

            r.EndFrame(nih);
        }
Пример #3
0
        public override void Draw()
        {
            var image = ChromeProvider.GetImage(Image + "-button", GetImage());
            var rect  = new Rectangle(RenderBounds.X, RenderBounds.Y, (int)image.size.X, (int)image.size.Y);

            if (rect.Contains(Viewport.LastMousePos))
            {
                rect = rect.InflateBy(3, 3, 3, 3);
                var pos = new int2(rect.Left, rect.Top);
                var m   = pos + new int2(rect.Width, rect.Height);
                var br  = pos + new int2(rect.Width, rect.Height + 20);

                var u = Game.Renderer.Fonts["Regular"].Measure(GetLongDesc().Replace("\\n", "\n"));

                br.X -= u.X;
                br.Y += u.Y;
                br   += new int2(-15, 25);

                var border = WidgetUtils.GetBorderSizes("dialog4");

                WidgetUtils.DrawPanelPartial("dialog4", rect
                                             .InflateBy(0, 0, 0, border[1]),
                                             PanelSides.Top | PanelSides.Left | PanelSides.Right | PanelSides.Center);

                WidgetUtils.DrawPanelPartial("dialog4", new Rectangle(br.X, m.Y, pos.X - br.X, br.Y - m.Y)
                                             .InflateBy(0, 0, border[3], 0),
                                             PanelSides.Top | PanelSides.Left | PanelSides.Bottom | PanelSides.Center);

                WidgetUtils.DrawPanelPartial("dialog4", new Rectangle(pos.X, m.Y, m.X - pos.X, br.Y - m.Y)
                                             .InflateBy(border[2], border[0], 0, 0),
                                             PanelSides.Right | PanelSides.Bottom | PanelSides.Center);

                pos.X = br.X + 8;
                pos.Y = m.Y + 8;
                Game.Renderer.Fonts["Bold"].DrawText(GetDescription(), pos, Color.White);

                pos += new int2(0, 20);
                Game.Renderer.Fonts["Regular"].DrawText(GetLongDesc().Replace("\\n", "\n"), pos, Color.White);
            }

            Game.Renderer.RgbaSpriteRenderer.DrawSprite(image, new int2(RenderBounds.X, RenderBounds.Y));
        }
Пример #4
0
        void DrawBuildTabs(World world)
        {
            const int tabWidth  = 24;
            const int tabHeight = 40;
            var       x         = paletteOrigin.X - tabWidth;
            var       y         = paletteOrigin.Y + 9;

            tabs.Clear();

            foreach (var queue in VisibleQueues)
            {
                string[] tabKeys   = { "normal", "ready", "selected" };
                var      producing = queue.CurrentItem();
                var      index     = queue == CurrentQueue ? 2 : (producing != null && producing.Done) ? 1 : 0;

                var race = world.LocalPlayer.Country.Race;
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage("tabs-" + tabKeys[index], race + "-" + queue.Info.Type), new float2(x, y));

                var rect = new Rectangle((int)x, (int)y, tabWidth, tabHeight);
                tabs.Add(Pair.New(rect, HandleTabClick(queue, world)));

                if (rect.Contains(Viewport.LastMousePos))
                {
                    var text = queue.Info.Type;
                    var font = Game.Renderer.Fonts["Bold"];
                    var sz   = font.Measure(text);
                    WidgetUtils.DrawPanelPartial("dialog4",
                                                 Rectangle.FromLTRB(rect.Left - sz.X - 30, rect.Top, rect.Left - 5, rect.Bottom),
                                                 PanelSides.All);

                    font.DrawText(text, new float2(rect.Left - sz.X - 20, rect.Top + 12), Color.White);
                }

                y += tabHeight;
            }
        }
Пример #5
0
        public override void Draw()
        {
            buttons.Clear();

            if (world.LocalPlayer == null)
            {
                return;
            }

            var manager   = world.LocalPlayer.PlayerActor.Trait <SupportPowerManager>();
            var powers    = manager.Powers.Where(p => !p.Value.Disabled);
            var numPowers = powers.Count();

            if (numPowers == 0)
            {
                return;
            }

            var rectBounds = RenderBounds;

            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"), new float2(rectBounds.X, rectBounds.Y));
            for (var i = 1; i < numPowers; i++)
            {
                WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
            }
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));

            // Hack Hack Hack
            rectBounds.Width  = 69;
            rectBounds.Height = 10 + numPowers * 51 + 21;

            var y = rectBounds.Y + 10;

            foreach (var kv in powers)
            {
                var sp    = kv.Value;
                var image = spsprites[sp.Info.Image];

                var drawPos = new float2(rectBounds.X + 5, y);
                var rect    = new Rectangle(rectBounds.X + 5, y, 64, 48);

                if (rect.Contains(Viewport.LastMousePos))
                {
                    var pos = drawPos.ToInt2();
                    var tl  = new int2(pos.X - 3, pos.Y - 3);
                    var m   = new int2(pos.X + 64 + 3, pos.Y + 48 + 3);
                    var br  = tl + new int2(64 + 3 + 20, 40);

                    if (sp.TotalTime > 0)
                    {
                        br += new int2(0, 20);
                    }

                    if (sp.Info.LongDesc != null)
                    {
                        br += Game.Renderer.Fonts["Regular"].Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
                    }
                    else
                    {
                        br += new int2(300, 0);
                    }

                    var border = WidgetUtils.GetBorderSizes("dialog4");

                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(tl.X, tl.Y, m.X + border[3], m.Y),
                                                 PanelSides.Left | PanelSides.Top | PanelSides.Bottom | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
                                                 PanelSides.Top | PanelSides.Right | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
                                                 PanelSides.Left | PanelSides.Right | PanelSides.Bottom | PanelSides.Center);

                    pos += new int2(77, 5);
                    Game.Renderer.Fonts["Bold"].DrawText(sp.Info.Description, pos, Color.White);

                    if (sp.TotalTime > 0)
                    {
                        pos += new int2(0, 20);
                        Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
                        Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45, 0), Color.White);
                    }

                    if (sp.Info.LongDesc != null)
                    {
                        pos += new int2(0, 20);
                        Game.Renderer.Fonts["Regular"].DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
                    }
                }

                WidgetUtils.DrawSHP(image, drawPos, worldRenderer);

                clock.PlayFetchIndex("idle",
                                     () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
                                     * (clock.CurrentSequence.Length - 1) / sp.TotalTime);
                clock.Tick();

                WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);

                var overlay = sp.Ready ? ReadyText : sp.Active ? null : HoldText;
                var font    = Game.Renderer.Fonts["TinyBold"];
                if (overlay != null)
                {
                    var size       = font.Measure(overlay);
                    var overlayPos = drawPos + new float2(32, 16);
                    font.DrawTextWithContrast(overlay, overlayPos - new float2(size.X / 2, 0), Color.White, Color.Black, 1);
                }

                buttons.Add(Pair.New(rect, HandleSupportPower(kv.Key, manager)));

                y += 51;
            }
        }