Added auto region detection
This commit is contained in:
@@ -30,6 +30,8 @@ public class Config
|
||||
public string AntiAliasingTip = "Display, screenshot antialiasing level. 0 - no AA, 1 - 2x MSAA, 2 - 4x MSAA, 3 - 8x MSAA";
|
||||
public int AntiAliasing = 2;
|
||||
|
||||
public bool RegionDetectionPassed = false;
|
||||
|
||||
public string VmdMorphConvertSettingTip = "The mapping of MMD mprphs to UMA mprphs during VMD recording, multiple UMA expression weights will be combined (not exceeding 1)";
|
||||
public List<MorphConvertConfig> VmdMorphConvertSetting = new List<MorphConvertConfig>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Popup : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text Text;
|
||||
[SerializeField] private Button AcceptButton;
|
||||
[SerializeField] private Button RejectButton;
|
||||
[SerializeField] private RectTransform PopupBody;
|
||||
|
||||
private System.Action _onAccept;
|
||||
private System.Action _onReject;
|
||||
|
||||
public static Popup Create(string text, float width = -1, float height = -1, string acceptText = "Ok", System.Action onAccept = null, string rejectText = "", System.Action onReject = null)
|
||||
{
|
||||
var popup = Instantiate(Resources.Load<Popup>("Prefabs/FullScreenPopup"), UmaViewerUI.Instance.canvasScaler.transform);
|
||||
|
||||
popup.Text.text = text;
|
||||
|
||||
if (!string.IsNullOrEmpty(acceptText))
|
||||
{
|
||||
popup._onAccept = onAccept;
|
||||
popup.AcceptButton.GetComponentInChildren<TMP_Text>().text = acceptText;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rejectText))
|
||||
{
|
||||
popup._onReject = onReject;
|
||||
popup.RejectButton.GetComponentInChildren<TMP_Text>().text = rejectText;
|
||||
}
|
||||
|
||||
var sizeDelta = popup.PopupBody.sizeDelta;
|
||||
if (width != -1)
|
||||
{
|
||||
sizeDelta.x = width;
|
||||
}
|
||||
if(height != -1)
|
||||
{
|
||||
sizeDelta.y = height;
|
||||
}
|
||||
popup.PopupBody.sizeDelta = sizeDelta;
|
||||
|
||||
return popup;
|
||||
}
|
||||
|
||||
public void OnAcceptButtonClick()
|
||||
{
|
||||
_onAccept?.Invoke();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
public void OnRejectButtonClick()
|
||||
{
|
||||
_onReject?.Invoke();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fdf458b0fe5fae4e80d6b62337c8e4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -76,7 +76,12 @@ public class UmaDatabaseController
|
||||
FaceTypeData = ReadFaceTypeData(masterDb);
|
||||
LiveData = ReadAllLiveData(masterDb);
|
||||
DressData = ReadAllDressData(masterDb);
|
||||
|
||||
#if UNITY_STANDALONE_WIN
|
||||
if (!Config.Instance.RegionDetectionPassed)
|
||||
{
|
||||
SetDefaultGameRegion(masterDb);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -84,7 +89,14 @@ public class UmaDatabaseController
|
||||
var msg = $"Database not found at: {Config.Instance.MainPath}";
|
||||
if(Config.Instance.WorkMode == WorkMode.Standalone)
|
||||
{
|
||||
msg += "\nPlease update the database in the settings panel";
|
||||
if(Config.Instance.Region == Region.Global)
|
||||
{
|
||||
msg = "Only `Default` mode is supported for Global version. Please change Work Mode to Default in `Other` settings.";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += "\nPlease update the database in the settings panel";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -143,6 +155,50 @@ public class UmaDatabaseController
|
||||
return meta;
|
||||
}
|
||||
|
||||
static void SetDefaultGameRegion(SqliteConnection conn)
|
||||
{
|
||||
var str = ReadMaster(conn, "SELECT text FROM text_data LIMIT 1");
|
||||
//check if first character of the first text_data entry is in English
|
||||
bool isAscii = str[0][0].ToString()[0] < 128;
|
||||
Region detectedRegion = isAscii? Region.Global : Region.Jp;
|
||||
|
||||
if (Config.Instance.Region != detectedRegion)
|
||||
{
|
||||
if (detectedRegion == Region.Global)
|
||||
Popup.Create($"Different game region was detected. Current region is {Config.Instance.Region}.\nDo you want to change it? (It can be changed again in `Other` settings)", -1, 200,
|
||||
"Set to Global (Steam)", () =>
|
||||
{
|
||||
Config.Instance.RegionDetectionPassed = true;
|
||||
Config.Instance.Region = detectedRegion;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
UmaViewerUI.Instance.OtherSettings.ApplySettings();
|
||||
UmaViewerUI.Instance.StartCoroutine(UmaViewerUI.Instance.ApplyGraphicsSettings());
|
||||
},
|
||||
"Keep Japan (DMM)", () =>
|
||||
{
|
||||
Config.Instance.RegionDetectionPassed = true;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
});
|
||||
else
|
||||
{
|
||||
Popup.Create($"Different game region was detected. Current region is {Config.Instance.Region}.\nDo you want to change it? (It can be changed again in `Other` settings)", -1, 200,
|
||||
"Set to Japan (DMM)", () =>
|
||||
{
|
||||
Config.Instance.RegionDetectionPassed = true;
|
||||
Config.Instance.Region = detectedRegion;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
UmaViewerUI.Instance.OtherSettings.ApplySettings();
|
||||
UmaViewerUI.Instance.StartCoroutine(UmaViewerUI.Instance.ApplyGraphicsSettings());
|
||||
},
|
||||
"Keep Global (Steam)", () =>
|
||||
{
|
||||
Config.Instance.RegionDetectionPassed = true;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static List<DataRow> ReadCharaMaster(SqliteConnection conn)
|
||||
{
|
||||
return ReadMaster(conn, "SELECT * FROM chara_data C,(SELECT D.'index' charaid,D.'text' charaname FROM text_data D WHERE id like 6) T WHERE C.id like T.charaid");
|
||||
|
||||
Reference in New Issue
Block a user