add standalone mode ,bug fix

This commit is contained in:
CroakFang
2023-02-13 10:38:40 +08:00
parent 7ba9b84a11
commit f11edb5924
46 changed files with 3599 additions and 34 deletions
+6 -1
View File
@@ -131,7 +131,6 @@ public class CameraOrbit : MonoBehaviour
if (Input.GetMouseButton(0) && controlOn)
{
position -= Input.GetAxis("Mouse X") * transform.right * OrbitCamSpeedSlider.value;
OrbitCamZoomSlider.value -= Input.mouseScrollDelta.y * OrbitCamZoomSpeedSlider.value;
OrbitCamHeightSlider.value -= Input.GetAxis("Mouse Y") * OrbitCamSpeedSlider.value;
}
else
@@ -139,6 +138,11 @@ public class CameraOrbit : MonoBehaviour
controlOn = false;
}
if (!eventSystem.IsPointerOverGameObject())
{
OrbitCamZoomSlider.value -= Input.mouseScrollDelta.y * OrbitCamZoomSpeedSlider.value;
}
if ((Input.GetMouseButtonDown(2) || Input.GetKeyDown(KeyCode.LeftControl)) && !eventSystem.IsPointerOverGameObject())
{
CameraTargetHelper.SetActive(true);
@@ -153,6 +157,7 @@ public class CameraOrbit : MonoBehaviour
CameraTargetHelper.SetActive(false);
}
float camDist = OrbitCamZoomSlider.value;
OrbitCamHeightSlider.maxValue = camDist + 1 - camDist * 0.2f;
OrbitCamHeightSlider.minValue = -camDist + 1 + camDist * 0.2f;
+23 -5
View File
@@ -1,23 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class Config
{
public static string configPath = Application.dataPath + "/../Config.json";
public static Config Instance;
public string Version = "";
public string LanguageTip = "Affects Uma names on the list. Language options: 0 - En, 1 - Jp";
public Language Language = Language.En;
public string MainPathTip = "Path to game folder, eg. D:\\Backup\\Cygames\\umamusume or D:/Backup/Cygames/umamusume";
public string MainPathTip = "Path to game folder, eg. D:/Backup/Cygames/umamusume";
public string MainPath = "";
public string WorkModeTip = "Affects how application work, options: 0 - work with game client, 1 - work without game client, Database needs to be updated manually";
public WorkMode WorkMode = WorkMode.Default;
public Config()
{
//TODO: Updating config file
Version = Application.version;
string configPath = Application.dataPath + "/../Config.json";
MainPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low"}\Cygames\umamusume";
if (!File.Exists(configPath))
@@ -32,17 +36,31 @@ public class Config
}
catch (Exception ex)
{
UmaViewerUI.Instance.LyricsText.text = "Config load error. Using default path. " + ex.Message;
UmaViewerUI.Instance.MessagePannel.SetActive(true);
UmaViewerUI.Instance.MessageText.text = "Config load error. Using default. " + ex.Message;
MainPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low"}\Cygames\umamusume";
}
}
Instance = this;
}
public void UpdateConfig()
{
File.WriteAllText(configPath, JsonUtility.ToJson(this, true));
UmaViewerUI.Instance.MessagePannel.SetActive(true);
UmaViewerUI.Instance.MessageText.text = "The configuration has changed. Please restart the application.";
}
}
public enum Language
{
En,
Jp
}
public enum WorkMode
{
Default,
Standalone
}
+9 -11
View File
@@ -17,7 +17,7 @@ public class ManifestDB
public ManifestDB()
{
string DBPath = $"{Config.Instance.MainPath}\\meta";
string DBPath = $"{Config.Instance.MainPath}\\meta_umaviewer";
ManifestDB.DBPath = DBPath;
if (!File.Exists(DBPath))
{
@@ -177,7 +177,7 @@ public class ManifestDB
callback?.Invoke($"Checking master.mdb");
SqliteCommand command = new SqliteCommand("SELECT h FROM a WHERE n LIKE 'master.mdb.lz4'", MetaDB);
var reader = command.ExecuteReader();
if (reader.Read())
{
var hash = reader.GetString(0);
@@ -230,28 +230,26 @@ public class ManifestDB
ulong count = reader.GetRowCount();
ManifestEntry[] manifests = new ManifestEntry[count];
if (kind == Kind.Default)
for (ulong i = 0; i < count; i++)
{
for (ulong i = 0; i < count; i++)
manifests[i].kind = (int)kind;
if (kind == Kind.Default)
{
manifests[i].kind = (int)kind;
if (!reader.ReadLine(ManifestEntry.GetBsvParser(ManifestEntry.Format.Full, reader), ref manifests[i]))
{
Debug.LogError("ReadLineError");
return null;
}
}
}
else
{
for (ulong i = 0; i < count; i++)
else
{
manifests[i].kind = (int)kind;
if (!reader.ReadLine(ManifestEntry.GetBsvParser(ManifestEntry.Format.Simplified, reader), ref manifests[i]))
{
Debug.LogError("ReadLineError");
return null;
}
}
}
return manifests;
@@ -320,6 +318,6 @@ public class ManifestDB
}
return platformEntrys[0];
}
}
+26 -3
View File
@@ -1,8 +1,8 @@
using RootMotion.Dynamics;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Gallop;
using System.IO;
public class UmaDatabaseEntry
{
@@ -11,7 +11,30 @@ public class UmaDatabaseEntry
public string Url;
public string Checksum;
public string Prerequisites;
public string FilePath => $"{Config.Instance.MainPath}\\dat\\{Url.Substring(0, 2)}\\{Url}";
public string FilePath
{
get
{
var path = $"{Config.Instance.MainPath}\\dat\\{Url.Substring(0, 2)}\\{Url}";
if (!File.Exists(path) && Config.Instance.WorkMode == WorkMode.Standalone)
{
UmaViewerMain.Instance.StartCoroutine(DownloadAsset(this));
}
return path;
}
}
public static IEnumerator DownloadAsset(UmaDatabaseEntry entry)
{
var path = $"{Config.Instance.MainPath}\\dat\\{entry.Url.Substring(0, 2)}\\{entry.Url}";
yield return UmaViewerDownload.DownloadAsset(entry, path , delegate(string msg)
{
UmaViewerUI.Instance.MessagePannel.SetActive(true);
UmaViewerUI.Instance.MessageText.text = msg;
});
}
}
public class UmaCharaData
@@ -57,7 +57,15 @@ public class UmaDatabaseController
{
try
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta;");
if(Config.Instance.WorkMode == WorkMode.Standalone)
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta_umaviewer;");
}
else
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta;");
}
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master.mdb;");
metaDb.Open();
@@ -71,8 +79,17 @@ public class UmaDatabaseController
}
catch
{
UmaViewerUI.Instance.LyricsText.text = $"Database not found: \n{Config.Instance.MainPath}\\meta\n{Config.Instance.MainPath}\\master\\master.mdb";
UmaViewerUI.Instance.LyricsText.color = Color.red;
UmaViewerUI.Instance.MessagePannel.SetActive(true);
UmaViewerUI.Instance.MessageText.text = $"Database not found at: {Config.Instance.MainPath}";
if(Config.Instance.WorkMode == WorkMode.Standalone)
{
UmaViewerUI.Instance.MessageText.text += "\nPlease update the database in the settings panel";
}
else
{
UmaViewerUI.Instance.MessageText.text += "\nPlease install the dmm game client";
}
masterDb.Close();
metaDb.Close();
}
@@ -186,4 +203,5 @@ public class UmaDatabaseController
masterDb.Close();
metaDb.Close();
}
}
+1
View File
@@ -1277,6 +1277,7 @@ public class UmaViewerBuilder : MonoBehaviour
foreach (var bundle in Main.LoadedBundles)
{
if(bundle.Value)
bundle.Value.Unload(unloadAllObjects);
}
if (unloadAllObjects)
+27
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
@@ -26,6 +28,31 @@ public class UmaViewerDownload : MonoBehaviour
}
}
public static IEnumerator DownloadAsset(UmaDatabaseEntry entry,string path, Action<string> callback = null)
{
string baseurl = GetAssetRequestUrl(entry.Url);
if (!string.IsNullOrEmpty(Path.GetExtension(entry.Name)))
{
baseurl = GetGenericRequestUrl(entry.Url);
}
using UnityWebRequest www = UnityWebRequest.Get(baseurl);
callback?.Invoke($"Downloading missing asset : {Path.GetFileName(entry.Name)}\n");
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Debug.LogError(www.error);
callback?.Invoke($"Failed to download resources : {www.error}");
}
else
{
Debug.Log("saving " + entry.Url);
Directory.CreateDirectory(Path.GetDirectoryName(path));
File.WriteAllBytes(path, www.downloadHandler.data);
callback?.Invoke($"Downloading missing asset : {Path.GetFileName(entry.Name)}\ncompleted, please load again");
}
}
public static string GetManifestRequestUrl(string hash)
{
return $"{MANIFEST_ROOT_URL}/{hash.Substring(0, 2)}/{hash}";
+39 -3
View File
@@ -1,4 +1,5 @@
using Gallop;
using SFB;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -23,18 +24,23 @@ public class UmaViewerUI : MonoBehaviour
public ScrollRect AnimationSetList;
public ScrollRect AnimationList;
public PageManager AnimationPageCtrl;
[Header("mini models")]
public ScrollRect MiniCharactersList;
public ScrollRect MiniCostumeList;
public ScrollRect MiniAnimationSetList;
public ScrollRect MiniAnimationList;
public PageManager MiniAnimationPageCtrl;
[Header("other")]
public ScrollRect PropList;
public PageManager PropPageCtrl;
public ScrollRect SceneList;
public PageManager ScenePageCtrl;
public GameObject MessagePannel;
public Text MessageText;
[Header("lists")]
public ScrollRect EmotionList;
public Transform FacialList;
public ScrollRect EarList;
@@ -49,6 +55,7 @@ public class UmaViewerUI : MonoBehaviour
public ScrollRect NormalSubSoundList;
public PageManager NormalSoundCtrl;
[Header("audio")]
public Slider AudioSlider;
public Button AudioPlayButton;
@@ -92,13 +99,15 @@ public class UmaViewerUI : MonoBehaviour
public Toggle GifTransparent;
public Slider GifQuality;
public TextMeshProUGUI GifQualityLabel;
public Slider GifSlider;
public Button GifButton;
public Button VMDButton;
public Button UpdateDBButton;
public TMP_Dropdown WorkModeDropdown;
public List<GameObject> TogglablePanels = new List<GameObject>();
public List<GameObject> TogglableFacials = new List<GameObject>();
[Header("prefabs")]
public GameObject UmaContainerPrefab;
public GameObject UmaContainerCostumePrefab;
public GameObject UmaContainerLivePrefab;
@@ -129,6 +138,11 @@ public class UmaViewerUI : MonoBehaviour
if (Application.platform == RuntimePlatform.Android)
canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink;
}
private void Start()
{
WorkModeDropdown.SetValueWithoutNotify((int)Config.Instance.WorkMode);
UpdateDBButton.interactable = (Config.Instance.WorkMode == WorkMode.Standalone);
}
private void Update()
{
@@ -1143,11 +1157,33 @@ public class UmaViewerUI : MonoBehaviour
}
public void UpdateGameDB() {
if (UpdateResVerCoroutine != null) return;
if (UpdateResVerCoroutine != null&&Config.Instance.WorkMode != WorkMode.Standalone) return;
UmaDatabaseController.Instance.CloseAllConnection();
ManifestDB dB = new ManifestDB();
UpdateResVerCoroutine = dB.UpdateResourceVersion(delegate (string msg) { LyricsText.text = msg; });
UpdateResVerCoroutine = dB.UpdateResourceVersion(delegate (string msg) { MessagePannel.SetActive(true); MessageText.text = msg; });
StartCoroutine(UpdateResVerCoroutine);
}
public void ChangeWorkMode(int mode)
{
if((int)Config.Instance.WorkMode != mode)
{
Config.Instance.WorkMode = (WorkMode)mode;
Config.Instance.UpdateConfig();
}
}
public void ChangeMainPath()
{
var path = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Config.Instance.MainPath, false);
if (path != null && path.Length > 0 && !string.IsNullOrEmpty(path[0]))
{
if(path[0] != Config.Instance.MainPath)
{
Config.Instance.MainPath = path[0];
Config.Instance.UpdateConfig();
}
}
}
}
+2 -1
View File
@@ -4,7 +4,8 @@
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:800597811bcc5d848b15e12807d6de45",
"GUID:d60799ab2a985554ea1a39cd38695018"
"GUID:d60799ab2a985554ea1a39cd38695018",
"GUID:145e2572884581c48a08acf566c1a1d6"
],
"includePlatforms": [],
"excludePlatforms": [],