using System.Collections; using UnityEngine; using UnityEngine.UI; public class _M : MonoBehaviour { public static void PH(int Num, float posY, string Color, float ScaleX, float ScaleY) { int code = 10 * Num + _G.L; Show(get(Num), posY, Color, ScaleX, ScaleY, code == 101 || code == 102 || code == 103); } /// /// Même bandeau que PH, mais avec un texte DÉJÀ traduit au lieu d'un numéro de la table de /// phrases. Pour les messages construits à l'exécution (normes, valeurs mesurées...) qui ne /// peuvent pas tenir dans le switch de get(). /// public static void PHText(string text, float posY, string Color, float ScaleX, float ScaleY) { Show(text, posY, Color, ScaleX, ScaleY, false); } static void Show(string text, float posY, string Color, float ScaleX, float ScaleY, bool showHH) { GameObject M = GameObject.Find("HIDER").transform.Find("MESSAGE").gameObject; M.SetActive(true); M.transform.localPosition = new Vector3(0, posY, 0); M.transform.localScale = new Vector3(ScaleX, ScaleY, 1); M.transform.Find("Background").GetComponent().color = DOIT.CSc(Color, 255); // Text1 pris SOUS M et non par GameObject.Find : MESSAGEWARNING a aussi un enfant "Text1", // et une recherche globale pourrait écrire dans le mauvais bandeau. Text t = M.transform.Find("Text1").GetComponent(); t.text = text; t.color = DOIT.CSc(Color == "ff0000" ? "ffffff" : "000000", 255); M.transform.Find("btnOK").gameObject.SetActive(posY == 100); M.transform.Find("HH").gameObject.SetActive(showHH); } // ─── Bandeau d'AVERTISSEMENT (normes) ──────────────────────────────────── // Objet "MESSAGEWARNING" du HIDER : pas de bouton OK ni de poignée de déplacement, mais un // bouton X pour le renvoyer (déjà câblé sur ButtonControl.closeThisOnlyAndOnthis). // Descente à l'apparition : de WARN_Y_TOP (hors champ, au-dessus) vers WARN_Y_SHOWN. const float WARN_Y_TOP = 295f; const float WARN_Y_SHOWN = 211f; const float WARN_SLIDE_SEC = 0.25f; static IEnumerator _slide; static IEnumerator SlideDown(Transform M) { Vector3 p = M.localPosition; M.localPosition = new Vector3(p.x, WARN_Y_TOP, p.z); // unscaledDeltaTime : l'animation doit jouer même si la scène est mise en pause. for (float t = 0f; t < WARN_SLIDE_SEC; t += Time.unscaledDeltaTime) { float k = Mathf.SmoothStep(0f, 1f, t / WARN_SLIDE_SEC); M.localPosition = new Vector3(p.x, Mathf.Lerp(WARN_Y_TOP, WARN_Y_SHOWN, k), p.z); yield return null; } M.localPosition = new Vector3(p.x, WARN_Y_SHOWN, p.z); _slide = null; } // Mis en cache : le contrôle des normes tourne à chaque image pendant un déplacement. La // comparaison Unity à null redevient vraie si l'objet a été détruit (rechargement de scène), // ce qui relance la recherche. static Transform _warnPanel; static Transform WarningPanel() { if (_warnPanel != null) return _warnPanel; GameObject hider = GameObject.Find("HIDER"); _warnPanel = hider != null ? hider.transform.Find("MESSAGEWARNING") : null; return _warnPanel; } /// Affiche l'avertissement. Texte déjà traduit. Idempotent. public static void Warning(string text, string Color = "ff0000") { Transform M = WarningPanel(); if (M == null) { Debug.LogWarning("[_M] MESSAGEWARNING introuvable — " + text); return; } M.gameObject.SetActive(true); // Descente depuis le haut. Warning() n'est appelé QUE lorsque le message change (voir // NormCheck.CheckAndWarn), l'animation ne redémarre donc pas à chaque image. if (_slide != null) StaticCoroutine.Stop(_slide); _slide = SlideDown(M); StaticCoroutine.Start(_slide); Transform bg = M.Find("Background"); //if (bg != null && bg.TryGetComponent(out Image img)) img.color = DOIT.CSc(Color, 255); Transform txt = M.Find("Text1"); Text t = txt != null ? txt.GetComponent() : M.GetComponentInChildren(true); if (t != null) { t.text = text; t.color = DOIT.CSc(Color == "ff0000" ? "ffffff" : "000000", 255); } // Ni validation ni déplacement : seul le X permet de renvoyer l'avertissement. foreach (string btn in new[] { "btnOK", "MOVE", "HH" }) { Transform b = M.Find(btn); if (b != null) b.gameObject.SetActive(false); } Transform x = M.Find("X"); if (x != null) x.gameObject.SetActive(true); } /// /// Met à jour le texte de l'avertissement SANS le réafficher : sert à suivre une mesure qui /// évolue pendant un déplacement. Ne fait rien si le bandeau a été renvoyé par le X — sinon il /// ressusciterait sous le pointeur et couperait le glissement en cours. /// public static void WarningRefresh(string text) { Transform M = WarningPanel(); if (M == null || !M.gameObject.activeSelf) return; Transform txt = M.Find("Text1"); Text t = txt != null ? txt.GetComponent() : M.GetComponentInChildren(true); if (t != null) t.text = text; } /// Masque l'avertissement. public static void HideWarning() { if (_slide != null) { StaticCoroutine.Stop(_slide); _slide = null; } Transform M = WarningPanel(); if (M != null) M.gameObject.SetActive(false); } public static string get(int num) { num = 10 * num + _G.L; string ph = ""; switch (num) { case 11: ph = "You have to make a selection."; break; case 12: ph = "Vous devez faire une sélection."; break; case 13: ph = "Tienes que hacer una selección."; break; case 21: ph = "File is saved."; break; case 22: ph = "Fichier sauvegardé."; break; case 23: ph = "El archivo se guarda."; break; case 31: ph = "Select where to place it,\nwall, floor or object."; break; case 32: ph = "Selectionnez ou le placer,\nmur, plancher ou object."; break; case 33: ph = "Selecciona donde colocarlo\npared, piso u objeto."; break; case 41: ph = "Select base cabinet to add sink."; break; case 42: ph = "Selectionnez un cabinet bas pour l'évier."; break; case 43: ph = "Seleccione el gabinete base para agregar el fregadero."; break; case 51: ph = "Please select a sink Cabinet."; break; case 52: ph = "Choisissez un cabinet pour évier."; break; case 53: ph = "Seleccione un gabinete del fregadero."; break; case 61: ph = "Select object to move with.\nUse green object to move the group."; break; case 62: ph = "Sélectionner les objets pour déplacer avec.\nUtiliser le vert pour déplacer le groupe."; break; case 63: ph = "Seleccionar objeto para mover con.\nUsa un objeto verde para mover el grupo."; break; case 71: ph = "Select other object for mesure."; break; case 72: ph = "Sélectionner un autre object pour la mesure."; break; case 73: ph = "Seleccione otro objeto para la medida."; break; case 81: ph = "Select target object."; break; case 82: ph = "Sélectionner un autre object."; break; case 83: ph = "Seleccione otro objeto."; break; case 91: ph = "You have to select an object."; break; case 92: ph = "Vous devez choisir un objet."; break; case 93: ph = "Tienes que seleccionar un objeto."; break; case 101: ph = "Prices may not be accurate.\nPlease check in store."; break; case 102: ph = "Les prix ne sont peut-être pas exacts.\nSVP vérifiez en magasin."; break; case 103: ph = "Los precios pueden no ser\nexactos.Por favor verifique en la tienda."; break; case 111: ph = "Restart new design.\nYour unsaved work will be lost."; break; case 112: ph = "Redémarrer un nouveau design.\nVotre design non sauvegardé sera effacé."; break; case 113: ph = "Reiniciar nuevo diseño\nTu trabajo no guardado se perderá."; break; case 121: ph = "You have to fill all feild correctly."; break; case 122: ph = "Désolé les champs ne sont pas remplis corrrectement."; break; case 123: ph = "Tienes que llenar todos los campos correctamente."; break; case 131: ph = "Now in construction."; break; case 132: ph = "En construction."; break; case 133: ph = "En construcción."; break; case 141: ph = "You have to select a wall or ceiling."; break; case 142: ph = "Vous devez sélectionner un mur ou le plafond"; break; case 143: ph = "Tienes que seleccionar una pared o techo."; break; case 151: ph = "The cabinet has been added to the library."; break; case 152: ph = "Le cabinet à été ajouté à la librairie."; break; case 153: ph = "El gabinete se ha agregado a la librería."; break; case 161: ph = "Do you really want to delete the cabinet from the list?"; break; case 162: ph = "Voulez vous vraiment supprimer le caisson de la list?."; break; case 163: ph = "¿Realmente desea eliminar el subwoofer de la lista?"; break; case 171: ph = "Name cabinet already exist, do you want to rewrite it?"; break; case 172: ph = "Le nom du cabinet exist déjà voulez vous le remplacer?."; break; case 173: ph = "El gabinete de nombre ya existe, ¿quieres reescribirlo?"; break; case 181: ph = "Saved to server."; break; case 182: ph = "Sauvegardé sur le serveur."; break; case 183: ph = "Guardado en el servidor."; break; case 191: ph = "Warning! One or more textures that are no longer available have been replaced."; break; case 192: ph = "Avertissement! Une ou plusieurs textures qui ne sont plus disponibles ont été remplacées."; break; case 193: ph = "¡Advertencia! Se han reemplazado una o más texturas que ya no están disponibles."; break; case 201: ph = "You cannot add to the Ukitchenit list, please modify the name of the library."; break; case 202: ph = "Vous ne pouvez ajouter à la liste Ukitchenit, SVP modifier le nom de la librairie."; break; case 203: ph = "No puede agregar a la lista Ukitchenit, modifique el nombre de la biblioteca."; break; case 211: ph = "Sorry there is no global match on the library."; break; case 212: ph = "Désolé, il n'y a pas de correspondance globale sur la librairie."; break; case 213: ph = "Lo sentimos, no hay una coincidencia global en la biblioteca."; break; case 221: ph = "Confirm the removal of the item from the list."; break; case 222: ph = "Confirmez la suppression de l'item de la liste."; break; case 223: ph = "Confirmar la eliminación del artículo de la lista."; break; case 231: ph = "At least one row must have a variable value."; break; case 232: ph = "Au moins une rangée doit avoir une valeur variable."; break; case 233: ph = "Al menos una fila debe tener un valor variable."; break; case 241: ph = "You have to unlock it to modify."; break; case 242: ph = "Il faut le déverrouiller pour modifier."; break; case 243: ph = "Tienes que desbloquearlo para modificarlo."; break; case 251: ph = "There is not models on list for this cathegory."; break; case 252: ph = "Aucun modèles disponible dans cette cathégorie."; break; case 253: ph = "No hay modelos en la lista para esta categoría."; break; case 261: ph = "You have to enter a unique name."; break; case 262: ph = "Vous devez entrer un nom unique."; break; case 263: ph = "Tienes que ingresar un nombre único."; break; case 271: ph = "Name already exist in the library, do you want to rewrite it?"; break; case 272: ph = "Le nom existe déjà dans la librairie voulez vous le remplacer?"; break; case 273: ph = "El nombre ya existe en la biblioteca, ¿quieres reemplazarlo?"; break; case 281: ph = "The item has been added to the library."; break; case 282: ph = "L'item' à été ajouté à la librairie."; break; case 283: ph = "El artículo ha sido agregado a la biblioteca."; break; case 291: ph = "No item in the scene is for the shopping cart."; break; case 292: ph = "Aucun item dans la scene est pour le panier d'achat."; break; case 293: ph = "Ningún artículo en la escena es para el carrito de compras."; break; case 301: ph = "Sorry, No match found."; break; case 302: ph = "Désolé, aucune trouvée."; break; case 303: ph = "Lo sentimos, no se encontró ninguna coincidencia."; break; case 311: ph = "Confirm that you want to modify to the server."; break; case 312: ph = "Confirmez que vous voulez sauvegarder sur le serveur."; break; case 313: ph = "Confirme que desea guardar en el servidor."; break; case 321: ph = "OUPS! List error."; break; case 322: ph = "OUPS ! Erreur de liste."; break; case 323: ph = "¡OUPS! Error de lista."; break; case 331: ph = "Select the walls where you want the cabinets."; break; case 332: ph = "Sélectionnez les murs ou vous voulez des armoires."; break; case 333: ph = "Selecciona las paredes donde quieres los armarios."; break; case 341: ph = "Ceiling height too low"; break; case 342: ph = "Hauteur plafond trop bas"; break; case 343: ph = "Ceiling height Too low"; break; case 351: ph = "PDF generate"; break; case 352: ph = "PDF Généré"; break; case 353: ph = "PDF generate"; break; case 361: ph = "File not find"; break; case 362: ph = "Fichier non trouvé"; break; case 363: ph = "Archivo no encontrado"; break; } return ph; } }