Ejemplo n.º 1
0
        public void Initialize(SimpleImGuiScene scene)
        {
            scene.OnBuildUI += Draw;

            this.scene = scene;
            this.pluginUI.ConfigWindow.Show();
        }
Ejemplo n.º 2
0
        static void Init(SimpleImGuiScene scene)
        {
            ParseSongs("xiv_bgm.csv");
            starImg     = scene.LoadImage("favoriteIcon.png");
            settingsImg = scene.LoadImage("settings.png");

            scene.OnBuildUI += Display;
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            using (var scene = new SimpleImGuiScene(RendererFactory.RendererBackend.DirectX11, new WindowCreateInfo
            {
                Title = "UI Test",
                Fullscreen = true,
                TransparentColor = new float[] { 0, 0, 0 },
            }))
            {
                scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

                scene.Window.OnSDLEvent += (ref SDL_Event sdlEvent) =>
                {
                    if (sdlEvent.type == SDL_EventType.SDL_KEYDOWN && sdlEvent.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_ESCAPE)
                    {
                        scene.ShouldQuit = true;
                    }
                };

                var fontPathJp = @"NotoSansCJKjp-Medium.otf";
                ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());

                ImGui.GetIO().Fonts.Build();

                ImGui.GetStyle().GrabRounding             = 3f;
                ImGui.GetStyle().FrameRounding            = 4f;
                ImGui.GetStyle().WindowRounding           = 4f;
                ImGui.GetStyle().WindowBorderSize         = 0f;
                ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Right;
                ImGui.GetStyle().ScrollbarSize            = 16f;

                ImGui.GetStyle().Colors[(int)ImGuiCol.WindowBg]          = new Vector4(0.06f, 0.06f, 0.06f, 0.87f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBg]           = new Vector4(0.29f, 0.29f, 0.29f, 0.54f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgHovered]    = new Vector4(0.54f, 0.54f, 0.54f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgActive]     = new Vector4(0.64f, 0.64f, 0.64f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TitleBgActive]     = new Vector4(0.29f, 0.29f, 0.29f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.CheckMark]         = new Vector4(0.86f, 0.86f, 0.86f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrab]        = new Vector4(0.54f, 0.54f, 0.54f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrabActive]  = new Vector4(0.67f, 0.67f, 0.67f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Button]            = new Vector4(0.71f, 0.71f, 0.71f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]     = new Vector4(0.47f, 0.47f, 0.47f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonActive]      = new Vector4(0.74f, 0.74f, 0.74f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Header]            = new Vector4(0.59f, 0.59f, 0.59f, 0.31f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderHovered]     = new Vector4(0.50f, 0.50f, 0.50f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderActive]      = new Vector4(0.60f, 0.60f, 0.60f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGrip]        = new Vector4(0.79f, 0.79f, 0.79f, 0.25f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripHovered] = new Vector4(0.78f, 0.78f, 0.78f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripActive]  = new Vector4(0.88f, 0.88f, 0.88f, 0.95f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Tab]        = new Vector4(0.23f, 0.23f, 0.23f, 0.86f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabHovered] = new Vector4(0.71f, 0.71f, 0.71f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabActive]  = new Vector4(0.36f, 0.36f, 0.36f, 1.00f);

                Init(scene);

                scene.Run();
            }
        }
Ejemplo n.º 4
0
        public void Initialize(SimpleImGuiScene scene)
        {
            // scene is a little different from what you have access to in dalamud
            // but it can accomplish the same things, and is really only used for initial setup hereThe

            scene.OnBuildUI += Draw;

            this.Visible = true;

            // saving this only so we can kill the test application by closing the window
            // (instead of just by hitting escape)
            this.scene = scene;
        }
Ejemplo n.º 5
0
        public void Initialize(SimpleImGuiScene scene)
        {
            // scene is a little different from what you have access to in dalamud
            // but it can accomplish the same things, and is really only used for initial setup here

            // eg, to load an image resource for use with ImGui
            this.goatImage = scene.LoadImage(@"goat.png");
            this.barImage  = scene.LoadImage(@"bar_textures.png");

            scene.OnBuildUI += Draw;

            this.Visible = true;

            // saving this only so we can kill the test application by closing the window
            // (instead of just by hitting escape)
            this.scene = scene;
        }
