Exemplo n.º 1
0
        public void Update(double delta)
        {
            var groupedEditors = Editors.GroupBy(e => e.Category);

            foreach (var editor in Editors.Where(e => e.HotKey.HasValue))
            {
                if (ImGui.IsKeyDown((int)Veldrid.Key.ShiftLeft) &&
                    ImGui.IsKeyDown((int)Veldrid.Key.ControlLeft) &&
                    ImGui.IsKeyPressed((int)Enum.Parse(typeof(Veldrid.Key), editor.HotKey.Value.ToString().ToUpper())))
                {
                    editor.IsActive = !editor.IsActive;
                }
            }

            if (ImGui.BeginMainMenuBar())
            {
                foreach (var group in groupedEditors)
                {
                    if (ImGui.BeginMenu(group.Key))
                    {
                        foreach (var editor in group)
                        {
                            bool active      = editor.IsActive;
                            var  shortcutStr = editor.HotKey.HasValue ? "Ctrl+Shft+" + editor.HotKey.Value : "";
                            ImGui.MenuItem(editor.Name, shortcutStr, ref active, true);
                            editor.IsActive = active;
                        }
                        ImGui.EndMenu();
                    }
                }
                ImGui.EndMainMenuBar();
            }

            foreach (var editor in Editors.Where(e => e.IsActive))
            {
                editor.DrawWindow(delta);
            }
        }
Exemplo n.º 2
0
        protected override void Update(InputSnapshot snapshot, float elapsedSeconds)
        {
            base.Update(snapshot, elapsedSeconds);

            if (targetFps >= 1)
            {
                TargetTicksPerFrame = System.Diagnostics.Stopwatch.Frequency / targetFps;
            }

            if (targetTps >= 10 && targetTps > targetFps)
            {
                TargetTicksPerUpdate = System.Diagnostics.Stopwatch.Frequency / targetTps;
            }

            if (ImGui.Begin("Settings"))
            {
                if (ImGui.BeginMenu("Application Settings"))
                {
                    ImGui.InputInt("Target FPS", ref targetFps);
                    ImGui.InputInt("Target TPS", ref targetTps);
                }
            }
        }
Exemplo n.º 3
0
        void DrawEditor()
        {
            DrawDock();

            DrawWindows();

            //simple menu system
            if (ImGui.BeginMainMenuBar())
            {
                menu.OnGUI();

                //this is for demo
                if (ImGui.BeginMenu("Demo"))
                {
                    ImGui.MenuItem("show demo", "", ref bShowDemo);
                    ImGui.MenuItem("show state", "", ref bShowState);
                    ImGui.MenuItem("show font", "", ref bShowFont);
                    ImGui.EndMenu();
                }
                ImGui.EndMainMenuBar();
            }

            if (bShowDemo)
            {
                ImGui.ShowDemoWindow();
            }

            if (bShowState)
            {
                AppNative.feApp_ShowState();
            }

            if (bShowFont)
            {
                ImGui.ShowFontSelector("font selector");
            }
        }
Exemplo n.º 4
0
        public void Render(out float menuHeight)
        {
            if (this.DarkMode)
            {
                ImGui.StyleColorsDark();
            }
            else
            {
                ImGui.StyleColorsLight();
            }

            menuHeight = 0.0f;
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("Theme"))
                {
                    if (ImGui.MenuItem("Light", string.Empty, !this.DarkMode, this.DarkMode))
                    {
                        this.DarkMode = false;
                    }

                    if (ImGui.MenuItem("Dark", string.Empty, this.DarkMode, !this.DarkMode))
                    {
                        this.DarkMode = true;
                    }

                    // if (ImGui.MenuItem("Demo", "", DemoMode))
                    // {
                    //     DemoMode = !DemoMode;
                    // }
                    ImGui.EndMenu();
                }

                menuHeight = ImGui.GetWindowHeight();
                ImGui.EndMainMenuBar();
            }
        }
Exemplo n.º 5
0
        internal static void RenderSettings()
        {
            if (ImGui.Begin("Settings"))
            {
                if (ImGui.BeginMenu("Raytracer Settings"))
                {
                    ImGui.Checkbox("Diffuse Light Sampling", ref Settings.DiffuseLightSampling);
                    ImGui.Checkbox("Sample One Light", ref Settings.DiffuseLightSamplingOneLight);
                    ImGui.DragInt("Sample Light", ref Settings.DiffuseLightSamplingLight, 1, 0, Lights.Length - 1);
                    ImGui.Checkbox("Specular Sampling", ref SpecularLightSampling);
                    ImGui.Checkbox("Randomize Bouncing", ref Settings.RandomizeBounceOnRoughness);
                    ImGui.Checkbox("Randomize Camera Ray", ref Settings.RandomizeCameraRays);
                    ImGui.DragInt("Skip Pixel Probability", ref SkipPixelProbability, 1, 0, 50);
                    ImGui.DragInt("Number of Bounces", ref Settings.MaxBounces, 1, 0, 50);
                    ImGui.DragInt("Number of Samples", ref Settings.NumberOfSamples, 16, 16, 81920);
                    ImGui.DragFloat("Minimum Illumination", ref Settings.MinimumIllumination, 0.1f, 0f, 1f);
                }
            }

            minimumIlluminationNoAlpha = new Vector4(Settings.MinimumIllumination, Settings.MinimumIllumination,
                                                     Settings.MinimumIllumination, 0.0f);
            minimumIlluminationFullAlpha = new Vector4(Settings.MinimumIllumination, Settings.MinimumIllumination,
                                                       Settings.MinimumIllumination, 1.0f);
        }
Exemplo n.º 6
0
        public void Render(out float menuHeight)
        {
            if (DarkMode)
            {
                ImGui.StyleColorsDark();
            }
            else
            {
                ImGui.StyleColorsLight();
            }

            menuHeight = 0.0f;
            if (!ImGui.BeginMainMenuBar())
            {
                return;
            }

            if (ImGui.BeginMenu("Theme"))
            {
                if (ImGui.MenuItem("Light", "", !DarkMode, DarkMode))
                {
                    DarkMode = false;
                }
                if (ImGui.MenuItem("Dark", "", DarkMode, !DarkMode))
                {
                    DarkMode = true;
                }
                if (ImGui.MenuItem("Demo", "", DemoMode))
                {
                    DemoMode = !DemoMode;
                }
                ImGui.EndMenu();
            }
            menuHeight = ImGui.GetWindowHeight();
            ImGui.EndMainMenuBar();
        }
Exemplo n.º 7
0
        protected override bool DrawNewItemSelector(string label, ref object obj, RenderContext rc)
        {
            bool result = false;

            ImGui.PushID(label);

            if (ImGui.BeginMenu(label))
            {
                foreach (Type t in _subTypes)
                {
                    if (ImGui.MenuItem(t.Name, ""))
                    {
                        obj    = Activator.CreateInstance(t);
                        result = true;
                    }
                }

                ImGui.EndMenu();
            }

            ImGui.PopID();

            return(result);
        }
Exemplo n.º 8
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        protected override void RenderImguiLayout()
        {
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    ImGui.MenuItem("Open", null, ref Opened);
                    ImGui.Separator();
                    ImGui.MenuItem("Save");
                    ImGui.MenuItem("Exit");
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Effects"))
                {
                    ImGui.MenuItem("Rotation", null, ref Rotation);
                    ImGui.MenuItem("Lightshow", null, ref Lightshow);
                    ImGui.EndMenu();
                }

                ImGui.EndMenuBar();
                Button.IsGloballyClickable = !ImGui.IsAnyItemHovered();
            }
        }
Exemplo n.º 9
0
        private void DrawMenuBar()
        {
            if (ImGui.BeginMenuBar())
            {
                if (ImGui.BeginMenu("View"))
                {
                    foreach (var document in documents)
                    {
                        if (document.IsOpen)
                        {
                            if (ImGui.BeginMenu(document.Title))
                            {
                                if (ImGui.MenuItem("Dock", !document.IsDocked))
                                {
                                    document.IsDocked = true;
                                }

                                ImGui.EndMenu();
                            }
                        }
                        else
                        {
                            if (ImGui.MenuItem($"Open {document.Title}", !document.IsOpen))
                            {
                                document.IsOpen   = true;
                                document.IsDocked = true;
                            }
                        }
                    }

                    ImGui.EndMenu();
                }

                ImGui.EndMenuBar();
            }
        }
