Skip to content

Commit 566d10f

Browse files
committed
Update LegendUpgradeConfirmUI.cs
1 parent aece44b commit 566d10f

File tree

1 file changed

+120
-100
lines changed

1 file changed

+120
-100
lines changed

Content/LegendWeapon/LegendUpgradeConfirmUI.cs

Lines changed: 120 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ internal class LegendUpgradeConfirmUI : UIHandle, ILocalizedModType
5757
private float particleSpawnTimer;
5858

5959
//布局常量
60-
private const float PanelWidth = 420f;
61-
private const float PanelHeight = 260f;
60+
private const float PanelWidth = 480f;
61+
private const float PanelHeight = 240f;
6262
private const float Padding = 24f;
6363
private const float ButtonHeight = 42f;
64-
private const float ButtonWidth = 150f;
64+
private const float ButtonWidth = 130f;
6565
private const float CornerRadius = 12f;
66+
private const float ItemShowcaseWidth = 120f;
6667

6768
//按钮
6869
private Rectangle confirmButtonRect;
@@ -239,28 +240,7 @@ public override void Update() {
239240
player.mouseInterface = true;
240241
}
241242

242-
//按钮位置(相对于缩放后的面板)
243-
float buttonY = DrawPosition.Y + scaledHeight - Padding * panelScaleAnim - ButtonHeight * panelScaleAnim;
244-
float centerX = DrawPosition.X + scaledWidth / 2f;
245-
float buttonSpacing = 24f * panelScaleAnim;
246-
float scaledButtonWidth = ButtonWidth * panelScaleAnim;
247-
float scaledButtonHeight = ButtonHeight * panelScaleAnim;
248-
249-
confirmButtonRect = new Rectangle(
250-
(int)(centerX - scaledButtonWidth - buttonSpacing / 2f),
251-
(int)buttonY,
252-
(int)scaledButtonWidth,
253-
(int)scaledButtonHeight
254-
);
255-
256-
cancelButtonRect = new Rectangle(
257-
(int)(centerX + buttonSpacing / 2f),
258-
(int)buttonY,
259-
(int)scaledButtonWidth,
260-
(int)scaledButtonHeight
261-
);
262-
263-
//悬停检测
243+
//按钮位置在DrawContent中动态计算,这里只更新悬停检测
264244
hoveringConfirm = confirmButtonRect.Contains(MouseHitBox) && contentFade > 0.5f;
265245
hoveringCancel = cancelButtonRect.Contains(MouseHitBox) && contentFade > 0.5f;
266246

@@ -528,9 +508,12 @@ private void DrawCornerOrnaments(SpriteBatch spriteBatch, Rectangle rect, float
528508
}
529509