Ejemplo n.º 6
0
        public void CreateScene(string iniPath = null)
        {
            this.scene = new SimpleImGuiScene(RendererFactory.RendererBackend.OpenGL3, new WindowCreateInfo
            {
                Title            = "ImGui Overlay",
                Fullscreen       = true,
                TransparentColor = new float[] { 0, 0, 0, 0 },
            })
            {
                ImGuiIniPath = iniPath,
            };

            this.scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

            this.scene.OnBuildUI += OnBuildUi;

            unsafe
            {
                ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
                fontConfig.GlyphExtraSpacing.X = 0.5f;

                var io = ImGui.GetIO();

                var defaultFontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("IslandUniverse.Assets.Roboto-Regular.ttf");
                var dfIntPtr          = Marshal.AllocHGlobal((int)defaultFontStream.Length);
                var defaultFont       = new UnmanagedMemoryStream((byte *)dfIntPtr.ToPointer(), defaultFontStream.Length, defaultFontStream.Length, FileAccess.Write);
                defaultFontStream.CopyTo(defaultFont);

                // ImGui's font upscaling is pretty bad, so we add some larger versions in advance.
                var fontPtr1 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 13, 13f, fontConfig);
                this.Fonts.Add("Roboto Regular 13px", fontPtr1);
                var fontPtr2 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 18, 18f, fontConfig);
                this.Fonts.Add("Roboto Regular 18px", fontPtr2);
                var fontPtr3 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 24, 24f, fontConfig);
                this.Fonts.Add("Roboto Regular 24px", fontPtr3);

                io.Fonts.Build();

                fontConfig.Destroy();
            }

            SetUiStyle(DefaultUiStyle);

            this.scene.Run();
        }
Ejemplo n.º 7
0
        public static unsafe void Inititalize(IPluginUIMock pluginUI)
        {
            // you can edit this if you want more control over things
            // mainly if you want a regular window instead of transparent overlay
            // Typically you don't want to change any colors here if you keep the fullscreen overlay
            using (var scene = new SimpleImGuiScene(RendererFactory.RendererBackend.DirectX11, new WindowCreateInfo
            {
                Title = "UI Test",
                Fullscreen = true,
                TransparentColor = new float[] { 0, 0, 0 },
            }))
            {
                // the background color of your window - typically don't change this for fullscreen overlays
                scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

                // this just makes the application quit if you hit escape
                scene.Window.OnSDLEvent += (ref SDL_Event sdlEvent) =>
                {
                    if (sdlEvent.type == SDL_EventType.SDL_KEYDOWN && sdlEvent.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_ESCAPE)
                    {
                        scene.ShouldQuit = true;
                    }
                };

                // all of this is taken straight from dalamud

                ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
                fontConfig.MergeMode  = true;
                fontConfig.PixelSnapH = true;

                var fontPathJp = @"NotoSansCJKjp-Medium.otf";
                ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());

                var fontPathGame = @"gamesym.ttf";

                var rangeHandle = GCHandle.Alloc(new ushort[]
                {
                    0xE020,
                    0xE0DB,
                    0
                }, GCHandleType.Pinned);


                ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, rangeHandle.AddrOfPinnedObject());

                ImGui.GetIO().Fonts.Build();

                fontConfig.Destroy();
                rangeHandle.Free();


                ImGui.GetStyle().GrabRounding             = 3f;
                ImGui.GetStyle().FrameRounding            = 4f;
                ImGui.GetStyle().WindowRounding           = 4f;
                ImGui.GetStyle().WindowBorderSize         = 0f;
                ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Right;
                ImGui.GetStyle().ScrollbarSize            = 16f;

                ImGui.GetStyle().Colors[(int)ImGuiCol.WindowBg]          = new Vector4(0.06f, 0.06f, 0.06f, 0.87f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBg]           = new Vector4(0.29f, 0.29f, 0.29f, 0.54f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgHovered]    = new Vector4(0.54f, 0.54f, 0.54f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgActive]     = new Vector4(0.64f, 0.64f, 0.64f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TitleBgActive]     = new Vector4(0.29f, 0.29f, 0.29f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.CheckMark]         = new Vector4(0.86f, 0.86f, 0.86f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrab]        = new Vector4(0.54f, 0.54f, 0.54f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrabActive]  = new Vector4(0.67f, 0.67f, 0.67f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Button]            = new Vector4(0.71f, 0.71f, 0.71f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]     = new Vector4(0.47f, 0.47f, 0.47f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonActive]      = new Vector4(0.74f, 0.74f, 0.74f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Header]            = new Vector4(0.59f, 0.59f, 0.59f, 0.31f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderHovered]     = new Vector4(0.50f, 0.50f, 0.50f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderActive]      = new Vector4(0.60f, 0.60f, 0.60f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGrip]        = new Vector4(0.79f, 0.79f, 0.79f, 0.25f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripHovered] = new Vector4(0.78f, 0.78f, 0.78f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripActive]  = new Vector4(0.88f, 0.88f, 0.88f, 0.95f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Tab]        = new Vector4(0.23f, 0.23f, 0.23f, 0.86f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabHovered] = new Vector4(0.71f, 0.71f, 0.71f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabActive]  = new Vector4(0.36f, 0.36f, 0.36f, 1.00f);
                // end dalamud copy

                pluginUI.Initialize(scene);

                scene.Run();

                pluginUI.Dispose();
            }
        }