using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; using NUnit.Framework; using Unity.VisualScripting; public class TopControl : MonoBehaviour { public static void ShowMesure() { bool isMoving = false; if (SceneModeManager.CompareSceneMode(SceneModes.MoveHandle)) isMoving = true; if (GameObject.Find("CONTROL")) { GameObject PNL = Get.o2("HIDER", "CONTROL"); int ADN = Get.GetObjectIndex(SceneModeManager.SelectedName);//object number string[] C = _G.OBJs[ADN]; GameObject sel = GameObject.Find(SceneModeManager.SelectedName); bool EDIT = false, LOCK = false, GHOST = false, OPENCLOSE = false, GLOBALS = false, MOVE = false, WALLDETACHED = false, RESIZE = true, TXTROTATION = false,VERTICALFLIP=false; //BUTTON CONDITION if (C[3] == "LOCK" && !SceneModeManager.CompareSceneMode(SceneModes.Follow)) { LOCK = true; } string Category = ""; if (C[1].Length >= 4) { Category = C[1][..4]; } if (new List { "ORNA","VASE", "SMAL", "PICT", "MIRR", "STOO", "LAMP", "CHAI", "TABL", "STOV", "DISH", "CELL", "FRID", "HOOW", "BLOC", "WIND" , "DOOS", "DOOD", "DOWS", "DOWD"}.Contains(Category) || C[2] == "Cabinet" || C[2] == "Panel" && _P.ListSwitch["ALLOW_EDIT_RECOVER"]) { EDIT = true; } for (int i = 1; i < _G.GHOSTLIST.Count; i++) { if (_G.GHOSTLIST[i] == SceneModeManager.SelectedName) { GHOST = true; } } if (C[22] != "floor" && C[22] != "ceil") { WALLDETACHED = true; } if (new List { "WIND", "DOOS", "DOOD", "DOWS", "DOWD", "PATI", "OPEN" }.Contains(Category)) { WALLDETACHED = false; } if (C[2] == "Cabinet" && _P.List["ALLOW_RESIZE_CABINET"] == "n") { RESIZE = false; } if (C[2] == "Bloc") { TXTROTATION = true; } if (C[2] == "Cabinet" && new List { "B1","W1","T1"}.Contains(C[4])) { VERTICALFLIP = true; } //ADD BOUL PNL.transform.Find("BTNGROUP/btnEDIT").gameObject.SetActive(EDIT); PNL.transform.Find("Lock").gameObject.SetActive(LOCK); PNL.transform.Find("Ghost").gameObject.SetActive(GHOST); PNL.transform.Find("OPEN_CLOSE").gameObject.SetActive(OPENCLOSE); PNL.transform.Find("TextureLibrary").gameObject.SetActive(GLOBALS); PNL.transform.Find("BTNGROUP/btnMOVE").gameObject.SetActive(MOVE); PNL.transform.Find("Resize").gameObject.SetActive(RESIZE); PNL.transform.Find("RotateTexture").gameObject.SetActive(TXTROTATION); PNL.transform.Find("BTNGROUP/btnFLIPVertical").gameObject.SetActive(VERTICALFLIP); Set.alpha(PNL.transform.Find("MB").gameObject, WALLDETACHED); //CALCULATE DEMENTIONS float fillerL = 0; float fillerR = 0; if (C[2] == "Cabinet" && _P.List["FILLER_ON_MESURE"] == "n")//Filler on size { fillerL = DOIT.ConvertStringToNumber(_G.OBJs[ADN][52]); fillerR = DOIT.ConvertStringToNumber(_G.OBJs[ADN][53]); } float CounterHeight = 0; if (C[2] == "Cabinet" && _P.List["COUNTER_ON_MESURE"] == "n")//Counter on size { CounterHeight = DOIT.ConvertStringToNumber(_G.OBJs[ADN][11]); } float Ow = sel.transform.localScale.x - 0.5f - fillerL - fillerR; float Oh = sel.transform.localScale.y - 0.5f - CounterHeight; float Od = sel.transform.localScale.z - 0.5f; //CACULATE DETACHED WALL AND FLOOR float mb = 0; float mu = 0; float mt = 0; if (C[22] != SceneModeManager.Floor.name && C[22] != SceneModeManager.Ceil.name) { //float os = DOIT.openOS(SceneModeManager.SelectedName); string stringToParse; string[] split = C[22].Split("_"); if (split.Length <= 0) { stringToParse = C[22]; } else { stringToParse = split[0]; } GameObject wall = GameObject.Find(C[22]); Vector3 normalwall = wall.transform.forward; Vector3 sP = sel.transform.position; float ObjectDepth = sel.transform.localScale.z; Vector3 DirectionObject = sel.transform.forward; Vector3 arriereCube = sP + 0.5f * ObjectDepth * DirectionObject; Vector3 murVersCube = arriereCube - wall.transform.position; mb = -(Vector3.Dot(murVersCube, normalwall) - 0.25f); if (mb > -0.0625 && mb <= 0.0625)mb=0; } Vector3 Opos = sel.transform.position; mu = _G.HEIGHT * 0.5F + Opos.y - (sel.transform.localScale.y - 0.5f) * 0.5F; mt = _G.HEIGHT * 0.5F - Opos.y - (sel.transform.localScale.y - 0.5f) * 0.5F; // if( C[4] == "panel"){(Ow, Od) = (Od, Ow); } string nameCode = C[1]; //print("C[61]===TOPControl="+C[61]); if (C[2] == "Cabinet") { if (C[61] != "none" && C[61] != "nodoor") { string DoorID = C[61].Split('?')[0]; string DoorColorID = C[61].Split('?')[1]; DoorColorID = UIT.IDCheckExist(Library.CabTexture, DoorColorID); string AddtoCabinetCode = UIT.Value(Library.CabTexture, DoorColorID, Header.Unique_Name); AddtoCabinetCode += " " + UIT.Value(Library.Door, DoorID, Header.Unique_Name); AddtoCabinetCode += " " + UIT.Value(Library.CabTexture, DoorColorID, Header.Unique_Name); if (Get.PreferenceBool("CABINET_BY_FINISH_BOX")) { string Box_Finish = UIT.Value(Library.Door, DoorID, Header.Box_finish); if (Box_Finish == "All") AddtoCabinetCode = "_" + UIT.Value(Library.CabTexture, DoorColorID, Header.Unique_Name); else AddtoCabinetCode = "_" + UIT.Value(Library.CabTexture, Box_Finish, Header.Unique_Name); } nameCode += " " + AddtoCabinetCode; } else { nameCode += " " + TRANS.This("T_SansPorte");//Sans Porte } } if (C[2] == "Panel"){ print("From panel C[61]===" + C[61]); if (C[61] != "none" && C[61] != "nodoor") { nameCode = ""; string ID = C[1]; string ColorID = C[61].Split("?")[0]; nameCode += " " + UIT.Value(Library.Panel, ID, Header.Unique_Name); nameCode += " " + UIT.Value(Library.CabTexture, ColorID, Header.Unique_Name); } (Ow, Od) = (Od, Ow); } //ADD VALUES W,H,D, WALLDETACHED,FLOORDETACHED PNL.transform.Find("nameCode").gameObject.GetComponent().text = nameCode;// Get.LibraryValue(nameCode, CsvHeaders.Unique_Name, DataTypes.Cabinet); PNL.transform.Find("ItemNum").gameObject.GetComponent().text = TRANS.This("C_ITEM NUMBER") + ADN.ToString(); PNL.transform.Find("MH").transform.Find("mcH").gameObject.GetComponent().text = DOIT.CNs(Oh); PNL.transform.Find("MW").transform.Find("mcW").gameObject.GetComponent().text = DOIT.CNs(Ow); PNL.transform.Find("MD").transform.Find("mcD").gameObject.GetComponent().text = DOIT.CNs(Od); PNL.transform.Find("MB/Btn Mesure").transform.Find("mcB").gameObject.GetComponent().text = DOIT.CNs(mb); PNL.transform.Find("MU/Btn Mesure").transform.Find("mcU").gameObject.GetComponent().text = DOIT.CNs(mu); PNL.transform.Find("MT/Btn Mesure").transform.Find("mcT").gameObject.GetComponent().text = DOIT.CNs(mt); //Price if (!isMoving) { float Price = 0; if (!Get.PreferenceBool("SHOW_PRICE")) { Set.alpha(PNL.transform.Find("PRICE").gameObject, false); } else { if (C[2] == "Cabinet") { string PriceColumn = ""; string PriceCode_ID = ""; if (Get.PreferenceBool("STORE_SELECTION")) { PriceColumn = _G.StoreZone; } string Color_ID = "nodoor"; if (_G.OBJs[ADN][61] != "nodoor") { Color_ID = _G.OBJs[ADN][61].Split("?")[1]; } if (!Get.PreferenceBool("CABINET_DOOR_RECIPE")) { PriceCode_ID = UIT.GetCabinetPriceID(_G.OBJs[ADN][1], _G.OBJs[ADN][61].Split("?")[0], Color_ID); Price += DOIT.ConvertStringToNumber(UIT.Value(Header.Price, PriceCode_ID, Header.Price + PriceColumn)); } //BOX ONLY if (Get.PreferenceBool("CABINET_DOOR_RECIPE")) { Price += PRICE.FromBox(ADN); //DOORS Price += PRICE.FromDoorRecipe(ADN); } //DRAWERS if (Get.PreferenceBool("CABINET_DRAWER_RECIPE")) { Price += PRICE.FromDrawerRecipe(ADN); } } if (C[2] == "Panel") { Price +=DOIT.ConvertStringToNumber( UIT.GetPanelPrice(C[1], C[61].Split("?")[0])) ; } PNL.transform.Find("PRICE").transform.Find("PRICE").gameObject.GetComponent().text = Price.ToString("F2") + "$"; } } GhostCommand.SetActiveGhostButton(_G.GHOSTLIST.Contains(SceneModeManager.SelectedName)); HideCommand.UpdateHideButtons(!_G.HIDELIST.Contains(SceneModeManager.SelectedName)); Get.o2("Canvas/HIDER/CONTROL","TopDimensions").GetComponent().isOn=false; _G.MesureONOFF = Get.o2("Canvas/Panel_SCENE/DASH","Dimensions").GetComponent().isOn; if (_G.MesureONOFF) Mesure.Show(); else Mesure.Hide(); //Hide language Set.alpha(Get.o2("Canvas", "Language"), false); //Global // if (_P.ListSwitch["CABS_HAS_ALL_DOORS"] && !isMoving && new List { "cabi", "pane", "bloc", "dish", "wine" }.Contains(C[0][..4])) // { // GameObject GlobalSelections = PNL.transform.Find("GlobalNumber").gameObject; // Set.GlobalColorBtn(GlobalSelections, "CONTROL", C[2]); // print("C[60]==" + C[60]); // if (C[60] == "UNIQUE") // { // DOIT.AllTogchildfalse(GlobalSelections); // } // } //if (_P.ListSwitch["CABS_HAS_ALL_DOORS"] && !isMoving && new List { "cabi", "pane", "bloc", "dish", "wine" }.Contains(C[0][..4])) if (!isMoving && new List { "cabi", "pane", "bloc", "dish", "wine" }.Contains(C[0][..4])) { PNL.transform.Find("TextureLibrary").gameObject.SetActive(true); GameObject Btn = PNL.transform.Find("btnG1").gameObject; if(C[0][..4]=="cabi")_Add.ShowDoorTexture(PNL.transform.Find("TextureLibrary").gameObject, Btn,C[1]); if(C[0][..4]=="pane")_Add.ShowPanelTexture(PNL.transform.Find("TextureLibrary").gameObject, Btn,C[1]); if(C[0][..4]=="bloc")_Add.ShowTexture(PNL.transform.Find("TextureLibrary").gameObject, Btn); } //Set lock Circle PNL.transform.Find("BTNGROUP/btnLOCK/Circle").gameObject.SetActive(C[3] == "LOCK"); //Island setup GameObject IslandBtn = Get.o2("Canvas/HIDER/CONTROL","TagIsland"); IslandBtn.SetActive(false); if(C[2] is "Cabinet" or "Panel" or "Bloc" || C[4] is "frid" or "stov" or "dish" or "wine" or "micr") { IslandBtn.SetActive(true); if (C[22] == "floor") { //IslandBtn.SetActive(true); IslandBtn.GetComponent().isOn=C[27]=="nonIsland"; } else { IslandBtn.GetComponent().isOn=C[27]!="Island"; } } } ColorSet.Do(); } }