using System.Reflection;
using ImGuiNET;
using SDL2;

namespace SDL2Demo.Forms
{
    internal class AboutWindow : IRenderable
    {
        private SDL.SDL_version sdlVersion;

        private PortableExecutableKinds peKind;
        private ImageFileMachine machine;

        public AboutWindow()
        {
            typeof(AboutWindow).Module.GetPEKind(out peKind, out machine);
            SDL2.SDL.SDL_GetVersion(out sdlVersion);
        }

        public void Render()
        {
            bool open = true;
            ImGui.Begin("About skyscraper5", ref open, ImGuiWindowFlags.AlwaysVerticalScrollbar);
            ImGui.Text("skyscraper5, written by Feyris-Tan");
            ImGui.Spacing();

            ImGui.Text(String.Format("Using SDL {0}.{1}.{2}", sdlVersion.major, sdlVersion.minor, sdlVersion.patch));
            ImGui.Text(String.Format("Using Dear ImGUI {0}", ImGui.GetVersion()));
            ImGui.Text(String.Format("Using StreamReader.dll by crazycat69"));
            ImGui.Spacing();

            ImGui.Text(String.Format("The currently executing image file is for {0} processors.", machine.ToString()));
            ImGui.Text(String.Format("You are running an {0}-bit operating system.", Environment.Is64BitOperatingSystem ? 64 : 32));
            ImGui.Text(String.Format("This is a {0}-bit process.", Environment.Is64BitProcess ? 64 : 32));
            if (Environment.Is64BitProcess)
            {
                ImGui.Text(String.Format("Please remember that StreamReader.dll requires a 32-bit context."));
                ImGui.Text("Consider using Remote Stream Reader");
            }

            if (ImGui.Button("OK"))
                Closed = true;
            ImGui.End();
            if (!open)
                Closed = true;
        }

        public bool Closed { get; set; }
    }
}
