StartMenu!

This commit is contained in:
SoulliesOfficial
2025-03-08 14:21:10 -05:00
parent 28e0a6e4b0
commit e0ae43c25c
193 changed files with 43412 additions and 7940 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Ichni.Editor
@@ -50,6 +51,7 @@ namespace Ichni.Editor
colorPreview.color = newValue;
connectedBaseElement.Refresh();
}
public void SliderChange(float value){
inputFieldBaseR.text=sliderR.value.ToString();
inputFieldBaseG.text=sliderG.value.ToString();
@@ -57,5 +59,18 @@ namespace Ichni.Editor
inputFieldBaseA.text=sliderA.value.ToString();
ApplyParameters();
}
public void AddListenerFunction(UnityAction action)
{
inputFieldBaseR.onEndEdit.AddListener(_ => action());
inputFieldBaseG.onEndEdit.AddListener(_ => action());
inputFieldBaseB.onEndEdit.AddListener(_ => action());
inputFieldBaseA.onEndEdit.AddListener(_ => action());
sliderR.onValueChanged.AddListener(_ => action());
sliderG.onValueChanged.AddListener(_ => action());
sliderB.onValueChanged.AddListener(_ => action());
sliderA.onValueChanged.AddListener(_ => action());
}
}
}

View File

@@ -12,6 +12,7 @@ namespace Ichni.Editor
public abstract class DynamicUIElement : MonoBehaviour
{
public TMP_Text title;
public CanvasGroup canvasGroup;
public IBaseElement connectedBaseElement;
/// <summary>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;
@@ -73,5 +74,17 @@ namespace Ichni.Editor
inputFieldEmissionB.text=sliderB.value.ToString();
ApplyParameters();
}
public void AddListenerFunction(UnityAction action)
{
inputFieldEmissionR.onEndEdit.AddListener(_ => action());
inputFieldEmissionG.onEndEdit.AddListener(_ => action());
inputFieldEmissionB.onEndEdit.AddListener(_ => action());
inputFieldEmissionI.onEndEdit.AddListener(_ => action());
sliderR.onValueChanged.AddListener(_ => action());
sliderG.onValueChanged.AddListener(_ => action());
sliderB.onValueChanged.AddListener(_ => action());
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
@@ -53,8 +54,8 @@ namespace Ichni.RhythmGame
colorA.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Color colorOffset = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
targetColorSubmodule.baseColorOffset.Add(colorOffset);
targetColorSubmodule.currentBaseColor = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
targetColorSubmodule.baseColorDirtyMark = true;
}
else
@@ -71,6 +72,34 @@ namespace Ichni.RhythmGame
colorB.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
colorA.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
}
public override void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
base.SetUpInspector();
var container = inspector.GenerateContainer("Base Color Change");
var colorRButton = inspector.GenerateButton(this, container, "Color R",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Color R", nameof(colorR)).SetAsFlexibleFloat();
});
var colorGButton = inspector.GenerateButton(this, container, "Color G",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Color G", nameof(colorG)).SetAsFlexibleFloat();
});
var colorBButton = inspector.GenerateButton(this, container, "Color B",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Color B", nameof(colorB)).SetAsFlexibleFloat();
});
var colorAButton = inspector.GenerateButton(this, container, "Color A",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Color A", nameof(colorA)).SetAsFlexibleFloat();
});
container.SetDeviver(1);
}
}
public partial class BaseColorChange

View File

@@ -53,11 +53,9 @@ namespace Ichni.RhythmGame
colorI.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Color colorOffset = new Color(colorR.value, colorG.value, colorB.value);
float intensityOffset = colorI.value;
targetColorSubmodule.emissionColorOffset.Add(colorOffset);
targetColorSubmodule.emissionIntensityOffset.Add(intensityOffset);
targetColorSubmodule.currentEmissionColor = new Color(colorR.value, colorG.value, colorB.value, 1);
targetColorSubmodule.currentEmissionIntensity = colorI.value;
targetColorSubmodule.emissionColorDirtyMark = true;
}
else

View File

