using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System.Linq; using System.Collections; public class UIT_CABINET : MonoBehaviour { public GameObject BoxSelections; public GameObject CABMODEL; public GameObject CABMODELContainer; public GameObject FILTERSContainer; public GameObject SUB_FILTERSContainer; public GameObject CabinetPln; static string model = "NA"; public void Setting(string name) { print("name===========================================================eee=========="+name); DOIT.CloseALLPNL(); CabinetPln.SetActive(true); _G.PON = "CABINETpnl"; _G.PNL = "Cabinet"; Get.o1("Title").GetComponent().text = name; //Clear library selection pnl DOIT.DELETEAllChild(FILTERSContainer.transform); DOIT.DELETEAllChild(SUB_FILTERSContainer.transform); Get.o2("CABINETpnl","SHOWSELECTION").GetComponent().alpha = 0; StaticCoroutine.Start(SetFILTERS(name)); //Set Box Selection SetBoxSelection(); ShowCabWithBoxSelection(); Get.o2("CABINETpnl","SaveToServer").SetActive(false); if(_G.User=="Admin" ){Get.o2("CABINETpnl","SaveToServer").SetActive(true);} //Resize Door Pattern Get.o2("CABINETpnl/SHOWSELECTION","RowHeightBtn").SetActive(_P.ListSwitch["ALLOW_DOORPATTERN_RESIZE"]); //BMR KENT bool isbmrKentHH=false; if(_G.PATH=="bmr" || _G.PATH=="kent" || _G.PATH=="homehardware" ){isbmrKentHH=true;} Get.o2("CABINETpnl/SHOWSELECTION","M_INSERT").SetActive(isbmrKentHH); Get.o2("CABINETpnl","M_COLOR").SetActive(isbmrKentHH); Get.o2("CABINETpnl","T_DoorSelection").SetActive(false); } //Box Selection----------------------------------------------------------------------------------------------- public void SetBoxSelection(){ List BoxList=new(); DOIT.AllChildOff(BoxSelections); string CodeRecipe=""; foreach (string line in _G.UIT_LibraryBoxTextures){ if(!string.IsNullOrEmpty(line) && line!=_G.UIT_LibraryBoxTextures[0]){ BoxList.Add(line.Split(",")[0]); } } if(BoxList.Count>1){ foreach (string ID in BoxList){//COUN.1?F6F6F6?F6F6F6?F6F6F6?1?0?0.5?0.3?1 string Texture=UIT.Value(Library.BoxTexture,ID,Header.Texture); string c1=UIT.Value(Library.BoxTexture,ID,Header.C1); string c2=UIT.Value(Library.BoxTexture,ID,Header.C2); string c3=UIT.Value(Library.BoxTexture,ID,Header.C3); string R=UIT.Value(Library.BoxTexture,ID,Header.Rotation); CodeRecipe+=Texture+"?"+c1+"?"+c2+"?"+c3+"?1?"+R+"?0.5?0.3?1"; Transform Box=BoxSelections.transform.Find("Box"+ID); Box.gameObject.SetActive(true); print("CodeRecipe===="+CodeRecipe); BoxSelections.transform.Find("Box"+ID+"/Background").GetComponent().sprite = UIT_MATERIAL.GetTexturebyRecipe(CodeRecipe); CodeRecipe=""; } } else {Get.o2("CABINETpnl","T_BoxSelection").SetActive(false);} //Set Globals // Set.GlobalColorBtn(Get.o2("CABINETpnl","GlobalNumber"),"CONSTRUCT","Cabinet"); //Set.GlobalSelections.SetActive(false); Get.o2("CABINETpnl", "AvailableDoors").SetActive(false); bool isTextGlobal=false; if(_P.Listfloat["GLOBAL_QTY"]!=1){ isTextGlobal=true;} Get.o2("CABINETpnl","T_DoorSelection").SetActive(isTextGlobal); } public void ShowCabWithBoxSelection(){ DOIT.AllChildOff(CABMODELContainer); List CainetOnPanel=new(); foreach(Transform CabOn in CABMODELContainer.transform){ CainetOnPanel.Add(CabOn.name); } string BoxSelection=Get.TogOn(BoxSelections).name; print("Box selection==="+BoxSelection); foreach (string CabName in CainetOnPanel) { print("CabName=="+CabName); string Box_finish = UIT.Value(Library.Cabinet, CabName, Header.Box_finish); if (Box_finish == BoxSelection[3..] || Box_finish == "All") { CABMODELContainer.transform.Find(CabName).gameObject.SetActive(true); } } Get.o2("CABINETpnl","SHOWSELECTION").GetComponent().alpha = 0; Get.o2("CABINETpnl","Description").GetComponent().text = ""; DOIT.AllTogchildfalse(CABMODELContainer); } //----------------------------------------------------------------------------------------------- //-------------------Setup----------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- public IEnumerator SetFILTERS(string Name)//FILTERS { //print("Name===2="+Name);//Name===2=TALL GameObject btn=Get.o2("CABINETpnl/BASEBTN","UIT_FILTER"); GameObject pnl=Get.o2("CABINETpnl/FILTERS/Viewport","Content"); List L = _G.UIT_LibraryCabinets; List list = new(); //if(_G.User=="Admin" || _G.PATH=="free"){AddLibrary("Ukitchenit",pnl,btn);} int CatIndex=UIT.Ind(Library.Cabinet,Header.Category); int LibraryIndex=UIT.Ind(Library.Cabinet,Header.Library_Name); //print("CatIndex===="+CatIndex); //print("LibraryIndex===="+LibraryIndex); for(int i=1; i IsReady(_G.UIT_LibraryCabinets)); //yield return new WaitForSeconds(0.5f); //Sort by Kithen first GameObject KitchenFilter=Get.o2("CABINETpnl/FILTERS/Viewport/Content","Kitchen"); if(KitchenFilter !=null){KitchenFilter.transform.SetSiblingIndex(0);} GameObject Models=Get.o2("CABINETpnl/FILTERS/Viewport","Content"); if(Models.transform.childCount!>0){ Models.transform.GetChild(0).gameObject.GetComponent().isOn=true; SetCategory(Get.o1("Title").GetComponent().text); } else{ _M.PH(25,0,"ffffff",1,1);//int Num, float posY, string C, float X, float Y Get.o2("PNL","CABINETpnl").SetActive(false); } Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl", "ADDINPUTS").SetActive(false); } private static bool IsReady(List L) { if (L == null || L.Count == 0) { Debug.Log("LibraryCabTextures is not ready"); return false; } return true; } public void SetCategory(string name)//SUBFILTERS { DOIT.DELETEAllChild("Canvas/Panel_SCENE/PNL/CABINETpnl/SUB_FILTERS/Viewport/Content"); DOIT.DELETEAllChild("Canvas/Panel_SCENE/PNL/CABINETpnl/CABMODEL/Viewport/Content"); Allfalse.SetCabPnlOpen(); Get.o2("CABINETpnl","SHOWSELECTION").GetComponent().alpha = 0; GameObject btn=Get.o2("CABINETpnl/BASEBTN","UIT_SUBFILTER"); GameObject pnl=Get.o2("CABINETpnl/SUB_FILTERS/Viewport","Content"); string LibraryName = UIT.TogOn("FILTERS"); List L=_G.UIT_LibraryCabinets; List list = new(); int SubCatIndex=UIT.Ind("Cabinet","Sub_Category"); int Library_NameIndex=UIT.Ind("Cabinet","Library_Name"); int CatIndex=UIT.Ind("Cabinet","Category"); for(int i=1; i().isOn=true; ShowSelections(); } //----------------------------------------------------------------------------------------------- //-------------------Add to list----------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- public static void AddCat(string SubCategory,GameObject pnl,GameObject btn,string Category) { print("SubCategory===="+SubCategory+" Category===="+Category);//SubCategory====Drawer | Door Category====TALL GameObject Cat = Instantiate(btn); Cat.transform.SetParent(pnl.transform, false); string SubCategoryName = TRANS.CabinetSubCategory(Category,SubCategory); Cat.transform.Find("Background").transform.Find("text").gameObject.GetComponent().text = TRANS.Retext(SubCategoryName); Cat.name = SubCategory; Cat.SetActive(true); } public static void AddLibrary(string Name,GameObject pnl,GameObject btn) { GameObject L = Instantiate(btn); L.transform.SetParent(pnl.transform, false); string nameLibrary = TRANS.This("T_" + Name); if (nameLibrary == "ERROR TXT") nameLibrary = Name; // print("Name=====AL==="+nameLibrary); L.transform.Find("Background").transform.Find("text").gameObject.GetComponent().text = TRANS.Retext(nameLibrary); L.name = Name; L.SetActive(true); } //----------------------------------------------------------------------------------------------- //-------------------Show Selections---------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- // used by Canvas/Panel_SCENE/PNL/CABINETpnl/BTNCABSORT // public void ShowSelections() // { // Showselections(name); // } public void ShowSelections()//SHOWSELECTION { string name = Get.TogOn(SUB_FILTERSContainer).name; Allfalse.SetCabPnlOpen(); Get.o2("CABINETpnl","SHOWSELECTION").GetComponent().alpha = 0; Get.o2("CABINETpnl","Description").GetComponent().text = ""; Get.o2("CABINETpnl","Flip").GetComponent().text = ""; model = Get.o1("CABINETpnl/Title").GetComponent().text; GameObject btn=Get.o2("CABINETpnl/BASEBTN","UIT_SELECTION"); GameObject pnl=Get.o2("CABINETpnl/CABMODEL/Viewport","Content"); DOIT.DELETEAllObjectChild(CABMODELContainer); List cablist = new(); List paternlist25 = new(); List paternlist26 = new(); List L=_G.UIT_LibraryCabinets; string LibraryName = UIT.TogOn("FILTERS"); string LN="Cabinet"; UIT.SortLibrary(_G.UIT_LibraryCabinets); int UNind=UIT.Ind(LN,"Unique_Name"); int SubCatIndex=UIT.Ind(LN,"Sub_Category"); int Library_NameIndex=UIT.Ind(LN,"Library_Name"); int CategoryIndex=UIT.Ind(LN,"Category"); int Door1=Get.IndexCSV(L,"Pattern_Door_1"); int Door2=Get.IndexCSV(L,"Pattern_Door_2"); for(int i=1; i().text = cablist[i]; //string ncat = cablist[i]; M.SetActive(true); M.transform.GetComponent().localScale = new Vector3(1.0f, 1.0f, 1.0f); M.transform.SetParent(pnl.transform, false); M.transform.SetSiblingIndex(cablist.Count - 1); AddPaternCab(M, paternlist25[i], paternlist26[i], 0f, 10f); } } ShowCabWithBoxSelection(); } //----------------------------------------------------------------------------------------------- //-------------------Action---------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- public static void AddPaternCab(GameObject Cab, string patern25, string patern26, float x, float y) { string catcab; if(UIT.TogOn("FILTERS")=="Ukitchenit"){catcab = UIT.Value("CabinetUkitchenit",Cab.name,"Cab_Model");} else{ catcab = UIT.Value("Cabinet",Cab.name,"Cab_Model");} string[] code25 = patern25.Split('_'); string[] code26 = patern26.Split('_'); GameObject CabImage = new(catcab); PaternDraw.Paterns(CabImage, code25, code26, Cab.name); CabImage.transform.SetParent(Cab.transform); CabImage.transform.localPosition = new Vector3(x, y, 1.0f); CabImage.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); } // used by // Canvas/Panel_SCENE/PNL/EMPTYpnl/MODIFYER/BASECAB/TopOff // Canvas/Panel_SCENE/PNL/EMPTYpnl/MODIFYER/BASECAB/TopOn public void TopOnOff() { _G.SC[1] =name; } // used by Canvas/Panel_SCENE/PNL/CABINETpnl/BTNLIBRARY public void LibrarySelect() { string name = Get.o1("Title").GetComponent().text; SetCategory(name); GameObject CAT = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SUB_FILTERS/Viewport/Content").transform.GetChild(0).gameObject; ShowSelections(); CAT.GetComponent().isOn = true; } }