2025-02-19 09:15:51 -05:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-02-19 19:01:21 -05:00
|
|
|
|
using Ichni.RhythmGame;
|
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
2025-02-19 09:15:51 -05:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2025-02-19 19:01:21 -05:00
|
|
|
|
namespace Ichni.Editor
|
2025-02-19 09:15:51 -05:00
|
|
|
|
{
|
2025-02-19 19:01:21 -05:00
|
|
|
|
public class OperationManager
|
2025-02-19 09:15:51 -05:00
|
|
|
|
{
|
2025-02-19 19:01:21 -05:00
|
|
|
|
public GameElement currentSelectedElement { get; private set; }
|
2025-02-19 09:15:51 -05:00
|
|
|
|
|
2025-02-19 19:06:26 -05:00
|
|
|
|
public CopyPasteDeleteModule CopyPasteDeleteModule;
|
2025-02-19 19:01:21 -05:00
|
|
|
|
|
|
|
|
|
|
public OperationManager()
|
|
|
|
|
|
{
|
2025-02-19 19:06:26 -05:00
|
|
|
|
CopyPasteDeleteModule = new CopyPasteDeleteModule();
|
2025-02-19 19:01:21 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SelectElement(GameElement gameElement)
|
|
|
|
|
|
{
|
2025-03-20 19:30:42 -04:00
|
|
|
|
if (currentSelectedElement != null)
|
2025-02-20 15:25:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
currentSelectedElement.connectedTab.isSelected = false;
|
2025-03-20 19:30:42 -04:00
|
|
|
|
if (currentSelectedElement.connectedTab.BgImage != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
|
|
|
|
|
|
}
|
2025-02-20 15:25:42 +08:00
|
|
|
|
}
|
2025-03-20 19:30:42 -04:00
|
|
|
|
|
2025-02-19 19:01:21 -05:00
|
|
|
|
currentSelectedElement = gameElement;
|
2025-02-20 15:25:42 +08:00
|
|
|
|
currentSelectedElement.connectedTab.isSelected = true;
|
|
|
|
|
|
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f,0.5f, 0.5f, 0.2f);
|
2025-02-19 19:01:21 -05:00
|
|
|
|
}
|
2025-02-19 09:15:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-19 19:06:26 -05:00
|
|
|
|
public class CopyPasteDeleteModule
|
2025-02-19 09:15:51 -05:00
|
|
|
|
{
|
2025-02-19 19:01:21 -05:00
|
|
|
|
public GameElement copiedElement;
|
2025-02-21 01:03:01 -05:00
|
|
|
|
public List<GameElement> pastedElementList;
|
|
|
|
|
|
|
2025-02-19 19:01:21 -05:00
|
|
|
|
public void CopyElement(GameElement gameElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWindow.Log("Copied element: " + gameElement.elementName);
|
|
|
|
|
|
copiedElement = gameElement;
|
|
|
|
|
|
}
|
2025-02-19 09:15:51 -05:00
|
|
|
|
|
2025-02-19 19:01:21 -05:00
|
|
|
|
public void PasteElement(GameElement parentElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (copiedElement == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWindow.Log("No element copied.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LogWindow.Log("Pasted element: " + copiedElement.elementName + " to " + parentElement.elementName);
|
2025-02-21 01:03:01 -05:00
|
|
|
|
pastedElementList = new List<GameElement>();
|
2025-02-19 19:01:21 -05:00
|
|
|
|
AffiliatedPaste(copiedElement, parentElement);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-19 19:06:26 -05:00
|
|
|
|
public void DeleteElement(GameElement gameElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWindow.Log("Deleted element: " + gameElement.elementName + " and all its children.");
|
|
|
|
|
|
|
|
|
|
|
|
if (gameElement.parentElement != null)
|
|
|
|
|
|
{
|
2025-02-20 19:36:49 -05:00
|
|
|
|
gameElement.parentElement.childElementList.Remove(gameElement); //从父物体的子物体列表中移除,避免报null
|
2025-02-19 19:06:26 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gameElement.Delete();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-20 19:36:49 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用递归的方式复制粘贴物体及其所有子物体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="gameElement">将要被粘贴的物体</param>
|
|
|
|
|
|
/// <param name="parent">(将要)被粘贴物体的父物体</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private void AffiliatedPaste(GameElement gameElement, GameElement parent)
|
2025-02-19 19:01:21 -05:00
|
|
|
|
{
|
|
|
|
|
|
gameElement.SaveBM();
|
|
|
|
|
|
GameElement pastedElement = (gameElement.matchedBM as GameElement_BM).DuplicateBM(parent);
|
2025-02-21 01:03:01 -05:00
|
|
|
|
pastedElementList.Add(pastedElement);
|
2025-02-19 19:01:21 -05:00
|
|
|
|
|
|
|
|
|
|
gameElement.submoduleList.ForEach(submodule =>
|
|
|
|
|
|
{
|
2025-02-21 01:03:01 -05:00
|
|
|
|
Debug.Log(submodule.GetType() + " is pasted.");
|
2025-02-19 19:01:21 -05:00
|
|
|
|
submodule.SaveBM();
|
|
|
|
|
|
(submodule.matchedBM as Submodule_BM).DuplicateBM(pastedElement);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (gameElement.childElementList != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < gameElement.childElementList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
AffiliatedPaste(gameElement.childElementList[i], pastedElement);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-19 09:15:51 -05:00
|
|
|
|
}
|
2025-02-19 19:01:21 -05:00
|
|
|
|
}
|