Exemple #1
0
    public SectorRenderer(Application application, Level level, Sector sector)
    {
        this.application = application;
        this.level       = level;
        this.sector      = sector;
        Layer layer = new Layer();

        foreach (IDrawableLayer IDrawableLayer in sector.GetObjects(typeof(IDrawableLayer)))
        {
            Node node = IDrawableLayer.GetSceneGraphNode();
            if (IDrawableLayer is Tilemap)              //Special handling for tilemaps
            {
                node = new TilemapNode((Tilemap)IDrawableLayer, level.Tileset);
            }
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(IDrawableLayer.Layer, colorNode);
            colors[IDrawableLayer] = colorNode;
        }

        objectsNode      = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach (IObject Object in sector.GetObjects(typeof(IObject)))
        {
            Node node = Object.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        // fill remaining place with one color
        sectorFill      = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));

        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox      = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color           = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded         += OnObjectAdded;
        sector.ObjectRemoved       += OnObjectRemoved;
        sector.SizeChanged         += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        //TODO: It should be possible to iterate over all (currently present?) types that implements ILayer.. How?
        FieldOrProperty.AnyFieldChanged += OnFieldChanged;
    }
    public SectorRenderer(Level level, Sector sector)
    {
        this.level = level;
        Layer layer = new Layer();

        backgroundNode = new NodeWithChilds();
        backgroundColorNode = new ColorNode(backgroundNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(-900, backgroundColorNode);
        foreach(Background background in sector.GetObjects(typeof(Background))) {
            Node node = background.GetSceneGraphNode();
            if(node == null) continue;
            backgroundNode.AddChild(node);
        }

        foreach(Tilemap tilemap in sector.GetObjects(typeof(Tilemap))) {
            Node node = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.ZPos, colorNode);
            colors[tilemap] = colorNode;
        }

        objectsNode = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach(IObject Object in sector.GetObjects(typeof(IObject))) {
            Node node = Object.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        // draw border around sector...
        sectorFill = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));
        layer.Add(-10000, color);

        sectorBBox = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded += OnObjectAdded;
        sector.ObjectRemoved += OnObjectRemoved;
        sector.SizeChanged += OnSizeChanged;

        Drag.DestSet(this, DestDefaults.All, ObjectListWidget.DragTargetEntries, Gdk.DragAction.Default);
        DragMotion += OnDragMotion;
    }
    public SectorRenderer(Application application, Level level, Sector sector)
    {
        this.application = application;
        this.level = level;
        this.sector = sector;
        Layer layer = new Layer();

        foreach(IDrawableLayer IDrawableLayer in sector.GetObjects(typeof(IDrawableLayer))) {
            Node node = IDrawableLayer.GetSceneGraphNode();
            if (IDrawableLayer is Tilemap)	//Special handling for tilemaps
                node = new TilemapNode((Tilemap) IDrawableLayer, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(IDrawableLayer.Layer, colorNode);
            colors[IDrawableLayer] = colorNode;
        }

        objectsNode = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach(IObject Object in sector.GetObjects(typeof(IObject))) {
            Node node = Object.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        // fill remaining place with one color
        sectorFill = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));
        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded += OnObjectAdded;
        sector.ObjectRemoved += OnObjectRemoved;
        sector.SizeChanged += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        //TODO: It should be possible to iterate over all (currently present?) types that implements ILayer.. How?
        FieldOrProperty.AnyFieldChanged += OnFieldChanged;
    }
    public SectorRenderer(IEditorApplication application, Level level, Sector sector)
    {
        this.application = application;
        this.level       = level;
        this.sector      = sector;
        Layer layer = new Layer();

        backgroundNode      = new NodeWithChilds();
        backgroundColorNode = new ColorNode(backgroundNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(-900, backgroundColorNode);
        foreach (Background background in sector.GetObjects(typeof(Background)))
        {
            Node node = background.GetSceneGraphNode();
            if (node == null)
            {
                continue;
            }
            backgroundNode.AddChild(node);
        }

        foreach (Tilemap tilemap in sector.GetObjects(typeof(Tilemap)))
        {
            Node      node      = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(tilemap.ZPos, colorNode);
            colors[tilemap] = colorNode;
        }

        objectsNode      = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach (IObject Object in sector.GetObjects(typeof(IObject)))
        {
            Node node = Object.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        // fill remaining place with one color
        sectorFill      = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));

        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox      = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color           = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded         += OnObjectAdded;
        sector.ObjectRemoved       += OnObjectRemoved;
        sector.SizeChanged         += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        FieldOrProperty.Lookup(typeof(Tilemap).GetField("ZPos")).Changed += OnTilemapZPosModified;
    }