|
5 | 5 | using Microsoft.Xna.Framework.Graphics; |
6 | 6 | using Microsoft.Xna.Framework.Input; |
7 | 7 | using ReLogic.Content; |
| 8 | +using System; |
8 | 9 | using System.Collections.Generic; |
9 | 10 | using Terraria; |
10 | 11 | using Terraria.Audio; |
@@ -562,6 +563,85 @@ public override void Draw(SpriteBatch spriteBatch) { |
562 | 563 | if (nightHovered) { |
563 | 564 | Main.hoverItemName = NightMode ? NightModeText.Value : SunModeText.Value; |
564 | 565 | } |
| 566 | + |
| 567 | + //如果任务检测被禁用,绘制禁止覆盖层 |
| 568 | + var qlPlayer = Main.LocalPlayer.GetModPlayer<QLPlayer>(); |
| 569 | + if (!qlPlayer.ShouldCheckQuestInCurrentWorld()) { |
| 570 | + DrawDisabledOverlay(spriteBatch); |
| 571 | + } |
| 572 | + } |
| 573 | + |
| 574 | + private float disabledOverlayAnimTime; |
| 575 | + |
| 576 | + private void DrawDisabledOverlay(SpriteBatch spriteBatch) { |
| 577 | + disabledOverlayAnimTime += 0.016f; |
| 578 | + |
| 579 | + Texture2D pixel = VaultAsset.placeholder2.Value; |
| 580 | + |
| 581 | + //半透明红色覆盖层 |
| 582 | + float pulseAlpha = 0.65f + MathF.Sin(disabledOverlayAnimTime * 2f) * 0.05f; |
| 583 | + Color overlayColor = new Color(150, 50, 50) * (mainPanelAlpha * pulseAlpha); |
| 584 | + spriteBatch.Draw(pixel, panelRect, overlayColor); |
| 585 | + |
| 586 | + //绘制禁止符号 |
| 587 | + Vector2 center = new Vector2(panelRect.X + panelRect.Width / 2f, panelRect.Y + panelRect.Height / 2f); |
| 588 | + |
| 589 | + //外圆 |
| 590 | + float circleRadius = 60f; |
| 591 | + float circleThickness = 8f; |
| 592 | + Color circleColor = new Color(200, 60, 60) * (mainPanelAlpha * 0.8f); |
| 593 | + |
| 594 | + //使用SoftGlow绘制发光效果 |
| 595 | + Texture2D softGlow = CWRAsset.SoftGlow.Value; |
| 596 | + float glowPulse = 0.8f + MathF.Sin(disabledOverlayAnimTime * 3f) * 0.2f; |
| 597 | + Color glowColor = new Color(200, 80, 80, 0) * (mainPanelAlpha * 0.4f * glowPulse); |
| 598 | + spriteBatch.Draw(softGlow, center, null, glowColor, 0f, |
| 599 | + softGlow.Size() / 2f, 2f, SpriteEffects.None, 0f); |
| 600 | + |
| 601 | + //绘制圆环 |
| 602 | + int segments = 36; |
| 603 | + for (int i = 0; i < segments; i++) { |
| 604 | + float angle1 = MathHelper.TwoPi * i / segments; |
| 605 | + float angle2 = MathHelper.TwoPi * (i + 1) / segments; |
| 606 | + |
| 607 | + Vector2 p1 = center + angle1.ToRotationVector2() * circleRadius; |
| 608 | + Vector2 p2 = center + angle2.ToRotationVector2() * circleRadius; |
| 609 | + |
| 610 | + float segAngle = MathF.Atan2(p2.Y - p1.Y, p2.X - p1.X); |
| 611 | + float segLength = Vector2.Distance(p1, p2); |
| 612 | + |
| 613 | + spriteBatch.Draw(pixel, p1, new Rectangle(0, 0, 1, 1), circleColor, |
| 614 | + segAngle, new Vector2(0, 0.5f), new Vector2(segLength + 1, circleThickness), SpriteEffects.None, 0f); |
| 615 | + } |
| 616 | + |
| 617 | + //绘制斜线(禁止符号) |
| 618 | + float lineAngle = MathHelper.PiOver4; |
| 619 | + float lineLength = circleRadius * 1.4f; |
| 620 | + Vector2 lineStart = center - lineAngle.ToRotationVector2() * lineLength / 2f; |
| 621 | + |
| 622 | + spriteBatch.Draw(pixel, lineStart, new Rectangle(0, 0, 1, 1), circleColor, |
| 623 | + lineAngle, new Vector2(0, 0.5f), new Vector2(lineLength, circleThickness), SpriteEffects.None, 0f); |
| 624 | + |
| 625 | + //绘制提示文本 |
| 626 | + string text = QuestWorldConfirmUI.DisabledOverlayText?.Value ?? "任务检测已被禁止"; |
| 627 | + string[] lines = text.Split('\n'); |
| 628 | + |
| 629 | + float textY = center.Y + circleRadius + 30f; |
| 630 | + float lineHeight = FontAssets.MouseText.Value.MeasureString("A").Y; |
| 631 | + |
| 632 | + for (int i = 0; i < lines.Length; i++) { |
| 633 | + Vector2 textSize = FontAssets.MouseText.Value.MeasureString(lines[i]); |
| 634 | + Vector2 textPos = new Vector2(center.X - textSize.X / 2f * 0.9f, textY + i * lineHeight); |
| 635 | + |
| 636 | + //文字阴影 |
| 637 | + Utils.DrawBorderString(spriteBatch, lines[i], textPos + new Vector2(2, 2), |
| 638 | + Color.Black * (mainPanelAlpha * 0.6f), 0.9f); |
| 639 | + |
| 640 | + //文字主体(带脉冲效果) |
| 641 | + Color textColor = Color.Lerp(new Color(255, 180, 180), new Color(255, 100, 100), |
| 642 | + MathF.Sin(disabledOverlayAnimTime * 2f) * 0.5f + 0.5f); |
| 643 | + Utils.DrawBorderString(spriteBatch, lines[i], textPos, textColor * mainPanelAlpha, 0.9f); |
| 644 | + } |
565 | 645 | } |
566 | 646 |
|
567 | 647 | private void DrawMainCloseButton(SpriteBatch spriteBatch) { |
|
0 commit comments