Exemplo n.º 1
0
    public SubPattern(Pattern pattern, DesignPatternInformation.DesignPatternPart part, bool import = false)
    {
        Colors  = new SubPatternColors(this);
        Pattern = pattern;
        Part    = part;
        Layers  = new List <Layer>();
        History = new History(this, 50);
        History.OnHistoryChanged = () => {
            Pattern.Editor.Tools.HistoryChanged(History);
        };
        if (!import)
        {
            var backgroundLayer = new RasterLayer(this, "Background");
            backgroundLayer.Colors = new UnityEngine.Color[Width * Height];
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    backgroundLayer.Colors[x + y * Width] = Colors[x + y * Width];
                }
            }

            backgroundLayer.UpdateTexture();
            Layers.Add(backgroundLayer);

            History.AddEvent(new History.LayerCreatedAction("Opened", 0, backgroundLayer));
        }
    }
Exemplo n.º 2
0
    public SubPattern(Pattern pattern, DesignPatternInformation.DesignPatternPart part, bool import = false)
    {
        Bitmap = new TextureBitmap(part.Width, part.Height);
        Bitmap.Clear();
        Bitmap.Texture.filterMode = UnityEngine.FilterMode.Point;
        Pattern = pattern;
        Part    = part;
        Layers  = new List <Layer>();
        History = new History(this, 50);
        History.OnHistoryChanged = () => {
            Pattern.Editor.Tools.HistoryChanged(History);
        };
        if (!import)
        {
            var backgroundLayer = new RasterLayer(this, "Background");

            unsafe
            {
                var colors      = pattern.Bitmap.GetColors();
                var layerColors = backgroundLayer.Texture.GetColors();
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerColors[x + (Height - 1 - y) * Width] = colors[Part.X + x + (pattern.Height - 1 - (Part.Y + y)) * pattern.Width];
                    }
                }
                //backgroundLayer.Texture.SetPixel(x, y, pattern.Bitmap.GetPixel(Part.X + x, (pattern.Height - 1 - Part.Y) + y));
            }
            Layers.Add(backgroundLayer);
            History.AddEvent(new History.LayerCreatedAction("Opened", 0, backgroundLayer));
        }
    }
Exemplo n.º 3
0
 public void SubPatternChanged(DesignPatternInformation.DesignPatternPart part)
 {
     foreach (var kv in PartIcons)
     {
         kv.Value.SetActive(part.Type == kv.Key);
     }
     PixelGrid.SubPatternChanged();
 }
Exemplo n.º 4
0
 public void SubPatternChanged(DesignPatternInformation.DesignPatternPart part)
 {
     try
     {
         bool found = false;
         foreach (var kv in PartIcons)
         {
             kv.Value.SetActive(part.Type == kv.Key);
             if (part.Type == kv.Key)
             {
                 found = true;
             }
         }
         SubPattern.gameObject.SetActive(found);
         PixelGrid.SubPatternChanged();
     }
     catch (System.Exception e) { Logger.Log(Logger.Level.ERROR, "[PatternEditor] Error in SubPatternChanged callback: " + e.ToString()); }
 }