@@ -97,7 +97,7 @@ namespace Ichni.RhythmGame
{
inspector.GenerateCompositeParameterWindow(this, "Position Z", nameof(positionZ)).SetAsFlexibleFloat();
});
var GraphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
var graphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
() =>
{
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Displacement",

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
@@ -75,6 +76,41 @@ namespace Ichni.RhythmGame
matchedBM = new Scale_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
scaleX.ConvertToBM(), scaleY.ConvertToBM(), scaleZ.ConvertToBM());
}
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Scale");
var scaleXButton = inspector.GenerateButton(this, container, "Scale X",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Scale X", nameof(scaleX)).SetAsFlexibleFloat();
});
var scaleYButton = inspector.GenerateButton(this, container, "Scale Y",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Scale Y", nameof(scaleY)).SetAsFlexibleFloat();
});
var scaleZButton = inspector.GenerateButton(this, container, "Scale Z",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Scale Z", nameof(scaleZ)).SetAsFlexibleFloat();
});
var graphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
() =>
{
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Displacement",
new FlexibleFloat[] { scaleX, scaleY, scaleZ },
new string[] { "ScaleX", "ScaleY", "ScaleZ" });
});
container.SetDeviver(1);
}
}
namespace Beatmap

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
@@ -77,6 +78,40 @@ namespace Ichni.RhythmGame
matchedBM = new Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM());
}
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Swirl");
var eulerAngleXButton = inspector.GenerateButton(this, container, "Euler Angle X",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Euler Angle X", nameof(eulerAngleX)).SetAsFlexibleFloat();
});
var eulerAngleYButton = inspector.GenerateButton(this, container, "Euler Angle Y",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Euler Angle Y", nameof(eulerAngleY)).SetAsFlexibleFloat();
});
var eulerAngleZButton = inspector.GenerateButton(this, container, "Euler Angle Z",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Euler Angle Z", nameof(eulerAngleZ)).SetAsFlexibleFloat();
});
var graphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
() =>
{
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Displacement",
new FlexibleFloat[] { eulerAngleX, eulerAngleY, eulerAngleZ },
new string[] { "EulerX", "EulerY", "EulerZ" });
});
container.SetDeviver(1);
}
}
namespace Beatmap

View File

@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using UniRx;
using UnityEngine;
namespace Ichni.RhythmGame
@@ -16,10 +17,6 @@ namespace Ichni.RhythmGame
public Color originalEmissionColor;
public float originalEmissionIntensity;
public List<Color> baseColorOffset = new List<Color>();
public List<Color> emissionColorOffset = new List<Color>();
public List<float> emissionIntensityOffset = new List<float>();
public Color currentBaseColor;
public Color currentEmissionColor;
public float currentEmissionIntensity;
@@ -40,6 +37,9 @@ namespace Ichni.RhythmGame
this.baseColorDirtyMark = false;
this.emissionColorDirtyMark = false;
(attachedGameElement as IHaveColorSubmodule).colorSubmodule = this;
(attachedGameElement as IHaveColorSubmodule).SetColorObserver();
}
public ColorSubmodule(GameElement attachedGameElement, Color originalBaseColor) : base(attachedGameElement)
@@ -57,6 +57,7 @@ namespace Ichni.RhythmGame
this.emissionColorDirtyMark = false;
(attachedGameElement as IHaveColorSubmodule).colorSubmodule = this;
(attachedGameElement as IHaveColorSubmodule).SetColorObserver();
}
public ColorSubmodule(GameElement attachedGameElement, Color originalBaseColor, bool emissionEnabled,
@@ -75,6 +76,7 @@ namespace Ichni.RhythmGame
this.emissionColorDirtyMark = false;
(attachedGameElement as IHaveColorSubmodule).colorSubmodule = this;
(attachedGameElement as IHaveColorSubmodule).SetColorObserver();
}
public override void SaveBM()
@@ -86,20 +88,78 @@ namespace Ichni.RhythmGame
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Color");
var baseColor = inspector.GenerateBaseColorPicker(this, container, "Base Color", nameof(originalBaseColor));
baseColor.AddListenerFunction(Refresh);
if (attachedGameElement.childElementList.Exists(x => x is BaseColorChange))
{
baseColor.title.text += " (Occupied by Animation)";
baseColor.canvasGroup.interactable = false;
}
if ((attachedGameElement as IHaveColorSubmodule).haveEmission)
{
var emissionColor = inspector.GenerateEmissionColorPicker(this, container, "Emission Color",
nameof(emissionEnabled), nameof(originalEmissionColor), nameof(originalEmissionIntensity));
emissionColor.AddListenerFunction(Refresh);
if (attachedGameElement.childElementList.Exists(x => x is EmissionColorChange))
{
emissionColor.title.text += " (Occupied by Animation)";
emissionColor.canvasGroup.interactable = false;
}
}
container.SetDeviver(1);
}
public override void Refresh()
{
currentBaseColor = originalBaseColor;
currentEmissionColor = originalEmissionColor;
baseColorDirtyMark = true;
emissionColorDirtyMark = true;
}
}
public interface IHaveColorSubmodule
{
public ColorSubmodule colorSubmodule { get; set; }
public bool haveEmission { get; }
public void SetColorObserver()
{
GameElement attachedGameElement = colorSubmodule.attachedGameElement;
Observable.EveryUpdate().Subscribe(_ =>
{
if (colorSubmodule == null)
{
return;
}
bool willRefresh = false;
if (colorSubmodule.baseColorDirtyMark)
{
//在动画物体中改变currentColor
colorSubmodule.baseColorDirtyMark = false;
willRefresh = true;
}
if (colorSubmodule.emissionColorDirtyMark)
{
//在动画物体中改变currentColor
colorSubmodule.emissionColorDirtyMark = false;
willRefresh = true;
}
if (willRefresh)
{
attachedGameElement.Refresh();
}
}).AddTo(attachedGameElement);
}
}
namespace Beatmap

