Load live data form masterDB
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
public class UmaViewerMain : MonoBehaviour
|
||||
{
|
||||
public static UmaViewerMain Instance;
|
||||
private UmaViewerUI UI => UmaViewerUI.Instance;
|
||||
private UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
|
||||
public JArray UmaCharaData;
|
||||
public JArray UmaLiveData;
|
||||
|
||||
@@ -62,36 +61,36 @@ public class UmaViewerMain : MonoBehaviour
|
||||
UI.LoadMapPanel();
|
||||
});
|
||||
|
||||
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicLiveDataInfo", txt =>
|
||||
{
|
||||
UmaLiveData = JArray.Parse(txt);
|
||||
var asset = AbList.FirstOrDefault(a => a.Name.Equals("livesettings"));
|
||||
if(asset != null)
|
||||
{
|
||||
string filePath = UmaDatabaseController.GetABPath(asset);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
||||
foreach (var item in UmaLiveData)
|
||||
{
|
||||
if (!Lives.Where(c => c.MusicId == (int)item["musicId"]).Any())
|
||||
{
|
||||
if (bundle.Contains((string)item["musicId"]))
|
||||
{
|
||||
TextAsset liveData = bundle.LoadAsset<TextAsset>((string)item["musicId"]);
|
||||
|
||||
Lives.Add(new LiveEntry(liveData.text)
|
||||
{
|
||||
MusicId = (int)item["musicId"],
|
||||
songName = (string)item["songName"]
|
||||
});
|
||||
}
|
||||
|
||||
var asset = AbList.FirstOrDefault(a => a.Name.Equals("livesettings"));
|
||||
if (asset != null)
|
||||
{
|
||||
string filePath = UmaDatabaseController.GetABPath(asset);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
||||
foreach (var item in UmaDatabaseController.Instance.LiveData)
|
||||
{
|
||||
var musicId = Convert.ToInt32(item["music_id"]);
|
||||
var songName = item["songname"].ToString();
|
||||
if (!Lives.Where(c => c.MusicId == musicId).Any())
|
||||
{
|
||||
if (bundle.Contains(musicId.ToString()))
|
||||
{
|
||||
TextAsset liveData = bundle.LoadAsset<TextAsset>(musicId.ToString());
|
||||
|
||||
Lives.Add(new LiveEntry(liveData.text)
|
||||
{
|
||||
MusicId = musicId,
|
||||
SongName = songName
|
||||
});
|
||||
}
|
||||
}
|
||||
UI.LoadLivePanels();
|
||||
}
|
||||
UI.LoadLivePanels();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenUrl(string url)
|
||||
@@ -99,31 +98,4 @@ public class UmaViewerMain : MonoBehaviour
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CharaEntry
|
||||
{
|
||||
public string Name;
|
||||
public Sprite Icon;
|
||||
public int Id;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LiveEntry
|
||||
{
|
||||
public int MusicId;
|
||||
public string songName;
|
||||
public string BackGroundId;
|
||||
public List<string[]> LiveSettings = new List<string[]>();
|
||||
|
||||
public LiveEntry(string data)
|
||||
{
|
||||
string[] lines = data.Split("\n"[0]);
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
{
|
||||
LiveSettings.Add(lines[i].Split(','));
|
||||
}
|
||||
BackGroundId = LiveSettings[1][2];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user