Exemplo n.º 10
0
        private void Update(float deltaSeconds)
        {
            _fta.AddTime(deltaSeconds);
            _scene.Update(deltaSeconds);

            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("Settings"))
                {
                    if (ImGui.BeginMenu("Graphics Backend"))
                    {
                        if (ImGui.MenuItem("Vulkan", GraphicsDevice.IsBackendSupported(GraphicsBackend.Vulkan)))
                        {
                            ChangeBackend(GraphicsBackend.Vulkan);
                        }
                        if (ImGui.MenuItem("OpenGL", GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGL)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGL);
                        }
                        if (ImGui.MenuItem("OpenGL ES", GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGLES)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGLES);
                        }
                        if (ImGui.MenuItem("Direct3D 11", GraphicsDevice.IsBackendSupported(GraphicsBackend.Direct3D11)))
                        {
                            ChangeBackend(GraphicsBackend.Direct3D11);
                        }
                        if (ImGui.MenuItem("Metal", GraphicsDevice.IsBackendSupported(GraphicsBackend.Metal)))
                        {
                            ChangeBackend(GraphicsBackend.Metal);
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("MSAA"))
                    {
                        if (ImGui.Combo("MSAA", ref _msaaOption, _msaaOptions))
                        {
                            ChangeMsaa(_msaaOption);
                        }

                        ImGui.EndMenu();
                    }
                    bool isFullscreen = _window.WindowState == WindowState.BorderlessFullScreen;
                    if (ImGui.MenuItem("Fullscreen", "F11", isFullscreen, true))
                    {
                        ToggleFullscreenState();
                    }
                    if (ImGui.MenuItem("Always Recreate Sdl2Window", string.Empty, _recreateWindow, true))
                    {
                        _recreateWindow = !_recreateWindow;
                    }
                    if (ImGui.IsItemHovered(HoveredFlags.Default))
                    {
                        ImGui.SetTooltip(
                            "Causes a new OS window to be created whenever the graphics backend is switched. This is much safer, and is the default.");
                    }
                    bool threadedRendering = _scene.ThreadedRendering;
                    if (ImGui.MenuItem("Render with multiple threads", string.Empty, threadedRendering, true))
                    {
                        _scene.ThreadedRendering = !_scene.ThreadedRendering;
                    }
                    bool tinted = _fsq.UseTintedTexture;
                    if (ImGui.MenuItem("Tinted output", string.Empty, tinted, true))
                    {
                        _fsq.UseTintedTexture = !tinted;
                    }
                    bool vsync = _gd.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", string.Empty, vsync, true))
                    {
                        _gd.SyncToVerticalBlank = !_gd.SyncToVerticalBlank;
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Materials"))
                {
                    if (ImGui.BeginMenu("Brick"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Brick);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Vase"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Vase);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Reflective"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Reflective);
                        ImGui.EndMenu();
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Debug"))
                {
                    if (ImGui.MenuItem("Refresh Device Objects"))
                    {
                        RefreshDeviceObjects(1);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (10 times)"))
                    {
                        RefreshDeviceObjects(10);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (100 times)"))
                    {
                        RefreshDeviceObjects(100);
                    }

                    ImGui.EndMenu();
                }

                ImGui.Text(_fta.CurrentAverageFramesPerSecond.ToString("000.0 fps / ") + _fta.CurrentAverageFrameTimeMilliseconds.ToString("#00.00 ms"));

                ImGui.EndMainMenuBar();
            }

            if (InputTracker.GetKeyDown(Key.F11))
            {
                ToggleFullscreenState();
            }

            _window.Title = _gd.BackendType.ToString();
        }
    void DrawMenu()
    {
        if (ImGui.BeginMainMenuBar())
        {
            if (ImGui.BeginMenu("File"))
            {
                if (ImGui.MenuItem("Open keyframe data", "Ctrl+O"))
                {
                    LoadKeyFrames();
                }

                if (ImGui.MenuItem("Save keyframe data", "Ctrl+S"))
                {
                    SaveKeyFrames();
                }

                if (ImGui.MenuItem("Import Music", "Ctrl+I"))
                {
                    StartCoroutine(OpenMusic());
                }

                if (ImGui.MenuItem("Export BanGround Lua code", "Ctrl+E"))
                {
                    ExportLua();
                }

                if (ImGui.MenuItem("Quit"))
                {
                    Application.Quit(0);
                }

                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Playback"))
            {
                if (ImGui.MenuItem("Play/Pause", "Space"))
                {
                    TogglePlaystate();
                }

                if (ImGui.MenuItem("Reset time to 0"))
                {
                    ass.time = 0.00f;
                }

                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Keyframe"))
            {
                if (ImGui.MenuItem("Add keyframe/Edit current keyframe", "S"))
                {
                    UpdateOrNewKeyframe();
                }

                ImGui.EndMenu();
            }

            ImGui.EndMainMenuBar();
        }
    }
Exemplo n.º 12
0
        public void Draw(Sdl2Window window)
        {
            ImGui.SetNextWindowPos(Vector2.Zero, ImGuiCond.Always, Vector2.Zero);
            ImGui.SetNextWindowSize(new Vector2(window.Width, window.Height), ImGuiCond.Always);

            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0);
            bool open = false;

            ImGui.Begin("OpenSAGE Big Editor", ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize);

            var wasOpenClicked        = false;
            var wasExportAllClicked   = false;
            var wasImportFilesClicked = false;
            var wasImportFileClicked  = false;

            if (ImGui.BeginMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open...", "Ctrl+O", false, true))
                    {
                        wasOpenClicked = true;
                    }
                    if (ImGui.MenuItem("Close", null, false, _bigArchive != null))
                    {
                        OpenBigFile(null);
                    }

                    ImGui.Separator();

                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Edit"))
                {
                    if (ImGui.MenuItem("Export All", "Ctrl+E", false, _bigArchive != null))
                    {
                        wasExportAllClicked = true;
                    }

                    ImGui.Separator();

                    if (ImGui.MenuItem("Import Files", "Ctrl+Shift+I", false, _bigArchive != null))
                    {
                        wasImportFilesClicked = true;
                    }

                    if (ImGui.MenuItem("Import File...", "Ctrl+I", false, _bigArchive != null))
                    {
                        wasImportFileClicked = true;
                    }

                    ImGui.EndMenu();
                }

                ImGui.EndMenuBar();
            }

            if (wasOpenClicked)
            {
                var openDialog = new OpenFileDialog("Open .big file");
                openDialog.Open(result => OpenBigFile(result.FileName), "Big archive(*.big) | *.big");
            }
            if (wasExportAllClicked)
            {
                var dirDialog = new DirectoryDialog("Select folder for export files");
                dirDialog.Open(result => Export(result.FileName));
            }
            if (wasImportFilesClicked)
            {
                var dirDialog = new DirectoryDialog("Select folder for import files");
                dirDialog.Open(result => Import(result.FileName));
            }
            if (wasImportFileClicked)
            {
                var openDialog = new OpenFileDialog("Select file which you want to import");
                openDialog.Open(result => ImportFile(result.FileName));
            }

            if (_bigArchive != null)
            {
                ImGui.BeginChild("body", new Vector2(0, -36), false, 0);

                DrawFilesList(new Vector2(window.Width, window.Height));

                ImGui.SameLine();

                DrawFileContent();

                ImGui.EndChild(); // end body

                DrawStatusPanel();
            }
            else
            {
                ImGui.Text("Open a .big file to see its contents here.");
            }

            ImGui.End();
            ImGui.PopStyleVar();
        }
Exemplo n.º 13
0
        private void DrawViewportMenu()
        {
            if (ImGui.BeginMenu("View Setting"))
            {
                if (ImGui.BeginMenu("Background"))
                {
                    ImGui.Checkbox("Display", ref DrawableBackground.Display);
                    ImGui.ColorEdit3("Color Top", ref DrawableBackground.BackgroundTop);
                    ImGui.ColorEdit3("Color Bottom", ref DrawableBackground.BackgroundBottom);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Grid"))
                {
                    ImGui.Checkbox("Display", ref DrawableFloor.Display);
                    ImGui.ColorEdit4("Grid Color", ref DrawableFloor.GridColor);
                    ImGui.InputInt("Grid Cell Count", ref Toolbox.Core.Runtime.GridSettings.CellAmount);
                    ImGui.InputFloat("Grid Cell Size", ref Toolbox.Core.Runtime.GridSettings.CellSize);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Bones"))
                {
                    ImGui.Checkbox("Display", ref Runtime.DisplayBones);
                    ImGui.InputFloat("Point Size", ref Runtime.BonePointSize);
                    ImGui.EndMenu();
                }

                if (ImGui.Checkbox("Mesh Picking", ref Pipeline._context.ColorPicker.EnablePicking))
                {
                    if (!Pipeline._context.ColorPicker.EnablePicking)
                    {
                        Pipeline._context.Scene.ResetSelected();
                    }
                }
                ImGui.Checkbox("Wireframe", ref Toolbox.Core.Runtime.RenderSettings.Wireframe);
                ImGui.Checkbox("WireframeOverlay", ref Toolbox.Core.Runtime.RenderSettings.WireframeOverlay);
                ImGui.Checkbox("Bounding Boxes", ref Toolbox.Core.Runtime.RenderBoundingBoxes);
                ImGui.Checkbox("Enable Bloom", ref Pipeline._context.EnableBloom);


                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu($"Shading: [{Runtime.DebugRendering}]"))
            {
                foreach (var mode in Enum.GetValues(typeof(Runtime.DebugRender)))
                {
                    bool isSelected = (Runtime.DebugRender)mode == Runtime.DebugRendering;
                    if (ImGui.Selectable(mode.ToString(), isSelected))
                    {
                        Runtime.DebugRendering = (Runtime.DebugRender)mode;
                    }
                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Camera"))
            {
                if (ImGui.Button("Reset Transform"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.ComboFromEnum <Camera.FaceDirection>("Direction", Pipeline._context.Camera, "Direction");
                if (ImGuiHelper.ComboFromEnum <Camera.CameraMode>("Mode", Pipeline._context.Camera, "Mode"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.InputFromBoolean("Orthographic", Pipeline._context.Camera, "IsOrthographic");
                ImGuiHelper.InputFromBoolean("Lock Rotation", Pipeline._context.Camera, "LockRotation");

                ImGuiHelper.InputFromFloat("Fov (Degrees)", Pipeline._context.Camera, "FovDegrees", true, 1f);
                if (Pipeline._context.Camera.FovDegrees != 45)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.FovDegrees = 45;
                    }
                }

                ImGuiHelper.InputFromFloat("ZFar", Pipeline._context.Camera, "ZFar", true, 1f);
                if (Pipeline._context.Camera.ZFar != 100000.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZFar = 100000.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("ZNear", Pipeline._context.Camera, "ZNear", true, 0.1f);
                if (Pipeline._context.Camera.ZNear != 0.1f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZNear = 0.1f;
                    }
                }

                ImGuiHelper.InputFromFloat("Zoom Speed", Pipeline._context.Camera, "ZoomSpeed", true, 0.1f);
                if (Pipeline._context.Camera.ZoomSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZoomSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Pan Speed", Pipeline._context.Camera, "PanSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.PanSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Key Move Speed", Pipeline._context.Camera, "KeyMoveSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("KeyMoveSpeed"))
                    {
                        Pipeline._context.Camera.KeyMoveSpeed = 1.0f;
                    }
                }

                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Reset Animations"))
            {
                TimelineWindow.Reset();
                ImGui.EndMenu();
            }

            ImGui.AlignTextToFramePadding();
            ImGui.Text("Active Model(s)");
            ImGui.SameLine();

            ImGui.PushItemWidth(250);
            if (ImGui.BeginCombo("##model_select", selectedModel))
            {
                bool isSelected = "All Models" == selectedModel;
                if (ImGui.Selectable("All Models", isSelected))
                {
                    selectedModel = "All Models";
                    ToggleModel();
                }
                if (isSelected)
                {
                    ImGui.SetItemDefaultFocus();
                }

                foreach (var file in Pipeline.Files)
                {
                    foreach (var model in file.Renderer.Models)
                    {
                        string name = $"{file.Renderer.Name}.{model.Name}";
                        isSelected = name == selectedModel;

                        if (ImGui.Selectable(name, isSelected))
                        {
                            selectedModel = name;
                            ToggleModel();
                        }
                        if (isSelected)
                        {
                            ImGui.SetItemDefaultFocus();
                        }
                    }
                }
                ImGui.EndCombo();
            }
            ImGui.PopItemWidth();
        }
Exemplo n.º 14
0
        public void Draw(ref bool isGameViewFocused)
        {
            float menuBarHeight = 0;

            if (ImGui.BeginMainMenuBar())
            {
                menuBarHeight = ImGui.GetWindowHeight();

                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Jump"))
                {
                    if (ImGui.BeginMenu("Map"))
                    {
                        foreach (var mapCache in _context.Game.AssetStore.MapCaches)
                        {
                            var mapName = mapCache.GetNameKey().Translate();

                            if (ImGui.MenuItem($"{mapName} ({mapCache.Name})"))
                            {
                                var playableSides = _context.Game.GetPlayableSides();
                                var faction1      = playableSides.First();
                                var faction2      = playableSides.Last();

                                _context.Game.StartMultiPlayerGame(
                                    mapCache.Name,
                                    new EchoConnection(),
                                    new PlayerSetting?[]
                                {
                                    new PlayerSetting(null, faction1, new ColorRgb(255, 0, 0)),
                                    new PlayerSetting(null, faction2, new ColorRgb(255, 255, 255)),
                                },
                                    0);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Windows"))
                {
                    foreach (var view in _views)
                    {
                        if (ImGui.MenuItem(view.DisplayName, null, view.IsVisible, true))
                        {
                            view.IsVisible = true;

                            ImGui.SetWindowFocus(view.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Preferences"))
                {
                    var isVSyncEnabled = _context.Game.GraphicsDevice.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true))
                    {
                        _context.Game.GraphicsDevice.SyncToVerticalBlank = isVSyncEnabled;
                    }
                    var isFullscreen = _context.Game.Window.Fullscreen;
                    if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true))
                    {
                        _context.Game.Window.Fullscreen = isFullscreen;
                    }
                    ImGui.EndMenu();
                }

                if (_context.Game.Configuration.UseRenderDoc && ImGui.BeginMenu("RenderDoc"))
                {
                    var renderDoc = Game.RenderDoc;

                    if (ImGui.MenuItem("Trigger Capture"))
                    {
                        renderDoc.TriggerCapture();
                    }
                    if (ImGui.BeginMenu("Options"))
                    {
                        bool allowVsync = renderDoc.AllowVSync;
                        if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                        {
                            renderDoc.AllowVSync = allowVsync;
                        }
                        bool validation = renderDoc.APIValidation;
                        if (ImGui.Checkbox("API Validation", ref validation))
                        {
                            renderDoc.APIValidation = validation;
                        }
                        int delayForDebugger = (int)renderDoc.DelayForDebugger;
                        if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                        {
                            delayForDebugger           = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                            renderDoc.DelayForDebugger = (uint)delayForDebugger;
                        }
                        bool verifyBufferAccess = renderDoc.VerifyBufferAccess;
                        if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                        {
                            renderDoc.VerifyBufferAccess = verifyBufferAccess;
                        }
                        bool overlayEnabled = renderDoc.OverlayEnabled;
                        if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                        {
                            renderDoc.OverlayEnabled = overlayEnabled;
                        }
                        bool overlayFrameRate = renderDoc.OverlayFrameRate;
                        if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                        {
                            renderDoc.OverlayFrameRate = overlayFrameRate;
                        }
                        bool overlayFrameNumber = renderDoc.OverlayFrameNumber;
                        if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                        {
                            renderDoc.OverlayFrameNumber = overlayFrameNumber;
                        }
                        bool overlayCaptureList = renderDoc.OverlayCaptureList;
                        if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                        {
                            renderDoc.OverlayCaptureList = overlayCaptureList;
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.MenuItem("Launch Replay UI"))
                    {
                        renderDoc.LaunchReplayUI();
                    }

                    ImGui.EndMenu();
                }

                DrawTimingControls();

                var fpsText     = $"{ImGui.GetIO().Framerate:N2} FPS";
                var fpsTextSize = ImGui.CalcTextSize(fpsText).X;
                ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - fpsTextSize);
                ImGui.Text(fpsText);

                ImGui.EndMainMenuBar();
            }

            foreach (var view in _views)
            {
                view.Draw(ref isGameViewFocused);
            }

            var launcherImage = _context.Game.LauncherImage;

            if (launcherImage != null)
            {
                var launcherImageMaxSize = new Vector2(150, 150);

                var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio(
                    new SizeF(launcherImage.Width, launcherImage.Height),
                    new Size((int)launcherImageMaxSize.X, (int)launcherImageMaxSize.Y));

                const int launcherImagePadding = 10;
                ImGui.SetNextWindowPos(new Vector2(
                                           _context.Game.Window.ClientBounds.Width - launcherImageSize.Width - launcherImagePadding,
                                           menuBarHeight + launcherImagePadding));

                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
                ImGui.Begin("LauncherImage", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration);

                ImGui.Image(
                    _context.ImGuiRenderer.GetOrCreateImGuiBinding(_context.Game.GraphicsDevice.ResourceFactory, launcherImage),
                    new Vector2(launcherImageSize.Width, launcherImageSize.Height),
                    Vector2.Zero,
                    Vector2.One,
                    Vector4.One,
                    Vector4.Zero);

                ImGui.End();
                ImGui.PopStyleVar();
            }
        }
Exemplo n.º 15
0
        public static void SubmitMainMenuBar()
        {
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Load FFX"))
                    {
#if RELEASE
                        try
                        {
#endif
                        System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
                        ofd.Filter = "FFX|*.fxr;*.xml";
                        ofd.Title  = "Open FFX";

                        if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (Path.GetExtension(ofd.FileName) == ".fxr")
                            {
                                var fxrXml = FXR3_XMLR.Fxr3EnhancedSerialization.Fxr3ToXml(FXR3_XMLR.Fxr3.Read(ofd.FileName));
                                LoadFfxFromXml(fxrXml, ofd.FileName);
                            }
                            else if (Path.GetExtension(ofd.FileName) == ".xml")
                            {
                                var fxrXml = XDocument.Load(ofd.FileName);
                                LoadFfxFromXml(fxrXml, ofd.FileName);
                            }
                        }
#if RELEASE
                    }
                    catch (Exception exception)
                    {
                        ExceptionManager.PushExceptionForRendering("ERROR: FFX loading failed", exception);
                    }
#endif
                    }
                    if (ImGui.MenuItem("Save", OpenFfXs.Any()))
                    {
                        try
                        {
                            if (SelectedFfxWindow.LoadedFilePath.EndsWith(".xml"))
                            {
                                SelectedFfxWindow.XDocLinq.Save(SelectedFfxWindow.LoadedFilePath);
                                FXR3_XMLR.Fxr3EnhancedSerialization.XmlToFxr3(SelectedFfxWindow.XDocLinq).Write(SelectedFfxWindow.LoadedFilePath.Substring(0, SelectedFfxWindow.LoadedFilePath.Length - 4));
                            }
                            else if (SelectedFfxWindow.LoadedFilePath.EndsWith(".fxr"))
                            {
                                SelectedFfxWindow.XDocLinq.Save(SelectedFfxWindow.LoadedFilePath + ".xml");
                                FXR3_XMLR.Fxr3EnhancedSerialization.XmlToFxr3(SelectedFfxWindow.XDocLinq).Write(SelectedFfxWindow.LoadedFilePath);
                            }
                        }
                        catch (Exception exception)
                        {
                            ExceptionManager.PushExceptionForRendering("ERROR: FFX saving failed", exception);
                        }
                    }
                    if (ImGui.MenuItem("Save as", OpenFfXs.Any()))
                    {
                        try
                        {
                            System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
                            saveFileDialog1.Filter = "FXR|*.fxr|XML|*.xml";
                            saveFileDialog1.Title  = "Save FFX as";

                            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                if (Path.GetExtension(saveFileDialog1.FileName) == ".fxr")
                                {
                                    FXR3_XMLR.Fxr3EnhancedSerialization.XmlToFxr3(SelectedFfxWindow.XDocLinq).Write(saveFileDialog1.FileName);
                                }
                                else if (Path.GetExtension(saveFileDialog1.FileName) == ".xml")
                                {
                                    SelectedFfxWindow.XDocLinq.Save(saveFileDialog1.FileName);
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            ExceptionManager.PushExceptionForRendering("ERROR: FFX saving failed", exception);
                        }
                    }
                    if (ImGui.MenuItem("Load FFX Resources For Texture Display - Requires Relatively Good Hardware", FfxTextureHandler == null))
                    {
                        var ofd = new OpenFileDialog()
                        {
                            Title = "Open frpg_sfxbnd_commoneffects_resource.ffxbnd", Filter = "FfxRes|frpg_sfxbnd_commoneffects_resource.ffxbnd.dcx"
                        };
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            FfxTextureHandler = new ImGuiFxrTextureHandler(BND4.Read(ofd.FileName));
                        }
                    }
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Edit"))
                {
                    if (ImGui.MenuItem("Undo", "Ctrl Z", false, SelectedFfxWindow != null ? SelectedFfxWindow.ActionManager.CanUndo() : false))
                    {
                        SelectedFfxWindow.ActionManager.UndoAction();
                    }
                    if (ImGui.MenuItem("Redo", "Ctrl Y", false, SelectedFfxWindow != null ? SelectedFfxWindow.ActionManager.CanRedo() : false))
                    {
                        SelectedFfxWindow.ActionManager.RedoAction();
                    }
                    if (ImGui.MenuItem("Extend Active FFX Treeview", SelectedFfxWindow != null))
                    {
                        SelectedFfxWindow.CollapseExpandTreeView = true;
                    }
                    if (ImGuiAddons.IsItemHoveredForTime(500, MainUserInterface.FrameRateForDelta, "HoverTimerTreeViewExpander"))
                    {
                        ImGui.Indent();
                        ImGui.Text("Holding Shift while clicking this button will expand properties aswell as the treeview itself.");
                        ImGui.Unindent();
                    }
                    if (ImGui.MenuItem("Search Actions..."))
                    {
                        IsSearchBarOpen = !IsSearchBarOpen;
                    }
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("UI Configs"))
                {
                    if (ImGuiAddons.BeginComboFixed("Theme Selector", _activeTheme))
                    {
                        foreach (string str in ThemeSelectorEntriesArray)
                        {
                            bool selected = false;
                            if (str == _activeTheme)
                            {
                                selected = true;
                            }
                            if (ImGui.Selectable(str, selected))
                            {
                                _activeTheme = str;
                                Themes.ThemesSelectorPush(_activeTheme);
                                SelectedThemeConfig.WriteConfigsIni(_activeTheme);
                            }
                        }
                        ImGuiAddons.EndComboFixed();
                    }
                    ImGui.InputInt("Displayed Texture Size", ref TextureDisplaySize, 10, 100);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Useful Info"))
                {
                    // Keybord Interactions Start
                    ImGui.Text("Keyboard Interactions Guide");
                    ImGui.SameLine();
                    ImGuiAddons.ToggleButton("Keyboard InteractionsToggle", ref _keyboardInputGuide);
                    // Keybord Interactions End

                    // AxBy Debugger Start
                    ImGui.Text("AxBy Debugger");
                    ImGui.SameLine();
                    ImGuiAddons.ToggleButton("AxByDebugger", ref _axbyDebugger);
                    // AxBy Debugger End

                    // No Action ID Filter Start
                    ImGui.Text("No ActionID Filter");
                    ImGui.SameLine();
                    ImGuiAddons.ToggleButton("No ActionID Filter", ref Filtertoggle);
                    // No Action ID Filter End
                    if (ImGui.MenuItem("Lock DFXR3E Input", "Shift-Escape"))
                    {
                        MessageBox.Show("DFXR3E Inputs are locked, press OK to unlock");
                    }
                    ImGui.EndMenu();
                }
                ImGui.EndMainMenuBar();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// draws the main menu bar
        /// </summary>
        void DrawMainMenuBar()
        {
            if (ImGui.BeginMainMenuBar())
            {
                _mainMenuBarHeight = ImGui.GetWindowHeight();
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Quit ImGui"))
                    {
                        SetEnabled(false);
                    }
                    ImGui.EndMenu();
                }

                if (_sceneSubclasses.Count > 0 && ImGui.BeginMenu("Scenes"))
                {
                    foreach (var sceneType in _sceneSubclasses)
                    {
                        if (ImGui.MenuItem(sceneType.Name))
                        {
                            var scene = (Scene)Activator.CreateInstance(sceneType);
                            Core.StartSceneTransition(new FadeTransition(() => scene));
                        }
                    }

                    ImGui.EndMenu();
                }

                if (_themes.Length > 0 && ImGui.BeginMenu("Themes"))
                {
                    foreach (var theme in _themes)
                    {
                        if (ImGui.MenuItem(theme.Name))
                        {
                            theme.Invoke(null, new object[] { });
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Game View"))
                {
                    var rtSize = Core.Scene.SceneRenderTargetSize;

                    if (ImGui.BeginMenu("Resize"))
                    {
                        if (ImGui.MenuItem("0.25x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X / 4f, rtSize.Y / 4f);
                        }
                        if (ImGui.MenuItem("0.5x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X / 2f, rtSize.Y / 2f);
                        }
                        if (ImGui.MenuItem("0.75x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X / 1.33f, rtSize.Y / 1.33f);
                        }
                        if (ImGui.MenuItem("1x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X, rtSize.Y);
                        }
                        if (ImGui.MenuItem("1.5x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X * 1.5f, rtSize.Y * 1.5f);
                        }
                        if (ImGui.MenuItem("2x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X * 2, rtSize.Y * 2);
                        }
                        if (ImGui.MenuItem("3x"))
                        {
                            _gameViewForcedSize = new Num.Vector2(rtSize.X * 3, rtSize.Y * 3);
                        }
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Reposition"))
                    {
                        foreach (var pos in Enum.GetNames(typeof(WindowPosition)))
                        {
                            if (ImGui.MenuItem(pos))
                            {
                                _gameViewForcedPos = (WindowPosition)Enum.Parse(typeof(WindowPosition), pos);
                            }
                        }

                        ImGui.EndMenu();
                    }


                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Window"))
                {
                    ImGui.MenuItem("ImGui Demo Window", null, ref ShowDemoWindow);
                    ImGui.MenuItem("Style Editor", null, ref ShowStyleEditor);
                    if (ImGui.MenuItem("Open imgui_demo.cpp on GitHub"))
                    {
                        System.Diagnostics.Process.Start("https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp");
                    }

                    ImGui.Separator();
                    ImGui.MenuItem("Core Window", null, ref ShowCoreWindow);
                    ImGui.MenuItem("Scene Graph Window", null, ref ShowSceneGraphWindow);
                    ImGui.MenuItem("Separate Game Window", null, ref ShowSeperateGameWindow);
                    ImGui.EndMenu();
                }

                ImGui.EndMainMenuBar();
            }
        }
Exemplo n.º 17
0
        protected override void Draw(double elapsed)
        {
            VertexBuffer.TotalDrawcalls = 0;
            EnableTextInput();
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            //
            if (world != null)
            {
                if (wireFrame)
                {
                    RenderState.Wireframe = true;
                }
                world.Renderer.Draw();
                RenderState.Wireframe = false;
            }
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var folder = FileDialog.ChooseFolder();
                    if (folder != null)
                    {
                        if (GameConfig.CheckFLDirectory(folder))
                        {
                            openLoad = true;
                            LoadData(folder);
                        }
                        else
                        {
                            //Error dialog
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (world != null)
            {
                if (ImGui.MenuItem("Change System (F6)"))
                {
                    sysIndex         = sysIndexLoaded;
                    openChangeSystem = true;
                }
            }
            if (ImGui.BeginMenu("View"))
            {
                if (ImGui.MenuItem("Debug Text", "", showDebug, true))
                {
                    showDebug = !showDebug;
                }
                if (ImGui.MenuItem("Wireframe", "", wireFrame, true))
                {
                    wireFrame = !wireFrame;
                }
                if (ImGui.MenuItem("Infocard", "", infocardOpen, true))
                {
                    infocardOpen = !infocardOpen;
                }
                if (ImGui.MenuItem("VSync", "", vSync, true))
                {
                    vSync = !vSync;
                    SetVSync(vSync);
                }
                ImGui.EndMenu();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            //Other Windows
            if (world != null)
            {
                if (showDebug)
                {
                    ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero);

                    ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar |
                                ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus);
                    ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname,
                                             camera.Position.X, camera.Position.Y, camera.Position.Z,
                                             DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers));
                    ImGui.End();
                }
                ImGui.SetNextWindowSize(new Vector2(100, 100), ImGuiCond.FirstUseEver);
                if (infocardOpen)
                {
                    if (ImGui.Begin("Infocard", ref infocardOpen))
                    {
                        var szX = Math.Max(20, ImGui.GetWindowWidth());
                        var szY = Math.Max(20, ImGui.GetWindowHeight());
                        if (icard == null)
                        {
                            icard = new InfocardControl(this, systemInfocard, szX);
                        }
                        icard.Draw(szX);
                    }
                    ImGui.End();
                }
            }
            //dialogs must be children of window or ImGui default "Debug" window appears
            if (openChangeSystem)
            {
                ImGui.OpenPopup("Change System");
                openChangeSystem = false;
            }
            bool popupopen = true;

            if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Combo("System", ref sysIndex, systems, systems.Length);
                if (ImGui.Button("Ok"))
                {
                    if (sysIndex != sysIndexLoaded)
                    {
                        camera.UpdateProjection();
                        camera.Free = false;
                        camera.Zoom = 5000;
                        Resources.ClearTextures();
                        curSystem      = GameData.GetSystem(systems[sysIndex]);
                        systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan);
                        if (icard != null)
                        {
                            icard.SetInfocard(systemInfocard);
                        }
                        GameData.LoadAllSystem(curSystem);
                        world.LoadSystem(curSystem, Resources);
                        sysIndexLoaded = sysIndex;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (openLoad)
            {
                ImGui.OpenPopup("Loading");
                openLoad = false;
            }
            popupopen = true;
            if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (world != null)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
Exemplo n.º 18
0
        protected override void Draw(double elapsed)
        {
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    string f;
                    if ((f = FileDialog.ChooseFolder()) != null)
                    {
                        NewGui(f);
                    }
                }
                if (selected is SaveableTab saveable)
                {
                    if (Theme.IconMenuItem($"Save '{saveable.Title}'", "save", Color4.White, true))
                    {
                        saveable.Save();
                    }
                }
                else
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }

                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Lua"))
            {
                if (ImGui.BeginMenu("Base Icons"))
                {
                    ImGui.MenuItem("Bar", "", ref TestApi.HasBar);
                    ImGui.MenuItem("Trader", "", ref TestApi.HasTrader);
                    ImGui.MenuItem("Equipment", "", ref TestApi.HasEquip);
                    ImGui.MenuItem("Ship Dealer", "", ref TestApi.HasShipDealer);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Active Room"))
                {
                    var rooms = TestApi.GetNavbarButtons();
                    for (int i = 0; i < rooms.Length; i++)
                    {
                        if (ImGui.MenuItem(rooms[i].IconName + "##" + i, "", TestApi.ActiveHotspotIndex == i))
                        {
                            TestApi.ActiveHotspotIndex = i;
                        }
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Room Actions"))
                {
                    ImGui.MenuItem("Launch", "", ref TestApi.HasLaunchAction);
                    ImGui.MenuItem("Repair", "", ref TestApi.HasRepairAction);
                    ImGui.MenuItem("Missions", "", ref TestApi.HasMissionVendor);
                    ImGui.MenuItem("News", "", ref TestApi.HasNewsAction);
                    ImGui.EndMenu();
                }
                ImGui.EndMenu();
            }
            if (UiData != null && ImGui.BeginMenu("View"))
            {
                ImGui.MenuItem("Project", "", ref projectWindow.IsOpen);
                ImGui.MenuItem("Resources", "", ref resourceEditor.IsOpen);
                ImGui.EndMenu();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            var prevSel = selected;

            TabHandler.TabLabels(tabs, ref selected);
            ImGui.BeginChild("##tabcontent");
            if (selected != null)
            {
                selected.Draw();
            }
            ImGui.EndChild();
            ImGui.End();
            if (resourceEditor != null)
            {
                resourceEditor.Draw();
            }
            if (projectWindow != null)
            {
                projectWindow.Draw();
            }
            //Status Bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            ImGui.Text($"InterfaceEdit{(XmlFolder != null ? " - Editing: " : "")}{(XmlFolder ?? "")}");
            ImGui.End();
            //Finish Render
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
Exemplo n.º 19
0
        public void Draw(ref bool isGameViewFocused)
        {
            var viewport = ImGui.GetMainViewport();

            ImGui.SetNextWindowPos(viewport.GetWorkPos());
            ImGui.SetNextWindowSize(viewport.GetWorkSize());
            ImGui.SetNextWindowViewport(viewport.ID);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);

            var windowFlags = ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoDocking;

            windowFlags |= ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
            windowFlags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoNavFocus;
            //windowFlags |= ImGuiWindowFlags.NoBackground;

            ImGui.Begin("Root", windowFlags);

            ImGui.PopStyleVar(3);

            ImGui.DockSpace(ImGui.GetID("DockSpace"), Vector2.Zero, ImGuiDockNodeFlags.None);

            float menuBarHeight = 0;

            if (ImGui.BeginMenuBar())
            {
                menuBarHeight = ImGui.GetWindowHeight();

                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Jump"))
                {
                    if (ImGui.BeginMenu("Faction: " + _faction.Side))
                    {
                        foreach (var side in _playableSides)
                        {
                            if (ImGui.MenuItem(side.Side))
                            {
                                _faction = side;
                                ImGui.SetWindowFocus(side.Name);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Map: " + _map.Item1.Name))
                    {
                        foreach (var mapCache in _maps)
                        {
                            if (ImGui.MenuItem(mapCache.Value))
                            {
                                _map = (mapCache.Key, mapCache.Value);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.Button("Go!"))
                    {
                        var random   = new Random();
                        var faction2 = _playableSides[random.Next(0, _playableSides.Count())];

                        if (_map.Item1.IsMultiplayer)
                        {
                            _context.Game.StartMultiPlayerGame(
                                _map.Item1.Name,
                                new EchoConnection(),
                                new PlayerSetting?[]
                            {
                                new PlayerSetting(null, _faction, new ColorRgb(255, 0, 0), PlayerOwner.Player),
                                new PlayerSetting(null, faction2, new ColorRgb(255, 255, 255), PlayerOwner.EasyAi),
                            },
                                0
                                );
                        }
                        else
                        {
                            _context.Game.StartSinglePlayerGame(_map.Item1.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Windows"))
                {
                    foreach (var view in _views)
                    {
                        if (ImGui.MenuItem(view.DisplayName, null, view.IsVisible, true))
                        {
                            view.IsVisible = true;

                            ImGui.SetWindowFocus(view.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Preferences"))
                {
                    var isVSyncEnabled = _context.Game.GraphicsDevice.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true))
                    {
                        _context.Game.GraphicsDevice.SyncToVerticalBlank = isVSyncEnabled;
                    }
                    var isFullscreen = _context.Game.Window.Fullscreen;
                    if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true))
                    {
                        _context.Game.Window.Fullscreen = isFullscreen;
                    }
                    ImGui.EndMenu();
                }

                if (_context.Game.Configuration.UseRenderDoc && ImGui.BeginMenu("RenderDoc"))
                {
                    var renderDoc = Game.RenderDoc;

                    if (ImGui.MenuItem("Trigger Capture"))
                    {
                        renderDoc.TriggerCapture();
                    }
                    if (ImGui.BeginMenu("Options"))
                    {
                        bool allowVsync = renderDoc.AllowVSync;
                        if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                        {
                            renderDoc.AllowVSync = allowVsync;
                        }
                        bool validation = renderDoc.APIValidation;
                        if (ImGui.Checkbox("API Validation", ref validation))
                        {
                            renderDoc.APIValidation = validation;
                        }
                        int delayForDebugger = (int)renderDoc.DelayForDebugger;
                        if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                        {
                            delayForDebugger           = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                            renderDoc.DelayForDebugger = (uint)delayForDebugger;
                        }
                        bool verifyBufferAccess = renderDoc.VerifyBufferAccess;
                        if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                        {
                            renderDoc.VerifyBufferAccess = verifyBufferAccess;
                        }
                        bool overlayEnabled = renderDoc.OverlayEnabled;
                        if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                        {
                            renderDoc.OverlayEnabled = overlayEnabled;
                        }
                        bool overlayFrameRate = renderDoc.OverlayFrameRate;
                        if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                        {
                            renderDoc.OverlayFrameRate = overlayFrameRate;
                        }
                        bool overlayFrameNumber = renderDoc.OverlayFrameNumber;
                        if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                        {
                            renderDoc.OverlayFrameNumber = overlayFrameNumber;
                        }
                        bool overlayCaptureList = renderDoc.OverlayCaptureList;
                        if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                        {
                            renderDoc.OverlayCaptureList = overlayCaptureList;
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.MenuItem("Launch Replay UI"))
                    {
                        renderDoc.LaunchReplayUI();
                    }

                    ImGui.EndMenu();
                }

                DrawTimingControls();

                var fpsText     = $"{ImGui.GetIO().Framerate:N2} FPS";
                var fpsTextSize = ImGui.CalcTextSize(fpsText).X;
                ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - fpsTextSize);
                ImGui.Text(fpsText);

                ImGui.EndMenuBar();
            }

            foreach (var view in _views)
            {
                view.Draw(ref isGameViewFocused);
            }

            var launcherImage = _context.Game.LauncherImage;

            if (launcherImage != null)
            {
                var launcherImageMaxSize = new Vector2(150, 150);

                var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio(
                    new SizeF(launcherImage.Width, launcherImage.Height),
                    new Size((int)launcherImageMaxSize.X, (int)launcherImageMaxSize.Y));

                const int launcherImagePadding = 10;
                ImGui.SetNextWindowPos(new Vector2(
                                           _context.Game.Window.ClientBounds.Width - launcherImageSize.Width - launcherImagePadding,
                                           menuBarHeight + launcherImagePadding));

                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
                ImGui.Begin("LauncherImage", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration);

                ImGui.Image(
                    _context.ImGuiRenderer.GetOrCreateImGuiBinding(_context.Game.GraphicsDevice.ResourceFactory, launcherImage),
                    new Vector2(launcherImageSize.Width, launcherImageSize.Height),
                    Vector2.Zero,
                    Vector2.One,
                    Vector4.One,
                    Vector4.Zero);

                ImGui.End();
                ImGui.PopStyleVar();
            }

            ImGui.End();
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            _useOculus = true;
            if (!VRContext.IsOculusSupported())
            {
                _useOculus = false;
                if (!VRContext.IsOpenVRSupported())
                {
                    Console.WriteLine("This sample requires an Oculus or OpenVR-capable headset.");
                    return;
                }
            }

            Sdl2Window window = VeldridStartup.CreateWindow(
                new WindowCreateInfo(
                    Sdl2Native.SDL_WINDOWPOS_CENTERED, Sdl2Native.SDL_WINDOWPOS_CENTERED,
                    1280, 720,
                    WindowState.Normal,
                    "Veldrid.VirtualReality Sample"));

            VRContextOptions options = new VRContextOptions
            {
                EyeFramebufferSampleCount = TextureSampleCount.Count4
            };
            VRContext vrContext = _useOculus ? VRContext.CreateOculus(options) : VRContext.CreateOpenVR(options);

            GraphicsBackend backend = GraphicsBackend.Direct3D11;

            bool debug = false;

#if DEBUG
            debug = true;
#endif

            GraphicsDeviceOptions gdo = new GraphicsDeviceOptions(debug, null, false, ResourceBindingModel.Improved, true, true, true);

            if (backend == GraphicsBackend.Vulkan)
            {
                // Oculus runtime causes validation errors.
                gdo.Debug = false;
            }

            (GraphicsDevice gd, Swapchain sc) = CreateDeviceAndSwapchain(window, vrContext, backend, gdo);
            window.Resized += () => sc.Resize((uint)window.Width, (uint)window.Height);

            vrContext.Initialize(gd);

            ImGuiRenderer igr = new ImGuiRenderer(gd, sc.Framebuffer.OutputDescription, window.Width, window.Height, ColorSpaceHandling.Linear);
            window.Resized += () => igr.WindowResized(window.Width, window.Height);

            AssimpMesh mesh = new AssimpMesh(
                gd,
                vrContext.LeftEyeFramebuffer.OutputDescription,
                Path.Combine(AppContext.BaseDirectory, "cat", "cat.obj"),
                Path.Combine(AppContext.BaseDirectory, "cat", "cat_diff.png"));

            Skybox skybox = new Skybox(
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_ft.png")),
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_bk.png")),
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_lf.png")),
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_rt.png")),
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_up.png")),
                Image.Load <Rgba32>(Path.Combine(AppContext.BaseDirectory, "skybox", "miramar_dn.png")));
            skybox.CreateDeviceObjects(gd, vrContext.LeftEyeFramebuffer.OutputDescription);

            CommandList windowCL = gd.ResourceFactory.CreateCommandList();
            CommandList eyesCL   = gd.ResourceFactory.CreateCommandList();

            MirrorTextureEyeSource eyeSource = MirrorTextureEyeSource.BothEyes;

            Stopwatch sw            = Stopwatch.StartNew();
            double    lastFrameTime = sw.Elapsed.TotalSeconds;

            while (window.Exists)
            {
                double newFrameTime = sw.Elapsed.TotalSeconds;
                double deltaSeconds = newFrameTime - lastFrameTime;
                lastFrameTime = newFrameTime;

                InputSnapshot snapshot = window.PumpEvents();
                if (!window.Exists)
                {
                    break;
                }
                InputTracker.UpdateFrameInput(snapshot, window);
                HandleInputs(deltaSeconds);

                igr.Update(1f / 60f, snapshot);

                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Settings"))
                    {
                        if (ImGui.BeginMenu("Mirror Texture"))
                        {
                            if (ImGui.MenuItem("Both Eyes", null, eyeSource == MirrorTextureEyeSource.BothEyes))
                            {
                                eyeSource = MirrorTextureEyeSource.BothEyes;
                            }
                            if (ImGui.MenuItem("Left Eye", null, eyeSource == MirrorTextureEyeSource.LeftEye))
                            {
                                eyeSource = MirrorTextureEyeSource.LeftEye;
                            }
                            if (ImGui.MenuItem("Right Eye", null, eyeSource == MirrorTextureEyeSource.RightEye))
                            {
                                eyeSource = MirrorTextureEyeSource.RightEye;
                            }

                            ImGui.EndMenu();
                        }

                        if (ImGui.BeginMenu("VR API"))
                        {
                            if (ImGui.MenuItem("Oculus", null, _useOculus) && !_useOculus)
                            {
                                _useOculus       = true;
                                _switchVRContext = true;
                            }
                            if (ImGui.MenuItem("OpenVR", null, !_useOculus) && _useOculus)
                            {
                                _useOculus       = false;
                                _switchVRContext = true;
                            }

                            ImGui.EndMenu();
                        }

                        ImGui.EndMenu();
                    }

                    ImGui.EndMainMenuBar();
                }

                windowCL.Begin();
                windowCL.SetFramebuffer(sc.Framebuffer);
                windowCL.ClearColorTarget(0, new RgbaFloat(0f, 0f, 0.2f, 1f));
                vrContext.RenderMirrorTexture(windowCL, sc.Framebuffer, eyeSource);
                igr.Render(gd, windowCL);
                windowCL.End();
                gd.SubmitCommands(windowCL);
                gd.SwapBuffers(sc);

                HmdPoseState poses = vrContext.WaitForPoses();

                // Render Eyes
                eyesCL.Begin();

                eyesCL.PushDebugGroup("Left Eye");
                Matrix4x4 leftView = poses.CreateView(VREye.Left, _userPosition, -Vector3.UnitZ, Vector3.UnitY);
                RenderEye(eyesCL, vrContext.LeftEyeFramebuffer, mesh, skybox, poses.LeftEyeProjection, leftView);
                eyesCL.PopDebugGroup();

                eyesCL.PushDebugGroup("Right Eye");
                Matrix4x4 rightView = poses.CreateView(VREye.Right, _userPosition, -Vector3.UnitZ, Vector3.UnitY);
                RenderEye(eyesCL, vrContext.RightEyeFramebuffer, mesh, skybox, poses.RightEyeProjection, rightView);
                eyesCL.PopDebugGroup();

                eyesCL.End();
                gd.SubmitCommands(eyesCL);

                vrContext.SubmitFrame();

                if (_switchVRContext)
                {
                    _switchVRContext = false;
                    vrContext.Dispose();
                    vrContext = _useOculus ? VRContext.CreateOculus() : VRContext.CreateOpenVR();
                    vrContext.Initialize(gd);
                }
            }

            vrContext.Dispose();
            gd.Dispose();
        }
Exemplo n.º 21
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!loadingSpinnerActive && !guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                    Theme.IconMenuItem("Save As", "saveas", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "saveas", Color4.White, true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem("Save As", "saveas", Color4.White, true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    options.Show();
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        StartLoadingSpinner();
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem("Generate Icon", "genicon", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImageFilter)) != null)
                    {
                        gen3dbDlg.Open(input);
                    }
                }
                if (Theme.IconMenuItem("Infocard Browser", "browse", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                if (ImGui.MenuItem("Projectile Viewer"))
                {
                    if (ProjectileViewer.Create(this, out var pj))
                    {
                        tabs.Add(pj);
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }

            options.Draw();
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }

            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
                openLoading = false;
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2020");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGuiExt.BeginModalNoClose("Processing", ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            gen3dbDlg.Draw();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            #if DEBUG
            const string statusFormat = "FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}";
            #else
            const string statusFormat = "{1} Materials | {2} Textures | Active: {3} - {4}";
            #endif
            ImGui.Text(string.Format(statusFormat,
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            RenderState.RenderTarget = lastFrame;
            RenderState.ClearColor   = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.Render(RenderState);
            RenderState.RenderTarget = null;
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Exemplo n.º 22
0
    private void RenderMainMenuBar(out int height)
    {
        height = 0;

        // Only render the main menu bar when the mouse is in the vicinity
        if (ImGui.GetIO().MousePos.Y > 30 && !_forceMainMenu && !Tig.Console.IsVisible)
        {
            return;
        }

        _forceMainMenu = false;

        if (ImGui.BeginMainMenuBar())
        {
            height = (int)ImGui.GetWindowHeight();

            _forceMainMenu = ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows);

            var anyMenuOpen = false;

            if (ImGui.MenuItem("Console"))
            {
                Tig.Console.IsVisible = !Tig.Console.IsVisible;
            }

            if (ImGui.BeginMenu("View"))
            {
                anyMenuOpen = true;

                var enabled = Globals.UiManager.Debug.DebugMenuVisible;
                if (ImGui.MenuItem("UI Debug Menu", null, ref enabled))
                {
                    Globals.UiManager.Debug.DebugMenuVisible = enabled;
                }

                ImGui.MenuItem("Debug Overlay", null, ref _renderDebugOverlay);

                ActionsDebugUi.RenderMenuOptions();

                ImGui.MenuItem("Game Object Tree", null, ref _renderObjectTree);
                ImGui.MenuItem("Raycast Stats", null, ref _renderRaycastStats);

                var showGoalsChecked = AnimGoalsDebugRenderer.Enabled;
                if (ImGui.MenuItem("Render Anim Goals", null, ref showGoalsChecked))
                {
                    AnimGoalsDebugRenderer.Enabled = showGoalsChecked;
                }

                var showNamesChecked = AnimGoalsDebugRenderer.ShowObjectNames;
                if (ImGui.MenuItem("Render Object Names", null, ref showNamesChecked))
                {
                    AnimGoalsDebugRenderer.ShowObjectNames = showNamesChecked;
                }

                var verbosePartyLogging = GameSystems.Anim.VerbosePartyLogging;
                if (ImGui.MenuItem("Verbose Anim Goal Logging (Party)", null, ref verbosePartyLogging))
                {
                    GameSystems.Anim.VerbosePartyLogging = verbosePartyLogging;
                }

                var gameRenderer = UiSystems.GameView.GameRenderer;

                var renderSectorDebug = gameRenderer.RenderSectorDebugInfo;
                if (ImGui.MenuItem("Sector Blocking Debug", null, ref renderSectorDebug))
                {
                    gameRenderer.RenderSectorDebugInfo = renderSectorDebug;
                }

                var renderSectorVisibility = gameRenderer.RenderSectorVisibility;
                if (ImGui.MenuItem("Sector Visibility", null, ref renderSectorVisibility))
                {
                    gameRenderer.RenderSectorVisibility = renderSectorVisibility;
                }

                var pathFindingDebug = gameRenderer.DebugPathFinding;
                if (ImGui.MenuItem("Debug Pathfinding", null, ref pathFindingDebug))
                {
                    gameRenderer.DebugPathFinding = pathFindingDebug;
                }

                if (ImGui.BeginMenu("Line of Sight"))
                {
                    var fogDebugRenderer = gameRenderer.MapFogDebugRenderer;
                    var index            = 0;
                    foreach (var partyMember in GameSystems.Party.PartyMembers)
                    {
                        var displayName = GameSystems.MapObject.GetDisplayName(partyMember);
                        var selected    = fogDebugRenderer.RenderFor == index;
                        if (ImGui.MenuItem(displayName, null, ref selected))
                        {
                            fogDebugRenderer.RenderFor = selected ? index : -1;
                        }

                        index++;
                    }

                    ImGui.EndMenu();
                }

                var particleSystems = Globals.Config.DebugPartSys;
                if (ImGui.MenuItem("Particle Systems", null, ref particleSystems))
                {
                    Globals.Config.DebugPartSys = particleSystems;
                }

                var clipping = GameSystems.Clipping.Debug;
                if (ImGui.MenuItem("Clipping Meshes", null, ref clipping))
                {
                    GameSystems.Clipping.Debug = clipping;
                }

                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Screenshot"))
            {
                anyMenuOpen = true;

                if (GameViews.Primary != null)
                {
                    if (ImGui.MenuItem("Game View"))
                    {
                        GameViews.Primary.TakeScreenshot("gameview.jpg");
                    }
                }

                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Scripts"))
            {
                anyMenuOpen = true;

                foreach (var availableScript in Tig.Console.AvailableScripts)
                {
                    if (ImGui.MenuItem(availableScript))
                    {
                        Tig.Console.RunScript(availableScript);
                    }
                }

                ImGui.EndMenu();
            }

            if (anyMenuOpen)
            {
                _forceMainMenu = true;
            }

            RenderCheatsMenu();

            if (GameViews.Primary != null)
            {
                var screenCenter = GameViews.Primary.CenteredOn;
                ImGui.Text($"X: {screenCenter.location.locx} Y: {screenCenter.location.locy}");
            }

            ImGui.End();
        }
    }
Exemplo n.º 23
0
        public void Render(PerspectiveCamera camera)
        {
            if (ImGui.BeginMenu("Debug"))
            {
                if (ImGui.MenuItem(DebugDisplay.None.ToString(), null, this.DebugState.DebugDisplay == DebugDisplay.None))
                {
                    this.DebugState.DebugDisplay = DebugDisplay.None;
                }

                if (ImGui.BeginMenu(DebugDisplay.Combined.ToString()))
                {
                    var descriptions = this.RenderTargetDescriber.RenderTargets;
                    var columns      = this.DebugState.Columns;
                    if (ImGui.SliderInt("Columns", ref columns, 1, Math.Max(5, descriptions.Count)))
                    {
                        this.DebugState.Columns = columns;
                    }

                    ImGui.Separator();

                    foreach (var target in descriptions)
                    {
                        var selected = this.DebugState.SelectedRenderTargets.Contains(target.Name);
                        if (ImGui.Checkbox(target.Name, ref selected))
                        {
                            if (selected)
                            {
                                this.DebugState.SelectedRenderTargets.Add(target.Name);
                            }
                            else
                            {
                                this.DebugState.SelectedRenderTargets.Remove(target.Name);
                            }

                            this.DebugState.SelectedRenderTargets.Sort();
                            this.DebugState.DebugDisplay = DebugDisplay.Combined;
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu(DebugDisplay.Single.ToString()))
                {
                    var descriptions = this.RenderTargetDescriber.RenderTargets;
                    foreach (var target in descriptions)
                    {
                        var selected = this.DebugState.SelectedRenderTarget == target.Name;
                        if (ImGui.MenuItem(target.Name, null, selected))
                        {
                            this.DebugState.SelectedRenderTarget = target.Name;
                            this.DebugState.DebugDisplay         = DebugDisplay.Single;
                        }
                    }
                    ImGui.EndMenu();
                }

                var textureContrast = this.DebugState.TextureContrast;
                if (ImGui.SliderFloat("Texture Contrast", ref textureContrast, 1.0f, 100.0f))
                {
                    this.DebugState.TextureContrast = textureContrast;
                    this.Renderer.TextureContrast   = textureContrast;
                }

                if (ImGui.MenuItem("Fixed Timestep", null, this.Game.IsFixedTimeStep))
                {
                    this.Game.IsFixedTimeStep = !this.Game.IsFixedTimeStep;
                }

                if (ImGui.MenuItem("Force Wireframe", null, this.DebugState.ForceWireFrame))
                {
                    this.DebugState.ForceWireFrame          = !this.DebugState.ForceWireFrame;
                    GraphicsDeviceExtensions.ForceWireFrame = this.DebugState.ForceWireFrame;
                }

                var showDemo = this.DebugState.ShowDemo;
                if (ImGui.MenuItem("Show Demo Window", null, ref showDemo))
                {
                    this.DebugState.ShowDemo = showDemo;
                }

                if (ImGui.MenuItem("Start Cutscene", null))
                {
                    this.CutsceneSystem.Start();
                }

                ImGui.EndMenu();
            }
        }
Exemplo n.º 24
0
 private void PropertyRowNameContextMenu(string originalName, FieldMetaData cellMeta)
 {
     if (ImGui.BeginPopupContextItem("rowName"))
     {
         if (ParamEditorScreen.ShowAltNamesPreference == true && ParamEditorScreen.AlwaysShowOriginalNamePreference == false)
         {
             ImGui.Text(originalName);
         }
         if (ImGui.Selectable("Search..."))
         {
             EditorCommandQueue.AddCommand($@"param/search/prop {originalName.Replace(" ", "\\s")} ");
         }
         if (ParamEditorScreen.EditorMode && cellMeta != null)
         {
             if (ImGui.BeginMenu("Add Reference"))
             {
                 foreach (string p in ParamBank.Params.Keys)
                 {
                     if (ImGui.Selectable(p))
                     {
                         if (cellMeta.RefTypes == null)
                         {
                             cellMeta.RefTypes = new List <string>();
                         }
                         cellMeta.RefTypes.Add(p);
                     }
                 }
                 ImGui.EndMenu();
             }
             if (cellMeta.RefTypes != null && ImGui.BeginMenu("Remove Reference"))
             {
                 foreach (string p in cellMeta.RefTypes)
                 {
                     if (ImGui.Selectable(p))
                     {
                         cellMeta.RefTypes.Remove(p);
                         if (cellMeta.RefTypes.Count == 0)
                         {
                             cellMeta.RefTypes = null;
                         }
                         break;
                     }
                 }
                 ImGui.EndMenu();
             }
             if (ImGui.Selectable(cellMeta.IsBool ? "Remove bool toggle" : "Add bool toggle"))
             {
                 cellMeta.IsBool = !cellMeta.IsBool;
             }
             if (cellMeta.Wiki == null && ImGui.Selectable("Add wiki..."))
             {
                 cellMeta.Wiki = "Empty wiki...";
             }
             if (cellMeta.Wiki != null && ImGui.Selectable("Remove wiki"))
             {
                 cellMeta.Wiki = null;
             }
         }
         ImGui.EndPopup();
     }
 }
Exemplo n.º 25
0
        private void BuildDalamudUi()
        {
            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow(CommandManager);
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            OnOpenCreditsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Settings window"))
                        {
                            OnOpenSettingsCommand(null, null);
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        if (ImGui.MenuItem("Cause AccessViolation"))
                        {
                            var a = Marshal.ReadByte(IntPtr.Zero);
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(Util.AssemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Game"))
                    {
                        if (ImGui.MenuItem("Replace ExceptionHandler"))
                        {
                            ReplaceExceptionHandler();
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        if (ImGui.MenuItem("Open Plugin Stats"))
                        {
                            if (!this.isImguiDrawPluginStatWindow)
                            {
                                this.pluginStatWindow            = new DalamudPluginStatWindow(this.PluginManager);
                                this.isImguiDrawPluginStatWindow = true;
                            }
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }

                        ImGui.Separator();
                        ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
                        ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.LocalizationManager.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.LocalizationManager.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawSettingsWindow)
            {
                this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }

            if (this.isImguiDrawPluginStatWindow)
            {
                this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
                if (!this.isImguiDrawPluginStatWindow)
                {
                    this.pluginStatWindow?.Dispose();
                    this.pluginStatWindow = null;
                }
            }
        }
Exemplo n.º 26
0
        private void BuildDalamudUi()
        {
            if (!this.isImguiDrawDevMenu && !ClientState.Condition.Any())
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.TextSelectedBg, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.Border, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 1));

                ImGui.SetNextWindowPos(new Vector2(0, 0), ImGuiCond.Always);
                ImGui.SetNextWindowBgAlpha(1);

                if (ImGui.Begin("DevMenu Opener", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoSavedSettings))
                {
                    if (ImGui.Button("###devMenuOpener", new Vector2(40, 25)))
                    {
                        this.isImguiDrawDevMenu = true;
                    }

                    ImGui.End();
                }

                ImGui.PopStyleColor(8);
            }

            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow(CommandManager);
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        if (AntiDebug == null && ImGui.MenuItem("Enable AntiDebug"))
                        {
                            AntiDebug = new AntiDebug(this.SigScanner);
                            AntiDebug.Enable();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            OnOpenCreditsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Settings window"))
                        {
                            OnOpenSettingsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Changelog window"))
                        {
                            OpenChangelog();
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        if (ImGui.MenuItem("Cause AccessViolation"))
                        {
                            var a = Marshal.ReadByte(IntPtr.Zero);
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(Util.AssemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Game"))
                    {
                        if (ImGui.MenuItem("Replace ExceptionHandler"))
                        {
                            ReplaceExceptionHandler();
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Plugin Stats"))
                        {
                            if (!this.isImguiDrawPluginStatWindow)
                            {
                                this.pluginStatWindow            = new DalamudPluginStatWindow(this.PluginManager);
                                this.isImguiDrawPluginStatWindow = true;
                            }
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }

                        ImGui.Separator();
                        ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
                        ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.LocalizationManager.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.LocalizationManager.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    if (this.Framework.Gui.GameUiHidden)
                    {
                        ImGui.BeginMenu("UI is hidden...", false);
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.Framework.Gui.GameUiHidden)
            {
                return;
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();

                if (!this.isImguiDrawPluginWindow)
                {
                    this.pluginWindow = null;
                }
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawSettingsWindow)
            {
                this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }

            if (this.isImguiDrawPluginStatWindow)
            {
                this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
                if (!this.isImguiDrawPluginStatWindow)
                {
                    this.pluginStatWindow?.Dispose();
                    this.pluginStatWindow = null;
                }
            }

            if (this.isImguiDrawChangelogWindow)
            {
                this.isImguiDrawChangelogWindow = this.changelogWindow != null && this.changelogWindow.Draw();
            }
        }
Exemplo n.º 27
0
        private void LoadFileMenu()
        {
            float framerate = ImGui.GetIO().Framerate;

            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open", "Ctrl+O", false, initGlobalShaders))
                    {
                        OpenFileWithDialog();
                    }
                    if (ImGui.BeginMenu("Recent"))
                    {
                        for (int i = 0; i < recentFiles.Count; i++)
                        {
                            if (ImGui.Selectable(recentFiles[i]))
                            {
                                LoadFileFormat(recentFiles[i]);
                            }
                        }
                        ImGui.EndMenu();
                    }

                    var canSave = Outliner.ActiveFileFormat != null && Outliner.ActiveFileFormat.CanSave;
                    if (ImGui.MenuItem("Save", "Ctrl+S", false, canSave))
                    {
                        SaveFileWithCurrentPath();
                    }
                    if (ImGui.MenuItem("Save As", "Ctrl+Shift+S", false, canSave))
                    {
                        SaveFileWithDialog();
                    }

                    if (ImGui.MenuItem("Clear Workspace"))
                    {
                        ClearWorkspace();
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Setting"))
                {
                    ImGui.InputFloat("Font Size", ref font_scale, 0.1f);

                    _config.RenderUI();

                    ImGui.EndMenu();
                }
                if (ImGui.MenuItem("Style Editor"))
                {
                    showStyleEditor = true;
                }

                if (_config.HasValidSMOPath)
                {
                    if (ImGui.MenuItem("Mario Viewer", initGlobalShaders))
                    {
                        TryLoadPartInfo();
                    }
                }

                /*    if (ImGui.MenuItem("Lighting"))
                 * {
                 *   showLightingEditor = true;
                 * }*/

                if (ImGui.MenuItem("Batch Render"))
                {
                    showBatchWindow = true;
                }

                if (ImGui.BeginMenu("Help"))
                {
                    if (ImGui.Selectable($"About"))
                    {
                        showAboutPage = true;
                    }
                    if (ImGui.Selectable($"Donate"))
                    {
                        BrowserHelper.OpenDonation();
                    }
                    ImGui.EndMenu();
                }

                float size = ImGui.GetWindowWidth();
                if (!string.IsNullOrEmpty(status))
                {
                    string statusLabel = $"Status: {status}";
                    float  lbSize      = ImGui.CalcTextSize(statusLabel).X;

                    ImGui.SetCursorPosX((size - (lbSize)) / 2);
                    ImGui.Text($"Status: {status}");
                }

                ImGui.SetCursorPosX(size - 100);
                ImGui.Text($"({framerate:0.#} FPS)");
                ImGui.EndMainMenuBar();
            }
            if (showBatchWindow)
            {
                if (ImGui.Begin("Batch Window", ref showBatchWindow))
                {
                    ImguiCustomWidgets.PathSelector("Input Folder", ref BatchRenderingTool.InputFolder);
                    ImguiCustomWidgets.PathSelector("Output Folder", ref BatchRenderingTool.OutputFolder);
                    ImGui.Checkbox("Odyssey Actor", ref BatchRenderingTool.OdysseyActor);
                    ImGui.InputInt("Image Width", ref BatchRenderingTool.ImageWidth);
                    ImGui.InputInt("Image Height", ref BatchRenderingTool.ImageHeight);
                    if (BatchRenderingTool.IsOperationActive)
                    {
                        float progress = (float)BatchRenderingTool.ProcessAmount / BatchRenderingTool.ProcessTotal;
                        ImGui.ProgressBar(progress, new System.Numerics.Vector2(300, 20));

                        ImGui.Text($"{BatchRenderingTool.ProcessName}");
                        if (ImGui.Button("Cancel Render"))
                        {
                            BatchRenderingTool.CancelOperation = true;
                        }
                    }
                    if (Directory.Exists(BatchRenderingTool.InputFolder) &&
                        Directory.Exists(BatchRenderingTool.OutputFolder) &&
                        !BatchRenderingTool.IsOperationActive)
                    {
                        if (ImGui.Button("Start Render"))
                        {
                            string path = BatchRenderingTool.InputFolder;
                            string output = BatchRenderingTool.OutputFolder;
                            int    width = BatchRenderingTool.ImageWidth; int height = BatchRenderingTool.ImageHeight;

                            var Thread3 = new Thread((ThreadStart)(() =>
                            {
                                BatchRenderingTool batchTool = new BatchRenderingTool();
                                batchTool.StartRender(path, output, width, height);
                            }));
                            Thread3.Start();
                        }
                    }
                    ImGui.End();
                }
            }

            if (ProbeDebugger.DEBUG_MODE)
            {
                ProbeDebugger.DrawWindow();
            }

            if (showStyleEditor)
            {
                if (ImGui.Begin("Style Editor", ref showStyleEditor))
                {
                    ImGui.ShowStyleEditor();
                    ImGui.End();
                }
            }
            if (showLightingEditor)
            {
                if (lightingEditor == null)
                {
                    lightingEditor = new BfresEditor.LightingEditor();
                }

                lightingEditor.Render(this.Pipeline._context);
            }
            if (showAboutPage)
            {
                if (ImGui.Begin($"About", ref showAboutPage))
                {
                    if (ImGui.CollapsingHeader($"Credits", ImGuiTreeNodeFlags.DefaultOpen))
                    {
                        ImGui.BulletText("KillzXGaming - main developer");
                        ImGui.BulletText("JuPaHe64 - created animation timeline");
                        ImGui.BulletText("Ryujinx - for shader libraries used to decompile and translate switch binaries into glsl code.");
                        ImGui.BulletText("OpenTK Team - for opengl c# bindings.");
                        ImGui.BulletText("mellinoe and IMGUI Team - for c# port and creating the IMGUI library");
                        ImGui.BulletText("Syroot - for bfres library and binary IO");
                    }
                    ImGui.End();
                }
            }
        }
Exemplo n.º 28
0
            private unsafe void SubmitGui()
            {
                //ImGui.SetNextWindowSize(new System.Numerics.Vector2(Width, Height), SetCondition.FirstUseEver);

                //ImGui.SetNextWindowPosCenter(SetCondition.Always);

                ImGui.BeginWindow("Test", ref _windowOpen, WindowFlags.NoResize | WindowFlags.NoTitleBar | WindowFlags.NoMove);

                ImGui.BeginMainMenuBar();

                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Menu item", "", false, true))
                    {
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Edit"))
                {
                    if (ImGui.MenuItem("Edit", "", false, true))
                    {
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("View"))
                {
                    if (ImGui.Checkbox("Wireframe Mode", ref _wireframeEnabled))
                    {
                        Console.WriteLine("Wireframe Mode:" + _wireframeEnabled);
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Options"))
                {
                    if (ImGui.Checkbox("Debug Mode", ref _debugEnabled))
                    {
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Tools"))
                {
                    if (ImGui.MenuItem("Edit", "", false, true))
                    {
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Windows"))
                {
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Help"))
                {
                    if (ImGui.MenuItem("Edit", "", false, true))
                    {
                    }
                    ImGui.EndMenu();
                }

                if (_debugEnabled)
                {
                    if (ImGui.BeginMenu("Debug"))
                    {
                        if (ImGui.MenuItem("Console"))
                        {
                            showConsole = !showConsole;
                        }

                        if (ImGui.MenuItem("OpenGL Console"))
                        {
                            showOpenGLConsole = !showOpenGLConsole;
                        }
                        ImGui.EndMenu();
                    }
                }

                ImGui.EndMainMenuBar();

                //ImGui.SetNextWindowPos(new Vector2(0, 20), SetCondition.Always);
                //ImGui.SetNextWindowSize(new Vector2(Width, 30), SetCondition.Always);

                ImGui.PushStyleVar(StyleVar.WindowPadding, new Vector2(5f, 5f));

                ImGui.BeginWindow("inner window", WindowFlags.NoMove | WindowFlags.NoTitleBar | WindowFlags.NoResize | WindowFlags.NoScrollbar | WindowFlags.NoScrollWithMouse);

                if (ImGui.Button("Btn1", new Vector2(50, 25)))
                {
                }

                ImGui.SameLine();

                if (ImGui.Button("Btn2"))
                {
                }

                ImGui.EndWindow();

                ImGui.PopStyleVar();

                ImGui.BeginChildFrame(1, new Vector2(50, 50), WindowFlags.AlwaysAutoResize);

                ImGui.Text("Outside");
                ImGui.Separator();
                ImGui.Spacing();
                ImGui.Spacing();
                ImGui.Spacing();
                ImGui.Spacing();
                ImGui.Spacing();
                ImGui.Text("Seperator");

                ImGui.EndWindow();

                if (showConsole)
                {
                    ImGui.BeginWindow("Console", ref showConsole, WindowFlags.Default);
                    ImGui.Text(stringWriter.ToString());
                    ImGui.EndWindow();
                }

                if (showOpenGLConsole)
                {
                    ImGui.BeginWindow("OpenGL Console", ref showOpenGLConsole, WindowFlags.Default);
                    //Create callback
                    GetGlDebugMessages();

                    ImGui.EndWindow();
                }
            }
Exemplo n.º 29
0
        private void Update(float deltaSeconds)
        {
            _fta.AddTime(deltaSeconds);
            _scene.Update(deltaSeconds);

            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("Settings"))
                {
                    if (ImGui.BeginMenu("Graphics Backend"))
                    {
                        if (ImGui.MenuItem("Vulkan", string.Empty, _gd.BackendType == GraphicsBackend.Vulkan, GraphicsDevice.IsBackendSupported(GraphicsBackend.Vulkan)))
                        {
                            ChangeBackend(GraphicsBackend.Vulkan);
                        }
                        if (ImGui.MenuItem("OpenGL", string.Empty, _gd.BackendType == GraphicsBackend.OpenGL, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGL)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGL);
                        }
                        if (ImGui.MenuItem("OpenGL ES", string.Empty, _gd.BackendType == GraphicsBackend.OpenGLES, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGLES)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGLES);
                        }
                        if (ImGui.MenuItem("Direct3D 11", string.Empty, _gd.BackendType == GraphicsBackend.Direct3D11, GraphicsDevice.IsBackendSupported(GraphicsBackend.Direct3D11)))
                        {
                            ChangeBackend(GraphicsBackend.Direct3D11);
                        }
                        if (ImGui.MenuItem("Metal", string.Empty, _gd.BackendType == GraphicsBackend.Metal, GraphicsDevice.IsBackendSupported(GraphicsBackend.Metal)))
                        {
                            ChangeBackend(GraphicsBackend.Metal);
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("MSAA"))
                    {
                        if (ImGui.Combo("MSAA", ref _msaaOption, _msaaOptions, _msaaOptions.Length))
                        {
                            ChangeMsaa(_msaaOption);
                        }

                        ImGui.EndMenu();
                    }
                    bool threadedRendering = _scene.ThreadedRendering;
                    if (ImGui.MenuItem("Render with multiple threads", string.Empty, threadedRendering, true))
                    {
                        _scene.ThreadedRendering = !_scene.ThreadedRendering;
                    }
                    bool tinted = _fsq.UseTintedTexture;
                    if (ImGui.MenuItem("Tinted output", string.Empty, tinted, true))
                    {
                        _fsq.UseTintedTexture = !tinted;
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Window"))
                {
                    bool isFullscreen = _window.WindowState == WindowState.BorderlessFullScreen;
                    if (ImGui.MenuItem("Fullscreen", "F11", isFullscreen, true))
                    {
                        ToggleFullscreenState();
                    }
                    if (ImGui.MenuItem("Always Recreate Sdl2Window", string.Empty, _recreateWindow, true))
                    {
                        _recreateWindow = !_recreateWindow;
                    }
                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip(
                            "Causes a new OS window to be created whenever the graphics backend is switched. This is much safer, and is the default.");
                    }
                    if (ImGui.MenuItem("sRGB Swapchain Format", string.Empty, _colorSrgb, true))
                    {
                        _colorSrgb = !_colorSrgb;
                        ChangeBackend(_gd.BackendType);
                    }
                    bool vsync = _gd.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", string.Empty, vsync, true))
                    {
                        _gd.SyncToVerticalBlank = !_gd.SyncToVerticalBlank;
                    }
                    bool resizable = _window.Resizable;
                    if (ImGui.MenuItem("Resizable Window", string.Empty, resizable))
                    {
                        _window.Resizable = !_window.Resizable;
                    }
                    bool bordered = _window.BorderVisible;
                    if (ImGui.MenuItem("Visible Window Border", string.Empty, bordered))
                    {
                        _window.BorderVisible = !_window.BorderVisible;
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Materials"))
                {
                    if (ImGui.BeginMenu("Brick"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Brick);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Vase"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Vase);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Reflective"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Reflective);
                        ImGui.EndMenu();
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Debug"))
                {
                    if (ImGui.MenuItem("Refresh Device Objects"))
                    {
                        RefreshDeviceObjects(1);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (10 times)"))
                    {
                        RefreshDeviceObjects(10);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (100 times)"))
                    {
                        RefreshDeviceObjects(100);
                    }
                    if (_controllerTracker != null)
                    {
                        if (ImGui.MenuItem("Controller State"))
                        {
                            _controllerDebugMenu = true;
                        }
                    }
                    else
                    {
                        if (ImGui.MenuItem("Connect to Controller"))
                        {
                            Sdl2ControllerTracker.CreateDefault(out _controllerTracker);
                            _scene.Camera.Controller = _controllerTracker;
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("RenderDoc"))
                {
                    if (_renderDoc == null)
                    {
                        if (ImGui.MenuItem("Load"))
                        {
                            if (RenderDoc.Load(out _renderDoc))
                            {
                                ChangeBackend(_gd.BackendType);
                            }
                        }
                    }
                    else
                    {
                        if (ImGui.MenuItem("Trigger Capture"))
                        {
                            _renderDoc.TriggerCapture();
                        }
                        if (ImGui.BeginMenu("Options"))
                        {
                            bool allowVsync = _renderDoc.AllowVSync;
                            if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                            {
                                _renderDoc.AllowVSync = allowVsync;
                            }
                            bool validation = _renderDoc.APIValidation;
                            if (ImGui.Checkbox("API Validation", ref validation))
                            {
                                _renderDoc.APIValidation = validation;
                            }
                            int delayForDebugger = (int)_renderDoc.DelayForDebugger;
                            if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                            {
                                delayForDebugger            = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                                _renderDoc.DelayForDebugger = (uint)delayForDebugger;
                            }
                            bool verifyBufferAccess = _renderDoc.VerifyBufferAccess;
                            if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                            {
                                _renderDoc.VerifyBufferAccess = verifyBufferAccess;
                            }
                            bool overlayEnabled = _renderDoc.OverlayEnabled;
                            if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                            {
                                _renderDoc.OverlayEnabled = overlayEnabled;
                            }
                            bool overlayFrameRate = _renderDoc.OverlayFrameRate;
                            if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                            {
                                _renderDoc.OverlayFrameRate = overlayFrameRate;
                            }
                            bool overlayFrameNumber = _renderDoc.OverlayFrameNumber;
                            if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                            {
                                _renderDoc.OverlayFrameNumber = overlayFrameNumber;
                            }
                            bool overlayCaptureList = _renderDoc.OverlayCaptureList;
                            if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                            {
                                _renderDoc.OverlayCaptureList = overlayCaptureList;
                            }
                            ImGui.EndMenu();
                        }
                        if (ImGui.MenuItem("Launch Replay UI"))
                        {
                            _renderDoc.LaunchReplayUI();
                        }
                    }
                    ImGui.EndMenu();
                }

                if (_controllerDebugMenu)
                {
                    if (ImGui.Begin("Controller State", ref _controllerDebugMenu, ImGuiWindowFlags.NoCollapse))
                    {
                        if (_controllerTracker != null)
                        {
                            ImGui.Columns(2);
                            ImGui.Text($"Name: {_controllerTracker.ControllerName}");
                            foreach (SDL_GameControllerAxis axis in (SDL_GameControllerAxis[])Enum.GetValues(typeof(SDL_GameControllerAxis)))
                            {
                                ImGui.Text($"{axis}: {_controllerTracker.GetAxis(axis)}");
                            }
                            ImGui.NextColumn();
                            foreach (SDL_GameControllerButton button in (SDL_GameControllerButton[])Enum.GetValues(typeof(SDL_GameControllerButton)))
                            {
                                ImGui.Text($"{button}: {_controllerTracker.IsPressed(button)}");
                            }
                        }
                        else
                        {
                            ImGui.Text("No controller detected.");
                        }
                    }
                    ImGui.End();
                }

                ImGui.Text(_fta.CurrentAverageFramesPerSecond.ToString("000.0 fps / ") + _fta.CurrentAverageFrameTimeMilliseconds.ToString("#00.00 ms"));

                ImGui.EndMainMenuBar();
            }

            if (InputTracker.GetKeyDown(Key.F11))
            {
                ToggleFullscreenState();
            }

            if (InputTracker.GetKeyDown(Key.Keypad6))
            {
                _window.X += 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad4))
            {
                _window.X -= 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad8))
            {
                _window.Y += 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad2))
            {
                _window.Y -= 10;
            }

            _window.Title = _gd.BackendType.ToString();
        }
Exemplo n.º 30
0
        public void Draw(Sdl2Window window)
        {
            ImGui.SetNextWindowPos(Vector2.Zero, ImGuiCond.Always, Vector2.Zero);
            ImGui.SetNextWindowSize(new Vector2(window.Width, window.Height), ImGuiCond.Always);

            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0);
            bool open = false;

            ImGui.Begin("OpenSAGE Big Editor", ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize);

            var wasOpenClicked = false;

            if (ImGui.BeginMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open...", "Ctrl+O", false, true))
                    {
                        wasOpenClicked = true;
                    }

                    if (ImGui.MenuItem("Close", null, false, _bigArchive != null))
                    {
                        OpenBigFile(null);
                    }

                    ImGui.Separator();

                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }
                ImGui.EndMenuBar();
            }

            const string openFilePopupId = "Open Big Archive##OpenBigArchive";

            if (wasOpenClicked)
            {
                ImGui.OpenPopup(openFilePopupId);
            }

            bool fileOpenPopupOpen = true;

            if (ImGui.BeginPopupModal(openFilePopupId, ref fileOpenPopupOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                DrawOpenFileDialog();

                ImGui.EndPopup();
            }

            if (_bigArchive != null)
            {
                DrawFilesList();

                ImGui.SameLine();

                DrawFileContent();
            }
            else
            {
                ImGui.Text("Open a .big file to see its contents here.");
            }

            ImGui.End();
            ImGui.PopStyleVar();
        }