UI系统优化
This commit is contained in:
@@ -8,6 +8,7 @@ using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using BaseGames.Quest;
|
||||
using BaseGames.Editor.Shared;
|
||||
using BaseGames.Localization;
|
||||
|
||||
namespace BaseGames.Editor.Modules
|
||||
{
|
||||
@@ -32,7 +33,7 @@ namespace BaseGames.Editor.Modules
|
||||
private System.Action<UnityEditor.PlayModeStateChange> _playModeHandler;
|
||||
|
||||
// 依赖关系图中 FindAll<QuestSO>() 的静态缓存,同一编辑器会话内复用,避免重复扫描磁盘
|
||||
private static QuestSO[] s_allQuestCache;
|
||||
private static List<QuestSO> s_allQuestCache;
|
||||
private static double s_allQuestCacheTime;
|
||||
private const double k_AllQuestCacheTtl = 5.0; // 秒;超时后下次打开 foldout 时刷新
|
||||
|
||||
@@ -96,62 +97,26 @@ namespace BaseGames.Editor.Modules
|
||||
};
|
||||
}
|
||||
|
||||
filterRow.Add(MakeFilterChip("主线", v => { filterCategory = v ? QuestCategory.Main : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(MakeFilterChip("支线", v => { filterCategory = v ? QuestCategory.Side : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(MakeFilterChip("日常", v => { filterCategory = v ? QuestCategory.Daily : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(MakeFilterChip("隐藏", v => { filterCategory = v ? QuestCategory.Hidden : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("主线", v => { filterCategory = v ? QuestCategory.Main : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("支线", v => { filterCategory = v ? QuestCategory.Side : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("日常", v => { filterCategory = v ? QuestCategory.Daily : (QuestCategory?)null; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("隐藏", v => { filterCategory = v ? QuestCategory.Hidden : (QuestCategory?)null; RebuildFilter(); }));
|
||||
// 分隔
|
||||
var sep = new Label("|");
|
||||
sep.style.opacity = 0.3f;
|
||||
sep.style.marginLeft = 2;
|
||||
sep.style.marginRight = 2;
|
||||
filterRow.Add(sep);
|
||||
filterRow.Add(MakeFilterChip("有前置", v => { filterPrereq = v; RebuildFilter(); }));
|
||||
filterRow.Add(MakeFilterChip("无目标", v => { filterNoObj = v; RebuildFilter(); }));
|
||||
filterRow.Add(MakeFilterChip("可失败", v => { filterCanFail = v; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("有前置", v => { filterPrereq = v; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("无目标", v => { filterNoObj = v; RebuildFilter(); }));
|
||||
filterRow.Add(DataHubEditorKit.MakeFilterChip("可失败", v => { filterCanFail = v; RebuildFilter(); }));
|
||||
|
||||
container.Add(_listPane);
|
||||
_listPane.Refresh();
|
||||
}
|
||||
|
||||
internal static VisualElement MakeFilterChip(string label, System.Action<bool> onToggle)
|
||||
{
|
||||
bool active = false;
|
||||
var chip = new Label(label);
|
||||
chip.style.fontSize = 10;
|
||||
chip.style.paddingLeft = 6;
|
||||
chip.style.paddingRight = 6;
|
||||
chip.style.paddingTop = 2;
|
||||
chip.style.paddingBottom = 2;
|
||||
chip.style.marginRight = 4;
|
||||
chip.style.marginBottom = 2;
|
||||
chip.style.borderTopLeftRadius = 8;
|
||||
chip.style.borderTopRightRadius = 8;
|
||||
chip.style.borderBottomLeftRadius = 8;
|
||||
chip.style.borderBottomRightRadius = 8;
|
||||
chip.style.borderTopWidth = 1;
|
||||
chip.style.borderRightWidth = 1;
|
||||
chip.style.borderBottomWidth = 1;
|
||||
chip.style.borderLeftWidth = 1;
|
||||
chip.style.borderTopColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
||||
chip.style.borderRightColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
||||
chip.style.borderBottomColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
||||
chip.style.borderLeftColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
||||
chip.style.opacity = 0.6f;
|
||||
|
||||
void SetActive(bool on)
|
||||
{
|
||||
active = on;
|
||||
chip.style.opacity = on ? 1f : 0.6f;
|
||||
chip.style.backgroundColor = on
|
||||
? new StyleColor(new Color(0.3f, 0.6f, 1f, 0.25f))
|
||||
: StyleKeyword.None;
|
||||
onToggle(on);
|
||||
}
|
||||
|
||||
chip.RegisterCallback<ClickEvent>(_ => SetActive(!active));
|
||||
return chip;
|
||||
}
|
||||
=> DataHubEditorKit.MakeFilterChip(label, onToggle);
|
||||
|
||||
public void BuildDetailPane(VisualElement container, UnityEngine.Object selected)
|
||||
{
|
||||
@@ -201,7 +166,7 @@ namespace BaseGames.Editor.Modules
|
||||
}
|
||||
else
|
||||
{
|
||||
var resolved = BaseGames.Localization.LocalizationManager.GetEditorPreview(s.displayNameKey, "Quest");
|
||||
var resolved = BaseGames.Localization.LocalizationManager.GetEditorPreview(s.displayNameKey, LocalizationTable.Quest);
|
||||
nameDisplay = resolved != null ? resolved : s.displayNameKey + " ⚠ [缺少本地化]";
|
||||
}
|
||||
SkillModule.AddChip(card, "名称", nameDisplay);
|
||||
@@ -343,7 +308,7 @@ namespace BaseGames.Editor.Modules
|
||||
// 目标描述(本地化预览,灰色小字,显示策划填写的实际内容)
|
||||
if (!string.IsNullOrEmpty(obj.displayTextKey))
|
||||
{
|
||||
var resolved = BaseGames.Localization.LocalizationManager.GetEditorPreview(obj.displayTextKey, "Quest");
|
||||
var resolved = BaseGames.Localization.LocalizationManager.GetEditorPreview(obj.displayTextKey, LocalizationTable.Quest);
|
||||
bool l10nMissing = resolved == null;
|
||||
string descText = l10nMissing ? obj.displayTextKey + " ⚠ [缺少本地化]" : resolved;
|
||||
var desc = new Label(descText);
|
||||
|
||||
Reference in New Issue
Block a user