using UnityEngine.UI; using UnityEngine; using UnityEngine.UI.Extensions; using System.Collections.Generic; using TMPro; public class ROWHEIGHT : MonoBehaviour { static float sc = 1; public void Open() { _G.PON="ROWHEIGHTPNL"; Get.o2("CABINETpnl","ROWHEIGHTPNL").SetActive(false); Allfalse.SetCabPnlOpen(); Get.o1("CABINETpnl").transform.Find("ROWHEIGHTPNL").gameObject.SetActive(true); Get.o2("ROWHEIGHTPNL", "FACEpnl").SetActive(false); Get.o1("SHOWSELECTION").transform.Find("DIMS").gameObject.SetActive(true); _G.Cab_Labrary_On="Cabinet"; //if(UIT.TogOn("FILTERS")=="Ukitchenit")_G.Cab_Labrary_On="CabinetUkitchenit"; _G.CODEPATERN = UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Pattern_Door_1"); _G.CODEPATERN2 = UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Pattern_Door_2"); _G.VF=UIT.Value(_G.Cab_Labrary_On,_G.SC[0], "FV1"); _G.VF2=UIT.Value(_G.Cab_Labrary_On,_G.SC[0], "FV2"); SetPWPH(); _G.CODEPATERN = DC.ResizeNew(_G.CODEPATERN, _G.D1W , _G.PH, _G.SC[0]).Replace(",", "_"); GameObject DoorNumber=Get.o2("CABINETpnl/ROWHEIGHTPNL","DoorNumber"); Set.alpha(DoorNumber,false); if(!string.IsNullOrEmpty(_G.CODEPATERN2)){ _G.CODEPATERN2 = DC.ResizeNew(_G.CODEPATERN2, _G.D1W , _G.PH, _G.SC[0]); _G.CODEPATERN2 = _G.CODEPATERN2.Replace(",", "_"); Set.alpha(DoorNumber,true); } AddPATERN(); RedoEditRow(); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "RowHeightBtn").SetActive(false); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "DELETEFROMLIST").SetActive(false); //Get.o2("CABINETpnl/SHOWSELECTION", "CREATENEWCAB").SetActive(false); //Set locks _G.VF=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"FV1"); _G.VF2=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"FV2"); string[] dvf = _G.VF.Split('_'); for (int i = 0; i < dvf.Length; i++) {//Get all variables and caculate if (dvf[i].IndexOf("f") != -1) { //set lock i to true Get.o2("CABINETpnl/ROWHEIGHTPNL/ROWEDITS/editRow"+(i+1).ToString(),"Lock").GetComponent().isOn=true; } } // if (_G.User == "Admin") { // Get.o2("CABINETpnl/SHOWSELECTION", "CREATENEWCAB").SetActive(true); // GameObject NumRow=Get.o2("CABINETpnl/ROWHEIGHTPNL", "RowNum"); // NumRow.SetActive(true); // NumRow.GetComponent().SetValueWithoutNotify(dvf.Length-1); // } // else { // Get.o2("CABINETpnl/SHOWSELECTION", "CabCreator").SetActive(false); // Get.o2("CABINETpnl/ROWHEIGHTPNL", "RowNum").SetActive(false); // } } public static void AddPATERN() { DOIT.DELETEAllChild("PATERN"); string[] C1=_G.CODEPATERN.Split('_'); string[] C2=_G.CODEPATERN.Split('_'); float XW = DOIT.ConvertStringToNumber(C1[0]); float YH = DOIT.ConvertStringToNumber(_G.CODEPATERN.Split('_')[1]); string model=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Model"); string path = "CABINETpnl/ROWHEIGHTPNL/PATERN"; if (_G.PNL == "NewCAB") { path = "CABINETpnl/ADDINPUTS/PATERN"; } GameObject PATERN = Get.o1(path); float ofs1=0; Scaling(XW,YH); GameObject DS1 = DrawPATERN( _G.CODEPATERN,1,1); GameObject DS2; if (!string.IsNullOrEmpty(_G.CODEPATERN2)){ XW+=DOIT.ConvertStringToNumber(C2[0]); DS2 = DrawPATERN(_G.CODEPATERN2,2,-1); Scaling(XW,YH); float ofs2=0; if (model == "B2" || model == "W2") { ofs1=(DOIT.ConvertStringToNumber(C1[0])+1)*0.5f*sc; ofs2=-(DOIT.ConvertStringToNumber(C2[0])+1)*0.5f*sc; } if (model == "B3" || model == "W3") { ofs1=-(DOIT.ConvertStringToNumber(C1[0])+1)*0.5f*sc; ofs2=(DOIT.ConvertStringToNumber(C2[0])+1)*0.5f*sc; } DS2.transform.localScale = new Vector3(sc, sc, 1); DS2.transform.SetParent(PATERN.transform,false); DS2.transform.localPosition= new Vector3(ofs2, 0, 0); } Scaling(XW,YH); DS1.transform.localScale = new Vector3(sc, sc, 1); DS1.transform.SetParent(PATERN.transform,false); DS1.transform.localPosition= new Vector3(ofs1, 0, 0); } public static void Scaling(float XW,float YH){ float scf = 300; sc = scf / YH;//(_G.D1W +_G.D2W); if(sc*XW>360)sc=360/XW; } public static GameObject DrawPATERN(string Code,int DoorNumber,int sens) { GameObject DS = new( "doorPatern"+DoorNumber.ToString()); Code=Code.Replace(",","_"); string[] C = Code.Split('_');//Code float sx = DOIT.ConvertStringToNumber(C[3]); float sy = DOIT.ConvertStringToNumber(C[4]); float PW = DOIT.ConvertStringToNumber(C[0]); float PH = DOIT.ConvertStringToNumber(C[1]); float px = -PW / 2f + sx / 2f; float py = PH / 2f - sy / 2f; int nd = (C.Length - 2) / 4;//number of door for (int i = 0; i < nd ; i++){ int a = 2 + 4 * i; if (i>0 ) { px += DOIT.ConvertStringToNumber(C[a-3])*0.5f+DOIT.ConvertStringToNumber(C[a+1])*0.5f ; if (px >= PW *0.5f) { _G.RTOT += 1; px = - PW / 2f + DOIT.ConvertStringToNumber(C[a+1])*0.5f ; py -= DOIT.ConvertStringToNumber(C[a-2])*0.5f + DOIT.ConvertStringToNumber(C[a+2])*0.5f; } } CreateDoor(DS, (i + 1).ToString(), C[a], DOIT.ConvertStringToNumber(C[a+1]) , DOIT.ConvertStringToNumber(C[a+2]) , px, py); //knob if (C[a] != "0") { if(C[a]!="dd"){ Addknob(DS,(i + 1).ToString(), DOIT.ConvertStringToNumber(C[a+1]), DOIT.ConvertStringToNumber(C[a+2]), C[a+3], px, py); } if(C[a]=="dd"){ Addknob(DS,(i + 1).ToString(), DOIT.ConvertStringToNumber(C[a+1]), DOIT.ConvertStringToNumber(C[a+2])*0.5f, C[a+3], px, py+DOIT.ConvertStringToNumber(C[a+2])*0.25f); Addknob(DS,(i + 1).ToString()+"B", DOIT.ConvertStringToNumber(C[a+1]), DOIT.ConvertStringToNumber(C[a+2])*0.5f, C[a+3], px, py-DOIT.ConvertStringToNumber(C[a+2])*0.25f); } } } //SIZE HEADER float W = DOIT.ConvertStringToNumber(C[0]); float H = DOIT.ConvertStringToNumber(C[1]); Get.o1("PaternSizeW").GetComponent().text = Del0(W) + _G.Sys; Get.o1("PaternSizeH").GetComponent().text = Del0(H) + _G.Sys; SetCab.Paternskew(UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Cab_Image")); return DS; } public static void RedoEditRow() { DOIT.DELETEAllChild("ROWEDITS"); string VF; if(GetDoorNumber()=="1"){VF=_G.VF;} else {VF=_G.VF2;} int RT=VF.Split('_').Length; string[] div=VF.Split('_'); AddRowEdit(1, GetRowYH(1,"Y"),div[0].Split('.').Length-1); if (RT > 1) { AddRowEdit(2, GetRowYH(2,"Y"),div[1].Split(',').Length-1); } if (RT > 2) { AddRowEdit(3, GetRowYH(3,"Y"),div[2].Split('.').Length-1); } if (RT > 3) { AddRowEdit(4, GetRowYH(4,"Y"),div[3].Split('.').Length-1); } if (RT > 4) { AddRowEdit(5, GetRowYH(5,"Y"),div[4].Split('.').Length-1); } if (RT > 5) { AddRowEdit(6, GetRowYH(6,"Y"),div[5].Split('.').Length-1); } } static void AddRowEdit(int Ns, float RY, int div) { GameObject ROWEDIT = Get.o2("CABINETpnl/","UIT_ROWEDIT"); GameObject EDITROW = Instantiate(ROWEDIT, new Vector3(0, 0, 0), Quaternion.identity); EDITROW.SetActive(true); EDITROW.name = "editRow" + Ns; string path = "CABINETpnl/ROWHEIGHTPNL/ROWEDITS"; if (_G.PNL == "NewCAB") { path = "CABINETpnl/ADDINPUTS/ROWEDITS"; } GameObject ROWEDITS = Get.o1(path); EDITROW.transform.SetParent(ROWEDITS.transform, false); EDITROW.transform.localPosition = new Vector3(0, RY* sc, 0); Get.o2(EDITROW.name, "InputField_HR").GetComponent().text = GetRowYH(Ns,"H").ToString(); Get.o2(EDITROW.name, "DivDrop").GetComponent().SetValueWithoutNotify(div-1); } public static void SetPWPH() { string category=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Category"); string model=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Model"); float A; float C; float E; float F; A=GetValue("A"); if(category =="BASE" || category =="TALL" || category =="CBASE" ){ _G.PH=GetValue("D"); } if(category =="WALL" || category =="CWALL" ){_G.PH=GetValue("B");} _G.D1W=A; if(model =="B2" || model =="B4" || model =="B11" || model =="W2" || model =="W4" || model =="W11"){ E=GetValue("E"); F=GetValue("F"); C=GetValue("C"); _G.D1W = A-E; _G.D2W = C-F; } if(model =="B3" || model =="B5" || model =="B12" || model =="W3" || model =="W5"|| model =="W12"){ E=GetValue("E"); F=GetValue("F"); C=GetValue("C"); _G.D1W = A-F; _G.D2W = C-E; } if(model =="B9" || model =="W9"){ E=GetValue("E"); _G.D1W = A-E; } if(model =="B10" || model =="W10"){ F=GetValue("F"); _G.D1W = A-F; } Get.o2("ROWHEIGHTPNL/Sizes", "PaternSizeW").GetComponent().text = DOIT.CNs(_G.D1W ); Get.o2("ROWHEIGHTPNL/Sizes", "PaternSizeH").GetComponent().text = DOIT.CNs(_G.PH); } public static void DIV(GameObject O,int DivNum) { string papa = O.transform.parent.name; DOIT.DELETEAllChild("PATERN"); int indPapa=int.Parse(papa.Replace("editRow","")); float RH = DOIT.ConvertStringToNumber(O.transform.parent.transform.Find("InputField_HR").GetComponent().text); string BC = CodeString("p", _G.D1W / DivNum, RH, "5"); string BCT = ""; if (DivNum == 1) { BCT = BC; } if (DivNum == 2) { BCT = BC + "_" + BC; } if (DivNum == 3) { BCT = BC + "_" + BC + "_" + BC; } if (DivNum == 4) { BCT = BC + "_" + BC + "_" + BC + "_" + BC; } //REDO CODEPATERN int RowTotal=GetRowTotal(); string[] pat=GetDoorPatern().Split('_'); string patern=pat[0]+"_"+pat[1]+"_"; string newRow; for(int i=1; i _G.PH) { RowH = _G.PH - AllFix - AllVar; } float UNLOCKTOTAL=RT-1-Lock[0]-Lock[1]-Lock[2]-Lock[3]-Lock[4]-Lock[5];//should be 2 if(UNLOCKTOTAL!=0)DivByAll=(_G.PH - RowH - AllFix)/UNLOCKTOTAL; if(DivByAll<=0){RowH=_G.PH - AllFix;} for(int i=0; i().isOn =true; } } } static void CreateDoor(GameObject ds, string N, string p, float Sx, float Sy, float Px, float Py) { string btnName = ""; GameObject Doorbtn = new(); if (p == "p") { Doorbtn = Get.o2("BTNPATERN", "DoorBTN"); btnName = "DOOR"; } if (p == "d") { Doorbtn = Get.o2("BTNPATERN", "DrawBTN"); btnName = "DRAW"; } if (p == "t") { Doorbtn = Get.o2("BTNPATERN", "TambBTN"); btnName = "TAMB"; } if (p == "o") { Doorbtn = Get.o2("BTNPATERN", "OpenBTN"); btnName = "OPEN"; } if (p == "c") { Doorbtn = Get.o2("BTNPATERN", "CutoBTN"); btnName = "CUTO"; } if (p == "w") { Doorbtn = Get.o2("BTNPATERN", "WineBTN"); btnName = "WINE"; } if (p == "g") { Doorbtn = Get.o2("BTNPATERN", "GlasBTN"); btnName = "GLAS"; } if (p == "dd") { Doorbtn = Get.o2("BTNPATERN", "DoubBTN"); btnName = "DOUB"; } GameObject R = Instantiate(Doorbtn, new Vector3(0, 0, 0), Quaternion.identity); R.SetActive(true); R.name = btnName + N.ToString(); R.transform.Find("Background").transform.GetComponent().sizeDelta = new (Sx, Sy); R.transform.Find("Background").transform.Find("Checkmark").transform.GetComponent().sizeDelta = new (Sx, Sy); if (p == "o" || p == "w" || p == "t" || p == "c" || p == "g" ) { R.transform.Find("Image").transform.GetComponent().sizeDelta = new (Sx, Sy); } R.transform.position = new Vector3(Px, Py, 0); R.transform.SetParent(ds.transform, true); UILineRenderer ui = R.transform.Find("Background").GetComponent(); Vector2 p1; Vector2 p2; Vector2 p3; Vector2 p4; Vector2 p5; Vector2 p6; Vector2 p7; Vector2 p8; if(p != "dd"){ p1 = new (0, 0); p2 = new (0, Sy); p3 = new (Sx, Sy); p4 = new (Sx, 0); p5 = new (0,0); List pointlist = new(){p1, p2,p3, p4, p5}; ui.Points = pointlist.ToArray(); ui.LineThickness = 120 / (sc * 100); ui.color = Color.white; } if(p == "dd"){ p1 = new (0,0); p2 = new (0, Sy); p3 = new (Sx, Sy); p4 = new (Sx, Sy/2); p5 = new (0,Sy/2); p6 = new (0, 0); p7 = new (Sx, 0); p8 = new (Sx ,Sy/2); List pointlist = new(){p1, p2,p3, p4, p5 , p6, p7, p8}; ui.Points = pointlist.ToArray(); ui.LineThickness = 120 / (sc * 100); ui.color = Color.white; } } static void Addknob(GameObject DS,string N, float sx, float sy, string pos, float px, float py) { GameObject Knob = Get.o2("BTNPATERN", "knobMarkwhite"); GameObject K = Instantiate(Knob, new Vector3(0, 0, 0), Quaternion.identity); K.SetActive(true); K.name = "k" + N; K.transform.GetComponent().sizeDelta = new (3, 3); if (pos == "1") { px = px - sx / 2 + 2; py = py + sy / 2 - 2; } if (pos == "2") { py = py + sy / 2 - 2; } if (pos == "3") { px = px + sx / 2 - 2; py = py + sy / 2 - 2; } if (pos == "4") { px = px - sx / 2 + 2; } if (pos == "5") { } if (pos == "6") { px = px + sx / 2 - 2; } if (pos == "7") { px = px - sx / 2 + 2; py = py - sy / 2 + 2; } if (pos == "8") { py = py - sy / 2 + 2; } if (pos == "9") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } K.transform.position = new Vector3(px, py, 0); float scale = 6f / sc; K.transform.localScale = new Vector3(scale, scale, 1); K.transform.SetParent(DS.transform); } static string CodeString(string d1, float w1, float h1, string k1) { string W1s = w1.ToString(); string H1s = h1.ToString(); string CodeS = d1 + "_" + W1s + "_" + H1s + "_" + k1; return CodeS; } public void SetCat() { bool SquareKnob=true; string newC = ""; string kpos = "5"; if (name == "DOOR") { newC = "p"; kpos = "5"; } if (name == "DRAW") { newC = "d"; kpos = "2"; } if (name == "OPEN") { newC = "o"; kpos = "0"; SquareKnob=false;} if (name == "CUTO") { newC = "c"; kpos = "0"; SquareKnob=false;} if (name == "GLAS") { newC = "g"; kpos = "8"; } if (name == "WINE") { newC = "w"; kpos = "0"; } if (name == "TAMB") { newC = "t"; kpos = "8"; } if (name == "DOUB") { newC = "dd"; kpos = "5"; } Get.o2("FACEpnl","Square").SetActive(SquareKnob); int btnNun = int.Parse(Get.o1("ROWHEIGHTPNL/FACEpnl/Dnum").GetComponent().text); string CODEPATERN; if(GetDoorNumber()=="2"){CODEPATERN=_G.CODEPATERN2;} else {CODEPATERN=_G.CODEPATERN;} string[] code = CODEPATERN.Split('_'); code[btnNun * 2 + (2 * (btnNun - 1))] = newC; CODEPATERN = ""; code[btnNun * 2 + (2 * (btnNun - 1) + 3)] = kpos; for (int i = 0; i < code.Length; i++) { if (i < code.Length - 1) { CODEPATERN+= code[i] + "_"; } else { CODEPATERN+= code[i]; } } if(GetDoorNumber()=="2"){_G.CODEPATERN2=CODEPATERN;} else {_G.CODEPATERN=CODEPATERN;} AddPATERN(); //Patern on cab string catcab; catcab=UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Cab_Image"); catcab = catcab.Split('.')[0] + "." + catcab.Split('.')[1] + "." + catcab.Split('.')[2]; SetCab.Paternskew(catcab); string newcat = name + btnNun; string path="PATERN/doorPatern"+GetDoorNumber(); Get.o2(path, newcat).GetComponent().isOn = true; SetCab.Paternskew(UIT.Value(_G.Cab_Labrary_On,_G.SC[0],"Cab_Image")); } public void ClosePnl(){ Get.o2("CABINETpnl","ROWHEIGHTPNL").SetActive(false); } /////GETTING//////////////////////////////////////////////////////////////////////////// public static float GetRowYH(int Row, string HY){ string[] DP=GetDoorPatern().Split('_');//DOOR PATERN print("_G.CODEPATERN===="+_G.CODEPATERN); float Y=DOIT.ConvertStringToNumber(DP[1])*0.5f; float H=0; float W=DOIT.ConvertStringToNumber(DP[0]); float WL=0; float[] ROWH = { 0, 0, 0, 0, 0, 0 }; float[] ROWY = { 0, 0, 0, 0, 0, 0 }; int RN=0;//Row number for(int i=3; i=W){ ROWH[RN]=DOIT.ConvertStringToNumber(DP[i+1]); ROWY[RN]=Y-H-DOIT.ConvertStringToNumber(DP[i+1])*0.5f; H+=ROWH[RN]; RN+=1; WL=0; } } if(HY=="H")return ROWH[Row-1]; if(HY=="Y")return ROWY[Row-1]; return 0; } public static string GetRowCode(int Row){ string[] DP=GetDoorPatern().Split('_');//DOOR PATERN float W=DOIT.ConvertStringToNumber(DP[0]); float WL=0; string[] ROWC = { "", "", "", "", "", "" }; int RN=0;//Row number for(int i=3; i=W){ RN+=1; WL=0; } } return ROWC[Row-1]; } public static string GetDoorPatern(){ if(GetDoorNumber()=="2"){ return _G.CODEPATERN2;} return _G.CODEPATERN; } public static string GetDoorNumber(){ GameObject doornumberToggle=Get.o2("CABINETpnl/ROWHEIGHTPNL","DoorNumber"); if(doornumberToggle.activeInHierarchy){ return Get.TogOn(doornumberToggle).name;} return "1"; } public static int GetRowTotal(){ return Get.o2("CABINETpnl/ROWHEIGHTPNL","ROWEDITS").transform.childCount; } static string Del0(float FV) { string SV = FV.ToString("F3"); if (SV.IndexOf(".") != -1) { if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == ".") SV = SV.Substring(0, SV.Length - 1); } return SV; } public static float GetValue(string L){ float V=0; if (Get.o2("DIMS", "Fix"+L).activeInHierarchy == true) V = DOIT.ConvertStringToNumber(Get.o2("DIMS", "Fix"+L).GetComponent().text); if (Get.o2("DIMS", "InputField"+L).activeInHierarchy == true) { V = DOIT.ConvertStringToNumber(Get.o2("DIMS", "InputField"+L).GetComponent().text); } if (Get.o2("DIMS", "Dropdown"+L).activeInHierarchy == true) { V = DOIT.ConvertStringToNumber(Get.o2("DIMS", "Dropdown"+L).GetComponent().itemText.text); } return V; } }