using UnityEngine.UI; using System.Collections.Generic; using UnityEngine; using System.Linq; using TMPro; using UnityEngine.Animations; using UnityEditor; using System.Collections; using System; using Unity.VisualScripting; public class DoorCabPNL : MonoBehaviour { //SET START public static void StartPNL() { print("DoorCabPNL====StartPNL"); // _P.ListSwitch["DOOR_SELECT"] = true; // _P.ListSwitch["CABS_HAS_ALL_DOORS"] = true; // if (_P.ListSwitch["DOOR_SELECT"] && _P.ListSwitch["CABS_HAS_ALL_DOORS"]) // { DOIT.CloseALLPNLONLY(); GameObject CabDoorPnl = Get.o2("PNL", "CABDOORpnl"); CabDoorPnl.SetActive(true); CabDoorPnl.transform.localPosition= Vector3.zero; _G.PON = "CABDOORpnl"; AddModel(); bool isCreateTexture = false; if (_G.PATH == "free" || _G.PATH == "laminam") { isCreateTexture = true; } Get.o2("CABDOORpnl", "CreateTexture").SetActive(isCreateTexture); Get.o2("CABDOORpnl", "Input").SetActive(isCreateTexture); Get.o2("CABDOORpnl", "PresetColors").SetActive(_G.PATH == "free"); Get.o2("CABDOORpnl/COLORS", "Finish").SetActive(_G.PATH == "free"); Get.o2("CABDOORpnl", "ROTATION").SetActive(_G.PATH == "free"); if (isCreateTexture) { CabTextureShow.FillFinishDropdown(); } //} } public static void AddModel() { List L = UIT.GetLibrary("Door"); GameObject PnlModel = Get.o2("CABDOORpnl/MODELS/Viewport", "Content"); GameObject BtnModel = Get.o2("CABDOORpnl/BASEBTN", "BTNMODEL"); DOIT.DELETEAllObjectChild(PnlModel); int IndexOfModelName = UIT.Ind(Library.Door, "M" + _G.L.ToString()); if(IndexOfModelName==0)IndexOfModelName = UIT.Ind(Library.Door, "L" + _G.L); int IndexModel = UIT.Ind(Library.Door, "Model"); //IF BY MODEL NAME List ModelNameList = new(); foreach (string Line in L) { string[] lineSplit = Line.Split(","); if (!string.IsNullOrEmpty(Line) && lineSplit.Length > 1 && !lineSplit[0].Contains("ID") && lineSplit[0] != "") { if(!ModelNameList.Contains(lineSplit[IndexOfModelName]+ "_Model=" + lineSplit[IndexModel])) { ModelNameList.Add(lineSplit[IndexOfModelName] + "_Model=" + lineSplit[IndexModel]); } } } foreach (string ModelName in ModelNameList) { string[] ModelNameSplit = ModelName.Split("_Model="); AddModeltoContainer(ModelNameSplit[0], BtnModel, PnlModel, ModelNameSplit[1]); } Set.ToggleGroupToAllChild(_G.PON + "/MODELS/Viewport/Content"); // for (int i = 1; i < L.Count; i++) // { // string ModelName; // if (!string.IsNullOrEmpty(L[i].Split(',')[0])) // { // GameObject O = Instantiate(BtnModel); // O.transform.SetParent(PnlModel.transform, false); // O.SetActive(true); // O.name = L[i].Split(',')[0]; // //O.transform.Find("Image/Text").GetComponent().text = UIT.Value("Door", O.name, "L" + _G.L); // //O.transform.Find("Image/Text").GetComponent().text = UIT.Value("Door", O.name, Header.Unique_Name); // O.transform.Find("Image/Text").GetComponent().text = UIT.Value("Door", O.name, "M" + _G.L); // string Model = UIT.Value(Library.Door, O.name, Header.Model); // if (Model == "D_29") Model = "D_11"; // O.transform.Find("Background").GetComponent().sprite = Resources.Load("ICONS/CABDOORS/" + Model); // } // } StaticCoroutine.Start(ShowDoorOnOpenNew()); } static void AddModeltoContainer(string name, GameObject BtnModel, GameObject Container, string Model) { GameObject O = Instantiate(BtnModel); O.transform.SetParent(Container.transform, false); O.SetActive(true); O.name = Model; O.transform.Find("Image/Text").GetComponent().text = name; if (Model == "D_29") Model = "D_11"; O.transform.Find("Background").GetComponent().sprite = Resources.Load("ICONS/CABDOORS/" + Model); } static void AddTexturetoContainer(string DoorID, GameObject BtnTexture,GameObject Container,string ColorID) { GameObject O = Instantiate(BtnTexture); O.transform.SetParent(Container.transform, false); O.SetActive(true); O.name = ColorID; //UIT.Value(Library.Door, DoorID, Header.Color_ID);//2_3_4_5_6_7 O.transform.Find("Image/Text").GetComponent().text = UIT.Value(Library.CabTexture, O.name, Header.Unique_Name); O.transform.Find("Background").GetComponent().sprite = UIT_MATERIAL.GetSprite(O.name); } static IEnumerator ShowDoorOnOpenNew() { //Show first selecton on open new Set.ToggleGroupToAllChild(_G.PON + "/MODELS/Viewport/Content"); Get.o2(_G.PON + "/MODELS/Viewport", "Content").transform.GetChild(0).GetComponent().isOn = true; string Name = Get.o2("CABDOORpnl/MODELS/Viewport", "Content").transform.GetChild(0).gameObject.name; ShowLibrary(Name); yield return new WaitForSeconds(0.25f); string TexColor = Get.o2("CABDOORpnl/TEXTCOL/Viewport", "Content").transform.GetChild(0).gameObject.name; ShowSelecded(TexColor, "Model"); } //LIBRARY public void ShowLibrary() { ShowLibrary(name); } public static void ShowLibrary(string Model) { //SET TEXTURE CONTAINER GameObject PnlTexture = Get.o2("CABDOORpnl/TEXTCOL/Viewport", "Content"); GameObject BtnTexture = Get.o2("CABDOORpnl/BASEBTN", "BTNTEXCOL"); DOIT.DELETEAllObjectChild(PnlTexture); //CREATE DOOR LIST AVAILABLE FOR THE MODEL List AvailableDoor = new(); List L = UIT.GetLibrary("Door"); int IndexOfDoorID = UIT.Ind(Library.Door, Header.ID); int IndexOfModel = UIT.Ind(Library.Door, Header.Model); int IndexOfModelName = UIT.Ind(Library.Door, "M" + _G.L); if (IndexOfModelName == 0) { IndexOfModelName = UIT.Ind(Library.Door, "L" + _G.L); } foreach (string Line in L) { string[] lineSplit = Line.Split(","); GameObject ModelSelect = UIT.TogOnObject(Get.o2("CABDOORpnl/MODELS/Viewport", "Content")); string ModelName = ModelSelect.transform.Find("Image/Text").GetComponent().text; //Slab door //print("ModelName====" + ModelName); if (!string.IsNullOrEmpty(Line) && lineSplit.Length > 1 && !lineSplit[0].Contains("ID") && lineSplit[IndexOfModel] == Model && lineSplit[IndexOfModelName] == ModelName) { if (!AvailableDoor.Contains(lineSplit[IndexOfDoorID])) { AvailableDoor.Add(lineSplit[IndexOfDoorID]); } } } //CREATE TEXTURE LIST AVAILABLE FOR THE MODEL List Color_IDList = new(); foreach (string DoorID in AvailableDoor) { string ColorID = UIT.Value(Library.Door, DoorID, Header.ColorID);//2_3_4_5_6_7 print("DoorID==" + DoorID + " ColorID ===== " + ColorID); if (ColorID.Contains("_")) { string[] ColorIDsplit=ColorID.Split("_"); foreach(string CID in ColorIDsplit) { Color_IDList.Add(CID+"_"+DoorID); } } else if (ColorID == "All") { foreach (string line in _G.UIT_LibraryCabTextures) { print("line====" + line); string[] l = line.Split(","); if (!string.IsNullOrEmpty(l[0]) && !l[0].Contains("ID") && !Color_IDList.Contains(l[0])) { print("ColorList.Add(l[0]==" + l[0]); if (!Color_IDList.Contains(l[0])) { Color_IDList.Add(l[0]+"_"+DoorID); } } } } else { if (!Color_IDList.Contains(ColorID+"_"+DoorID)) { Color_IDList.Add(ColorID+"_"+DoorID); } } } //ADD TEXTURE TO CONTAINER foreach (string Color in Color_IDList) { string[] Col = Color.Split("_"); AddTexturetoContainer(Col[1], BtnTexture, PnlTexture, Col[0]); } Set.ToggleGroupToAllChild(_G.PON + "/TEXTCOL/Viewport/Content"); // string ColorID; // if (UIT.Ind(Library.Door, Header.ColorID) != 0) { ColorID = UIT.Value(Library.Door, Model, Header.ColorID); } // else { ColorID = UIT.Value(Library.Door, Model, Header.Color_ID); } // DOIT.DELETEAllObjectChild(PnlTexture); // int CabTextureCount = _G.UIT_LibraryCabTextures.Count; // List ColorIDSelection = new(); // if (ColorID == "All") // { // for (int i = 1; i < CabTextureCount; i++) // { // if (!string.IsNullOrEmpty(_G.UIT_LibraryCabTextures[i])) // { // ColorIDSelection.Add(_G.UIT_LibraryCabTextures[i].Split(',')[0]); // } // } // } // else ColorIDSelection = ColorID.Split('_').ToList(); // for (int i = 0; i < ColorIDSelection.Count; i++) // { // GameObject O = Instantiate(BtnTexture); // O.transform.SetParent(PnlTexture.transform, false); // O.SetActive(true); // O.name = ColorIDSelection[i]; // O.transform.Find("Image/Text").GetComponent().text = UIT.Value(Library.CabTexture, O.name, Header.Unique_Name); // //print("O.name==="+O.name); // //Image Background // O.transform.Find("Background").GetComponent().sprite = UIT_MATERIAL.GetSprite(O.name); // } // Set.ToggleGroupToAllChild(_G.PON + "/TEXTCOL/Viewport/Content"); } //SHOW public void ModelClick(){ //print(name); ShowLibrary(); string TexColor= UIT.TogOn("TEXTCOL"); print("TexColor===="+TexColor); Get.o2(_G.PON + "/TEXTCOL/Viewport/Content", TexColor).GetComponent().isOn = true; ShowSelecded(TexColor,"Model"); } public void ShowSelecded(){ string ParentName=transform.parent.name; ShowSelecded(name,ParentName); } public static void ShowSelecded(string Colorname, string ParentName) { if (Colorname == "") Colorname = Get.o2(_G.PON + "/TEXTCOL/Viewport", "Content").transform.GetChild(0).name; string model = UIT.TogOn("MODELS"); string ModelName = UIT.GetDoorModelNameTextFromModelSelect(); string DoorID = UIT.GetIDbyModel(Library.Door, model, ModelName); float ct = 0.25f; float E_H = DOIT.ConvertStringToNumber(UIT.Value(Library.Door, DoorID, Header.E_H)); float E_V = DOIT.ConvertStringToNumber(UIT.Value(Library.Door, DoorID, Header.E_V)); float Gap = 0; float dt = DOIT.ConvertStringToNumber(UIT.Value(Library.Door, DoorID, Header.Thick)); DoorShow.FromModel(model, 18, 30, dt, ct, E_H, E_V, Gap, Colorname); //PRESET COLORS if (_G.PATH == "free") { if (ParentName == "PresetColors") { AddColorsToShow(); } else { string C1 = UIT.Value(Library.CabTexture, Colorname, Header.C1).Replace("#", ""); print("C1======" + C1); GameObject PresetColor = Get.o2("CABDOORpnl/PresetColors", C1); if (PresetColor != null) { PresetColor.GetComponent().isOn = true; } } } //DESCRIPTIONS GameObject DES = Get.o2("CABDOORpnl/SHOWSELECTION", "DES"); DOIT.AllChildOff(DES); GameObject IDname = DES.transform.Find("ID").gameObject; IDname.SetActive(true); IDname.GetComponent().text = UIT.Value(Library.Door, DoorID, Header.Unique_Name); GameObject Model = DES.transform.Find("Model").gameObject; Model.SetActive(true); Model.GetComponent().text = UIT.Value(Library.Door, DoorID, "L" + _G.L.ToString()); GameObject ColorUniqueName = DES.transform.Find("ColorUniqueName").gameObject; ColorUniqueName.SetActive(true); ColorUniqueName.GetComponent().text = UIT.Value(Library.CabTexture, Colorname, Header.Unique_Name); GameObject ColorName = DES.transform.Find("ColorDes").gameObject; ColorName.SetActive(true); ColorName.GetComponent().text = UIT.Value(Library.CabTexture, Colorname, "L" + _G.L.ToString()); } //ADD public static void Add() { string model = UIT.TogOn("MODELS"); string TextureID = UIT.TogOn("TEXTCOL"); string ModelName = UIT.GetDoorModelNameTextFromModelSelect(); string DoorID = UIT.GetIDbyModel(Library.Door, model, ModelName); string Code = DoorID + "?" + TextureID ; if (_G.PATH == "free" || _G.PATH == "laminam") { string[] Line = UIT.GetLibraryLine(Library.Door, DoorID); int IndexE_H = UIT.Ind(Library.Door, Header.E_H); int IndexE_V = UIT.Ind(Library.Door, Header.E_V); int IndThick = UIT.Ind(Library.Door, Header.Thick); string Edge = Get.o2("CABDOORpnl/Input", "Edge").GetComponent().text; string Thickness = Get.o2("CABDOORpnl/Input", "DoorThickness").GetComponent().text; Line[IndexE_H] = Edge; Line[IndexE_V] = Edge; Line[IndThick] = Thickness; string UniqueName = UIT.Value(Library.Door, DoorID, Header.Unique_Name); string NewCode = AddToLibrary.ConstructLineCode(Line); print("NewCode ====" + NewCode);//2,Model 2,Modèle 2,Modelo 2,D_02,All,2,2,2,1,1,0.125,0.75,end UIT.ReplaceLineOnLibrary(Library.Door, UniqueName, NewCode); string C1 = Get.TogOn(Get.o2("CABDOORpnl", "PresetColors")).name; string C2 = HexColor2(C1); string TextModel = UIT.Value(Library.CabTexture, TextureID , Header.Texture); TMP_Dropdown Dropdown = Get.o2("CABDOORpnl/COLORS", "Finish").GetComponent(); string Finish = Dropdown.options[Dropdown.value].text; if (C1 != "FFFFFF" && !CabTextureExist(TextModel, Finish, C1, C2)) { //Add new texture to library and Panel int NumberOfCabTextureStart = Get.o2("CABDOORpnl/TEXTCOL/Viewport", "Content").transform.childCount; SaveToLibrary.CabTexture(); if (_G.UIT_LibraryCabTextures.Count > NumberOfCabTextureStart) { TextureID = (NumberOfCabTextureStart + 1).ToString(); } } string eh = Edge; string ev = Edge; string t = Thickness; string ct = "0.25"; string slatWide = "2";//H,V,CH,CV = wood sens on door string senswood = "H";//H,V,CH,CV Code += "?" + eh + "?" + ev + "?" + t + "?" + ct + "?" + slatWide + "?" + senswood;//eh?ev?t?ct?ts?slat } Code = DoorID + "?" + TextureID; //Add to library new col if (!_AI.On && _P.List["GLOBAL_QTY"] != "0") { if (SceneModeManager.SelectedName != "") DOUNIQUE(Code); else DOGLOBAL(Code); } else if (!_AI.On &&_P.List["GLOBAL_QTY"] == "0") { SELECTMETHODE(Code); } else if (_AI.On) { if (AiStep.BoolTitle("Door base")) { DOAi(Code); } else { MODIFICATIONAi(Code); } } } public static bool CabTextureExist(string Text,string Finish ,string C1, string C2){ foreach(string Line in _G.UIT_LibraryCabTextures){ string[] L=Line.Split(','); if(L.Contains(Text) && L.Contains(Finish) && L.Contains(C1) && L.Contains(C2)){ return true; } } return false; } public static void DOGLOBAL(string code) { //print("Global Door========================================================"+UIT.Global(Header.Door,_G.G)); print("Coode from Dogloabal========================================================" + code); //Coode from Dogloabal========================================================D_01?3 //print("G.G========================================================"+_G.G); UIT.GlobalSet(Header.Door, code, _G.G); //Door code ==1?6 DOIT.AddtoCodeCabGlobal(61, code, _G.G); string ExteriorFinishCode = Match_Finish.Exterior_From_Door(code); string KickFinishCode = Match_Finish.Kick_From_Door(code); if (_P.ListSwitch["EXTERIOR_MATCH_DOOR"]) { if (ExteriorFinishCode != "NoMatch") { DOIT.AddtoCodeCabGlobal(69, ExteriorFinishCode, _G.G); UIT.GlobalSet(Header.Ext, ExteriorFinishCode, _G.G); } } if (_P.ListSwitch["KICK_MATCH_DOOR"]) { if (KickFinishCode != "NoMatch") { DOIT.AddtoCodeCabGlobal(63, KickFinishCode, _G.G); UIT.GlobalSet(Header.Kick, KickFinishCode, _G.G); } } //print("Global Door==================new======================================"+UIT.Global(Header.Door,_G.G)); DOIT.REDOALLCab_GNum(_G.G); DOIT.CloseALLPNL(); _MOL.SetMolding(); } public static void DOUNIQUE(string code) { int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); _G.OBJs[nO][60] = "UNIQUE"; _G.OBJs[nO][61] =code; DOIT.REDOCAB(nO); DOIT.CloseALLPNL(); //_MOL.SetMolding(); } public static void DOAi(string code) { string ExteriorFinishCode = Match_Finish.Exterior_From_Door(code); string KickFinishCode = Match_Finish.Kick_From_Door(code); _AI.Door1 = code; _AI.Door2 = code; for (int i = 1; i < 4; i++) { UIT.GlobalSet(Header.Door, code, i); UIT.GlobalSet(Header.Ext, ExteriorFinishCode, i); UIT.GlobalSet(Header.Kick, KickFinishCode, i); } AiButton.Instance.GetButtonGoNext().SetActive(true); AiStep.ShowCounterPreferences(); DOIT.CloseALLPNL(); } public static void MODIFICATIONAi(string code) { string path = "PNL/AI_PNL/MODIFICAION/Selection"; string ModifSelect = Get.ToggleOnInChild(path); int GG = _G.G; if (ModifSelect == "Door Base") { GG = 1; } else if (ModifSelect == "Door Wall") { GG = 2; } else if (ModifSelect == "Door Island") { GG = 3; } UIT.GlobalSet(Header.Door, code, GG); string ExteriorFinishCode = Match_Finish.Exterior_From_Door(code); string KickFinishCode = Match_Finish.Kick_From_Door(code); string ColorID = code.Split("?")[1]; UIT.GlobalSet(Header.Ext, ExteriorFinishCode, GG); UIT.GlobalSet(Header.Kick, KickFinishCode, GG); //Change filler color && Panel attache to cabinet for (var i = 0; i < _G.OBJnum; i++) { if (DOIT.exist(i)) { string[] ADN = _G.OBJs[i]; if (ADN[2] == "Cabinet" && ADN[60].Contains(GG.ToString())) { ADN[61] = code; ADN[69] = ExteriorFinishCode; ADN[63] = KickFinishCode; if (ADN[51] != "NONE") { ADN[51] = DOIT.ChangeCodeOnPos(ADN[51], 1, ColorID, "?"); } if (ADN[81].Contains("?")) { string New81 = ""; string[] ADN81 = ADN[81].Split("_"); foreach (string Side in ADN81) { if (Side == "0") New81 += "0_"; if (Side.Contains("?")) { New81 += DOIT.ChangeCodeOnPos(Side, 1, ColorID, "?") + "_"; } } ADN[81] = New81[..^1]; print("new ADN[81]=====" + ADN[81]); } } if (ADN[2] == "Panel" && ADN[60].Contains(GG.ToString())) { print("ADN[61] ====" + ADN[61]); ADN[61] = DOIT.ChangeCodeOnPos(ADN[61], 0, ColorID, "?"); print("ADN[61] ===2=" + ADN[61]); } } } print("ModifSelect == " + ModifSelect + " GG====" + GG + " code===" + code); DOIT.REDOALLCab_GNum(GG); DOIT.CloseALLPNL(); DOIT.AllSelOff(); } public static void SELECTMETHODE(string code){ UIT.GlobalSet(Header.Door, code, _G.G); string ColorID = code.Split("?")[1]; List CabinetsToModify = Get.CabinetsToModifyInt(); if(!_Add.YOUR_DOORS.Contains(code)){ print("Add door =====" + code); _Add.Door(code); } foreach (int Ind in CabinetsToModify) { string[] ADN = _G.OBJs[Ind]; ADN[61] = code; ADN[69] = Match_Finish.Exterior_From_Door(code); string Sens = ADN[69].Split('?')[1]; _Add.Panel(code.Split("?")[1] + "?0"); ADN[63] = Match_Finish.Kick_From_Door(code); if (ADN[51] != "NONE") { ADN[51] = DOIT.ChangeCodeOnPos(ADN[51], 1, ColorID, "?"); } if (ADN[81].Contains("?")) { string New81 = ""; string[] ADN81 = ADN[81].Split("_"); foreach (string Side in ADN81) { if (Side == "0") New81 += "0_"; if (Side.Contains("?")) { New81 += DOIT.ChangeCodeOnPos(Side, 1, ColorID, "?") + "_"; } } ADN[81] = New81[..^1]; } DOIT.REDOCAB(Ind); } DOIT.CloseALLPNL(); DOIT.AllSelOff(); } //PRESET COLORS FREE VERSION public void SetColor() { string ColorHex = Get.TogOn(Get.o2("CABDOORpnl", "PresetColors")).name; print("ColorHex===" + ColorHex); string Texture = UIT.TogOn("TEXTCOL"); ShowSelecded(Texture, "PresetColors"); } public static void AddColorsToShow(){ string ColorHex=Get.TogOn(Get.o2("CABDOORpnl","PresetColors")).name; GameObject DoorShow=Get.o1("3D Object Show").transform.GetChild(0).gameObject; string ColorHex2= HexColor2(ColorHex); foreach(Transform Mcx in DoorShow.transform){ Mcx.GetComponent().material.SetColor("_c1",DOIT.CSc(ColorHex,255)); Mcx.GetComponent().material.SetColor("_c2",DOIT.CSc(ColorHex2,255)); } } public static string HexColor2(string C1) { string ColorHex2 = C1; switch (C1) { case "FFFFFF": ColorHex2 = "000000"; break; case "EBE8DB": ColorHex2 = "CAB7A7"; break; case "DEDEDE": ColorHex2 = "939393"; break; case "BBB5B5": ColorHex2 = "5E5B5B"; break; case "827C7C": ColorHex2 = "000000"; break; case "F3E5CD": ColorHex2 = "8A8A8A"; break; case "D2B796": ColorHex2 = "736363"; break; case "A9836D": ColorHex2 = "574423"; break; case "7F4A21": ColorHex2 = "#C07439"; break; case "634238": ColorHex2 = "9C816E00"; break; case "4F3F3F": ColorHex2 = "000000"; break; case "AEC7B5": ColorHex2 = "83936B"; break; case "8698A5": ColorHex2 = "5F6371"; break; case "596E5E": ColorHex2 = "162615"; break; case "4E5D7F": ColorHex2 = "1A1F33"; break; case "BB4242": ColorHex2 = "411111"; break; case "A6977E": ColorHex2 = "655147"; break; case "858773": ColorHex2 = "404132"; break; } return ColorHex2; } }