View File

@@ -23,7 +23,7 @@ namespace Ichni.RhythmGame
this.songName = songName;
this.bpm = bpm;
this.delay = delay;
songLocation = EditorManager.instance.projectInformation.projectPath + "/" + songName + ".wav";
songLocation = EditorManager.instance.projectInformation.projectPath + "/" + songName;
Debug.Log("Loading song from " + songLocation + " " + ES3.FileExists(songLocation));
song = ES3.LoadAudio(songLocation, AudioType.WAV);
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
@@ -11,15 +12,16 @@ namespace Ichni.RhythmGame
{
public bool isStatic;
public static SubstantialObject GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, GameElement parentElement, string themeBundleName, string objectName, bool isStatic)
public static EnvironmentObject GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement, bool isStatic)
{
EnvironmentObject themeBundleObject =
ThemeBundleManager.instance.GetObject<EnvironmentObject>(themeBundleName, objectName);
EnvironmentObject environmentObject =
Instantiate(themeBundleObject, parentElement.transform).GetComponent<EnvironmentObject>();
environmentObject.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
EnvironmentObject environmentObject =
SubstantialObject.GenerateElement(elementName, id, tags, isFirstGenerated, themeBundleName, objectName, parentElement)
.GetComponent<EnvironmentObject>();
environmentObject.isStatic = isStatic;
environmentObject.gameObject.isStatic = isStatic;
return environmentObject;
}
}
@@ -31,6 +33,38 @@ namespace Ichni.RhythmGame
matchedBM = new EnvironmentObject_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM, themeBundleName, objectName, isStatic);
}
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Generate");
var environmentObjectButton = inspector.GenerateButton(this, container, "Environment Object",
() => TemporaryObject.GenerateElement("New Environment Object", Guid.NewGuid(), new List<string>(),
true, this));
var isStaticToggle = inspector.GenerateToggle(this, container, "Is Static", nameof(isStatic));
isStaticToggle.AddListenerFunction(_ => gameObject.isStatic = isStatic);
var generateContainer = inspector.GenerateContainer("Generate");
var generateDisplacementButton = inspector.GenerateButton(this, generateContainer, "Displacement",
() => Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateSwirlButton = inspector.GenerateButton(this, generateContainer, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateScaleButton = inspector.GenerateButton(this, generateContainer, "Scale",
() => Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateBaseColorChangeButton = inspector.GenerateButton(this, generateContainer, "Base Color Change",
() => BaseColorChange.GenerateElement("New Base Color Change", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
if (haveEmission)
{
var generateEmissionColorChangeButton = inspector.GenerateButton(this, generateContainer, "Emission Color Change",
() => EmissionColorChange.GenerateElement("New Emission Color Change", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
}
}
}
namespace Beatmap
@@ -54,13 +88,13 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
matchedElement = EnvironmentObject.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), themeBundleName, objectName, isStatic);
themeBundleName, objectName,GetElement(attachedElementGuid), isStatic);
}
public override GameElement DuplicateBM(GameElement parent)
{
return EnvironmentObject.GenerateElement(elementName, Guid.NewGuid(), tags, false,
parent, themeBundleName, objectName, isStatic);
themeBundleName, objectName, parent, isStatic);
}
}
}

