using System.Collections; using UnityEngine; using UnityEngine.Networking; using System.Text; using System.Collections.Generic; using System.Globalization; using UnityEngine.UIElements.Experimental; using UnityEngine.UI; using System.Linq; public class UIT_LoadLibrary : MonoBehaviour { public static void Load() { BackgroundSave.Instance.ValidateRefId(); //print("-------------------------------------------------------------------------UUIIIT LOOADING"); StaticCoroutine.Start(ImportLibrary()); } public static IEnumerator ImportLibrary() { string basepath = "https://ukitchenit.com/members/"; //print("_G.PATH======" + _G.PATH); StringBuilder sb = new(basepath); sb.Append(_G.PATH); sb.Append("/start/"); Loadlogo.FileSelected(sb.ToString() + "logo.png"); LoadBG.FileSelected(sb.ToString() + "background.png"); sb.Clear(); sb.Append(basepath); sb.Append(_G.PATH); sb.Append("/library/"); string libraryPath = sb.ToString(); string PriceListnameCSV = "PRICEList.csv"; //if(_G.PATH=="homehardware" ||_G.PATH=="kwizine" ||_G.PATH=="kent" ){PriceListnameCSV="PRICEList.csv";} StaticCoroutine.Start(LoadURL(libraryPath + "CABTEXTUREList.csv", "CabTexture")); StaticCoroutine.Start(LoadURL(libraryPath + "GLOBALSTARTList.csv", "GlobalStart")); StaticCoroutine.Start(LoadURL(libraryPath + "PREFERENCESList.csv", "Preferences")); StaticCoroutine.Start(LoadURL(libraryPath + "SOFTCOLORList.csv", "SoftColor")); StaticCoroutine.Start(LoadURL(libraryPath + "DOORList.csv", "Door")); StaticCoroutine.Start(LoadURL(libraryPath + "BOXTEXTUREList.csv", "BoxTexture")); StaticCoroutine.Start(LoadURL(libraryPath + "MOLDINGList.csv", "Molding")); StaticCoroutine.Start(LoadURL(libraryPath + "PANELList.csv", "Panel")); StaticCoroutine.Start(LoadURL(libraryPath + "CABINETList.csv", "Cabinet")); StaticCoroutine.Start(LoadURL(libraryPath + PriceListnameCSV, "Price")); StaticCoroutine.Start(LoadURL(libraryPath + "STOREList.csv", "Store")); StaticCoroutine.Start(LoadURL(libraryPath + "LEXIQUEList.csv", "Lexique")); StaticCoroutine.Start(LoadURL(libraryPath + "ITEMSList.csv", "Items")); if (_G.PATH == "laminam") StaticCoroutine.Start(LoadURL(libraryPath + "TOPCOUNTERList.csv", "TopCounter")); yield return new WaitUntil(() => IsReady()); StaticCoroutine.Start(Preferences.Members()); StaticCoroutine.Start(LoadLOGO2L()); } #if UNITY_WEBGL && !UNITY_EDITOR public static IEnumerator LoadURL(string url, string library) { url = url + "?" + Random.value.ToString(); using UnityWebRequest www = UnityWebRequest.Get(url); UnityWebRequest.ClearCookieCache(); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { if (www.downloadHandler.data == null) yield break; string load = BinaryToText(www.downloadHandler.data); string[] loads = load.Split(new char[] { '\n' }); _G.LibraryLoads = new List(); foreach (string line in loads) {string l = line.Replace("/", "|"); _G.LibraryLoads.Add(l); } SetLibrary(loads, library); } yield return new WaitUntil(() => IsReady()); } #endif #if UNITY_STANDALONE && !UNITY_EDITOR public static IEnumerator LoadURL(string url, string library) { url = url + "?" + Random.value.ToString(CultureInfo.InvariantCulture); using UnityWebRequest www = UnityWebRequest.Get(url); UnityWebRequest.ClearCookieCache(); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { if (www.downloadHandler.data == null) yield break; string load = BinaryToText(www.downloadHandler.data); string[] loads = load.Split(new char[] { '\n' }); _G.LibraryLoads = new List(); foreach (string line in loads) { string l = line.Replace("/", "|"); _G.LibraryLoads.Add(l); } SetLibrary(loads, library); } } #endif #if UNITY_EDITOR public static IEnumerator LoadURL(string url, string library) { url = url + "?" + Random.value.ToString(CultureInfo.InvariantCulture); using UnityWebRequest www = UnityWebRequest.Get(url); { UnityWebRequest.ClearCookieCache(); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error + " library===" + library); } else { if (www.downloadHandler.data == null) yield break; string load = BinaryToText(www.downloadHandler.data); string[] loads = load.Split(new char[] { '\n' }); _G.LibraryLoads = new List(); foreach (string line in loads) { string l = line.Replace("/", "|"); if (l != "" && l != " ") _G.LibraryLoads.Add(l); } //if(library=="Panel" && _G.PATH=="free"){UkitchenitDIY();} SetLibrary(loads, library); } } } #endif public static string BinaryToText(byte[] data) { return System.Text.Encoding.UTF8.GetString(data); } public static void SetLibrary(string[] loads, string library) { //print("library==="+library); //Clean Load List ListLoad = new(loads);//Delete on loads = // for(int i=0; i(loads); StaticCoroutine.Start(ColorSetting()); break; default: break; } } public static void AddtoDictionaryPreferences(string[] loads) { for (int i = 0; i < loads.Length; i++) { if (!string.IsNullOrEmpty(loads[i])) { string Key = loads[i].Split(",")[0].Replace(" ", string.Empty); string Value = loads[i].Split(",")[1].Replace(" ", string.Empty); _P.List.Add(Key, Value); } } _P.Listfloat = new(){ {"GLOBAL_QTY" ,DOIT.ConvertStringToNumber(_P.List["GLOBAL_QTY"]) }, {"KICK_HEIGHT" ,DOIT.ConvertStringToNumber(_P.List["KICK_HEIGHT"]) }, {"KICK_FRONT_RETRACTION" ,DOIT.ConvertStringToNumber(_P.List["KICK_FRONT_RETRACTION"]) }, {"COUNTER_HEIGHT" ,DOIT.ConvertStringToNumber(_P.List["COUNTER_HEIGHT"]) }, {"COUNTER_FRONT_PROJECTION" ,DOIT.ConvertStringToNumber(_P.List["COUNTER_FRONT_PROJECTION"]) }, {"DOOR_GAP" ,DOIT.ConvertStringToNumber(_P.List["DOOR_GAP"]) }, {"BASE_HEIGHT" ,DOIT.ConvertStringToNumber(_P.List["BASE_HEIGHT"]) }, {"WALL_HEIGHT" ,DOIT.ConvertStringToNumber(_P.List["WALL_HEIGHT"]) }, {"TALL_HEIGHT" ,DOIT.ConvertStringToNumber(_P.List["TALL_HEIGHT"]) }, {"BASE_DEPTH" ,DOIT.ConvertStringToNumber(_P.List["BASE_DEPTH"]) }, {"WALL_DEPTH" ,DOIT.ConvertStringToNumber(_P.List["WALL_DEPTH"]) }, {"TALL_DEPTH" ,DOIT.ConvertStringToNumber(_P.List["TALL_DEPTH"]) }, }; List Plist = _P.List.Keys.ToList(); for (int i = 0; i < Plist.Count; i++) { if (_P.List[Plist[i]].IndexOf("y") != -1) { _P.ListSwitch.Add(Plist[i], true); } if (_P.List[Plist[i]].IndexOf("n") != -1) { _P.ListSwitch.Add(Plist[i], false); } } StaticCoroutine.Start(Preferences.Members()); } public static void AddtoDictionaryLexique(string[] loads) { for (int i = 0; i < loads.Length; i++) { if (!string.IsNullOrEmpty(loads[i])) { string Key = loads[i].Split(',')[0]; string Value = loads[i].Split(',')[1]; //print(Key+" value===="+Value); _G.Lexique.Add(Key, Value); } } } public static IEnumerator LanguagePreferenceSetting() { yield return new WaitForSeconds(1f); Set.LanguageSelection(); Set.SetSystemMesurePreference(); } public static IEnumerator AddYourLibrary() { yield return new WaitForSeconds(1f); string[] YL = _G.UIT_YourLibrary.Split('_'); for (int i = 0; i < YL.Length; i++) { if (!string.IsNullOrEmpty(YL[i])) { _G.UIT_LibraryCabTextures.Add(YL[i]); } } Restart.SetGlobal123(); yield return null; } public static IEnumerator ColorSetting() { yield return new WaitForSeconds(1f); Global(); //Restart.SetGlobal123(); yield return null; } public static void Global() { string[] sC = _G.UIT_LibrarySoftColors[1].Split(','); _G.colorBar = DOIT.CSc(sC[1], byte.Parse(sC[2]));//Bar_Color,Bar_Alpha _G.colorButton = DOIT.CSc(sC[3], byte.Parse(sC[4]));//Button_Color,Button_Alpha _G.colorIcon = DOIT.CSc(sC[5], byte.Parse(sC[6]));//Icon_Color,Icon_Alpha _G.colorText = DOIT.CSc(sC[7], byte.Parse(sC[8]));//Icon_Color,Icon_Alpha _G.colorBG = DOIT.CSc(sC[9], byte.Parse(sC[10]));//Text_Color,Text_Alpha _G.Color1 = sC[3]; _G.Color2 = sC[5]; } public static IEnumerator UkitchenitCabinet() { string path = "LibrairyCSV/UIT_CABINETList"; var load = Resources.Load(path); string[] loads = load.text.Split(new char[] { '\n' }); _G.UKITCHENIT_LibraryCabinets = new List(); foreach (string line in loads) { string l = line.Replace("/", "|"); _G.UKITCHENIT_LibraryCabinets.Add(l); } yield return null; } public static IEnumerator StoreSelection() { string StoreName = _G.UIT_LibraryStores[1].Split(',')[0]; if (!string.IsNullOrEmpty(StoreName)) _G.StoreSelect = StoreName; yield return null; } private static bool IsReady() { if (_G.UIT_LibraryCabTextures == null || _G.UIT_LibraryCabTextures.Count == 0) { Debug.Log("LibraryCabTextures is not ready"); return false; } if (_G.UIT_LibraryCabinets == null || _G.UIT_LibraryCabinets.Count == 0) { Debug.Log("LibraryCabinets is not ready"); return false; } if (_G.UIT_LibraryDoors == null || _G.UIT_LibraryDoors.Count == 0) { Debug.Log("LibraryDoors is not ready"); return false; } if (_G.UIT_LibraryMoldings == null || _G.UIT_LibraryMoldings.Count == 0) { Debug.Log("LibraryCounters is not ready"); return false; } if (_G.UIT_LibraryPanels == null || _G.UIT_LibraryPanels.Count == 0) { Debug.Log("LibraryPanels is not ready"); return false; } if (_G.UIT_LibrarySoftColors == null || _G.UIT_LibrarySoftColors.Count == 0) { Debug.Log("LibrarySoftColors is not ready"); return false; } // if (_G.UIT_LibraryPreferences == null || _G.UIT_LibraryPreferences.Count == 0) // { // Debug.Log("LibraryPreferences is not ready"); // return false; // } if (_G.UIT_LibraryGlobalStart == null || _G.UIT_LibraryGlobalStart.Count == 0) { Debug.Log("LibraryGlobalStart is not ready"); return false; } // if (_G.UIT_LibraryPrices == null || _G.UIT_LibraryPrices.Count == 0) // { // Debug.Log("_G.UIT_LibraryPrices is not ready"); // return false; // } // if (_G.LibraryCounters == null || _G.LibraryCounters.Count == 0) // { // Debug.Log("LibraryCounters is not ready"); // return false; // } // if (_G.LibraryKnobs == null || _G.LibraryKnobs.Count == 0) // { // Debug.Log("LibraryKnobs is not ready"); // return false; // } return true; } public static IEnumerator LoadLOGO2L() { //yield return new WaitForSeconds(2); WaitCircle.Setting(true, TRANS.This("M_Download")); yield return null; if (Get.PreferenceBool("LOGO2")) { string basepath = "https://ukitchenit.com/members/"; Set.alpha(Get.o1("logo2"), true); Loadlogo.FileSelected(basepath + "/" + _G.PATH + "/start/logo2.png"); } yield return null; WaitCircle.Setting(false, "" ); } }