StartMenu!
This commit is contained in:
56
Assets/Scripts/StartMenu/LoadProjectModule.cs
Normal file
56
Assets/Scripts/StartMenu/LoadProjectModule.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user