diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 4f46ff05..a3aed7df 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs b/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs index b3f445c3..b40e1be5 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs @@ -115,6 +115,9 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori public int ExpressionId => _expressionId; public bool IsThinking => _isThinking; + public float ThinkingStartTime => _thinkingStartTime; + public int ThinkingPhaseIndex => _thinkingPhaseIndex; + public bool ThinkingPhaseRetry => _thinkingPhaseRetry; public void InitializeConversation(string eventDefName) { if (string.IsNullOrWhiteSpace(eventDefName)) diff --git a/Source/WulaFallenEmpire/EventSystem/AI/UI/Dialog_AIConversation.cs b/Source/WulaFallenEmpire/EventSystem/AI/UI/Dialog_AIConversation.cs index 36f102e3..fe2c4582 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/UI/Dialog_AIConversation.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/UI/Dialog_AIConversation.cs @@ -1238,11 +1238,9 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori _isThinking = _core.IsThinking; } - // 右上角:切换到小窗口按钮 // 左上角:切换到小窗口按钮 Rect switchBtnRect = new Rect(0f, 0f, 25f, 25f); - base.DrawCustomButton(switchBtnRect, "-", isEnabled: true); - if (Widgets.ButtonInvisible(switchBtnRect)) + if (DrawHeaderButton(switchBtnRect, "-")) { EventDef eventDef = this.def; if (eventDef != null) @@ -1310,12 +1308,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori Rect descriptionRect = new Rect(paddedRect.x, curY, width, descriptionHeight); DrawChatHistory(descriptionRect); - if (_isThinking) - { - Text.Anchor = TextAnchor.MiddleCenter; - Widgets.Label(descriptionRect, BuildThinkingStatus()); - Text.Anchor = TextAnchor.UpperLeft; - } + // 移除这里的 DrawThinkingIndicator,因为它现在被包含在 DrawChatHistory 内部 curY += descriptionHeight + spacing; @@ -1443,6 +1436,12 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori viewHeight += Text.CalcHeight(text, contentWidth) + padding + 10f; } + // 为思考指示器预留高度 + if (_isThinking) + { + viewHeight += 40f; + } + Rect viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight); if (_scrollToBottom) { @@ -1489,6 +1488,11 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori } curY += height + 10f; } + + if (_isThinking) + { + DrawThinkingIndicator(new Rect(innerPadding, curY, contentWidth, 35f)); + } Widgets.EndScrollView(); } finally @@ -1519,14 +1523,59 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori private string BuildThinkingStatus() { - if (!Prefs.DevMode) - { - return "Wula_AI_Thinking_Simple".Translate(); - } - // 开发者模式下也不再显示秒数计时,只显示阶段信息 - return "Wula_AI_Thinking_Status_NoTimer".Translate(_thinkingPhaseIndex, ThinkingPhaseTotal); + if (_core == null) return "Thinking..."; + + float elapsedSeconds = Mathf.Max(0f, Time.realtimeSinceStartup - _core.ThinkingStartTime); + string elapsedText = elapsedSeconds.ToString("0.0", CultureInfo.InvariantCulture); + return $"P.I.A is thinking... ({elapsedText}s Phase {_core.ThinkingPhaseIndex}/3)"; } + private void DrawThinkingIndicator(Rect rect) + { + GUI.color = Color.gray; + Text.Font = GameFont.Small; + Text.Anchor = TextAnchor.MiddleLeft; + + string status = BuildThinkingStatus(); + + // 简单的左对齐样式 + Rect iconRect = new Rect(rect.x, rect.y + (rect.height - 24f) / 2f, 24f, 24f); + Widgets.DrawBoxSolid(iconRect, Color.gray); + + Rect labelRect = new Rect(iconRect.xMax + 10f, rect.y, rect.width - 34f, rect.height); + Widgets.Label(labelRect, status); + + GUI.color = Color.white; + } + + private bool DrawHeaderButton(Rect rect, string label) + { + 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 + Color textColor = isMouseOver ? Color.white : new Color(0.9f, 0.9f, 0.9f); + + var originalColor = GUI.color; + var originalAnchor = Text.Anchor; + var originalFont = Text.Font; + + GUI.color = buttonColor; + Widgets.DrawBoxSolid(rect, buttonColor); + + GUI.color = textColor; + Text.Font = GameFont.Small; + Text.Anchor = TextAnchor.MiddleCenter; + Widgets.Label(rect, label); + + GUI.color = originalColor; + Text.Anchor = originalAnchor; + Text.Font = originalFont; + + return Widgets.ButtonInvisible(rect); + } + + protected override void DrawSingleOption(Rect rect, EventOption option) { float optionWidth = Mathf.Min(rect.width, Dialog_CustomDisplay.Config.optionSize.x * (rect.width / Dialog_CustomDisplay.Config.windowSize.x)); diff --git a/Source/WulaFallenEmpire/EventSystem/AI/UI/Overlay_WulaLink.cs b/Source/WulaFallenEmpire/EventSystem/AI/UI/Overlay_WulaLink.cs index 7223ac32..3ad03690 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/UI/Overlay_WulaLink.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/UI/Overlay_WulaLink.cs @@ -212,7 +212,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Small; GUI.color = statusColor; - Widgets.Label(textRect, status); + Widgets.Label(textRect, _core.IsThinking ? BuildThinkingStatus() : "Standby"); GUI.color = Color.white; // 右侧:小巧的展开按钮 @@ -568,16 +568,24 @@ namespace WulaFallenEmpire.EventSystem.AI.UI GUI.color = Color.white; } + private string BuildThinkingStatus() + { + if (_core == null) return "Thinking..."; + float elapsedSeconds = Mathf.Max(0f, Time.realtimeSinceStartup - _core.ThinkingStartTime); + string elapsedText = elapsedSeconds.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture); + return $"P.I.A is thinking... ({elapsedText}s Phase {_core.ThinkingPhaseIndex}/3)"; + } + private void DrawThinkingIndicator(Rect rect) { Text.Anchor = TextAnchor.MiddleLeft; GUI.color = Color.gray; Rect iconRect = new Rect(rect.x + 60f, rect.y, 24f, 24f); - Rect labelRect = new Rect(iconRect.xMax + 5f, rect.y, 200f, 24f); + Rect labelRect = new Rect(iconRect.xMax + 5f, rect.y, 400f, 24f); // Draw a simple box as thinking indicator if TexUI is missing Widgets.DrawBoxSolid(iconRect, Color.gray); - Widgets.Label(labelRect, "P.I.A is thinking..."); + Widgets.Label(labelRect, BuildThinkingStatus()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white;