using UnityEngine.UI; using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.PlayerLoop; using System.Collections.Specialized; using System.Linq; using System.Runtime.InteropServices; using UnityEngine.Rendering.LookDev; public class UIT : MonoBehaviour { public static string[] GetLibraryLine(string Library, string unique) { List L=GetLibrary(Library); for(int i=1; i L = GetLibrary(Library); for(int i = 1; i L = GetLibrary(Library); for(int i = 1; i L = GetLibrary(Library); for(int i = 1; i L=GetLibrary(Library); string[] line = L[0].Split(','); for(int i=0; i 1) { value=value.Split("_")[1]; } return DOIT.ConvertStringToNumber(value); } //Get--------------------------------------------------------------------------------------------- public static string GetCabinetPriceID(string Cabinet_ID, string Door_ID, string DoorColor_ID) { //string Cabinet_UniqueName=Value(Library.Cabinet,Cabinet_ID,Header.Unique_Name); string Door_UniqueName = ""; string DoorColor_UniqueName = ""; string BoxFinish = ""; // print("from GetCabinetPriceID Cabinet_ID==="+Cabinet_ID); // print("from GetCabinetPriceID Door_ID==="+Door_ID); // print("from GetCabinetPriceID DoorColor_ID==="+DoorColor_ID); //Conditions if (Get.PreferenceBool("CABINET_BY_FINISH_BOX")) { string BoxFinish_ID = Value(Library.Cabinet, Cabinet_ID, Header.Box_finish); if (BoxFinish_ID == "All") { BoxFinish_ID = DoorColor_ID; } BoxFinish = Value(Library.CabTexture, BoxFinish_ID, Header.Unique_Name); } ; if (Get.PreferenceBool("CABINET_BY_MODEL_DOOR")) { Door_UniqueName = Value(Library.Door, Door_ID, Header.Unique_Name); } ; if (BoxFinish != "") BoxFinish = "-" + BoxFinish; if (Door_UniqueName != "") Door_UniqueName = "-" + Door_UniqueName; if (DoorColor_UniqueName != "") DoorColor_UniqueName += "-" + DoorColor_UniqueName; return Cabinet_ID + BoxFinish + Door_UniqueName + DoorColor_UniqueName; } public static string GetPanelPrice(string PanelCodeID,string ColorCodeID) { string PanelUniqueName=Value(Library.Panel,PanelCodeID,Header.Unique_Name); string ColorUniqueName=Value(Library.CabTexture,ColorCodeID,Header.Unique_Name); string PriceCode_ID=GetPanelPriceCode_ID(PanelUniqueName,ColorUniqueName,""); return Value(Library.Price,PriceCode_ID,Header.Price +_G.StoreZone); } public static string GetFillerPrice(string FillerID,string ColorCodeID) { string FillerUniqueName=Value(Library.Molding,FillerID,Header.Unique_Name); string ColorUniqueName=Value(Library.CabTexture,ColorCodeID,Header.Unique_Name); string PriceCode_ID=GetPanelPriceCode_ID(FillerUniqueName,ColorUniqueName,""); return Value(Library.Price,PriceCode_ID,Header.Price +_G.StoreZone); } public static string GetMoldingPrice(string Molding_ID,string ColorCodeID) { string MoldingUniqueName=Value(Library.Molding,Molding_ID,Header.Unique_Name); string ColorUniqueName=Value(Library.CabTexture,ColorCodeID,Header.Unique_Name); string PriceCode_ID=GetPanelPriceCode_ID(MoldingUniqueName,ColorUniqueName,""); return Value(Library.Price,PriceCode_ID,Header.Price +_G.StoreZone); } public static string CabinetID_byUniqueName(string UniqueName){ string ID=""; int IndUniqueName=Ind(Library.Cabinet,Header.Unique_Name); int IndID=Ind(Library.Cabinet,Header.ID); foreach(string sel in _G.UIT_LibraryCabinets){ if(!string.IsNullOrEmpty(sel)){ string[] Line = sel.Split(","); if(UniqueName==Line[IndUniqueName]){ ID=Line[IndID]; } } } return ID; } public static string PanelID_byUniqueNameAndColorID(string UniqueName,string ColorID){ string ID=""; int IndUniqueName=Ind(Library.Panel,Header.Unique_Name); int IndColorID=Ind(Library.Panel,Header.ColorID); int IndID=Ind(Library.Panel,Header.ID); foreach(string sel in _G.UIT_LibraryPanels){ if(!string.IsNullOrEmpty(sel)){ string[] Line = sel.Split(","); if(UniqueName==Line[IndUniqueName] && Line[IndColorID].Split("_").Contains(ColorID)){ ID=Line[IndID]; } } } return ID; } public static string GetIDByUnique_Name(string Library,string UniqueName){ //print("GetIDByUnique_Name Library==="+Library); //print("GetIDByUnique_Name LUniqueName==="+UniqueName); List L=GetLibrary(Library); int Ind_UniqueName=Ind(Library,Header.Unique_Name); //print("GetIDByUnique_Name Ind_UniqueName==="+Ind_UniqueName); foreach(string Line in L){ if(Line!="" && Line!=L[0]){ string UniqueFromList=Line.Split(',')[Ind_UniqueName]; if(UniqueFromList==UniqueName)return Line.Split(',')[0]; } } return null; } public static string Ecomerce_ID(string Cabinet_ID,string DoorModeColor_ID) { string DoorModel=Value(Library.Door,DoorModeColor_ID.Split('?')[0],Header.Unique_Name); string ColorID=Value(Library.CabTexture,DoorModeColor_ID.Split('?')[1],Header.Unique_Name); string DoorModelColor=DoorModel+" "+ColorID; int IndCabinet_ID=Ind(Library.Price,Header.Cabinet_ID); int IndDoor_ID=Ind(Library.Price,Header.Cabinet_ID); int IndEcomerce_ID=Ind(Library.Price,Header.Cabinet_ID); foreach(string line in _G.UIT_LibraryPrices) { string[] L=line.Split(','); if(L[IndCabinet_ID]==Cabinet_ID && L[IndDoor_ID]==DoorModelColor){return L[IndEcomerce_ID];} } return "N/A" ; } public static List GetLibrary(string L) { if(L=="Cabinet")return _G.UIT_LibraryCabinets; if(L=="Door")return _G.UIT_LibraryDoors; if(L=="Molding")return _G.UIT_LibraryMoldings; if(L=="GlobalStart")return _G.UIT_LibraryGlobalStart; if(L=="Preference")return _G.UIT_LibraryPreferences; if(L=="SoftColors")return _G.UIT_LibrarySoftColors; if(L=="CabTexture")return _G.UIT_LibraryCabTextures; if(L=="Panel")return _G.UIT_LibraryPanels; if(L=="CabinetUkitchenit")return _G.UKITCHENIT_LibraryCabinets; if(L=="Kick")return _G.UIT_LibraryMoldings; if(L=="Ogee")return _G.UIT_LibraryMoldings; if(L=="Fascia")return _G.UIT_LibraryMoldings; if(L=="Cornice")return _G.UIT_LibraryMoldings; if(L=="Valance")return _G.UIT_LibraryMoldings; if(L=="Price")return _G.UIT_LibraryPrices; if(L=="Store")return _G.UIT_LibraryStores; if(L=="BoxTexture")return _G.UIT_LibraryBoxTextures; if(L=="Items")return _G.UIT_LibraryItems; return null ; } public static string GetIDbyModel(string Library, string Model, string Name){ List L=GetLibrary(Library); int Ind_Model=Ind("Door","Model"); int IndL=Ind("Door","M"+_G.L); if (IndL == 0) {IndL=Ind("Door", "L" + _G.L);} foreach(string Line in L) { string[] l = Line.Split(","); if(!string.IsNullOrEmpty(l[0]) && l[Ind_Model]==Model && l[IndL] == Name) { return l[0]; } } return null; } public static string TogOn(string pnl) { string path = _G.PON + "/" + pnl + "/Viewport/Content"; return Get.ToggleOnInChild(path); } public static GameObject TogOnObject(GameObject Container) { //string path = _G.PON + "/" + pnl + "/Viewport/Content"; foreach(Transform Object in Container.transform) { if(Object.GetComponent().isOn)return Object.gameObject; } return null; } public static string GetDoorModelNameTextFromModelSelect() { GameObject ModelSelect =TogOnObject(Get.o2("CABDOORpnl/MODELS/Viewport", "Content")); return ModelSelect.transform.Find("Image/Text").GetComponent().text; //Slab door } public static string Global(string Header,int GG){ return Value(Library.GlobalStart,"G_"+GG.ToString(),Header); } public static void GlobalSet(string Header,string value,int GG){ string[] Line = GetLibraryLine(Library.GlobalStart, "G_"+GG.ToString()); int ind = Ind(Library.GlobalStart,Header); Line[ind] = value; _G.UIT_LibraryGlobalStart[GG]=Set.AsString(Line); } public static bool ExistInLibrary(string LibraryName, string ID){ List L = GetLibrary(LibraryName); for(int i = 1; i L=_G.UIT_LibraryGlobalStart; for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++){ string ExtValueString = Value(Library.GlobalStart,L[i].Split(',')[0],Header.Ext); GlobalSet(Header.Ext,ExtValueString ,i); } } public static void SetPreference() { //System measure List options=new(); Dropdown Sys=Get.o2("Canvas/Language","SYS").GetComponent(); Sys.ClearOptions(); if(_P.ListSwitch[Pref.MEASURE_IMPERIAL]){ options.Add("Imperial"); } if(_P.ListSwitch[Pref.MEASURE_METRIC]){ options.Add("Metric"); } if(!_P.ListSwitch[Pref.MEASURE_IMPERIAL] && !_P.ListSwitch[Pref.MEASURE_METRIC]){options.Add("Imperial");} Sys.AddOptions(options); } //Add------------------------------------------------------------------------------------------------- public static void AddToLibraryCabTexture(){ List L=UIT.GetLibrary("CabTexture"); string ID ="new"+L.Count+","; string L1=""+","; string L2=""+","; string L3=""+","; string Supplier="Ukitchenit"+","; string Texture =TogOn("TEXTCOL")+","; string Finish =Get.TogOn(Get.o2(_G.PON,"FINISH")).name[..1] +","; string Contrast=Get.o2(_G.PON+"/COLOR_SLIDER","_contrast").GetComponent().value.ToString()+","; //Colors string path=_G.PON+"/COLORS/ColorPickerTexture"; Color col1=Get.o1(path+"_1/Button/Image").GetComponent().color; Color col2=Get.o1(path+"_2/Button/Image").GetComponent().color; Color col3=Get.o1(path+"_3/Button/Image").GetComponent().color; string c1=ColorUtility.ToHtmlStringRGB(col1)+","; string c2=ColorUtility.ToHtmlStringRGB(col2)+","; string c3=ColorUtility.ToHtmlStringRGB(col3)+","; string Library="YourLibrary"+","; string line=ID+L1+L2+L3+Supplier+Texture+Finish+Contrast+c1+c2+c3+Library+"end"; L.Add(line); } public static void AddbtntoList(GameObject List,GameObject btn,int i){ GameObject C = Instantiate(btn); C.transform.Find("Image").transform.Find("Text").gameObject.GetComponent().text ="Template "+(i+1).ToString(); string filter= UIT.TogOn("FILTERS"); string IDTexture=""; if(filter=="YourLibrary" || filter=="Standard" ){ List L=UIT.GetLibrary("CabTexture"); IDTexture=L[i].Split(',')[0]; C.name=IDTexture; } else {C.name="TEXT.1."+(i+1).ToString();} C.transform.SetParent(List.transform, false); if (List.transform.childCount < 20) {C.gameObject.SetActive(true);} // if(filter=="CreateIt")C.transform.Find("Background").GetComponent().material = UIT_MATERIAL.GetMaterialCreateIt(C.name,"PNL"); else C.transform.Find("Background").GetComponent().material = UIT_MATERIAL.GetMaterial(C.name); } public static bool Exist(string Unique,string Lib){ List L = GetLibrary(Lib); for(int i=0; i< L.Count; i++){ if(L[i]!=""){ if(L[i].Split(',')[0] == Unique){ return true;} if(L[i].Split(',')[1] == Unique){ return true;} } } return false; } public static void SortLibrary(List L){ string Header = L[0]; L.Remove(Header); L.Sort(); L.Insert(0,Header); } public static string IDCheckExist(string Library,string ID){ List L=GetLibrary(Library); for(int i=0; i