private List<MaskPix> m_zoneToUpdate; // Zone à mettre à jour #endregion Fields #region Methods //----------------------------------------------------- // Ajoute une zone de gommage / rétablissement public void AddEraserZone(List<MaskPix> newZone, int xMin, int xMax, int yMin, int yMax) { int h = (int)transform.GetChild(0).GetComponent<GUITexture>().pixelInset.height; int w = (int)transform.GetChild(0).GetComponent<GUITexture>().pixelInset.width; MaskedZone newMZone = new MaskedZone(newZone, w, h, xMin, xMax, yMin, yMax); // Fusionner les plus anciennes zones en une seule si la pile est pleine while(m_erasedZones.Count > m_maxUndoCount) MergeZones(); // Ajouter la zone aux zones enregistrées m_erasedZones.AddLast(newMZone); m_backupZones.Add(CloneZone(newMZone)); m_undoedZones.Clear(); // Supprimer définitivement les zones annulées (plus de redo possible) GameObject.Find("MainScene").GetComponent<PleaseWaitUI>().SetDisplayIcon(true); m_zoneToUpdate = newZone; m_added = true; // Debug.Log("Zone added ..."); // for(int i=0; i<newMZone.m_images.Length; i++) // { // if(newMZone.m_images[i]) // { // int x = i%4; // int y = (i-x)/4; // Debug.Log("Dans la sous-image "+i+" ("+x+","+y+")"); // } // } }
//----------------------------------------------------- public MaskedZone CloneZone(MaskedZone mzone) { List<MaskPix> zone = mzone.m_pixels; List<MaskPix> clone = new List<MaskPix>(); if(m_tool == GUIEditTools.EditTool.Grass) { for(int i=0; i<zone.Count; i++) clone.Add((MaskPix)((MaskPixRGB)(zone[i])).Clone()); } else { for(int i=0; i<zone.Count; i++) clone.Add((MaskPix)zone[i].Clone()); } return new MaskedZone(clone, 0,0,0,0,0,0); }
public IEnumerator loadMZ(MaskedZone mz) { m_zoneToUpdate = null; m_erasedZones.AddLast(mz); GameObject.Find("MainScene").GetComponent<PleaseWaitUI>().SetDisplayIcon(true); //m_zoneToUpdate = mz.m_pixels;//((MaskedZone)m_erasedZones.Last.Value).m_pixels; m_added = false; StartCoroutine( UpdateEraserImage(mz.m_pixels, m_added) ); yield return true; }
//----------------------------------------------------- /* * Chargement du mask */ public void loadMaskZone(MaskedZone mz) { // m_erasedZones.Clear(); m_erasedZones.AddLast(mz); GameObject.Find("MainScene").GetComponent<PleaseWaitUI>().SetDisplayIcon(true); m_zoneToUpdate = ((MaskedZone)m_erasedZones.Last.Value).m_pixels; m_added = false; }