示例#1
0
    public void Draw(SpriteBatch sb, int index)
    {
        if (dead)
        {
            return;
        }
        int w = (int)(Math.Max(Main.fontMouseText.MeasureString(ac.title).X, Main.fontMouseText.MeasureString(ac.description).X *.75f) + (ac.tex == null ? 0 : 52) + 8);

        int xx = (int)((Main.screenWidth - w) / 2f), yy = Main.screenHeight - y;

        sb.Draw(frame1, new Rectangle(xx, yy, w, 56), Color.White);
        sb.Draw(frame2, new Rectangle(xx, yy, 1, 56), Color.White);
        sb.Draw(frame2, new Rectangle(xx + w, yy, 1, 56), Color.White);

        xx += 4;
        if (ac.tex != null)
        {
            float scale = 1f;
            if (ac.tex.Width > 48)
            {
                scale = 48f / ac.tex.Width;
            }
            if (ac.tex.Height * scale > 48f)
            {
                scale = 48f / ac.tex.Height;
            }
            sb.Draw(ac.tex, new Rectangle((int)(xx + (48 - ac.tex.Width * scale) / 2f), (int)(yy + 4 + (48 - ac.tex.Height * scale) / 2f), (int)(ac.tex.Width * scale), (int)(ac.tex.Height * scale)), Color.White);
            xx += 52;
        }
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, ac.title, new Vector2(xx, yy + 8), Color.White, Color.Black);
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, ac.description, new Vector2(xx, yy + 28), Color.White, Color.Black, default(Vector2), .75f);
    }
示例#2
0
    public void Draw(SpriteBatch sb, int xx, ref int yy, int ww)
    {
        if (!Visible())
        {
            return;
        }

        if (Main.mouseLeft && Main.mouseLeftRelease && ModWorld.GuiAchievements.MouseIn(sb.GraphicsDevice.ScissorRectangle, new Rectangle(xx, yy, ww, 42)))
        {
            toggled = !toggled;
            if (toggled)
            {
                GuiAchievements.setScroll = yy + GuiAchievements.scroll - 120;
            }
        }

        Color white    = new Color(255, 255, 255, 191);
        Color limish   = new Color(136, 255, 0, 191);
        bool  achieved = Achieved();

        sb.Draw(ModWorld.Notifier.frame1, new Rectangle(xx + 1, yy, ww - 2, 42), achieved ? limish : white);
        sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx, yy, 1, 42), achieved ? limish : white);
        sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx + ww - 1, yy, 1, 42), achieved ? limish : white);

        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, title, new Vector2(xx + 8, yy + 10), Color.White, Color.Black);
        string value = "" + Value(true) + "/" + Value(false);

        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, value, new Vector2(xx + ww - 12 - Main.fontMouseText.MeasureString(value).X, yy + 10), Color.White, Color.Black);

        yy += 42;

        if (toggled)
        {
            for (int i = 0; i < categories.Count; i++)
            {
                categories[i].Draw(sb, xx + 24, ref yy, ww - 48);
            }
            for (int i = 0; i < achievements.Count; i++)
            {
                achievements[i].Draw(sb, xx + 24, ref yy, ww - 48);
            }
        }
    }
    public static void Draw(SpriteBatch sb)
    {
        if (!visible)
        {
            return;
        }
        if (Config.tileInterface != null || Config.npcInterface != null || Main.npcShop != 0 || Main.signBubble || (Main.npcChatText != null && Main.npcChatText != ""))
        {
            Toggle();
            return;
        }

        sb.End();

        int guiX = 80, guiY = 120, guiW = Main.screenWidth - guiX * 2, guiH = Main.screenHeight - guiY * 2 - 40;

        sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _rasterizerState);
        sb.GraphicsDevice.ScissorRectangle = new Rectangle(guiX, guiY, guiW + 1, guiH);

        int yStart = guiY - scroll, yy = yStart;

        for (int i = 0; i < categories.Count; i++)
        {
            categories[i].Draw(sb, guiX, ref yy, guiW - 32);
        }
        for (int i = 0; i < achievements.Count; i++)
        {
            achievements[i].Draw(sb, guiX, ref yy, guiW - 32);
        }

        sb.End();
        sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);

        int hMax = yy - yStart, scrollMax = hMax - guiH;

        if (scrollMax < 0)
        {
            scrollMax = 0;
        }
        if (scroll < 0)
        {
            scroll = 0;
        }
        if (scroll > scrollMax)
        {
            scroll = scrollMax;
        }

        float     sliderY = scrollMax == 0 ? 0f : 1f * scroll / scrollMax, sliderH = scrollMax == 0 ? 1f : 1f * guiH / hMax;
        Rectangle rectBlack = new Rectangle(guiX + guiW - 24, guiY, 24, guiH); sb.Draw(whiteTex, rectBlack, new Color(1f, 1f, 1f, .75f));
        Rectangle rectWhite = new Rectangle(guiX + guiW - 22, (int)(guiY + 2 + (guiH - 4 - (guiH - 4) * sliderH) * sliderY), 20, (int)((guiH - 4) * sliderH)); sb.Draw(whiteTex, rectWhite, new Color(0f, 0f, 0f, .75f));

        if (scrollDragY == -1)
        {
            if (Main.mouseLeft && Main.mouseLeftRelease)
            {
                if (MouseIn(rectBlack))
                {
                    if (MouseIn(rectWhite))
                    {
                        scrollDragY = Main.mouseY - rectWhite.Y;
                    }
                    else
                    {
                        scrollDragY = rectWhite.Height / 2;
                        scroll      = (int)(1f * (Main.mouseY - scrollDragY - (guiY + 2)) / (guiH - 4) * hMax);
                    }
                }
            }
        }
        else
        {
            scroll = (int)(1f * (Main.mouseY - scrollDragY - (guiY + 2)) / (guiH - 4) * hMax);
            if (!Main.mouseLeft)
            {
                scrollDragY = -1;
            }
        }

        if (setScroll >= 0)
        {
            scroll    = setScroll;
            setScroll = -1;
        }

        stateOld = state;
        state    = Microsoft.Xna.Framework.Input.Mouse.GetState();
        if (stateOld.HasValue && state.HasValue)
        {
            int mouseScrollDiff = (state.Value.ScrollWheelValue - stateOld.Value.ScrollWheelValue) / 120;
            scroll -= mouseScrollDiff * 56;
            Main.player[Main.myPlayer].selectedItem += mouseScrollDiff;
            while (Main.player[Main.myPlayer].selectedItem < 0)
            {
                Main.player[Main.myPlayer].selectedItem += 10;
            }
            while (Main.player[Main.myPlayer].selectedItem > 9)
            {
                Main.player[Main.myPlayer].selectedItem -= 10;
            }
        }

        if (scroll < 0)
        {
            scroll = 0;
        }
        if (scroll > scrollMax)
        {
            scroll = scrollMax;
        }

        int acAchieved = 0, acTotal = 0, acHidden = 0, acLocked = 0, acPoints = 0, acPointsTotal = 0;

        UpdateCounters(ref acAchieved, ref acTotal, ref acHidden, ref acLocked, ref acPoints, ref acPointsTotal);

        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, "Achieved: " + acAchieved + "/" + acTotal + (acHidden + acLocked != 0 ? " (" + (acHidden > 0 ? "+" + acHidden + " hidden" : "") + (acLocked > 0 ? (acHidden > 0 ? ", " : "") + "+" + acLocked + " locked" : "") + ")" : ""), new Vector2(guiX, guiY + guiH + 10), Color.White, Color.Black);
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, "Total points: " + acPoints + "/" + acPointsTotal, new Vector2(guiX + guiW - Main.fontMouseText.MeasureString("Total points: " + acPoints + "/" + acPointsTotal).X, guiY + guiH + 10), Color.White, Color.Black);
    }
