优化
This commit is contained in:
@@ -3,8 +3,11 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using DG.Tweening;
|
||||
using Ichni.RhythmGame;
|
||||
using Lean.Pool;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
@@ -24,9 +27,16 @@ namespace Ichni.Editor
|
||||
public Button clipLoadButton;
|
||||
public Button beatmapToolsButton;
|
||||
|
||||
[Title("Search")]
|
||||
public TMP_InputField searchInput;
|
||||
public RectTransform searchResultsRoot;
|
||||
public GameObject searchResultItemPrefab;
|
||||
|
||||
[Title("Windows")]
|
||||
public GeneralSecondaryWindow clipManagementWindow;
|
||||
|
||||
private readonly List<GameObject> searchResultItems = new List<GameObject>();
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
@@ -40,6 +50,84 @@ namespace Ichni.Editor
|
||||
beatmapToolsButton.onClick.AddListener(GenerateBeatmapToolsWindow);
|
||||
//songInfoButton.onClick.AddListener(已经在songinfo好了);
|
||||
//projectInfoButton.onClick.AddListener(已经在projectinfo好了);
|
||||
|
||||
SetupSearch();
|
||||
}
|
||||
|
||||
private void SetupSearch()
|
||||
{
|
||||
searchInput.onValueChanged.AddListener(OnSearchValueChanged);
|
||||
searchInput.onSelect.AddListener(_ =>
|
||||
{
|
||||
searchResultsRoot.transform.DOScaleX(1, 0.25f);
|
||||
searchResultsRoot.gameObject.SetActive(true);
|
||||
});
|
||||
// searchInput.onDeselect.AddListener(_ =>
|
||||
// {
|
||||
// // 延迟隐藏,避免点击结果项时面板先消失了
|
||||
//
|
||||
// });
|
||||
searchResultsRoot.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnSearchValueChanged(string query)
|
||||
{
|
||||
ClearSearchResults();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query)) return;
|
||||
|
||||
string lowerQuery = query.ToLower();
|
||||
|
||||
var matches = EditorManager.instance.beatmapContainer.gameElementList
|
||||
.Where(e => e != null && e.elementName.ToLower().Contains(lowerQuery))
|
||||
.Take(20)
|
||||
.ToList();
|
||||
|
||||
if (matches.Count == 0) return;
|
||||
|
||||
searchResultsRoot.gameObject.SetActive(true);
|
||||
|
||||
foreach (var element in matches)
|
||||
{
|
||||
var item = LeanPool.Spawn(searchResultItemPrefab, searchResultsRoot);
|
||||
var itemText = item.GetComponentInChildren<TMP_Text>();
|
||||
if (itemText != null)
|
||||
itemText.text = element.elementName + " " + element.GetType().ToString();
|
||||
|
||||
var button = item.GetComponentInChildren<Button>();
|
||||
if (button != null)
|
||||
{
|
||||
GameElement captured = element;
|
||||
button.onClick.RemoveAllListeners();
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
EditorManager.instance.uiManager.hierarchy.FindTab(captured);
|
||||
|
||||
searchResultsRoot.transform.DOScaleX(0, 0.25f).OnComplete(() =>
|
||||
{
|
||||
searchInput.text = string.Empty;
|
||||
ClearSearchResults();
|
||||
searchResultsRoot.gameObject.SetActive(false);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
searchResultItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearSearchResults()
|
||||
{
|
||||
foreach (var item in searchResultItems)
|
||||
{
|
||||
if (item != null)
|
||||
LeanPool.Despawn(item);
|
||||
}
|
||||
searchResultItems.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +302,7 @@ namespace Ichni.Editor
|
||||
flick.Refresh();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var ResetNoteAudioButton = beatmapToolsWindow.GenerateButton(beatmapToolsSettings, "Reset Note Audio", () =>
|
||||
{
|
||||
List<NoteBase> allNotes = EditorManager.instance.beatmapContainer.gameElementList.FindAll(x => x is NoteBase).ConvertAll(x => x as NoteBase);
|
||||
@@ -227,11 +315,11 @@ namespace Ichni.Editor
|
||||
{
|
||||
hold.submoduleList.Remove(hold.noteAudioSubmodule);
|
||||
hold.noteAudioSubmodule = null;
|
||||
hold.noteAudioSubmodule = new NoteAudioSubmodule(hold,
|
||||
new List<string>(){"DefaultEndHold"},
|
||||
hold.noteAudioSubmodule = new NoteAudioSubmodule(hold,
|
||||
new List<string>() { "DefaultEndHold" },
|
||||
new List<string>(), new List<string>(),
|
||||
new List<string>(), new List<string>(),
|
||||
new List<string>(){"DefaultStartHold"});
|
||||
new List<string>() { "DefaultStartHold" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +329,8 @@ namespace Ichni.Editor
|
||||
{
|
||||
flick.submoduleList.Remove(flick.noteAudioSubmodule);
|
||||
flick.noteAudioSubmodule = null;
|
||||
flick.noteAudioSubmodule = new NoteAudioSubmodule(flick,
|
||||
new List<string>(){"DefaultFlick"},
|
||||
flick.noteAudioSubmodule = new NoteAudioSubmodule(flick,
|
||||
new List<string>() { "DefaultFlick" },
|
||||
new List<string>(), new List<string>(),
|
||||
new List<string>(), new List<string>(),
|
||||
new List<string>());
|
||||
|
||||
Reference in New Issue
Block a user