Files
ichni_Creator_Studio/Assets/Scripts/StartMenu/LoadProjectModule.cs
2025-05-11 14:12:47 +08:00

59 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
using UnityEngine.UI;
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;
public Image MemuMask;
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);
tab.MemuMask = MemuMask;
}
}
}
}