Mp3读取,Effect Remove

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-07-12 18:27:10 +08:00
parent 2ccac78620
commit 47ec9ddb21
164 changed files with 308674 additions and 50659 deletions

View File

@@ -109,18 +109,19 @@ namespace Ichni.RhythmGame
if ((attachedGameElement as IHaveColorSubmodule).haveBaseColor)
{
// var baseColor = inspector.GenerateBaseColorPicker(this, subcontainer, "Base Color", nameof(originalBaseColor));
// baseColor.AddListenerFunction(Refresh);
var baseColor = inspector.GenerateBaseColorPicker(this, subcontainer, "Base Color", nameof(originalBaseColor));
baseColor.AddListenerFunction(Refresh);
// 新增HSV轮盘
var hsvDrawer = inspector.GenerateHsvDrawer(this, subcontainer, "HSV", nameof(originalBaseColor));
hsvDrawer.AddListenerFunction(Refresh);
baseColor.hsvDrawer = hsvDrawer;
hsvDrawer.baseColorPicker = baseColor;
if (attachedGameElement.childElementList.Exists(x => x is BaseColorChange))
{
// baseColor.title.text += " (Occupied by Animation)";
// baseColor.canvasGroup.interactable = false;
baseColor.title.text += " (Occupied by Animation)";
baseColor.canvasGroup.interactable = false;
hsvDrawer.title.text += " (Occupied by Animation)";
hsvDrawer.canvasGroup.interactable = false;
hsvDrawer.gameObject.SetActive(false); // 隐藏HSV轮盘
}
}

View File

@@ -60,12 +60,17 @@ namespace Ichni.RhythmGame
{
(EditorManager.instance.beatmapContainer).lowPriorityActions.Add(() =>
{
effectList.Add(effectBM.ConvertToGameType(attachedGameElement));
var a = effectBM.ConvertToGameType(attachedGameElement);
effectList.Add(a);
a.AccommodatingList = effectList;
});
}
else
{
effectList.Add(effectBM.ConvertToGameType(attachedGameElement));
var a = effectBM.ConvertToGameType(attachedGameElement);
effectList.Add(a);
a.AccommodatingList = effectList;
}
}
@@ -103,6 +108,7 @@ namespace Ichni.RhythmGame
{
newEffect.attachedGameElement = attachedGameElement;
effectCollection[effect.Key].Add(newEffect);
newEffect.AccommodatingList = effectCollection[effect.Key];
inspectorMain.SetInspector(attachedGameElement);
}
else
@@ -173,6 +179,7 @@ namespace Ichni.RhythmGame
foreach (var effectBase in effect.Value)
{
effectList.Add(effectBase.ConvertToBM());
}
effectCollection.Add(effect.Key, effectList);
}
@@ -349,7 +356,21 @@ namespace Ichni.RhythmGame
}
public List<EffectBase> AccommodatingList;
public abstract void SetUpInspector();
public void SetRemove(DynamicUISubcontainer effectSettings)
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var RemoveButtom = inspector.GenerateButton(this, effectSettings, "Remove", () =>
{
nowEffectState = EffectState.Before;
AccommodatingList.Remove(this);
EditorManager.instance.uiManager.inspector.SetInspector(attachedGameElement);
});
}
}
namespace Beatmap

View File

@@ -5,7 +5,7 @@ using System.IO;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
using NLayer;
namespace Ichni.RhythmGame
{
public class SongInformation : IBaseElement
@@ -35,7 +35,7 @@ namespace Ichni.RhythmGame
string extension = Path.GetExtension(songLocation).ToLower();
song = extension switch
{
".mp3" => ES3.LoadAudio(songLocation, AudioType.MPEG),
".mp3" => LoadMP3(songLocation),
".ogg" => ES3.LoadAudio(songLocation, AudioType.OGGVORBIS),
".wav" => ES3.LoadAudio(songLocation, AudioType.WAV),
_ => throw new Exception("Unsupported audio format: " + extension)
@@ -46,6 +46,22 @@ namespace Ichni.RhythmGame
}
songLength = song.length;
}
private AudioClip LoadMP3(string filepath)//猜猜我从哪里偷的
{
string filename = System.IO.Path.GetFileNameWithoutExtension(filepath);
MpegFile mpegFile = new MpegFile(filepath);
// assign samples into AudioClip
AudioClip ac = AudioClip.Create(filename,
(int)(mpegFile.Length / sizeof(float) / mpegFile.Channels),
mpegFile.Channels,
mpegFile.SampleRate,
true,
data => { int actualReadCount = mpegFile.ReadSamples(data, 0, data.Length); },
position => { mpegFile = new MpegFile(filepath); });
return ac;
}
public void SaveBM()
{