Exemplo n.º 1
0
    public virtual void Draw(Gdk.Rectangle cliprect)
    {
        float offsetX = (application.CurrentTilemap == null?0:application.CurrentTilemap.X);
        float offsetY = (application.CurrentTilemap == null?0:application.CurrentTilemap.Y);

        if (state == State.DRAWING || state == State.NONE)
        {
            gl.Color4f(1, 1, 1, 0.7f);
            Vector pos = new Vector(
                MouseTilePos.X * Tileset.TILE_WIDTH + offsetX,
                MouseTilePos.Y * Tileset.TILE_HEIGHT + offsetY);
            selection.Draw(pos, Tileset);
            gl.Color4f(1, 1, 1, 1);
        }
        else if (state == State.FILLING || state == State.SELECTING)
        {
            float left   = SelectionP1.X * Tileset.TILE_WIDTH + offsetX;
            float top    = SelectionP1.Y * Tileset.TILE_HEIGHT + offsetY;
            float right  = (SelectionP2.X + 1) * Tileset.TILE_WIDTH + offsetX;
            float bottom = (SelectionP2.Y + 1) * Tileset.TILE_HEIGHT + offsetY;

            gl.Color4f(0, 0, 1, 0.7f);
            gl.Disable(gl.TEXTURE_2D);

            gl.Begin(gl.QUADS);
            gl.Vertex2f(left, top);
            gl.Vertex2f(right, top);
            gl.Vertex2f(right, bottom);
            gl.Vertex2f(left, bottom);
            gl.End();

            gl.Enable(gl.TEXTURE_2D);
            gl.Color4f(1, 1, 1, 1);
        }
    }