using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Globalization; using TMPro; using System.Collections.Generic; public class Resize : MonoBehaviour { public Image model; public InputField A; public InputField B; public InputField C; public InputField D; public InputField E; public InputField F; public InputField K; public TMP_Dropdown AD; public TMP_Dropdown BD; public TMP_Dropdown CD; public TMP_Dropdown DD; public Text FixB; public Text FixA; public Text FixC; public Text FixD; public Text FixE; public Text FixF; public Text FixK; static string[] ADN; static int ADNInd; public void Open() { _G.PNL = "Resize"; Get.o2("HIDER", "RESIZE").SetActive(true); Get.o2("HIDER", "RESIZE").transform.localPosition = new Vector3(0, -22, 0); ADNInd= Get.GetObjectIndex(SceneModeManager.SelectedName); ADN = _G.OBJs[ADNInd]; DOIT.AllChildOff(Get.o1("HIDER/RESIZE/SHOWSELECTION/DIMS")); Get.o2("HIDER/RESIZE/Direction","Cube").GetComponent().isOn=true; string CAT = Cat(); string ADN6 = ADN[6];//Wide string ADN7 = ADN[7];//Height if(CAT=="CABINET"){ //string[] c=Get.CabinetCode(_G.OBJs[ADN][1]); string Cab_Image=UIT.Value(Library.Cabinet,ADN[1],Header.Cab_Image); string mod=Cab_Image.Split('.')[0]+"."+Cab_Image.Split('.')[1]+"."+Cab_Image.Split('.')[2]; model.GetComponent().sprite=Resources.Load("CABIMAGE/"+mod); float ValueB=DOIT.ConvertStringToNumber(ADN[7]); float ValueK=DOIT.ConvertStringToNumber(ADN[10]); float ValueD = ValueB - ValueK; //Dimensions AddDimCabinet(ADN6,"A"); AddDimCabinet(ADN7,"B"); AddDimCabinet(ADN[8],"C"); AddDimCabinet(ValueD.ToString(),"D"); AddDimCabinet(ADN[28],"E"); AddDimCabinet(ADN[29],"F"); AddDimCabinet(ADN[10],"K"); } if(CAT=="PNL"){ string ImageName="MPNLold"; if(_G.PATH=="free"){ImageName="MPNL";} if(ADN[1].IndexOf("Shelf")!=-1)ImageName="Shelf"; model.GetComponent().sprite = Resources.Load("CABIMAGE/"+ImageName); //Dimensions AddDimPanel(ADN6,"Wide"); AddDimPanel(ADN[7],"Height"); AddDimPanel(ADN[8],"Thick"); } if (CAT == "WH") { model.GetComponent().sprite = Resources.Load("CABIMAGE/MAB"); SetDIM_ABC(A.gameObject, ADNInd, DOIT.CSss(ADN6)); SetDIM_ABC(B.gameObject, ADNInd, DOIT.CSss(ADN7)); } if (CAT == "WHD") { model.GetComponent().sprite = Resources.Load("CABIMAGE/MABC"); SetDIM_ABC(A.gameObject, ADNInd, DOIT.CSss(ADN[6])); SetDIM_ABC(B.gameObject, ADNInd, DOIT.CSss(ADN[7])); SetDIM_ABC(C.gameObject, ADNInd, DOIT.CSss(ADN[8])); } } //DIMENSIONS---------------------------------------------------------------------------------------------------------------------------- public void SetDIM_ABC(GameObject O, int ind, string Size) { O.SetActive(true); O.transform.Find("min").GetComponent().text = "1"; O.GetComponent().text = Size; O.transform.Find("max").GetComponent().text = "96"; } public static void AddDimPanel(string PanelValue,string L){ string Code=UIT.Value(Library.Panel,ADN[1],L); if(L=="Wide")L="A"; if(L=="Height")L="B"; if(L=="Thick")L="C"; AddDim(PanelValue,L,Code); } public static void AddDimCabinet(string CabinetValue,string L){ string Code=UIT.Value(Library.Cabinet,ADN[1],L); AddDim(CabinetValue,L,Code); } public static void AddDim(string CabinetValue,string L,string Code){ if(!string.IsNullOrEmpty(Code) && Code!="0") { GameObject Letter = Get.o2("SHOWSELECTION/DIMS","InputField"+L); GameObject Fix = Get.o2("SHOWSELECTION/DIMS","Fix"+L); GameObject DD = Get.o2("SHOWSELECTION/DIMS","Dropdown"+L); Letter.SetActive(false); Fix.SetActive(false); DD.SetActive(false); string[] codeV=Code.Split('_'); string[] codeFV=Code.Split('?'); //Variable Min Max if(codeV.Length>=3 && codeV[0] != codeV[2]) { Letter.SetActive(true); Letter.transform.Find("min").GetComponent().text=codeV[0]; Letter.transform.Find("max").GetComponent().text=codeV[2]; Letter.GetComponent().text=CabinetValue; } //Fix if(codeV.Length==3 && codeV[0] == codeV[2] || codeV.Length==1 && Code.IndexOf("?")==-1 ){ Fix.SetActive(true); Fix.GetComponent().text=CabinetValue; } //Fix Variable if(codeFV.Length>1){ DD.SetActive(true); List options = new(); for(int i=0; i().ClearOptions(); DD.GetComponent().AddOptions(options); } } } //RESIZE---------------------------------------------------------------------------------------------------------------------------- public void resetInput() { ADNInd = Get.GetObjectIndex(SceneModeManager.SelectedName); if (_G.OBJs[ADNInd][2] == "Cabinet") { SetCab.ResetInput(this.name); } } public void newsize() { print("----newsize----"); ADNInd = Get.GetObjectIndex(SceneModeManager.SelectedName); RepositionObject(); string CAT = Cat(); if (CAT == "CABINET") { CABINET(); } if (CAT == "WH") { WH(); } if (CAT == "WHD") { WHD(); } if (CAT == "PNL") { WHD(); } StaticCoroutine.Start(RedoTopControl()); } private static IEnumerator RedoTopControl() { yield return new WaitForSeconds(0.2f); DOIT.SaveObjectPositionInData(SceneModeManager.Selected); TopControl.ShowMesure(); Get.o2("HIDER", "RESIZE").SetActive(false); _MOL.SetMolding(); } public static void ResetCabinetDIM(string InputName) { print("O name=======================" + InputName); //CabinetListData c = Get.CabinetCode(_G.SC[0]); //bool CornerAC=false; //if(Get.Bool(c.Cab_Sub_Category,"B2_B3_B4_B5_B6_B7_W2_W3_W4_W5_W6_W7"))CornerAC=true; //Min Max stop //Minmax("A"); //Minmax("B"); //Minmax("C"); Minmax("D"); //Minmax("E"); //Minmax("F"); Minmax("K"); // float A=GetfloatActif("A"); // float B=GetfloatActif("B"); // float C=GetfloatActif("C"); float D=GetfloatActif("D"); // float E=GetfloatActif("E"); // float F=GetfloatActif("F"); float K=GetfloatActif("K"); if(InputName=="InputK" ){AddString("FixB", D+K);} if(InputName=="InputD" ){AddString("FixB", D+K);} // if(InputName=="InputB" && _P.CabinetValueBChange=="D"){AddString("InputFieldD", B-K);} // if(InputName=="InputB" && _P.CabinetValueBChange=="K"){AddString("InputFieldK", B-D);} // if(InputName=="InputD" && _P.CabinetValueBChange=="B"){AddString("InputFieldB", D+K);} // if(InputName=="InputD" && _P.CabinetValueBChange=="K"){AddString("InputFieldK", B-D);} // if(InputName=="InputE" && _P.CabinetCornerSameEF){AddString("InputFieldF", E);} // if(InputName=="InputF" && _P.CabinetCornerSameEF){AddString("InputFieldE", F);} // if(InputName=="InputA" && _P.CabinetCornerSameAC && CornerAC){AddString("InputFieldC", A);} // if(InputName=="InputC" && _P.CabinetCornerSameAC && CornerAC){AddString("InputFieldA", C);} // if(InputName=="InputK" && _P.CabinetValueBChange=="K"){AddString("InputFieldB", D+K);} // if(InputName=="InputK" && _P.CabinetValueBChange=="D"){AddString("InputFieldD", B-K);} } public static void RepositionObject() { ADNInd = Get.GetObjectIndex(SceneModeManager.SelectedName);//object number string[] C = _G.OBJs[ADNInd]; float ws = DOIT.ConvertStringToNumber(C[6]);//Wide start float hs = DOIT.ConvertStringToNumber(C[7]);//Height start7 float ds = DOIT.ConvertStringToNumber(C[8]);//Depth start float ffs = DOIT.ConvertStringToNumber(C[21]);//From floor start float we = DOIT.ConvertStringToNumber(GetDim("A")); float he = DOIT.ConvertStringToNumber(GetDim("B")); float de = ds; if (Get.o2("DIMS", "InputFieldC").activeInHierarchy == true) { de = DOIT.ConvertStringToNumber(GetDim("C")); } float dw = ws - we; float dh = hs - he; float dd = ds - de; string Dir = Get.ToggleOnInChild("Direction"); // print("Dir==="+Dir); if (Dir == "L") { Reposition.newResizeposition(Dir, dw / 2); } if (Dir == "R") { Reposition.newResizeposition(Dir, dw / 2); } if (Dir == "U") { Reposition.newResizeposition(Dir, dh / 2); } if (Dir == "T") { Reposition.newResizeposition(Dir, dh / 2); } if (Dir == "B") { Reposition.newResizeposition(Dir, dd / 2); } if (Dir == "F") { Reposition.newResizeposition(Dir, dd / 2); } //C[16]=(_G.HEIGHT/2+C[21]+he/2).ToString(); } public static void WH() { //int ADN = Get.GetObjectIndex(SceneModeManager.SelectedName); GameObject objectToDelete = GameObject.Find(SceneModeManager.SelectedName); objectToDelete.SetActive(false); Destroy(objectToDelete); float w = DOIT.ConvertStringToNumber(GameObject.Find("InputFieldA").GetComponent().text); float h = DOIT.ConvertStringToNumber(GameObject.Find("InputFieldB").GetComponent().text); _G.OBJs[ADNInd][6] = w.ToString(); _G.OBJs[ADNInd][7] = h.ToString(); switch (SceneModeManager.SelectedName[..4]) { case "open": ConstructOpen.AddOpen(ADNInd); HOLE.RefreshAllWalls(); break; case "wind": ConstructWindow.AddWindow(ADNInd); HOLE.RefreshAllWalls(); break; case "door": ConstructDoor.AddDoor(ADNInd); HOLE.RefreshAllWalls(); break; case "pati": ConstructPatio.AddPatio(ADNInd); HOLE.RefreshAllWalls(); break; case "slid": ConstructSlider.AddSlider(ADNInd); break; } } public static void WHD() { //int ADN = Get.GetObjectIndex(SceneModeManager.SelectedName); GameObject objectToDelete = GameObject.Find(SceneModeManager.SelectedName); objectToDelete.SetActive(false); Destroy(objectToDelete); string w=ADN[6]; string h=ADN[7]; string d=ADN[8]; if(GameObject.Find("InputFieldA"))w=GameObject.Find("InputFieldA").GetComponent().text; if(GameObject.Find("InputFieldB"))h=GameObject.Find("InputFieldB").GetComponent().text; if(GameObject.Find("InputFieldC"))d=GameObject.Find("InputFieldC").GetComponent().text; string Category=SceneModeManager.SelectedName[..4]; //if(Category== "pane"){(w,d)=(d,w);} _G.OBJs[ADNInd][6] = w.ToString(); _G.OBJs[ADNInd][7] = h.ToString(); _G.OBJs[ADNInd][8] = d.ToString(); float FF = DOIT.ConvertStringToNumber(_G.OBJs[ADNInd][21]);//From floor //_G.OBJs[ADNInd][16]=(-_G.HEIGHT/2+h/2+FF).ToString(); if (_G.OBJs[ADNInd][1].IndexOf("STOV") != -1) { ConstructStove.AddStove(ADNInd); } else if (_G.OBJs[ADNInd][1].IndexOf("BUIL") != -1) { ConstructBuildin.AddBuilding(ADNInd); } else if (_G.OBJs[ADNInd][1].IndexOf("PLAT") != -1) { ConstructPlatestove.AddStovePlates(ADNInd); } switch(Category){ case "frid": ConstructFRIDGE.AddFridge(ADNInd); break; case "hood": ConstructHood.AddHood(ADNInd); break; case "dish": ConstructDishwasher.AddDishwasher(ADNInd); break; case "micr": ConstructMicrowave.AddMicrowave(ADNInd); break; case "wine": ConstructWiner.AddWiner(ADNInd); break; case "vase": ConstructVase.AddVase(ADNInd); break; case "smal": ConstructSmallelectro.AddSmallElectro(ADNInd); break; case "pict": ConstructPicture.AddPicture(ADNInd); break; case "stoo": ConstructStool.AddStool(ADNInd); break; case "lamp": ConstructLamp.AddLamp(ADNInd); break; case "bloc": ConstructBloc.AddBloc(ADNInd); break; case "coun": ConstructCounter.AddCounter(ADNInd); break; case "deco": ConstructDECO.AddObject(ADNInd); break; case "wadr": ConstructWD.AddWD(ADNInd); break; case "toil": ConstructToilet.AddToilet(ADNInd); break; case "bath": ConstructBath.AddBath(ADNInd); break; case "show": ConstructShower.AddShower(ADNInd); break; case "basi": ConstructBathSink.AddBathSink(ADNInd); break; case "pane": ConstructPanel.AddPanel(ADNInd); break; case "mirr": ConstructMirror.AddMirror(ADNInd); break; case "tabl": ConstructTable.AddTable(ADNInd); break; case "chai": ConstructChair.AddChair(ADNInd); break; case "orna": ConstructOrnament.AddOrnament(ADNInd); break; } } public static void CABINET() { GameObject objectToDelete = GameObject.Find(SceneModeManager.SelectedName); objectToDelete.SetActive(false); Destroy(objectToDelete); _G.OBJs[ADNInd][6] = GetDim("A"); _G.OBJs[ADNInd][7] = GetDim("B"); _G.OBJs[ADNInd][8] = GetDim("C"); if (SetCab.checkBool("InputFieldE")) { _G.OBJs[ADNInd][28] = GetDim("E"); } if (SetCab.checkBool("InputFieldF")) { _G.OBJs[ADNInd][29] = GetDim("F"); } if (SetCab.checkBool("InputFieldK")) { _G.OBJs[ADNInd][10] = GetDim("K"); _G.OBJs[ADNInd][35] = GetDim("K"); } //Panel if (_G.OBJs[ADNInd][2] == "Panel") { if (_G.OBJs[ADNInd][5] == "PNL") ConstructPanel.AddPanel(ADNInd); PRICE.Calprice(); } _G.nO=ADNInd; //cab if (_G.OBJs[ADNInd][2] == "Cabinet") { if (_G.OBJs[ADNInd][5] == "BA") CreateCAB.CabDispatch( _G.OBJs[ADNInd] ); if (_G.OBJs[ADNInd][5] == "WA") CreateCAB.CabDispatch( _G.OBJs[ADNInd] ); if (_G.OBJs[ADNInd][5] == "TA") ConstructTALL.AddCab(ADNInd); if (_G.OBJs[ADNInd][5] == "CB") ConstructCORNERBASE.AddCab(ADNInd); if (_G.OBJs[ADNInd][5] == "CW") ConstructCORNERWALL.AddCab(ADNInd); if (_G.OBJs[ADNInd][5] == "PNL") ConstructPanel.AddPanel(ADNInd); } // SceneModeManager.SelectedName = _G.OBJs[ADNInd][0]; } public static string GetDim(string L) { string vs = ""; if (Get.o2("DIMS", "InputField" + L).activeInHierarchy == true) { vs = GameObject.Find("InputField" + L).GetComponent().text; } if (Get.o2("DIMS", "Fix" + L).activeInHierarchy == true) vs = GameObject.Find("Fix" + L).GetComponent().text; if (L == "A" || L == "B" || L == "C" || L == "D" || L == "E" || L == "F" ) { if (Get.o2("DIMS", "Dropdown" + L).activeInHierarchy == true) { vs = DOIT.CSs(GameObject.Find("Dropdown" + L).transform.Find("Label").GetComponent().text); } } return vs; } public static string Cat() { string cat = SceneModeManager.SelectedName.Substring(0, 4); switch (SceneModeManager.SelectedName.Substring(0, 4)) { case "cabi": cat = "CABINET"; break; case "pane": cat = "PNL"; break; case "stov": cat = "WHD"; break; case "frid": cat = "WHD"; break; case "hood": cat = "WHD"; break; case "dish": cat = "WHD"; break; case "micr": cat = "WHD"; break; case "wine": cat = "WHD"; break; case "vase": cat = "WHD"; break; case "smal": cat = "WHD"; break; case "pict": cat = "WHD"; break; case "stoo": cat = "WHD"; break; case "lamp": cat = "WHD"; break; case "bloc": cat = "WHD"; break; case "coun": cat = "WHD"; break; case "deco": cat = "WHD"; break; case "wadr": cat = "WHD"; break; case "toil": cat = "WHD"; break; case "bath": cat = "WHD"; break; case "show": cat = "WHD"; break; case "basi": cat = "WHD"; break; case "open": cat = "WH"; break; case "wind": cat = "WH"; break; case "door": cat = "WH"; break; case "pati": cat = "WH"; break; case "mirr": cat = "WHD"; break; case "tabl": cat = "WHD"; break; case "chai": cat = "WHD"; break; case "orna": cat = "WHD"; break; } return cat; } public static bool CheckBool(string Mesure) { bool check = false; if (Get.o2("DIMS", Mesure).activeInHierarchy == true) check = true; return check; } public static void Minmax(string L) { L = "InputField" + L; float min = GetfloatMinMax(L, "min"); float max = GetfloatMinMax(L, "max"); float AI = Getfloat(L); if (AI < min) AI = min; if (AI > max) AI = max; Addstring(L, AI); } public static void Addstring(string Mesure, float value) { string VS = DOIT.CNs(value); if (Mesure.IndexOf("Fix") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; if (Mesure.IndexOf("Input") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; } public static float Getfloat(string Mesure) { float v = 0; if (Mesure.IndexOf("Fix") != -1) v = DOIT.ConvertStringToNumber(Get.o2("DIMS", Mesure).GetComponent().text); if (Mesure.IndexOf("Input") != -1) v = DOIT.ConvertStringToNumber(Get.o2("DIMS", Mesure).GetComponent().text); return v; } public static float GetfloatMinMax(string Mesure, string mm) { float v = 0; v = DOIT.ConvertStringToNumber(Get.o3("DIMS", Mesure, mm).GetComponent().text); return v; } public static float GetfloatActif(string Letter) { GameObject Input=Get.o2("DIMS","InputField"+Letter); if(Input.activeInHierarchy)return DOIT.ConvertStringToNumber(Input.GetComponent().text); GameObject Fix=Get.o2("DIMS","Fix"+Letter); if(Fix.activeInHierarchy)return DOIT.ConvertStringToNumber(Fix.GetComponent().text); return 0; } public static void AddString(string Mesure, float value) { string VS = DOIT.CNs(value); if (_G.VTcat != "TMP") { if (Mesure.IndexOf("Fix") != -1) Get.o2("DIMS", Mesure).GetComponent().text = VS; if (Mesure.IndexOf("Input") != -1) Get.o2("DIMS", Mesure).GetComponent().text = VS; } else { if (Mesure.IndexOf("Fix") != -1) Get.o2("DIMS", Mesure).GetComponent().text = VS; if (Mesure.IndexOf("Input") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; } } }