upgrade CCK to v3.5

This commit is contained in:
Crispy 2023-07-30 01:20:46 +02:00
parent 6fe98b333d
commit 3005cfc8aa
43 changed files with 1213 additions and 289 deletions

View file

@ -23,9 +23,9 @@ namespace ABI.CCK.Scripts.Editor
[InitializeOnLoad]
public class CCK_BuildManagerWindow : EditorWindow
{
public static string Version = "3.4 RELEASE";
public static int BuildID = 90;
private const string CCKVersion = "3.4 RELEASE (Build 92)";
public static string Version = "3.5 RELEASE";
public static int BuildID = 98;
private const string CCKVersion = "3.5 RELEASE (Build 98)";
private string[] SupportedUnityVersions = new[]
{
@ -34,7 +34,11 @@ namespace ABI.CCK.Scripts.Editor
"2019.4.13f1", "2019.4.14f1", "2019.4.15f1", "2019.4.16f1", "2019.4.17f1", "2019.4.18f1",
"2019.4.19f1", "2019.4.20f1", "2019.4.21f1", "2019.4.22f1", "2019.4.23f1", "2019.4.24f1",
"2019.4.25f1", "2019.4.26f1", "2019.4.27f1", "2019.4.28f1", "2019.4.29f1", "2019.4.30f1",
"2019.4.31f1"
"2019.4.31f1",
"2021.3.1f1", "2021.3.2f1", "2021.3.3f1", "2021.3.4f1", "2021.3.5f1", "2021.3.6f1", "2021.3.7f1",
"2021.3.8f1", "2021.3.9f1", "2021.3.10f1", "2021.3.11f1", "2021.3.12f1", "2021.3.13f1", "2021.3.14f1",
"2021.3.15f1", "2021.3.16f1", "2021.3.17f1", "2021.3.18f1", "2021.3.19f1", "2021.3.20f1", "2021.3.21f1",
"2021.3.22f1", "2021.3.23f1", "2021.3.24f1"
};
string _username;
@ -108,13 +112,41 @@ namespace ABI.CCK.Scripts.Editor
{
EditorPrefs.SetBool("m_ABI_isBuilding", false);
EditorPrefs.SetString("m_ABI_TempVersion", Version);
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab");
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab");
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab");
if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar");
string[] filePaths = Directory.GetFiles(Application.dataPath + "/ABI.CCK/Resources/Cache/", "*.prefab");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvravatar");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvravatar.manifest");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvrprop");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvrprop.manifest");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
/*if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar");
if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop.manifest");*/
if (File.Exists(Application.persistentDataPath + "/bundle.cvrworld")) File.Delete(Application.persistentDataPath + "/bundle.cvrworld");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrworld.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrworld.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.png")) File.Delete(Application.persistentDataPath + "/bundle.png");
@ -128,10 +160,15 @@ namespace ABI.CCK.Scripts.Editor
if (state == PlayModeStateChange.EnteredPlayMode && EditorPrefs.GetBool("m_ABI_isBuilding"))
{
CCK_BuildUtility.upload_id = EditorPrefs.GetString("m_ABI_uploadId");
string randomNum = EditorPrefs.GetString("m_ABI_uploadRand");
var ui = Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab"));
OnGuiUpdater up = ui.GetComponentInChildren<OnGuiUpdater>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRAvatar").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load<GameObject>($"Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRSpawnable").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load<GameObject>($"Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRWorld").GetComponent<CVRAssetInfo>();
}
}
@ -690,71 +727,30 @@ namespace ABI.CCK.Scripts.Editor
{
_attemptingToLogin = true;
using (HttpClient httpclient = new HttpClient())
{
HttpResponseMessage response;
response = await httpclient.PostAsync(
"https://api.abinteractive.net/1/cck/validateKey",
new StringContent(JsonConvert.SerializeObject(new {Username = _username, AccessKey = _key}),
Encoding.UTF8, "application/json")
);
APIConnection.Initialize(_username, _key);
APIConnection.BaseResponse<APIConnection.UserinfoResponse> response = await APIConnection.MakeRequest<APIConnection.UserinfoResponse>("cck/userinfo");
if (response.IsSuccessStatusCode)
if (response != null)
{
if (response.Data != null)
{
string result = await response.Content.ReadAsStringAsync();
BaseResponse<LoginResponse> usr = Abi.Newtonsoft.Json.JsonConvert.DeserializeObject<BaseResponse<LoginResponse>>(result);
if (usr == null || usr.Data == null) return;
if (usr.Data.isValidCredentials)
{
_apiUserRank = usr.Data.userRank;
Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API.");
EditorPrefs.SetString("m_ABI_Username", _username);
EditorPrefs.SetString("m_ABI_Key", _key);
_loggedIn = true;
_hasAttemptedToLogin = false;
}
else
{
Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + usr.Message + ".");
_loggedIn = false;
_hasAttemptedToLogin = true;
_username = _key = string.Empty;
}
_apiUserRank = response.Data.UserRank;
Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API.");
EditorPrefs.SetString("m_ABI_Username", _username);
EditorPrefs.SetString("m_ABI_Key", _key);
_loggedIn = true;
_hasAttemptedToLogin = false;
}
else
{
Debug.LogError("[ABI:CCK] Web Request Error while trying to authenticate.");
Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + response.Message + ".");
_loggedIn = false;
_hasAttemptedToLogin = true;
_username = _key = string.Empty;
}
}
_attemptingToLogin = false;
}
}
}
public class LoginResponse
{
public bool isValidCredentials { get; set; }
public bool isAccountUnlocked { get; set; }
public string userId { get; set; }
public string userRank { get; set; }
}
public class BaseResponse<T>
{
public string Message { get; set; }
public T Data { get; set; }
public BaseResponse(string message = null, T data = default)
{
Message = message;
Data = data;
}
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}