zc
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -45,9 +45,9 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
this.forcePause = false;
|
||||
this.absorbInputAroundWindow = false;
|
||||
this.closeOnClickedOutside = false;
|
||||
this.closeOnAccept = false; // 防止 Enter 键误关闭
|
||||
this.closeOnAccept = false; // 防止 Enter 键误关闭
|
||||
this.doWindowBackground = false; // We draw our own
|
||||
this.drawShadow = false; // 禁用阴影
|
||||
this.drawShadow = false; // 禁用阴影
|
||||
this.draggable = true;
|
||||
this.resizeable = true;
|
||||
this.preventCameraMotion = false;
|
||||
@@ -65,16 +65,16 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
|
||||
if (_isMinimized)
|
||||
{
|
||||
// 最小化时保持当前位置,只调整大小
|
||||
// 最小化时保持当前位置,只调整大小
|
||||
windowRect.width = _minimizedSize.x;
|
||||
windowRect.height = _minimizedSize.y;
|
||||
// 确保不超出屏幕边界
|
||||
// 确保不超出屏幕边界
|
||||
windowRect.x = Mathf.Clamp(windowRect.x, 0, Verse.UI.screenWidth - _minimizedSize.x);
|
||||
windowRect.y = Mathf.Clamp(windowRect.y, 0, Verse.UI.screenHeight - _minimizedSize.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 展开时居中到屏幕中心
|
||||
// 展开时居中到屏幕中心
|
||||
windowRect.width = _expandedSize.x;
|
||||
windowRect.height = _expandedSize.y;
|
||||
windowRect.x = (Verse.UI.screenWidth - _expandedSize.x) / 2f;
|
||||
@@ -183,7 +183,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
Color statusColor = _core.IsThinking ? Color.yellow : Color.green;
|
||||
|
||||
GUI.color = statusColor;
|
||||
Widgets.Label(statusRect, $"鈼?{status}");
|
||||
Widgets.Label(statusRect, $"鈼?{status}");
|
||||
GUI.color = Color.white;
|
||||
|
||||
// Unread Badge
|
||||
@@ -245,17 +245,17 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
titleRect.x += 10f;
|
||||
Widgets.Label(titleRect, _def.characterName ?? "MomoTalk");
|
||||
|
||||
// Header Icons (Minimize/Close) - 自定义样式
|
||||
// Header Icons (Minimize/Close) - 自定义样式
|
||||
Rect closeRect = new Rect(rect.width - 35f, 10f, 25f, 25f);
|
||||
Rect minRect = new Rect(rect.width - 65f, 10f, 25f, 25f);
|
||||
|
||||
// 最小化按钮
|
||||
// 最小化按钮
|
||||
if (DrawHeaderButton(minRect, "-"))
|
||||
{
|
||||
ToggleMinimize();
|
||||
}
|
||||
|
||||
// 关闭按钮
|
||||
// 关闭按钮
|
||||
if (DrawHeaderButton(closeRect, "X"))
|
||||
{
|
||||
Close();
|
||||
@@ -269,8 +269,8 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
{
|
||||
bool isMouseOver = Mouse.IsOver(rect);
|
||||
Color buttonColor = isMouseOver
|
||||
? new Color(0.6f, 0.3f, 0.3f, 1f) // Hover: 深红色
|
||||
: new Color(0.4f, 0.2f, 0.2f, 0.8f); // Normal: 暗红色
|
||||
? new Color(0.6f, 0.3f, 0.3f, 1f) // Hover: 深红色
|
||||
: new Color(0.4f, 0.2f, 0.2f, 0.8f); // Normal: 暗红色
|
||||
Color textColor = isMouseOver ? Color.white : new Color(0.9f, 0.9f, 0.9f);
|
||||
|
||||
var originalColor = GUI.color;
|
||||
@@ -301,8 +301,9 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
var displayHistory = new List<(string role, string message, string displayText)>();
|
||||
foreach (var msg in history)
|
||||
{
|
||||
// Skip tool/toolcall/system messages in normal mode
|
||||
if ((msg.role == "tool" || msg.role == "toolcall" || msg.role == "system") && !Prefs.DevMode) continue;
|
||||
// Skip tool/toolcall messages to avoid empty spacing
|
||||
if (msg.role == "tool" || msg.role == "toolcall") continue;
|
||||
if (msg.role == "system" && !Prefs.DevMode) continue;
|
||||
|
||||
// For assistant messages, strip XML and check if empty
|
||||
string displayText = msg.message;
|
||||
@@ -456,18 +457,18 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
float bubbleHeight = textHeight + (BubblePadding * 2);
|
||||
float bubbleWidth = Mathf.Min(Text.CalcSize(text).x + (BubblePadding * 2) + 10f, maxBubbleWidth);
|
||||
|
||||
// 气泡位置 - 右对齐,留出箭头空间
|
||||
// 气泡位置 - 右对齐,留出箭头空间
|
||||
float arrowSize = 8f;
|
||||
Rect bubbleRect = new Rect(rect.xMax - bubbleWidth - arrowSize - 5f, rect.y, bubbleWidth, bubbleHeight);
|
||||
|
||||
// 绘制圆角气泡背景 - 蓝色 (Sensei color)
|
||||
// 绘制圆角气泡背景 - 蓝色 (Sensei color)
|
||||
Color bubbleColor = new Color(0.29f, 0.54f, 0.78f, 1f); // #4a8ac6 MomoTalk Sensei blue
|
||||
DrawRoundedBubble(bubbleRect, bubbleColor, 8f);
|
||||
|
||||
// 绘制右侧箭头
|
||||
// 绘制右侧箭头
|
||||
DrawBubbleArrow(bubbleRect.xMax, bubbleRect.y + 10f, arrowSize, bubbleColor, false);
|
||||
|
||||
// 绘制文字
|
||||
// 绘制文字
|
||||
GUI.color = Color.white;
|
||||
Text.Anchor = TextAnchor.MiddleLeft;
|
||||
Widgets.Label(bubbleRect.ContractedBy(BubblePadding), text);
|
||||
@@ -480,11 +481,11 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
float avatarX = 10f;
|
||||
Rect avatarRect = new Rect(avatarX, rect.y, AvatarSize, AvatarSize);
|
||||
|
||||
// 绘制圆形头像背景
|
||||
// 绘制圆形头像背景
|
||||
Color avatarBgColor = new Color(0.2f, 0.2f, 0.25f, 1f);
|
||||
DrawRoundedBubble(avatarRect, avatarBgColor, AvatarSize / 2f);
|
||||
|
||||
// 绘制头像
|
||||
// 绘制头像
|
||||
int expId = _core?.ExpressionId ?? 1;
|
||||
string portraitPath = _def.portraitPath ?? $"Wula/Events/Portraits/WULA_Legion_{expId}";
|
||||
if (expId > 1 && _def.portraitPath == null)
|
||||
@@ -499,7 +500,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
// 显示占位符
|
||||
// 显示占位符
|
||||
GUI.color = Color.white;
|
||||
Text.Font = GameFont.Tiny;
|
||||
Text.Anchor = TextAnchor.MiddleCenter;
|
||||
@@ -507,7 +508,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
}
|
||||
GUI.color = Color.white;
|
||||
|
||||
// 气泡
|
||||
// 气泡
|
||||
float maxBubbleWidth = rect.width * MaxBubbleWidthRatio;
|
||||
float arrowSize = 8f;
|
||||
float bubbleX = avatarRect.xMax + arrowSize + 5f;
|
||||
@@ -520,14 +521,14 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
|
||||
Rect bubbleRect = new Rect(bubbleX, rect.y, bubbleWidth, bubbleHeight);
|
||||
|
||||
// 绘制圆角气泡背景 - 灰色 (Student color)
|
||||
// 绘制圆角气泡背景 - 灰色 (Student color)
|
||||
Color bubbleColor = new Color(0.85f, 0.85f, 0.87f, 1f); // Light gray like MomoTalk
|
||||
DrawRoundedBubble(bubbleRect, bubbleColor, 8f);
|
||||
|
||||
// 绘制左侧箭头
|
||||
// 绘制左侧箭头
|
||||
DrawBubbleArrow(bubbleRect.x, bubbleRect.y + 10f, arrowSize, bubbleColor, true);
|
||||
|
||||
// 绘制文字
|
||||
// 绘制文字
|
||||
GUI.color = new Color(0.1f, 0.1f, 0.1f, 1f); // Dark text
|
||||
Text.Anchor = TextAnchor.MiddleLeft;
|
||||
Widgets.Label(bubbleRect.ContractedBy(BubblePadding), text);
|
||||
@@ -609,17 +610,17 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
return Widgets.ButtonInvisible(rect);
|
||||
}
|
||||
|
||||
// MomoTalk 风格的圆角气泡
|
||||
// MomoTalk 风格的圆角气泡
|
||||
private void DrawRoundedBubble(Rect rect, Color color, float radius)
|
||||
{
|
||||
var originalColor = GUI.color;
|
||||
GUI.color = color;
|
||||
|
||||
// 主体矩形
|
||||
// 主体矩形
|
||||
Widgets.DrawBoxSolid(new Rect(rect.x + radius, rect.y, rect.width - radius * 2, rect.height), color);
|
||||
Widgets.DrawBoxSolid(new Rect(rect.x, rect.y + radius, rect.width, rect.height - radius * 2), color);
|
||||
|
||||
// 四个角的近似圆角
|
||||
// 四个角的近似圆角
|
||||
float step = radius / 4f;
|
||||
for (float dx = 0; dx < radius; dx += step)
|
||||
{
|
||||
@@ -639,13 +640,13 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
GUI.color = originalColor;
|
||||
}
|
||||
|
||||
// MomoTalk 风格的气泡箭头
|
||||
// MomoTalk 风格的气泡箭头
|
||||
private void DrawBubbleArrow(float x, float y, float size, Color color, bool pointLeft)
|
||||
{
|
||||
var originalColor = GUI.color;
|
||||
GUI.color = color;
|
||||
|
||||
// 用小方块模拟三角形箭头
|
||||
// 用小方块模拟三角形箭头
|
||||
float step = size / 4f;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -660,3 +661,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user