530510
private void DrawContent(SpriteBatch spriteBatch, float alpha) {
531-
Texture2D pixel = VaultAsset.placeholder2.Value;
532511
float scale = panelScaleAnim;
533512

513+
//计算左侧文本区域和右侧物品展示区域
514+
float showcaseWidth = ItemShowcaseWidth * scale;
515+
float textAreaWidth = Size.X - showcaseWidth - Padding * scale * 2;
516+
534517
//标题
535518
Vector2 titlePos = DrawPosition + new Vector2(Padding * scale, Padding * scale);
536519
string title = TitleText.Value;
@@ -548,16 +531,14 @@ private void DrawContent(SpriteBatch spriteBatch, float alpha) {
548531
Color titleColor = Color.Lerp(new Color(255, 240, 200), new Color(255, 200, 100), breatheAnim * 0.3f);
549532
Utils.DrawBorderString(spriteBatch, title, titlePos, titleColor * alpha, scale);
550533

551-
//分割线(带渐变和动画)
534+
//分割线(只在文本区域)
552535
Vector2 dividerStart = titlePos + new Vector2(0, 40 * scale);
553-
Vector2 dividerEnd = dividerStart + new Vector2((PanelWidth - Padding * 2) * scale, 0);
554-
555-
//分割线背景
536+
Vector2 dividerEnd = dividerStart + new Vector2(textAreaWidth, 0);
556537
DrawAnimatedDivider(spriteBatch, dividerStart, dividerEnd, alpha);
557538

558539
//描述文本
559540
if (pendingItem != null) {
560-
Vector2 descPos = dividerStart + new Vector2(0, 20 * scale);
541+
Vector2 descPos = dividerStart + new Vector2(0, 18 * scale);
561542
string itemName = pendingItem.Name;
562543
string desc = string.Format(DescText.Value, itemName, targetLevel);
563544
string[] lines = desc.Split('\n');
@@ -570,28 +551,123 @@ private void DrawContent(SpriteBatch spriteBatch, float alpha) {
570551
Vector2 linePos = descPos + new Vector2(0, i * lineHeight);
571552
string lineText = lines[i];
572553

573-
//如果包含物品名或等级,高亮显示
574554
if (lineText.Contains(itemName) || lineText.Contains(targetLevel.ToString())) {
575-
Utils.DrawBorderString(spriteBatch, lineText, linePos, highlightColor, 0.9f * scale);
555+
Utils.DrawBorderString(spriteBatch, lineText, linePos, highlightColor, 0.85f * scale);
576556
}
577557
else {
578-
Utils.DrawBorderString(spriteBatch, lineText, linePos, textColor, 0.9f * scale);
558+
Utils.DrawBorderString(spriteBatch, lineText, linePos, textColor, 0.85f * scale);
579559
}
580560
}
581561

582-
//物品图标展示区
583-
float iconAreaY = descPos.Y + lineHeight * lines.Length + 15 * scale;
584-
DrawItemShowcase(spriteBatch, pendingItem, new Vector2(DrawPosition.X + Size.X / 2f, iconAreaY), alpha, scale);
562+
//右侧物品展示区
563+
Rectangle showcaseRect = new(
564+
(int)(DrawPosition.X + Size.X - showcaseWidth - Padding * scale * 0.5f),
565+
(int)(DrawPosition.Y + Padding * scale),
566+
(int)showcaseWidth,
567+
(int)(Size.Y - ButtonHeight * scale)
568+
);
569+
DrawItemShowcasePanel(spriteBatch, pendingItem, showcaseRect, alpha, scale);
585570
}
586571

587-
//按钮
572+
//按钮(放在左侧文本区域下方)
573+
float buttonY = DrawPosition.Y + Size.Y - Padding * scale - ButtonHeight * scale;
574+
float buttonCenterX = DrawPosition.X + Padding * scale + textAreaWidth / 2f;
575+
float buttonSpacing = 16f * scale;
576+
float scaledButtonWidth = ButtonWidth * scale;
577+
float scaledButtonHeight = ButtonHeight * scale;
578+
579+
confirmButtonRect = new Rectangle(
580+
(int)(buttonCenterX - scaledButtonWidth - buttonSpacing / 2f),
581+
(int)buttonY,
582+
(int)scaledButtonWidth,
583+
(int)scaledButtonHeight
584+
);
585+
586+
cancelButtonRect = new Rectangle(
587+
(int)(buttonCenterX + buttonSpacing / 2f),
588+
(int)buttonY,
589+
(int)scaledButtonWidth,
590+
(int)scaledButtonHeight
591+
);
592+
588593
DrawButton(spriteBatch, confirmButtonRect, ConfirmText.Value, confirmHoverAnim, confirmPressAnim, alpha, true, scale);
589594
DrawButton(spriteBatch, cancelButtonRect, CancelText.Value, cancelHoverAnim, cancelPressAnim, alpha, false, scale);
590595
}
591596

597+
private void DrawItemShowcasePanel(SpriteBatch spriteBatch, Item item, Rectangle rect, float alpha, float scale) {
598+
Texture2D pixel = VaultAsset.placeholder2.Value;
599+
600+
//展示框背景(深色带渐变)
601+
Color bgTop = new Color(35, 30, 22) * (alpha * 0.9f);
602+
Color bgBottom = new Color(25, 22, 16) * (alpha * 0.9f);
603+
DrawGradientRoundedRect(spriteBatch, rect, bgTop, bgBottom, 8f);
604+
605+
//展示框边框
606+
Color borderColor = new Color(100, 85, 50) * (alpha * 0.7f);
607+
DrawRoundedRectBorder(spriteBatch, rect, borderColor, 8f, 1);
608+
609+
//内发光
610+
DrawInnerGlow(spriteBatch, rect, new Color(255, 180, 80) * (alpha * 0.08f), 8f, 12);
611+
612+
//物品居中位置
613+
Vector2 itemCenter = new(rect.X + rect.Width / 2f, rect.Y + rect.Height / 2f - 10f);
614+
float floatOffset = MathF.Sin(itemFloatPhase) * 3f;
615+
Vector2 itemPos = itemCenter + new Vector2(0, floatOffset);
616+
617+
//使用SoftGlow纹理绘制背景光晕
618+
Texture2D softGlow = CWRAsset.SoftGlow.Value;
619+
float glowScale = (0.8f + itemGlowIntensity * 0.4f) * scale;
620+
Color glowColor = new Color(255, 180, 80, 0) * (alpha * 0.35f * itemGlowIntensity);
621+
spriteBatch.Draw(softGlow, itemPos, null, glowColor, 0f,
622+
softGlow.Size() / 2f, glowScale, SpriteEffects.None, 0f);
623+
624+
//使用StarTexture绘制星芒效果
625+
Texture2D starTex = CWRAsset.SoftGlow.Value;
626+
float starScale = (0.3f + MathF.Sin(globalTime * 2f) * 0.1f) * scale;
627+
Color starColor = new Color(255, 220, 150, 0) * (alpha * 0.5f);
628+
spriteBatch.Draw(starTex, itemPos, null, starColor, globalTime * 0.5f,
629+
starTex.Size() / 2f, starScale, SpriteEffects.None, 0f);
630+
631+
//第二层星芒(反向旋转)
632+
Color starColor2 = new Color(255, 200, 100, 0) * (alpha * 0.3f);
633+
spriteBatch.Draw(starTex, itemPos, null, starColor2, -globalTime * 0.3f,
634+
starTex.Size() / 2f, starScale * 0.7f, SpriteEffects.None, 0f);
635+
636+
//物品图标
637+
if (item.type > ItemID.None) {
638+
float itemScale = 1.3f * scale;
639+
VaultUtils.SimpleDrawItem(spriteBatch, item.type, itemPos,
640+
item.width, itemScale, itemRotation, Color.White * alpha);
641+
}
642+
643+
//等级徽章(在物品下方)
644+
string levelText = $"Lv.{targetLevel}";
645+
Vector2 levelTextSize = FontAssets.MouseText.Value.MeasureString(levelText) * 0.75f * scale;
646+
Vector2 levelPos = new(rect.X + rect.Width / 2f, rect.Y + rect.Height - 20f * scale);
647+
648+
//徽章背景
649+
Rectangle badgeRect = new(
650+
(int)(levelPos.X - levelTextSize.X / 2f - 8f * scale),
651+
(int)(levelPos.Y - levelTextSize.Y / 2f - 4f * scale),
652+
(int)(levelTextSize.X + 16f * scale),
653+
(int)(levelTextSize.Y + 8f * scale)
654+
);
655+
656+
Color badgeBg = new Color(50, 42, 25) * (alpha * 0.95f);
657+
Color badgeBorder = new Color(255, 200, 100) * (alpha * 0.8f);
658+
DrawGradientRoundedRect(spriteBatch, badgeRect, badgeBg, badgeBg * 0.8f, 4f);
659+
DrawRoundedRectBorder(spriteBatch, badgeRect, badgeBorder, 4f, 1);
660+
661+
//等级文字
662+
Vector2 textPos = levelPos - levelTextSize / 2f + new Vector2(0, 2f * scale);
663+
Color levelColor = Color.Lerp(new Color(255, 220, 150), new Color(255, 180, 80), breatheAnim);
664+
Utils.DrawBorderString(spriteBatch, levelText, textPos, levelColor * alpha, 0.75f * scale);
665+
}
666+
592667
private void DrawAnimatedDivider(SpriteBatch spriteBatch, Vector2 start, Vector2 end, float alpha) {
593668
Texture2D pixel = VaultAsset.placeholder2.Value;
594669
float length = (end - start).Length();
670+
if (length < 1f) return;
595671
Vector2 dir = Vector2.Normalize(end - start);
596672

597673
//底层线条
@@ -602,69 +678,13 @@ private void DrawAnimatedDivider(SpriteBatch spriteBatch, Vector2 start, Vector2
602678
//流光效果
603679
float shimmerT = (globalTime * 0.5f) % 1f;
604680
Vector2 shimmerPos = Vector2.Lerp(start, end, shimmerT);
605-
Color shimmerColor = new Color(255, 200, 100) * (alpha * 0.8f);
681+
Color shimmerColor = new Color(255, 200, 100, 0) * (alpha * 0.8f);
606682

607-
//流光主体
608-
float shimmerWidth = length * 0.15f;
609-
spriteBatch.Draw(pixel, shimmerPos - dir * shimmerWidth / 2f, new Rectangle(0, 0, 1, 1),
610-
shimmerColor, 0f, new Vector2(0, 0.5f), new Vector2(shimmerWidth, 2f), SpriteEffects.None, 0f);
611-
612-
//流光光晕
613-
spriteBatch.Draw(pixel, shimmerPos - dir * shimmerWidth, new Rectangle(0, 0, 1, 1),
614-
shimmerColor * 0.3f, 0f, new Vector2(0, 0.5f), new Vector2(shimmerWidth * 2f, 4f), SpriteEffects.None, 0f);
615-
}
616-
617-
private void DrawItemShowcase(SpriteBatch spriteBatch, Item item, Vector2 center, float alpha, float scale) {
618-
Texture2D pixel = VaultAsset.placeholder2.Value;
619-
620-
//物品浮动效果
621-
float floatOffset = MathF.Sin(itemFloatPhase) * 4f;
622-
Vector2 itemPos = center + new Vector2(0, floatOffset);
623-
624-
//背景光环
625-
float glowSize = 50f + itemGlowIntensity * 20f;
626-
Color glowColor = new Color(255, 180, 80) * (alpha * 0.2f * itemGlowIntensity);
627-
for (int i = 3; i >= 0; i--) {
628-
float layerSize = glowSize * (1f + i * 0.3f);
629-
float layerAlpha = 0.15f / (i + 1);
630-
spriteBatch.Draw(pixel, itemPos, new Rectangle(0, 0, 1, 1),
631-
glowColor * layerAlpha, globalTime * 0.2f + i * 0.5f,
632-
new Vector2(0.5f), new Vector2(layerSize), SpriteEffects.None, 0f);
633-
}
634-
635-
//旋转光芒
636-
int rayCount = 6;
637-
for (int i = 0; i < rayCount; i++) {
638-
float rayAngle = MathHelper.TwoPi * i / rayCount + globalTime * 0.3f;
639-
float rayLength = 35f + MathF.Sin(globalTime * 2f + i) * 10f;
640-
Color rayColor = new Color(255, 200, 100) * (alpha * 0.3f);
641-
642-
spriteBatch.Draw(pixel, itemPos, new Rectangle(0, 0, 1, 1), rayColor,
643-
rayAngle, new Vector2(0, 0.5f), new Vector2(rayLength, 2f), SpriteEffects.None, 0f);
644-
}
645-
646-
//物品图标
647-
if (item.type > ItemID.None) {
648-
float itemScale = 1.2f * scale;
649-
VaultUtils.SimpleDrawItem(spriteBatch, item.type, itemPos,
650-
item.width, itemScale, itemRotation, Color.White * alpha);
651-
}
652-
653-
//等级徽章
654-
string levelText = $"Lv.{targetLevel}";
655-
Vector2 levelPos = itemPos + new Vector2(30f, -20f);
656-
Color badgeColor = new Color(60, 50, 30) * (alpha * 0.9f);
657-
Color badgeBorder = new Color(255, 200, 100) * alpha;
658-
659-
//徽章背景
660-
Vector2 textSize = FontAssets.MouseText.Value.MeasureString(levelText) * 0.7f;
661-
Rectangle badgeRect = new((int)(levelPos.X - textSize.X / 2 - 6), (int)(levelPos.Y - textSize.Y / 2 - 3),
662-
(int)(textSize.X + 12), (int)(textSize.Y + 6));
663-
spriteBatch.Draw(pixel, badgeRect, new Rectangle(0, 0, 1, 1), badgeColor);
664-
DrawRoundedRectBorder(spriteBatch, badgeRect, badgeBorder, 3f, 1);
665-
666-
Utils.DrawBorderString(spriteBatch, levelText, levelPos - textSize / 2 + new Vector2(0, 2),
667-
new Color(255, 220, 150) * alpha, 0.7f);
683+
//使用SoftGlow纹理绘制流光
684+
Texture2D softGlow = CWRAsset.SoftGlow.Value;
685+
float glowScale = 0.15f;
686+
spriteBatch.Draw(softGlow, shimmerPos, null, shimmerColor * 0.6f, 0f,
687+
softGlow.Size() / 2f, new Vector2(glowScale * 2f, glowScale * 0.5f), SpriteEffects.None, 0f);
668688
}
669689

670690
private void DrawButton(SpriteBatch spriteBatch, Rectangle rect, string text,

0 commit comments

Comments
 (0)