using System.Collections.Generic; //using System.Diagnostics.Eventing.Reader; //using System.Windows.Forms; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class EditPNL : MonoBehaviour { [SerializeField] GameObject PNL; [SerializeField] GameObject OptionsList; [SerializeField] Text Tittle; [SerializeField] GameObject SwitchBtn; [SerializeField] GameObject Fillers; [SerializeField] GameObject Counters; [SerializeField] GameObject Recovers; [SerializeField] GameObject Side; [SerializeField] GameObject BackSplash; [SerializeField] GameObject Knob; [SerializeField] GameObject Door; [SerializeField] GameObject Ogee; [SerializeField] GameObject Valance; [SerializeField] GameObject Fascia; [SerializeField] GameObject Kick; [SerializeField] GameObject EDITOR; [SerializeField] GameObject SideSelectorList; [SerializeField] GameObject Left; [SerializeField] GameObject Right; [SerializeField] GameObject Back; [SerializeField] GameObject Front; [SerializeField] GameObject Back_Right; [SerializeField] GameObject Back_Left; [SerializeField] GameObject ColorSelectionList; [SerializeField] GameObject MoreOptionsList; [SerializeField] GameObject Ghost; [SerializeField] GameObject DropdownList; [SerializeField] GameObject DropSelection1; [SerializeField] GameObject DropSelection2; [SerializeField] GameObject CounterList; [SerializeField] GameObject Add_Btn; [SerializeField] GameObject BackSplashList; [SerializeField] GameObject _ModifyColor; [SerializeField] GameObject Retraction; [SerializeField] GameObject InputField; [SerializeField] GameObject SliderLight; private string OptionActive; private string UniqueName; private string GlobalNumberSelectedColor; private string Side_Select; private string CategoryObject; private string CabinetModel; GameObject CounterInputs; GameObject BackSplashInputs; string[] CounterCode; public void OpenPNL() { _G.nO = Get.GetObjectIndex(SceneModeManager.SelectedName); //print("_G.OBJs[_G.nO][1]====1="+_G.OBJs[_G.nO][1]);//_G.OBJs[_G.nO][1]====1=BD2 string Category=""; if(_G.OBJs[_G.nO][1].Length>4){Category=_G.OBJs[_G.nO][1][..4];} // print("_G.OBJs[_G.nO][1]====1=Category==="+Category); if(new List {"BLOC","TABL","CHAI","STOO","MIRR","VASE","PICT","SMAL","LAMP","TOIL","BATH","SHAW",}.Contains(Category) ) { //Modify Color if(SceneModeManager.SelectedName.IndexOf("bloc")!=-1) { _ModifyColor.SetActive(true); } else{ _ModifyColor.SetActive(true); } } else { //OPEN EDIT PNL PNL.SetActive(true); SceneModeManager.Instance.SetSceneMode(SceneModes.Panel); PNL.transform.localPosition=new(0,0,0); //Add selection on Title Tittle.text=_G.OBJs[_G.nO][1]; //Options SetAvailableOptions(); //All list false AllActive(false,new (){SideSelectorList,Add_Btn,ColorSelectionList,MoreOptionsList,DropdownList,CounterList,InputField,SliderLight}); } if(_G.OBJs[_G.nO][2]=="Panel"){ CABTEXTUREpnl.StartPNLFromEdit("ObjectPanel"); } } public void SetAvailableOptions() { UniqueName=_G.OBJs[_G.nO][1]; CategoryObject=_G.OBJs[_G.nO][2]; //string[] LineCode; DOIT.AllChildOff(OptionsList); if(CategoryObject=="Cabinet"){ //LineCode=UIT.GetLibraryLine(Library.Cabinet,UniqueName); CabinetModel=_G.OBJs[_G.nO][4]; //_G.SC[1]=CabinetModel ; List ListOptions=new(){}; if(new List {"B1","B2","B3","B4","B5","B6","B7","B9","B10","B19","B20"}.Contains(CabinetModel)) { ListOptions=new (){Fillers,Counters,BackSplash,Knob}; if(_P.ListSwitch["ALLOW_EDIT_KICK"])ListOptions.Add(Kick); } if(new List {"W1","W2","W3","W4","W5","W6","W7","W9","W10","W19","W20"}.Contains(CabinetModel)) { ListOptions=new (){Fillers,BackSplash,Knob,SwitchBtn}; if(_P.ListSwitch["OGEE_SELECT"])ListOptions.Add(Ogee); if(_P.ListSwitch["FASCIA_SELECT"])ListOptions.Add(Fascia); if(_P.ListSwitch["VALANCE_SELECT"])ListOptions.Add(Valance); } if(new List {"T1"}.Contains(CabinetModel)) { ListOptions=new (){Fillers,BackSplash,Knob}; if(_P.ListSwitch["OGEE_SELECT"])ListOptions.Add(Ogee); if(_P.ListSwitch["FASCIA_SELECT"])ListOptions.Add(Fascia); if(_P.ListSwitch["KICK_SELECT"])ListOptions.Add(Kick); } if(_P.ListSwitch["DOOR_SELECT"])ListOptions.Add(Door); if(_P.ListSwitch["EXTERIOR_SELECT"])ListOptions.Add(Side); AddOptionsOnList(OptionsList,ListOptions); } if(CategoryObject=="Window" || _G.OBJs[_G.nO][4]=="stov" ){ AddOptionsOnList(OptionsList,new (){BackSplash}); } else if(_G.OBJs[_G.nO][4]=="dish" ){ CabinetModel=_G.OBJs[_G.nO][4]; AddOptionsOnList(OptionsList,new (){BackSplash,Counters}); } else if(_G.OBJs[_G.nO][4]=="hood" ){ AddOptionsOnList(OptionsList,new (){BackSplash,SwitchBtn}); } else if(_G.OBJs[_G.nO][4]=="wine" ){ CabinetModel="B1"; AddOptionsOnList(OptionsList,new (){Counters}); } DOIT.AllTogchildfalse(OptionsList); } public void SelectionClick(){ OptionActive=Get.TogOn(OptionsList).name; AllActive(false,new (){SideSelectorList,Add_Btn,ColorSelectionList,MoreOptionsList,DropdownList,CounterList,BackSplashList,InputField,Retraction,SliderLight}); if(OptionActive=="FILLER" && OptionsList.transform.Find("FILLER").GetComponent().isOn){ SelectionFILLER(); } switch(OptionActive){ case "COUNTER":SelectionCOUNTER();break; case "RECOVER":SelectionRECOVER();break; case "BACKSPLASH":SelectionBACKSPLASH();break; case "DOOR":SelectionDOOR();break; case "OGEE":SelectionOGEE();break; case "FASCIA":SelectionFASCIA();break; case "VALANCE":SelectionVALANCE();break; case "KICK":SelectionKICK();break; case "SIDE":SelectionSIDE();break; case "SWITCH":SelectionSWITCH();break; } } //---------------------SELECTIONS------------------------------------------- public void SelectionFILLER(){ AllActive(true,new (){ColorSelectionList,SideSelectorList,DropdownList,MoreOptionsList,Add_Btn}); AddOptionsOnList(SideSelectorList,new (){Left,Right}); DOIT.AllTogchildfalse(SideSelectorList); DropSelection1.SetActive(false); DropSelection2.SetActive(false); Add_Btn.SetActive(false); SetGlobalTexture(); //InputField.SetActive(true); //SetFillerWide(); } public void SelectionCOUNTER(){ AllActive(true,new (){ColorSelectionList,CounterList,MoreOptionsList,Add_Btn}); AddOptionsOnList(DropdownList,new (){DropSelection1}); SetGlobalTexture(); SetCounterList(); } public void SelectionRECOVER(){ AllActive(true,new (){ColorSelectionList,SideSelectorList,DropdownList,Add_Btn}); AddOptionsOnList(SideSelectorList,new (){Left,Back,Right}); DOIT.AllTogchildfalse(SideSelectorList); DropSelection1.SetActive(false); DropSelection2.SetActive(false); Add_Btn.SetActive(false); SetGlobalTexture(); } public void SelectionBACKSPLASH(){ AllActive(true,new (){ColorSelectionList,BackSplashList,Add_Btn}); DOIT.AllChildOff(BackSplashList); Add_Btn.SetActive(false); SetGlobalTexture(); SetBackSplashList(); } public void SelectionDOOR(){ DoorCabPNL.StartPNL(); } public void SelectionOGEE(){ MoldingPNL.StartPNL("Ogee"); } public void SelectionVALANCE(){ MoldingPNL.StartPNL("Valance"); } public void SelectionFASCIA(){ MoldingPNL.StartPNL("Fascia"); } public void SelectionKICK(){ AllActive(true,new (){ColorSelectionList,Retraction,SideSelectorList,Add_Btn}); if(new List(){"B1","T1"}.Contains(CabinetModel)) { AddOptionsOnList(SideSelectorList,new (){Left,Back,Right,Front}); } if(new List(){"B2","B3","B4","B5","B9","B10"}.Contains(CabinetModel)) { AddOptionsOnList(SideSelectorList,new (){Left,Back_Left,Back_Right,Right,Front}); } SetGlobalTexture(); //SetFillerWide(); //MoldingPNL.StartPNL("Kick"); } public void SelectionSIDE(){ AllActive(true,new (){ColorSelectionList,SideSelectorList,Add_Btn}); if(new List(){"B1","T1","W1"}.Contains(CabinetModel)) { AddOptionsOnList(SideSelectorList,new (){Left,Back,Right}); } if(new List(){"B2","B3","B4","B5","B9","B10","W2","W3","W4","W5","W9","W10"}.Contains(CabinetModel)) { AddOptionsOnList(SideSelectorList,new (){Left,Back_Left,Back_Right,Right}); } SetGlobalTexture(); } public void SelectionSWITCH(){ print("SWITCH SELLECT"); AllActive(true,new (){SliderLight,Add_Btn}); Switch.OnOff(); } //------------------SETTING LIST------------------------ public void AddOptionsOnList(GameObject ListObject, List ListOptions){ DOIT.AllChildOff(ListObject); foreach(GameObject o in ListOptions){ o.SetActive(true); } } public void AllActive(bool isActive,List ListOptions){ foreach(GameObject o in ListOptions){ o.SetActive(isActive); } } public void SetGlobalTexture(){ DOIT.AllChildOff(ColorSelectionList); ColorSelectionList.transform.Find("NONE").gameObject.SetActive(true); if(new List {"FILLER","RECOVER" }.Contains(OptionActive)) { ColorSelectionList.transform.Find("NONE").gameObject.SetActive(true); // for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++){ // string[] G=UIT.Global(Header.Ext,i).Split('?'); // ColorSelectionList.transform.Find("G"+i.ToString()).gameObject.SetActive(true); // ColorSelectionList.transform.Find("G"+_G.G.ToString()).gameObject.GetComponent().isOn=true; // Get.o2("G"+i.ToString(), "Background").GetComponent().sprite = UIT_MATERIAL.GetSprite(G[0]); // } } if(OptionActive=="COUNTER") { for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++){ string CounterCode=UIT.Global(Header.Counter,i); ColorSelectionList.transform.Find("G"+i.ToString()).gameObject.SetActive(true); ColorSelectionList.transform.Find("G"+_G.G.ToString()).gameObject.GetComponent().isOn=true; Get.o2("G"+i.ToString(), "Background").GetComponent().sprite= UIT_MATERIAL.GetSprite(CounterCode); } } if(OptionActive=="BACKSPASH") { for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++){ string SplashCode=UIT.Global(Header.Splash,i); ColorSelectionList.transform.Find("G"+i.ToString()).gameObject.SetActive(true); ColorSelectionList.transform.Find("G"+_G.G.ToString()).gameObject.GetComponent().isOn=true; Get.o2("G"+i.ToString(), "Background").GetComponent().sprite= UIT_MATERIAL.GetSprite(SplashCode); } } if(OptionActive=="KICK") { for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++) { string KickCode=UIT.Global(Header.Kick,i); ColorSelectionList.transform.Find("G"+i.ToString()).gameObject.SetActive(true); ColorSelectionList.transform.Find("G"+_G.G.ToString()).gameObject.GetComponent().isOn=true; Get.o2("G"+i.ToString(), "Background").GetComponent().sprite= UIT_MATERIAL.GetSprite(KickCode); } ColorSelectionList.transform.Find("SETCOL").gameObject.SetActive(true); } if(OptionActive=="SIDE") { for(int i=1; i<_P.Listfloat["GLOBAL_QTY"]+1; i++) { string ColorCode=UIT.Global(Header.Ext,i); ColorSelectionList.transform.Find("G"+i.ToString()).gameObject.SetActive(true); ColorSelectionList.transform.Find("G"+_G.G.ToString()).gameObject.GetComponent().isOn=true; Get.o2("G"+i.ToString(), "Background").GetComponent().sprite= UIT_MATERIAL.GetSprite(ColorCode); } ColorSelectionList.transform.Find("SETCOL").gameObject.SetActive(true); } } public void SetCounterList(){ print("_G.OBJs[_G.nO][42]===="+_G.OBJs[_G.nO][42]); DOIT.AllChildOff(CounterList); CounterInputs= CounterList.transform.Find("COUNTER"+CabinetModel).gameObject; CounterInputs.SetActive(true); //Fill all inputs _G.OBJs[_G.nO][42]=_G.OBJs[_G.nO][42].Replace(",","_"); CounterCode=_G.OBJs[_G.nO][42].Split('_'); CounterInputs.transform.Find("MoH/Btn Mesure/mH").gameObject.GetComponent().text=CounterCode[0]; if(new List {"B1","dish"}.Contains(CabinetModel)) { SetCounterInput("L", 1); SetCounterInput("B", 2); SetCounterInput("R", 3); SetCounterInput("F", 4); SetCounterInput("BL", 5); SetCounterInput("BR", 6); } if(new List {"B2","B3","B4","B5","B9","B9"}.Contains(CabinetModel)) { SetCounterInput("L", 1); SetCounterInput("BL", 2); SetCounterInput("BR", 3); SetCounterInput("R", 4); SetCounterInput("F", 5); } } public void SetBackSplashList(){ DOIT.AllChildOff(BackSplashList); if(_G.OBJs[_G.nO][2]=="Cabinet"){ BackSplashInputs = BackSplashList.transform.Find("BS"+CabinetModel).gameObject; } else if(_G.OBJs[_G.nO][2]=="Window"){ BackSplashInputs = BackSplashList.transform.Find("BSW1").gameObject; } else if(_G.OBJs[_G.nO][4]=="dish" || _G.OBJs[_G.nO][4]=="stov"){ BackSplashInputs = BackSplashList.transform.Find("BSB1").gameObject; } else if(_G.OBJs[_G.nO][1].IndexOf("HOOW")!=-1){ BackSplashInputs = BackSplashList.transform.Find("BSW1").gameObject; } BackSplashInputs.SetActive(true); //Fill all inputs // CounterCode=_G.OBJs[_G.nO][42].Split('_'); // CounterInputs.transform.Find("MoH/Btn Mesure/mH").gameObject.GetComponent().text=CounterCode[0]; // if(new List {"B1"}.Contains(CabinetModel)) // { // SetCounterInput("L", 1); // SetCounterInput("B", 2); // SetCounterInput("R", 3); // SetCounterInput("F", 4); // SetCounterInput("BL", 5); // SetCounterInput("BR", 6); // } } public void SetCounterInput(string Letter, int Indcode){ print("Letter===="+Letter); CounterInputs.transform.Find("TopControl/Selection/Mo"+Letter+"/Btn Mesure/m"+Letter).gameObject.GetComponent().text=CounterCode[Indcode]; } public void SetDropdownRecoverSelection(){ // List PanelSelection= new(); // foreach(string sel in _G.UIT_LibraryPanels){ // if(!string.IsNullOrEmpty(sel) && sel.Split(',')[0].IndexOf("ID")==-1){ // string ID=sel.Split(',')[0]; // string uniqueName=UIT.Value(Library.Panel,ID,Header.Unique_Name); // PanelSelection.Add(uniqueName); // } // } // TMP_Dropdown DropSel=DropSelection1.GetComponent(); // DropSel.ClearOptions(); // DropSel.AddOptions(PanelSelection); //Recover.AddFitPanelFromList(); } public static void AddDropdownItems(GameObject DropSel,List ListItems){ TMP_Dropdown Drop = DropSel.GetComponent(); Drop.ClearOptions(); Drop.AddOptions(ListItems); } public void SetFillerWide(){ InputField.GetComponent().text="3"; InputField.transform.Find("Min").GetComponent().text="0.125"; InputField.transform.Find("Max").GetComponent().text="3"; } //------------------GET VALUES----------------------- public string GetCounterInput(string Letter){ GameObject Input = CounterInputs.transform.Find("TopControl/Selection/Mo"+Letter+"/Btn Mesure/m"+Letter).gameObject; if(Input == null || !Input.activeInHierarchy){return "O";} return DOIT.CSs(Input.GetComponent().text).Replace(" ",""); } public string GetCounterFallOut(string Letter){ GameObject Input = CounterInputs.transform.Find("TopControl/SIDES/Side"+Letter).gameObject; if(Input == null || !Input.activeInHierarchy){return "OFF";} if(Input.GetComponent().isOn)return "ON"; return "OFF"; } //------------------ADD TO SCENE----------------------- public void ADDclick(){ if(OptionActive=="FILLER"){ AddFILLER();} if(OptionActive=="COUNTER"){AddCOUNTER();} if(OptionActive=="RECOVER"){AddRECOVER();} if(OptionActive=="KICK"){AddKICK();} if(OptionActive=="SIDE"){AddSIDE();} if(OptionActive=="SWITCH"){PNL.SetActive(false);} } public void AddFILLER(){ print("----FILLER----"); Side_Select=Get.TogOn(SideSelectorList).name; GlobalNumberSelectedColor=Get.TogOn(ColorSelectionList).name; TMP_Dropdown DropSel=DropSelection1.GetComponent(); string MoldingUniqueName=DropSel.options[DropSel.value].text; bool isGhost=Ghost.GetComponent().isOn; //Get size from Input //Color From Dropbox2 TMP_Dropdown DropColor=DropSelection2.GetComponent(); string ColorUniqueName=DropColor.options[DropColor.value].text; string ColorID=UIT.GetIDByUnique_Name(Library.CabTexture,ColorUniqueName); Filler.AddtoCabinet(MoldingUniqueName,GlobalNumberSelectedColor,Side_Select,isGhost,ColorID); } public void AddCOUNTER(){ Side_Select=Get.TogOn(SideSelectorList).name; string[] C=_G.OBJs[_G.nO]; string ComptorHeight=CounterInputs.transform.Find("MoH/Btn Mesure/mH").gameObject.GetComponent().text; C[42]=DOIT.CSs(ComptorHeight).Replace(" ","") +"_"; if(C[4]=="B1" || C[4]=="dish" || C[4]=="wine") { C[42]+=GetCounterInput("L")+"_"; C[42]+=GetCounterInput("B")+"_"; C[42]+=GetCounterInput("R")+"_"; C[42]+=GetCounterInput("F")+"_"; C[42]+=GetCounterInput("BL")+"_"; C[42]+=GetCounterInput("BR")+"_0_0"; C[45]=GetCounterFallOut("L"); C[46]=GetCounterFallOut("B"); C[47]=GetCounterFallOut("R"); } if(new List{"B2","B3","B4","B5","B9","B10"}.Contains(C[4])) { C[42]+=GetCounterInput("L")+"_"; C[42]+=GetCounterInput("BL")+"_"; C[42]+=GetCounterInput("BR")+"_"; C[42]+=GetCounterInput("R")+"_"; C[42]+=GetCounterInput("F")+"_"; C[42]+=GetCounterInput("F")+"_0_0"; } print("C[42]===="+C[42]);//C[42]====2_0_0_0_0_0_0_0_0 GlobalNumberSelectedColor=Get.TogOn(ColorSelectionList).name;//G1 if(GlobalNumberSelectedColor!="NONE"){ int GlobalInd=int.Parse(GlobalNumberSelectedColor.Replace("G","")); C[41] = UIT.Global(Header.Counter,GlobalInd); bool isGhost=Ghost.GetComponent().isOn; C[11]=C[42].Split("_")[0].Replace(" ",""); Counter.AddtoCabinet(isGhost); } else{ C[42]="0_0_0_0_0_0_0_0"; C[11]="0"; Counter.AddtoCabinet(false); } } public void AddRECOVER(){ Side_Select=Get.TogOn(SideSelectorList).name; GlobalNumberSelectedColor=Get.TogOn(ColorSelectionList).name; //TMP_Dropdown DropSel=DropSelection1.GetComponent(); Recover.AddtoCabinetFromEditPNL(GlobalNumberSelectedColor,Side_Select); } public void AddKICK(){ Side_Select=Get.TogOn(SideSelectorList).name; GlobalNumberSelectedColor=Get.TogOn(ColorSelectionList).name; string Retraction = Get.o2("EDITCABpnl/EDITOR/Retraction/MoR/Btn Mesure","mR").GetComponent().text; EditKick.SetKickFromEditPNL(Side_Select,GlobalNumberSelectedColor,Retraction); } public void AddSIDE(){ GameObject SelectionSide=Get.TogOn(SideSelectorList); GlobalNumberSelectedColor=Get.TogOn(ColorSelectionList).name; //Add Message when no selection if(SelectionSide.GetComponent().isOn){ SideSelect.AddtoCabinetFromEditPNL(GlobalNumberSelectedColor,SelectionSide.name); } else{ print("Message"); _M.PH(1, 0, "ffffff", 1, 1); } } public void UniqueColor(){ print("OptionActive==="+OptionActive); if(OptionActive=="KICK"){MoldingPNL.StartPNL("Kick");} if(OptionActive=="SIDE"){ _G.SC[0]=Get.TogOn(SideSelectorList).name; CABTEXTUREpnl.StartPNLFromEdit("EditSidePnl"); } } }