コード例 #1
0
        public bool MouseHovering()
        {
            Vector2 Pos           = Get4ButtonPos(NPCAttacker.FocusText1, NPCAttacker.FocusText3);
            string  LocalizedText = TranslationUtils.GetTranslation("Arm");
            Vector2 Size          = Get4ButtonSize(LocalizedText);

            if (Main.mouseX > Pos.X && Main.mouseX < Pos.X + Size.X)
            {
                if (Main.mouseY > Pos.Y && Main.mouseY < Pos.Y + Size.Y)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        public override void OnActivate()
        {
            Vector2 Pos = Get4ButtonPos(NPCAttacker.FocusText1, NPCAttacker.FocusText3);

            string  LocalizedText = TranslationUtils.GetTranslation("Arm");
            Vector2 Size          = Get4ButtonSize(LocalizedText);

            TextButton = new UIImageButton(Main.itemTexture[ItemID.BlackDye]);
            TextButton.Left.Set(Pos.X, 0f);
            TextButton.Top.Set(Pos.Y, 0f);
            TextButton.Width.Set(Size.X, 0f);
            TextButton.Height.Set(Size.Y, 0f);
            TextButton.OnClick += Chat_OnClick;

            Append(TextButton);
            base.OnActivate();
        }
コード例 #3
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Vector2 Pos           = Get4ButtonPos(NPCAttacker.FocusText1, NPCAttacker.FocusText3);
            string  LocalizedText = TranslationUtils.GetTranslation("Arm");
            Vector2 Size          = Get4ButtonSize(LocalizedText);
            Vector2 Scale         = new Vector2(0.9f);

            if (MouseHovering())
            {
                Scale *= 1.1f;
            }
            Vector2 Unit      = new Vector2(1f);
            Color   chatColor = Color.Red;

            if (Main.LocalPlayer.talkNPC != -1)
            {
                if (Main.npc[Main.LocalPlayer.talkNPC].type == NPCID.Nurse)
                {
                    chatColor = CombatText.HealLife;
                }
            }
            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, LocalizedText, Pos + Size * Unit * 0.5f, chatColor, 0f, Size * 0.5f, Scale * Unit, -1f, 2f);
        }
コード例 #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            Vector2 Pos           = Get4ButtonPos(NPCAttacker.FocusText1, NPCAttacker.FocusText3);
            string  LocalizedText = TranslationUtils.GetTranslation("Arm");
            Vector2 Size          = Get4ButtonSize(LocalizedText);

            TextButton.Left.Set(Pos.X, 0f);
            TextButton.Top.Set(Pos.Y, 0f);
            TextButton.Width.Set(Size.X, 0f);
            TextButton.Height.Set(Size.Y, 0f);
            Append(TextButton);
            if (MouseHovering() && !HasHover)
            {
                Main.PlaySound(SoundID.MenuTick, -1, -1, 1, 1f, 0f);
                HasHover = true;
            }
            if (!MouseHovering() && HasHover)
            {
                Main.PlaySound(SoundID.MenuTick, -1, -1, 1, 1f, 0f);
                HasHover = false;
            }
        }
コード例 #5
0
ファイル: ArmUI.cs プロジェクト: DarthHA/NPCAttacker
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            base.DrawSelf(spriteBatch);

            // This will hide the crafting menu similar to the reforge menu. For best results this UI is placed before "Vanilla: Inventory" to prevent 1 frame of the craft menu showing.
            Main.HidePlayerCraftingMenu = true;

            const int slotX = 50;
            const int slotY = 270;

            if (Main.mouseX > slotX && Main.mouseX < slotX + _vanillaItemSlot.Width.GetValue(0f))
            {
                if (Main.mouseY > slotY && Main.mouseX < slotY + _vanillaItemSlot.Height.GetValue(0f))
                {
                    Main.hoverItemName = TranslationUtils.GetTranslation("ArmUIHoverText");
                }
            }

            if (!_vanillaItemSlot.Item.IsAir)
            {
                string message = TranslationUtils.GetTranslation("ArmUIarmered");
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, message, new Vector2(slotX + 50, slotY + 50), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
            }
            else
            {
                string message1  = TranslationUtils.GetTranslation("ArmUIunarmered1");
                string message2  = TranslationUtils.GetTranslation("ArmUINote");
                string ClassInfo = "";
                if (Main.LocalPlayer.talkNPC != -1)
                {
                    NPC talkNPC = Main.npc[Main.LocalPlayer.talkNPC];
                    switch (NPCID.Sets.AttackType[talkNPC.type])
                    {
                    case 0:
                        if (talkNPC.type == NPCID.Nurse)
                        {
                            ClassInfo = TranslationUtils.GetTranslation("ArmUIClassNurse");
                        }
                        else
                        {
                            ClassInfo = TranslationUtils.GetTranslation("ArmUIClassThrown");
                        }
                        break;

                    case 1:
                        ClassInfo = TranslationUtils.GetTranslation("ArmUIClassRanged");
                        break;

                    case 2:
                        ClassInfo = TranslationUtils.GetTranslation("ArmUIClassMagic");
                        break;

                    case 3:
                        ClassInfo = TranslationUtils.GetTranslation("ArmUIClassMelee");
                        break;
                    }
                }
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, message1, new Vector2(slotX + 50, slotY + 50), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, ClassInfo, new Vector2(slotX + 50, slotY + 100), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, message2, new Vector2(slotX + 50, slotY + 150), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
            }
        }