Ejemplo n.º 1
0
        public static void Draw()
        {
            if (Main.playerInventory)
            {
                Main.playerInventory = false;
                WindowActive         = false;
                return;
            }
            if (Main.mouseX >= WindowPosition.X && Main.mouseX < WindowPosition.X + WindowWidth &&
                Main.mouseY >= WindowPosition.Y && Main.mouseY < WindowPosition.Y + WindowHeight)
            {
                Main.player[Main.myPlayer].mouseInterface = true;
            }
            DrawRectangle(WindowPosition.X, WindowPosition.Y, WindowWidth, WindowHeight, Color.Green);
            DrawRectangle(WindowPosition.X - 2, WindowPosition.Y - 2, 2, WindowHeight + 4, Color.Black);
            DrawRectangle(WindowPosition.X, WindowPosition.Y - 2, WindowWidth, 2, Color.Black);
            DrawRectangle(WindowPosition.X + WindowWidth, WindowPosition.Y, 2, WindowHeight + 2, Color.Black);
            DrawRectangle(WindowPosition.X, WindowPosition.Y + WindowHeight, WindowWidth, 2, Color.Black);
            Vector2 DrawPosition = new Vector2(WindowPosition.X + WindowWidth * 0.5f, WindowPosition.Y - 2);

            Utils.DrawBorderString(Main.spriteBatch, "Buddies Mode", DrawPosition, Color.Yellow, 1.2f, 0.5f);
            DrawPosition.Y += 28;
            foreach (string s in GameModeInfo)
            {
                DrawPosition.Y += Utils.DrawBorderString(Main.spriteBatch, s, DrawPosition, Color.White, 0.9f, 0.5f).Y;
            }
            DrawPosition.X = WindowPosition.X + 2;
            float ElementStartPosY = DrawPosition.Y;
            int   MenuWidth = 228, MenuHeight = (int)(WindowPosition.Y - DrawPosition.Y + WindowHeight - 2);

            DrawRectangle(DrawPosition.X, DrawPosition.Y, MenuWidth, MenuHeight, Color.LightBlue);
            int  MaxElements             = MenuHeight / 30;
            bool PreviouslyPickedSomeone = false;

            for (int i = 0; i < MaxElements; i++)
            {
                int  index       = i + MenuScroll;
                byte MenuElement = 1; //0 = Up Arrow, 1 = Companion, 2 = DownArrow
                if (MenuScroll > 0 && i == 0)
                {
                    MenuElement = 0;
                }
                if (MenuScroll + MaxElements < PossibleGuardianIDs.Length && i == MaxElements - 1)
                {
                    MenuElement = 2;
                }
                if (index < 0 || i >= PossibleGuardianIDs.Length)
                {
                    continue;
                }
                Vector2 OptionPosition = DrawPosition;
                OptionPosition.X += MenuWidth * 0.5f;
                OptionPosition.Y += 30 * i;
                string Text = "";
                if (MenuElement == 0)
                {
                    Text = "= Up =";
                }
                else if (MenuElement == 2)
                {
                    Text = "= Down =";
                }
                else
                {
                    Text = PossibleGuardianNames[index];
                }
                if (DrawTextButton(Text, OptionPosition, 1f) && !PreviouslyPickedSomeone)
                {
                    PreviouslyPickedSomeone = true;
                    if (MenuElement == 0)
                    {
                        MenuScroll--;
                    }
                    else if (MenuElement == 2)
                    {
                        MenuScroll++;
                    }
                    else
                    {
                        if (DisplayGuardian == null || DisplayGuardian.MyID != PossibleGuardianIDs[index])
                        {
                            DisplayGuardian = new TerraGuardian(PossibleGuardianIDs[index].ID, PossibleGuardianIDs[index].ModID);
                        }
                        SelectedBuddy = index;
                    }
                }
            }
            DrawPosition.X += MenuWidth + 2 + (WindowWidth - MenuWidth) / 2;
            DrawPosition.Y  = WindowPosition.Y + WindowHeight - 152;
            if (SelectedBuddy > -1)
            {
                if (DisplayGuardian != null)
                {
                    DisplayGuardian.Position = DrawPosition + Main.screenPosition;
                    DisplayGuardian.Draw(true, true);
                    Utils.DrawBorderString(Main.spriteBatch, DisplayGuardian.Name, DrawPosition, Color.White, 1.1f, 0.5f);
                    DrawPosition.Y += 28;
                    Utils.DrawBorderString(Main.spriteBatch, DisplayGuardian.Base.Description, DrawPosition, Color.White, 1, 0.5f);
                }
            }
            DrawPosition.X = WindowPosition.X + WindowWidth * 0.5f;
            DrawPosition.Y = WindowPosition.Y + WindowHeight - 22;
            if (SelectedBuddy > -1 && !DisplayGuardian.Base.InvalidGuardian && DrawTextButton("Pick Buddy", DrawPosition, 1.2f))
            {
                if (Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().SetBuddyMode(PossibleGuardianIDs[SelectedBuddy].ID, PossibleGuardianIDs[SelectedBuddy].ModID))
                {
                    Close();
                }
            }
            DrawPosition.X += 120;
            if (DrawTextButton("Close", DrawPosition, 1.2f))
            {
                Close();
            }
        }