89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public class OperationManager
|
|
{
|
|
public GameElement currentSelectedElement { get; private set; }
|
|
|
|
public CopyPasteDeleteModule CopyPasteDeleteModule;
|
|
|
|
public OperationManager()
|
|
{
|
|
CopyPasteDeleteModule = new CopyPasteDeleteModule();
|
|
}
|
|
|
|
public void SelectElement(GameElement gameElement)
|
|
{
|
|
if(currentSelectedElement != null)
|
|
{
|
|
currentSelectedElement.connectedTab.isSelected = false;
|
|
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
|
|
}
|
|
currentSelectedElement = gameElement;
|
|
currentSelectedElement.connectedTab.isSelected = true;
|
|
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f,0.5f, 0.5f, 0.2f);
|
|
}
|
|
}
|
|
|
|
public class CopyPasteDeleteModule
|
|
{
|
|
public GameElement copiedElement;
|
|
|
|
public void CopyElement(GameElement gameElement)
|
|
{
|
|
LogWindow.Log("Copied element: " + gameElement.elementName);
|
|
copiedElement = gameElement;
|
|
}
|
|
|
|
public void PasteElement(GameElement parentElement)
|
|
{
|
|
if (copiedElement == null)
|
|
{
|
|
LogWindow.Log("No element copied.");
|
|
return;
|
|
}
|
|
|
|
LogWindow.Log("Pasted element: " + copiedElement.elementName + " to " + parentElement.elementName);
|
|
AffiliatedPaste(copiedElement, parentElement);
|
|
}
|
|
|
|
public void DeleteElement(GameElement gameElement)
|
|
{
|
|
LogWindow.Log("Deleted element: " + gameElement.elementName + " and all its children.");
|
|
|
|
if (gameElement.parentElement != null)
|
|
{
|
|
gameElement.parentElement.childElementList.Remove(gameElement);
|
|
}
|
|
|
|
gameElement.Delete();
|
|
}
|
|
|
|
private GameElement AffiliatedPaste(GameElement gameElement, GameElement parent)
|
|
{
|
|
gameElement.SaveBM();
|
|
GameElement pastedElement = (gameElement.matchedBM as GameElement_BM).DuplicateBM(parent);
|
|
|
|
gameElement.submoduleList.ForEach(submodule =>
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
|
|
return pastedElement;
|
|
}
|
|
}
|
|
} |