View File

@@ -13,16 +13,13 @@ namespace Ichni.RhythmGame
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public ColorSubmodule colorSubmodule { get; set; }
public bool haveEmission { get; }
public bool haveEmission => false;
public static SubstantialObject GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
string themeBundleName, string objectName, GameElement parentElement)
{
GameObject themeBundleObject = ThemeBundleManager.instance.GetObject<GameObject>(themeBundleName, objectName);
SubstantialObject substantialObject = Instantiate(themeBundleObject, parentElement.transform).GetComponent<SubstantialObject>();
substantialObject.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
substantialObject.themeBundleName = themeBundleName;

View File

@@ -65,8 +65,8 @@ namespace Ichni.RhythmGame
float size = transformSubmodule.currentScale.x;
Color color = colorSubmodule.currentBaseColor;
transform.position = position;
transform.rotation = Quaternion.LookRotation(normal);
transform.localPosition = position;
transform.localRotation = Quaternion.LookRotation(normal);
transform.localScale = Vector3.one * size;
node = new SplinePoint(position, Vector3.up, normal, size, color);

View File

@@ -50,6 +50,8 @@ namespace Ichni.RhythmGame
{
trackPathSubmodule.ClosePath();
}
Refresh();
}

View File

@@ -76,11 +76,18 @@ namespace Ichni.RhythmGame
var container = inspector.GenerateContainer("Track Time Movable");
var startTimeInputField =
inspector.GenerateInputField(this, container, "Start Time", nameof(trackStartTime));
startTimeInputField.AddListenerFunction(_ => RefreshChildren());
var endTimeInputField = inspector.GenerateInputField(this, container, "End Time", nameof(trackEndTime));
endTimeInputField.AddListenerFunction(_ => RefreshChildren());
var visibleTimeInputField =
inspector.GenerateInputField(this, container, "Visible Time Length", nameof(visibleTrackTimeLength));
var animationCurveDropdown = inspector.GenerateDropdown(this, container, "Animation Curve",
typeof(AnimationCurveType), nameof(animationCurveType));
animationCurveDropdown.AddListenerFunction(_ => RefreshChildren());
var deleteButton = inspector.GenerateButton(this, container, "Delete",
() =>
{
@@ -90,6 +97,17 @@ namespace Ichni.RhythmGame
track.Refresh();
});
}
private void RefreshChildren()
{
track.childElementList.ForEach(child =>
{
if (child is NoteBase note)
{
note.UpdateNoteInTrack();
}
});
}
}
namespace Beatmap

View File

