Load live data form masterDB
This commit is contained in:
@@ -64,6 +64,33 @@ public class FaceTypeData
|
||||
}
|
||||
}
|
||||
|
||||
[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];
|
||||
}
|
||||
}
|
||||
|
||||
public enum UmaFileType
|
||||
{
|
||||
_3d_cutt,
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Mono.Data.Sqlite;
|
||||
using System.IO;
|
||||
using UnityEngine.XR;
|
||||
using System.Data;
|
||||
|
||||
public class UmaDatabaseController
|
||||
@@ -45,6 +40,7 @@ public class UmaDatabaseController
|
||||
public IEnumerable<UmaDatabaseEntry> MetaEntries;
|
||||
public IEnumerable<UmaCharaData> CharaData;
|
||||
public IEnumerable<FaceTypeData> FaceTypeData;
|
||||
public IEnumerable<DataRow> LiveData;
|
||||
|
||||
/// <summary> Meta Database Connection </summary>
|
||||
private SqliteConnection metaDb;
|
||||
@@ -67,9 +63,11 @@ public class UmaDatabaseController
|
||||
}
|
||||
metaDb.Open();
|
||||
MetaEntries = ReadMeta(metaDb);
|
||||
|
||||
masterDb.Open();
|
||||
CharaData = ReadMaster(masterDb);
|
||||
FaceTypeData = ReadFaceTypeData(masterDb);
|
||||
LiveData = ReadAllLiveData(masterDb);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -142,6 +140,21 @@ public class UmaDatabaseController
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadAllLiveData(SqliteConnection conn)
|
||||
{
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText =
|
||||
$"SELECT * FROM live_data L,(SELECT D.'index' songid,D.'text' songname FROM text_data D WHERE id like 16) T WHERE L.music_id like T.songid";
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
var result = new DataTable();
|
||||
result.Load(sqlite_datareader);
|
||||
var temp = result.Rows.GetEnumerator();
|
||||
while (temp.MoveNext())
|
||||
{
|
||||
yield return (DataRow)temp.Current;
|
||||
}
|
||||
}
|
||||
|
||||
public static DataRow ReadCharaData(int id)
|
||||
{
|
||||
SqliteCommand sqlite_cmd = instance.masterDb.CreateCommand();
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
{
|
||||
var liveInstance = live;
|
||||
var container = Instantiate(UmaContainerNoTMPPrefab, LiveList.content).GetComponent<UmaUIContainer>();
|
||||
container.GetComponentInChildren<Text>().text = " "+ live.MusicId + " " + live.songName;
|
||||
container.GetComponentInChildren<Text>().text = " "+ live.MusicId + " " + live.SongName;
|
||||
var imageInstance1 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(LiveList.content, imageInstance1);
|
||||
@@ -287,7 +287,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
});
|
||||
|
||||
var CharaContainer = Instantiate(UmaContainerNoTMPPrefab, LiveSoundList.content).GetComponent<UmaUIContainer>();
|
||||
CharaContainer.GetComponentInChildren<Text>().text = " " + live.MusicId + " " + live.songName;
|
||||
CharaContainer.GetComponentInChildren<Text>().text = " " + live.MusicId + " " + live.SongName;
|
||||
var CharaimageInstance1 = CharaContainer.GetComponent<Image>();
|
||||
CharaContainer.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(LiveSoundList.content, CharaimageInstance1);
|
||||
|
||||
Reference in New Issue
Block a user