示例#4
0
    public void Draw(SpriteBatch sb, int xx, ref int yy, int ww)
    {
        Color white  = new Color(255, 255, 255, 191);
        Color limish = new Color(136, 255, 0, 191);
        Color orange = new Color(255, 127, 0, 191);

        float progress = GetProgress();

        if (achieved)
        {
            progress = 1f;
        }
        Color c = achieved ? limish : white;

        if (progress <= 0f || progress >= 1f)
        {
            sb.Draw(ModWorld.Notifier.frame1, new Rectangle(xx + 1, yy, ww - 2, 56), c);
            sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx, yy, 1, 56), c);
            sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx + ww - 1, yy, 1, 56), c);
        }
        else
        {
            int progressW = (int)((ww - 2) * progress);
            sb.Draw(ModWorld.Notifier.frame1, new Rectangle(xx + 1, yy, progressW, 56), orange);
            sb.Draw(ModWorld.Notifier.frame1, new Rectangle(xx + 1 + progressW, yy, ww - 2 - progressW, 56), white);
            sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx, yy, 1, 56), orange);
            sb.Draw(ModWorld.Notifier.frame2, new Rectangle(xx + ww - 1, yy, 1, 56), white);
        }

        xx += 4;
        if (tex != null)
        {
            float scale = 1f;
            if (tex.Width > 48)
            {
                scale = 48f / tex.Width;
            }
            if (tex.Height * scale > 48f)
            {
                scale = 48f / tex.Height;
            }
            sb.Draw(tex, new Rectangle((int)(xx + (48 - tex.Width * scale) / 2f), (int)(yy + 4 + (48 - tex.Height * scale) / 2f), (int)(tex.Width * scale), (int)(tex.Height * scale)), Color.White);
            xx += 52;
        }
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, title, new Vector2(xx, yy + 8), Color.White, Color.Black);
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, description, new Vector2(xx, yy + 28), Color.White, Color.Black, default(Vector2), .75f);
        string progressText = GetProgressText();

        if (!achieved && progressText != null)
        {
            ModWorld.DrawStringShadowed(sb, Main.fontMouseText, progressText, new Vector2((int)(xx + Main.fontMouseText.MeasureString(description).X *.75f + 20), yy + 18), Color.White, Color.Black, default(Vector2), .75f);
        }
        xx -= 4; if (tex != null)
        {
            xx -= 52;
        }
        ModWorld.DrawStringShadowed(sb, Main.fontMouseText, "" + value, new Vector2(xx + ww - 12 - Main.fontMouseText.MeasureString("" + value).X, yy + 16), Color.White, Color.Black);

        yy += 56;

        for (int i = 0; i < sub.Count; i++)
        {
            sub[i].Draw(sb, xx + 24, ref yy, ww - 48);
        }
    }