@@ -59,7 +59,17 @@ namespace Ichni
this.elementName = "EditorManager";
this.elementGuid = Guid.Empty;
uiManager.hierarchy.GenerateTab(this, null);
StartCoroutine(DelayLoading());
if (InformationTransistor.instance.isLoadedProject)
{
LoadProject("TestProject");
}
else
{
projectManager.GenerateEmptyProject(InformationTransistor.instance.projectInfo_BM, InformationTransistor.instance.songInfo_BM);
projectManager.saveManager.Save();
}
isLoaded = true;
}
private void Update()
@@ -67,19 +77,17 @@ namespace Ichni
if(isLoaded) projectManager.autoSaveManager.UpdateAutoSave();
}
public IEnumerator DelayLoading()
public void LoadProject(string projectName)
{
StartCoroutine(projectManager.loadManager.Load("TestProject"));
projectManager.loadManager.Load(projectName);
musicPlayer.audioSource.clip = songInformation.song;
yield return new WaitForSeconds(1);//什么时候能加个loading界面
beatmapContainer.gameElementList.ForEach(gameElement =>
{
gameElement.AfterInitialize();
gameElement.Refresh();
});
isLoaded = true;
}
public override void SetUpInspector()
{
IHaveInspection inspector = uiManager.inspector;

View File

@@ -42,20 +42,13 @@ namespace Ichni
autoSaveManager = new AutoSaveManager();
}
public void GenerateProject(string projectName)
public void GenerateEmptyProject(ProjectInformation_BM projectInfo_BM, SongInformation_BM songInfo_BM)
{
EditorManager.instance.projectInformation = new ProjectInformation(projectName, "Soullies", "2.0",
DateTime.Now.ToString(CultureInfo.CurrentCulture), DateTime.Now.ToString(CultureInfo.CurrentCulture),
new List<string>());
EditorManager.instance.songInformation = new SongInformation("TestSong", 120, 0);
projectInfo_BM.ExecuteBM();
songInfo_BM.ExecuteBM();
EditorManager.instance.beatmapContainer = new BeatmapContainer();
EditorManager.instance.commandScripts = new CommandScripts(new List<string>());
//Create project folder
if (!System.IO.Directory.Exists(EditorManager.instance.projectInformation.projectPath))
{
System.IO.Directory.CreateDirectory(EditorManager.instance.projectInformation.projectPath);
}
}
}
@@ -154,16 +147,11 @@ namespace Ichni
public class LoadManager
{
public IEnumerator Load(string projectName)
public void Load(string projectName)
{
LoadProjectInfo(projectName);
LoadSongInfo();
LoadCommandScripts();
while (ThemeBundleManager.instance.waitingBundleAmount != 0)
{
yield return new WaitForEndOfFrame();
}
LoadBeatMap();
LogWindow.Log("Load Complete", Color.green);
}

View File

@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UniRx;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Serialization;
@@ -15,19 +16,25 @@ namespace Ichni
public List<string> selectedThemeBundleList;
public List<ThemeBundle> loadedThemeBundleList;
public int waitingBundleAmount;
public IntReactiveProperty waitingBundleAmount;
private void Awake()
{
instance = this;
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else if (instance != this)
{
Destroy(gameObject);
}
loadedThemeBundleList = new List<ThemeBundle>();
AssetBundle.UnloadAllAssetBundles(true);
LoadAllThemeBundlesAbstract();
//DontDestroyOnLoad(gameObject);
LoadThemeBundle("departure_to_multiverse");
LoadThemeBundle("basic");
//LoadThemeBundle("basic");
//LoadThemeBundle("departure_to_multiverse");
}
public bool TryGetThemeBundle(string themeBundleName, out ThemeBundle themeBundle)
@@ -36,30 +43,14 @@ namespace Ichni
return themeBundle != null;
}
private IEnumerator WaitAndLoad()
public T GetObject<T>(string themeBundleName, string objectName) where T : class
{
while (waitingBundleAmount != 0)
{
yield return null;
}
}
public T GetObject<T>(string themeBundleName, string objectName) where T : class//?
{
var i = loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
if (i == null)
{
Debug.LogError("Object not found");
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == "basic")?.GetObject<T>("BasicNoteTap3D");
}
else
return i;
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
}
public void LoadThemeBundles(List<string> list)
{
waitingBundleAmount = new IntReactiveProperty(list.Count);
foreach (var bundle in list)
{
LoadThemeBundle(bundle);
@@ -68,7 +59,8 @@ namespace Ichni
public void LoadAllThemeBundlesAbstract()
{
string uri = Application.streamingAssetsPath + "/ThemeBundles";
string uri = Application.streamingAssetsPath + "/ThemeBundles/";
if (ES3.DirectoryExists(uri))
{
List<string> allFileList = ES3.GetFiles(uri).ToList();
@@ -83,15 +75,13 @@ namespace Ichni
foreach (var abs in absList)
{
ES3Settings settings = new ES3Settings(uri + "/" + abs, ES3.EncryptionType.None);
themeBundleAbstractList.Add(ES3.Load<ThemeBundleAbstract>("ThemeBundleAbstract", settings));
themeBundleAbstractList.Add(ES3.Load<ThemeBundleAbstract>("ThemeBundleAbstract", uri + abs));
}
}
}
public void LoadThemeBundle(string themeBundleName)
{
waitingBundleAmount++;
StartCoroutine(LoadThemeBundleCoroutine(themeBundleName));
}
@@ -137,7 +127,7 @@ namespace Ichni
}
yield return new WaitForEndOfFrame();
waitingBundleAmount--;
waitingBundleAmount.Value--;
print(themeBundleName + " Done!");
}
}

