using System.Runtime.InteropServices;
using Decal.Interop.Core;
using Decal.Interop.Render;

namespace Decal.DecalRender
{
    [ComVisible(true)]
    [Guid("175D6713-E942-41C0-8BC9-90A565024F76")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("DecalRender.RenderTargetWrapper")]
    public class RenderTargetWrapperImpl : IRenderTarget
    {
        private object _surface;
        private tagRECT _region;

        public bool Lost => false;

        public void SetSurface(object pSurface) => _surface = pSurface;
        public object GetSurface() => _surface;

        public tagRECT Region { get => _region; set => _region = value; }
        public tagRECT Constraints => _region;

        public void Fill(ref tagRECT FillArea, int Color) { }
        public void Clear(ref tagRECT ClearArea) { }

        public void BeginRender(bool bFilterTexture) { }
        public void EndRender() { }

        public void BeginText(string FontName, int lHeight, int lWeight, bool bItalic) { }
        public void EndText() { }

        public void DrawPortalImage(int lPortalFile, ref tagRECT DestArea) { }
        public void DrawPortalImageEx(int lPortalFile, int lAlpha, ref tagRECT SrcArea, ref tagRECT DestArea) { }
        public void DrawImage(int pBuffer, int lSize, ref tagRECT DestRegion, int lColorKey) { }
        public void WriteText(ref tagRECT Region, int lColor, int lFormat, string Text) { }
        public void TilePortalImage(int lPortalFile, ref tagRECT DestArea) { }
        public void TilePortalImageEx(int lPortalFile, ref tagRECT SrcArea, ref tagRECT DestArea) { }

        public RenderTargetWrapper Constrain(ref tagRECT Region)
        {
            var wrapper = new RenderTargetWrapperImpl { _region = Region, _surface = _surface };
            return (RenderTargetWrapper)(object)wrapper;
        }
    }
}
