@@ -204,19 +204,14 @@ namespace Ichni
|
||||
Instantiate(EditorManager.instance.basePrefabs.generalSecondaryWindow,
|
||||
EditorManager.instance.uiManager.mainPage.mainCanvas.GetComponent<RectTransform>()).GetComponent<GeneralSecondaryWindow>();
|
||||
|
||||
QuitWindow.Initialize("Do You Want To Save?", () =>
|
||||
{
|
||||
Destroy(QuitWindow.gameObject);
|
||||
});
|
||||
QuitWindow.Initialize("Do You Want To Save?");
|
||||
|
||||
|
||||
var container = QuitWindow.GenerateContainer("Save confirm");
|
||||
var beatmapToolsSettings = container.GenerateSubcontainer(3);
|
||||
var yesButton = QuitWindow.GenerateButton(beatmapToolsSettings, "Yes", () =>
|
||||
{
|
||||
isQuit = true;
|
||||
EditorManager.instance.projectManager.saveManager.Save();
|
||||
Application.Quit();
|
||||
SaveAndQuit();
|
||||
|
||||
});
|
||||
var noButton = QuitWindow.GenerateButton(beatmapToolsSettings, "No", () =>
|
||||
@@ -236,5 +231,12 @@ namespace Ichni
|
||||
// }
|
||||
|
||||
}
|
||||
async void SaveAndQuit()
|
||||
{
|
||||
isQuit = true;
|
||||
LogWindow.Log("Start Saving...", Color.yellow);
|
||||
await projectManager.saveManager.SaveAllCoroutine();
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,9 @@ namespace Ichni.Editor
|
||||
public partial class InputListener : MonoBehaviour
|
||||
{
|
||||
public static InputListener instance;
|
||||
private PointerEventData pointerEventData;
|
||||
private bool isPointerOverUI;
|
||||
public bool isPointerOverUI;
|
||||
public TMP_Text hoveredUIText;
|
||||
public GameObject hoveredUI;
|
||||
//public GameObject hoveredUI;
|
||||
public EventSystem eventSystem;
|
||||
public List<GraphicRaycaster> graphicRaycasters;
|
||||
private List<SelectionConnector> lastHitConnectors = new List<SelectionConnector>();
|
||||
@@ -47,7 +46,7 @@ namespace Ichni.Editor
|
||||
if (currentMousePosition != lastMousePosition || frameCount % uiCheckFrameInterval == 0)
|
||||
{
|
||||
lastMousePosition = currentMousePosition;
|
||||
isPointerOverUI = IsPointerOverUI(out hoveredUI);
|
||||
isPointerOverUI = IsPointerOverUI();
|
||||
}
|
||||
SceneCameraOperation();
|
||||
MusicPlayerOperation();
|
||||
@@ -152,6 +151,19 @@ namespace Ichni.Editor
|
||||
{
|
||||
StartCoroutine(EditorManager.instance.musicPlayer.PlayBackMusic());
|
||||
}
|
||||
if (Keyboard.current.leftCtrlKey.isPressed)
|
||||
{
|
||||
if (Keyboard.current.rightArrowKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.musicPlayer.audioSource.pitch += 0.1f;
|
||||
LogWindow.Log($"Music pitch: {EditorManager.instance.musicPlayer.audioSource.pitch}", Color.white);
|
||||
}
|
||||
else if (Keyboard.current.leftArrowKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.musicPlayer.audioSource.pitch -= 0.1f;
|
||||
LogWindow.Log($"Music pitch: {EditorManager.instance.musicPlayer.audioSource.pitch}", Color.white);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,68 +320,34 @@ namespace Ichni.Editor
|
||||
{
|
||||
private TMP_Text UIText => EditorManager.instance.UIText;
|
||||
|
||||
public bool IsPointerOverUI(out GameObject hoveredUI)
|
||||
{
|
||||
hoveredUI = null;
|
||||
// 类级别缓存
|
||||
private PointerEventData EventData;
|
||||
private List<RaycastResult> raycastResults = new List<RaycastResult>();
|
||||
|
||||
public bool IsPointerOverUI()
|
||||
{
|
||||
if (Mouse.current == null) return false;
|
||||
|
||||
pointerEventData = new PointerEventData(eventSystem)
|
||||
if (EventData == null)
|
||||
{
|
||||
position = Mouse.current.position.ReadValue()
|
||||
};
|
||||
EventData = new PointerEventData(eventSystem);
|
||||
}
|
||||
EventData.position = Mouse.current.position.ReadValue();
|
||||
|
||||
List<RaycastResult> allResults = new List<RaycastResult>();
|
||||
raycastResults.Clear(); // 复用列表
|
||||
EventSystem.current.RaycastAll(EventData, raycastResults);
|
||||
|
||||
// 使用EventSystem的RaycastAll来确保检测所有UI
|
||||
EventSystem.current.RaycastAll(pointerEventData, allResults);
|
||||
|
||||
// 或者手动检测所有GraphicRaycaster
|
||||
foreach (var raycaster in FindObjectsOfType<GraphicRaycaster>())
|
||||
for (int i = 0; i < raycastResults.Count; i++)
|
||||
{
|
||||
if (!raycaster.enabled || !raycaster.gameObject.activeInHierarchy)
|
||||
continue;
|
||||
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
raycaster.Raycast(pointerEventData, results);
|
||||
allResults.AddRange(results);
|
||||
var result = raycastResults[i];
|
||||
if (result.gameObject != null &&
|
||||
result.gameObject.activeInHierarchy &&
|
||||
result.gameObject.GetComponent<RectTransform>() != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 移除无效结果
|
||||
allResults.RemoveAll(r =>
|
||||
r.gameObject == null ||
|
||||
!r.gameObject.activeInHierarchy ||
|
||||
!r.gameObject.GetComponent<RectTransform>());
|
||||
|
||||
if (allResults.Count > 0)
|
||||
{
|
||||
// 完整排序
|
||||
// allResults.Sort((a, b) =>
|
||||
// {
|
||||
// // 先按sorting layer
|
||||
// int layerCompare = SortingLayer.GetLayerValueFromID(b.sortingLayer)
|
||||
// .CompareTo(SortingLayer.GetLayerValueFromID(a.sortingLayer));
|
||||
// if (layerCompare != 0) return layerCompare;
|
||||
|
||||
// // 再按sorting order
|
||||
// int orderCompare = b.sortingOrder.CompareTo(a.sortingOrder);
|
||||
// if (orderCompare != 0) return orderCompare;
|
||||
|
||||
// // 最后按depth
|
||||
// return b.depth.CompareTo(a.depth);
|
||||
// });
|
||||
|
||||
// hoveredUI = allResults[0].gameObject;
|
||||
// string text = $"UI: {hoveredUI.name}, Layer: {SortingLayer.IDToName(allResults[0].sortingLayer)}, Order: {allResults[0].sortingOrder}";
|
||||
// if (UIText.text != text)
|
||||
// {
|
||||
// UIText.text = text;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//UIText.text = "No UI";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class NoteManager : MonoBehaviour
|
||||
{
|
||||
private List<(NoteBase note, float activationTime, float finishTime)> pendingNotes = new List<(NoteBase, float, float)>();
|
||||
public List<(NoteBase note, float activationTime, float finishTime)> pendingNotes = new List<(NoteBase, float, float)>();
|
||||
private int nextNoteIndex = 0;
|
||||
|
||||
|
||||
public void RegisterNote(NoteBase note, float activationTime, float finishTime)
|
||||
{
|
||||
pendingNotes.Add((note, activationTime, finishTime));
|
||||
AllNotesRegistered();
|
||||
}
|
||||
|
||||
// 在所有物体注册完毕后,对列表进行一次排序
|
||||
@@ -20,20 +22,39 @@ namespace Ichni.RhythmGame
|
||||
pendingNotes.Sort((a, b) => a.activationTime.CompareTo(b.activationTime));
|
||||
}
|
||||
|
||||
void Update()
|
||||
void LateUpdate()
|
||||
{
|
||||
foreach ((NoteBase note, float activationTime, float finishTime) note in pendingNotes)
|
||||
List<(NoteBase note, float activationTime, float finishTime)> toRemove = new List<(NoteBase, float, float)>();
|
||||
foreach ((NoteBase note, float activationTime, float finishTime) in pendingNotes)
|
||||
{
|
||||
if (EditorManager.instance.songInformation.songTime >= note.activationTime &&
|
||||
EditorManager.instance.songInformation.songTime <= note.finishTime)
|
||||
if (note == null)
|
||||
{
|
||||
note.note.gameObject.SetActive(true);
|
||||
toRemove.Add((note, activationTime, finishTime));
|
||||
continue;
|
||||
}
|
||||
if (EditorManager.instance.songInformation.songTime >= activationTime &&
|
||||
EditorManager.instance.songInformation.songTime <= finishTime)
|
||||
{
|
||||
if (!note.gameObject.activeSelf)
|
||||
{
|
||||
|
||||
note.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
note.note.gameObject.SetActive(false);
|
||||
if (note.gameObject.activeSelf)
|
||||
{
|
||||
note.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = toRemove.Count - 1; i >= 0; i--)
|
||||
{
|
||||
pendingNotes.Remove(toRemove[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
@@ -111,15 +112,21 @@ namespace Ichni
|
||||
public void Save()
|
||||
{
|
||||
LogWindow.Log("Start Saving...");
|
||||
_ = SaveAllCoroutine();
|
||||
|
||||
SaveProjectInfo();
|
||||
SaveSongInfo();
|
||||
SaveBeatMap();
|
||||
SaveCommandScripts();
|
||||
}
|
||||
public async Task SaveAllCoroutine()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
SaveProjectInfo();
|
||||
SaveSongInfo();
|
||||
SaveBeatMap();
|
||||
SaveCommandScripts();
|
||||
});
|
||||
|
||||
LogWindow.Log("Save Complete", Color.green);
|
||||
}
|
||||
|
||||
private void SaveProjectInfo()
|
||||
{
|
||||
EditorManager.instance.projectInformation.SaveBM();
|
||||
@@ -535,11 +542,11 @@ namespace Ichni
|
||||
File.Delete(oldestSave);
|
||||
saveFiles.RemoveAt(saveFiles.Count - 1);
|
||||
|
||||
LogWindow.Log("AutoSave finished, the oldest file deleted");
|
||||
LogWindow.Log("AutoSaving... , the oldest file deleted");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWindow.Log("AutoSave finished");
|
||||
LogWindow.Log("AutoSaving...");
|
||||
}
|
||||
|
||||
// 依次重命名存档
|
||||
@@ -558,9 +565,17 @@ namespace Ichni
|
||||
|
||||
private void SaveBeatMap(string autoSavePath)
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("Beatmap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
autoSavePath, ProjectManager.SaveSettings);
|
||||
SaveBeatMapCoroutine(autoSavePath);
|
||||
}
|
||||
async void SaveBeatMapCoroutine(string autoSavePath)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("Beatmap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM, autoSavePath, ProjectManager.SaveSettings);
|
||||
});
|
||||
|
||||
LogWindow.Log("Auto-saved", Color.green);
|
||||
}
|
||||
|
||||
private List<string> GetSortedSaveFiles()
|
||||
|
||||
Reference in New Issue
Block a user