View File

@@ -0,0 +1,200 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using DG.Tweening;
using Ichni.RhythmGame.Beatmap;
using TMPro;
using UniRx;
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace Ichni.StartMenu
{
public partial class CreateEmptyProjectPage : MonoBehaviour
{
public CanvasGroup canvasGroup;
public Tweener fadeIn, fadeOut;
public TMP_InputField projectNameInputField, creatorNameInputField, bpmInputField, songLocationInputField, delayInputField;
public Button selectSongButton, autoFillSongPathButton;
public Button createEmptyProjectButton;
private OpenFileName songFile;
public string songName;
public ThemeBundleSelector themeBundleSelector;
private void Awake()
{
InitializeAnimations();
InitializeInfoUI();
}
private void Update()
{
if (Keyboard.current.escapeKey.wasPressedThisFrame)
{
fadeOut.Restart();
}
}
private void CreateEmptyProject()
{
string projectPath = Application.streamingAssetsPath + "/Projects/" + projectNameInputField.text;
//Create project folder
if (!Directory.Exists(projectPath))
{
Directory.CreateDirectory(projectPath);
}
InformationTransistor.instance.projectInfo_BM = new ProjectInformation_BM(
projectNameInputField.text,
creatorNameInputField.text,
PlayerSettings.bundleVersion,
DateTime.Now.ToString(CultureInfo.CurrentCulture),
DateTime.Now.ToString(CultureInfo.CurrentCulture),
themeBundleSelector.GetSelectedThemeBundleList());
File.Copy(songLocationInputField.text,
Application.streamingAssetsPath + "/Projects/" +
projectNameInputField.text + "/" + songName, true);
InformationTransistor.instance.songInfo_BM = new SongInformation_BM(
songName, float.Parse(bpmInputField.text),
float.Parse(delayInputField.text));
InformationTransistor.instance.isLoadedProject = false;
//Load ThemeBundles, then go to EditorScene
ThemeBundleManager.instance.LoadThemeBundles(InformationTransistor.instance.projectInfo_BM.selectedThemeBundleList);
ThemeBundleManager.instance.waitingBundleAmount
.Where(amount => amount == 0) // 当 waitingAmount 变为 0 时触发
.First()
.Subscribe(_ =>
{
Debug.Log("All AssetBundles are loaded. Switching scene.");
SceneManager.LoadScene("EditorScene");
}).AddTo(this);
}
}
public partial class CreateEmptyProjectPage
{
private void InitializeAnimations()
{
fadeIn = canvasGroup.DOFade(1f, 0.5f)
.SetEase(Ease.InOutQuad)
.SetAutoKill(false)
.OnComplete(() =>
{
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
}).Pause();
fadeOut = canvasGroup.DOFade(0f, 0.5f)
.SetEase(Ease.InOutQuad)
.SetAutoKill(false)
.OnPlay(() =>
{
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
})
.OnComplete(() =>
{
StartMenuManager.instance.startPage.fadeIn.Restart();
})
.Pause();
}
private void InitializeInfoUI()
{
songLocationInputField.onEndEdit.AddListener((str) =>
{
string forward = Application.streamingAssetsPath + "/Songs/";
songName = str.Replace(forward, "");
});
selectSongButton.onClick.AddListener(SelectSong);
autoFillSongPathButton.onClick.AddListener(AutoFillSongPath);
createEmptyProjectButton.onClick.AddListener(CreateEmptyProject);
}
public void AutoFillSongPath()
{
string path = Application.streamingAssetsPath + "/Songs/";
songLocationInputField.text = path;
}
public void SelectSong()
{
songFile = new OpenFileName();
songFile.structSize = Marshal.SizeOf(songFile);
songFile.filter = "Music Files(*音频文件)\0*.wav;\0";
songFile.file = new string(new char[256]);
songFile.maxFile = songFile.file.Length;
songFile.fileTitle = new string(new char[64]);
songFile.maxFileTitle = songFile.fileTitle.Length;
songFile.initialDir = Application.streamingAssetsPath.Replace('/', '\\');//默认路径
songFile.title = "Select A Song";
songFile.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
if (LocalDialog.GetOpenFileName(songFile) && songFile.file != "")
{
songName = Path.GetFileName(songFile.file);
songLocationInputField.text = Path.GetFullPath(songFile.file);
}
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class OpenFileName
{
public int structSize = 0;
public IntPtr dlgOwner = IntPtr.Zero;
public IntPtr instance = IntPtr.Zero;
public string filter = null;
public string customFilter = null;
public int maxCustFilter = 0;
public int filterIndex = 0;
public string file = null;
public int maxFile = 0;
public string fileTitle = null;
public int maxFileTitle = 0;
public string initialDir = null;
public string title = null;
public int flags = 0;
public short fileOffset = 0;
public short fileExtension = 0;
public string defExt = null;
public IntPtr custData = IntPtr.Zero;
public IntPtr hook = IntPtr.Zero;
public string templateName = null;
public IntPtr reservedPtr = IntPtr.Zero;
public int reservedInt = 0;
public int flagsEx = 0;
}
public static class LocalDialog
{
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetOpenFileName([In, Out] OpenFileName ofn);
public static bool GetOFN([In, Out] OpenFileName ofn)
{
return GetOpenFileName(ofn);
}
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetSaveFileName([In, Out] OpenFileName ofn);
public static bool GetSFN([In, Out] OpenFileName ofn)
{
return GetSaveFileName(ofn);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3aa727ae213742148372dfe4f74aa62
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni
{
public class InformationTransistor : SerializedMonoBehaviour
{
public static InformationTransistor instance;
public bool isLoadedProject;
public ProjectInformation_BM projectInfo_BM;
public SongInformation_BM songInfo_BM;
private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else if (instance != this)
{
Destroy(gameObject);
}
}
}
}

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.StartMenu
{
public class LoadProjectModule : MonoBehaviour
{
public GameObject LoadProjectTab;
public RectTransform loadTabList;
public List<string> projectFileList;
public List<ProjectInformation_BM> projectInformationList;
public List<SongInformation_BM> songInformationList;
private void Start()
{
projectInformationList = new List<ProjectInformation_BM>();
songInformationList = new List<SongInformation_BM>();
GetAllProjects();
}
public void GetAllProjects()
{
string path = Path.Combine(Application.streamingAssetsPath, "Projects");
projectFileList = ES3.GetDirectories(path).ToList();
foreach (string project in projectFileList)
{
string projectInformationPath = path + "/" + project + "/ProjectInfo.json";
string songInformationPath = path + "/" + project + "/SongInfo.json";
if (!File.Exists(projectInformationPath) || !File.Exists(songInformationPath)) continue;
projectInformationList.Add(ES3.Load<ProjectInformation_BM>("ProjectInformation", projectInformationPath));
songInformationList.Add(ES3.Load<SongInformation_BM>("SongInformation", songInformationPath));
}
for (int i = 0; i < projectInformationList.Count; i++)
{
var currentProject = projectInformationList[i];
var song = songInformationList[i];
string projectName = currentProject.projectName;
string lastSavedTime = currentProject.lastSaveTime;
string songName = song.songName;
LoadProjectTab tab = LeanPool.Spawn(LoadProjectTab, loadTabList).GetComponent<LoadProjectTab>();
tab.SetUpTab(projectName, lastSavedTime, songName);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e40dd0d51c6a0462dbb1a6a406064156
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.StartMenu
{
public class LoadProjectTab : MonoBehaviour
{
public string projectName;
public TMP_Text projectNameText, lastSavedTimeText, songNameText;
public Button loadButton;
public void SetUpTab(string projectName, string lastSavedTime, string songName)
{
this.projectName = projectName;
projectNameText.text = projectName;
lastSavedTimeText.text = lastSavedTime;
songNameText.text = songName;
loadButton.onClick.AddListener(LoadProject);
}
public void LoadProject()
{
// var b = IchniApp.instance.GetModel<InformationTransistor>();
// if (b == null) Debug.LogError("XXX");
// b.isLoadedProject = true;
// IchniApp.instance.GetModel<InformationTransistor>().loadingFolder = projectName;
// StartPageManager.startPageManager.GoToEditScene();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaf1c7bed195b4399aa6d3b5b4265930
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.StartMenu
{
public class StartMenuManager : MonoBehaviour
{
public static StartMenuManager instance;
public StartPage startPage;
public CreateEmptyProjectPage createEmptyProjectPage;
private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else if (instance != this)
{
Destroy(gameObject);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ee1f97eeecda414cbd7e21a9d0589a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Michsky.MUIP;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ichni.StartMenu
{
public partial class StartPage : MonoBehaviour
{
public RectTransform background;
public CanvasGroup canvasGroup;
public ButtonManager createEmptyProjectButton;
public Sequence fadeIn, fadeOut;
private void Awake()
{
InitializeAnimations();
createEmptyProjectButton.onClick.AddListener(GoToNewProjectPage);
}
public void GoToNewProjectPage()
{
fadeOut.Restart();
}
}
public partial class StartPage
{
private void InitializeAnimations()
{
fadeIn = DOTween.Sequence();
fadeOut = DOTween.Sequence();
fadeIn.Join(canvasGroup.DOFade(1f, 0.5f))
.Join(background.DOScale(Vector3.one, 0.5f))
.SetEase(Ease.InOutQuad)
.SetAutoKill(false)
.OnComplete(() =>
{
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
}).Pause();
fadeOut.Join(canvasGroup.DOFade(0f, 0.5f))
.Join(background.DOScale(Vector3.one * 2f, 0.5f))
.SetEase(Ease.InOutQuad)
.SetAutoKill(false)
.OnPlay(() =>
{
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
})
.OnComplete(() =>
{
StartMenuManager.instance.createEmptyProjectPage.fadeIn.Restart();
})
.Pause();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7f4b9216445764528a39790ae30bcde1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ichni.StartMenu
{
public class ThemeBundleSelector : MonoBehaviour
{
public GameObject themeBundleTab;
public RectTransform listTransform;
public List<ThemeBundleTab> themeBundleTabs;
private void Start()
{
SetUpList();
}
private void SetUpList()
{
themeBundleTabs = new List<ThemeBundleTab>();
foreach (var bundle in ThemeBundleManager.instance.themeBundleAbstractList)
{
ThemeBundleTab tab = Instantiate(themeBundleTab, listTransform).GetComponent<ThemeBundleTab>();
tab.SetUpTab(bundle);
themeBundleTabs.Add(tab);
}
}
public List<string> GetSelectedThemeBundleList()
{
return (from tab in themeBundleTabs where tab.toggle.isOn select tab.connectedThemeBundle.fileName).ToList();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2af4f91bacbc744c188532d3a8f1bea8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.StartMenu
{
public class ThemeBundleTab : MonoBehaviour
{
public ThemeBundleAbstract connectedThemeBundle;
public TMP_Text titleText;
public Toggle toggle;
public void SetUpTab(ThemeBundleAbstract themeBundleAbstract)
{
this.connectedThemeBundle = themeBundleAbstract;
this.titleText.text = themeBundleAbstract.displayName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8f408eaf8e6644d58a38d215032f4e52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,18 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InformationTransistor : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}