示例#1
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);
        }
示例#2
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);
        }
        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();
            imGui.NewFrame(elapsed);
            Renderer2D.Start(Width, Height);
            Renderer2D.DrawString("Arial", 16, "Librelancer", new Vector2(8), Color4.Black);
            Renderer2D.DrawString("Arial", 16, "Librelancer", new Vector2(6), Color4.White);
            var startY = Renderer2D.LineHeight("Arial", 16) + 8;

            Renderer2D.Finish();
            ImGui.PushFont(ImGuiHelper.Noto);
            var size = (Vector2)ImGui.GetIO().DisplaySize;

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

            ImGui.Begin("screen", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize |
                        ImGuiWindowFlags.NoBackground);
            if (ImGui.BeginPopupModal("Error", ref openError, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Freelancer Directory: ");
            ImGui.SameLine();
            freelancerFolder.InputText("##folder", ImGuiInputTextFlags.None, 280);
            ImGui.SameLine();
            if (ImGui.Button("..."))
            {
                string newFolder;
                if ((newFolder = FileDialog.ChooseFolder()) != null)
                {
                    freelancerFolder.SetText(newFolder);
                }
            }
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Resolution: ");
            ImGui.SameLine();
            ImGui.PushItemWidth(130);
            ImGui.InputInt("##resX", ref resolutionX, 0, 0);
            resolutionX = MathHelper.Clamp(resolutionX, 600, 16384);
            ImGui.SameLine();
            ImGui.Text("x");
            ImGui.SameLine();
            ImGui.InputInt("##resY", ref resolutionY, 0, 0);
            resolutionY = MathHelper.Clamp(resolutionY, 400, 16384);
            ImGui.PopItemWidth();
            SoundSlider("Master Volume: ", ref masterVolume);
            SoundSlider("Music Volume: ", ref musicVolume);
            SoundSlider("Sfx Volume: ", ref sfxVolume);
            ImGui.Checkbox("VSync", ref vsync);
            if (Program.introForceDisable)
            {
                ImGui.Text("Intro Movies Disabled");
            }
            else
            {
                ImGui.Checkbox("Skip Intro Movies", ref skipIntroMovies);
            }
            ImGui.Dummy(new Vector2(16));
            ImGui.Dummy(new Vector2(1));
            ImGui.SameLine(ImGui.GetWindowWidth() - 70);
            if (ImGui.Button("Launch"))
            {
                LaunchClicked();
            }
            ImGui.End();
            ImGui.PopFont();
            imGui.Render(RenderState);
        }
        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 (cutscene != null)
            {
                cutscene.Draw();
            }
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            bool openLoad = false;

            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Load Game Data", "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("Open Thn", "open", Color4.White, GameData != null))
                {
                    var file = FileDialog.Open();
                    if (file != null)
                    {
                        var script = new ThnScript(file);
                        var ctx    = new ThnScriptContext(new[] { script });
                        cutscene = new Cutscene(ctx, GameData, new Viewport(0, 0, Width, Height), this);
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            bool popupopen = true;

            if (openLoad)
            {
                ImGui.OpenPopup("Loading");
                openLoad = false;
            }
            popupopen = true;
            if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (loaded)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
示例#5
0
        protected override void Draw(double elapsed)
        {
            VertexBuffer.TotalDrawcalls = 0;
            EnableTextInput();
            RenderContext.ReplaceViewport(0, 0, Width, Height);
            RenderContext.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderContext.ClearAll();
            //
            if (world != null)
            {
                if (wireFrame)
                {
                    RenderContext.Wireframe = true;
                }
                world.Renderer.Draw();
                RenderContext.Wireframe = false;
            }
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem(Icons.Open, "Open", true))
                {
                    var folder = FileDialog.ChooseFolder();
                    if (folder != null)
                    {
                        if (GameConfig.CheckFLDirectory(folder))
                        {
                            openLoad = true;
                            LoadData(folder);
                        }
                        else
                        {
                            //Error dialog
                        }
                    }
                }
                if (Theme.IconMenuItem(Icons.Quit, "Quit", 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("Universe Map", "", universeOpen, true))
                {
                    universeOpen = !universeOpen;
                }
                if (ImGui.MenuItem("Controls", "", controlsOpen, true))
                {
                    controlsOpen = !controlsOpen;
                }

                if (ImGui.MenuItem("VSync", "", vSync, true))
                {
                    vSync = !vSync;
                    SetVSync(vSync);
                }
                ImGui.EndMenu();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            //Other Windows
            if (camera != null && controlsOpen)
            {
                if (ImGui.Begin("Controls", ref controlsOpen))
                {
                    ImGui.Text("WSAD - Movement");
                    ImGui.Text("Arrow Keys - Rotation");
                    ImGui.SliderFloat("Move Speed", ref camera.MoveSpeed, 1, 12000);
                    if (ImGui.Button(LOWSPEED.ToString()))
                    {
                        camera.MoveSpeed = LOWSPEED;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button(MEDSPEED.ToString()))
                    {
                        camera.MoveSpeed = MEDSPEED;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button(HIGHSPEED.ToString()))
                    {
                        camera.MoveSpeed = HIGHSPEED;
                    }
                    ImGui.End();
                }
            }
            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();
                }
                if (infocardOpen)
                {
                    ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver);
                    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();
                    }
                }

                if (universeOpen)
                {
                    ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver);
                    if (ImGui.Begin("Map", ref universeOpen))
                    {
                        ImGui.BeginTabBar("##maptabs");
                        if (ImGui.BeginTabItem("Universe"))
                        {
                            var    szX    = Math.Max(20, ImGui.GetWindowWidth());
                            var    szY    = Math.Max(20, ImGui.GetWindowHeight() - 50);
                            string result = UniverseMap.Draw(universeBackgroundRegistered, GameData, (int)szX,
                                                             (int)szY, 20);
                            if (result != null)
                            {
                                for (int i = 0; i < systems.Length; i++)
                                {
                                    if (result.Equals(systems[i], StringComparison.OrdinalIgnoreCase))
                                    {
                                        sysIndex = i;
                                        ChangeSystem();
                                        break;
                                    }
                                }
                            }

                            ImGui.EndTabItem();
                        }

                        if (ImGui.BeginTabItem("System"))
                        {
                            var szX = Math.Max(20, ImGui.GetWindowWidth());
                            var szY = Math.Max(20, ImGui.GetWindowHeight() - 70);
                            systemMap.Draw((int)szX, (int)szY, elapsed);
                            ImGui.EndTabItem();
                        }

                        ImGui.EndTabBar();
                        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"))
                {
                    ChangeSystem();
                    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, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderContext);
        }
示例#6
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 (cutscene != null)
            {
                cutscene.Draw();
            }
            Typewriter.Render();
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            bool openLoad     = false;
            bool openMultiple = false;

            isMultipleOpen = false;
            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Load Game Data", "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("Open Thn", "open", Color4.White, GameData != null))
                {
                    var file = FileDialog.Open();
                    if (file != null)
                    {
                        Open(file);
                    }
                }

                if (Theme.IconMenuItem("Open Multiple", "open", Color4.White, GameData != null))
                {
                    openFiles    = new List <string>();
                    openMultiple = true;
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("View"))
            {
                ImGui.MenuItem("Decompiled", "", ref decompiledOpen);
                ImGui.EndMenu();
            }

            if (toReload != null && ImGui.MenuItem("Reload (F5)"))
            {
                Reload();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            bool popupopen = true;

            if (openLoad)
            {
                ImGui.OpenPopup("Loading");
                openLoad = false;
            }
            popupopen = true;
            if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (loaded)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGuiExt.Spinner("##spinner", 10, 2, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }

            popupopen = true;
            if (openMultiple)
            {
                ImGui.OpenPopup("Open Multiple");
            }
            if (ImGui.BeginPopupModal("Open Multiple", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                isMultipleOpen = true;
                if (ImGui.Button("+"))
                {
                    var file = FileDialog.Open();
                    if (file != null)
                    {
                        openFiles.Add(file);
                    }
                }
                ImGui.BeginChild("##files", new Vector2(200, 200), true, ImGuiWindowFlags.HorizontalScrollbar);
                int j = 0;
                foreach (var f in openFiles)
                {
                    ImGui.Selectable(ImGuiExt.IDWithExtra(f, j++));
                }
                ImGui.EndChild();
                if (ImGuiExt.Button("Open", openFiles.Count > 0))
                {
                    ImGui.CloseCurrentPopup();
                    Open(openFiles.ToArray());
                }
            }
            if (decompiled != null)
            {
                if (decompiledOpen)
                {
                    ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver);
                    int j = 0;
                    if (ImGui.Begin("Decompiled", ref decompiledOpen))
                    {
                        ImGui.BeginTabBar("##tabs", ImGuiTabBarFlags.Reorderable);
                        foreach (var file in decompiled)
                        {
                            var tab = ImGuiExt.IDWithExtra(file.Name, j++);
                            if (ImGui.BeginTabItem(tab))
                            {
                                if (ImGui.Button("Copy"))
                                {
                                    SetClipboardText(file.Text);
                                }

                                ImGui.SetNextItemWidth(-1);
                                var th = ImGui.GetWindowHeight() - 100;
                                ImGui.PushFont(ImGuiHelper.SystemMonospace);
                                ImGui.InputTextMultiline("##src", ref file.Text, uint.MaxValue, new Vector2(0, th),
                                                         ImGuiInputTextFlags.ReadOnly);
                                ImGui.PopFont();
                                ImGui.EndTabItem();
                            }
                        }
                        ImGui.EndTabBar();
                    }
                }
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
示例#7
0
        protected override void Draw(double elapsed)
        {
            var delta = elapsed;

            RenderDelta = delta;
            RenderContext.ReplaceViewport(0, 0, Width, Height);
            RenderContext.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderContext.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem(Icons.File, "New", true))
                {
                    string folder;
                    string outpath;
                    if ((folder = FileDialog.ChooseFolder()) != null)
                    {
                        if ((outpath = FileDialog.Save(projectFilters)) != null)
                        {
                            var proj = new Project(this);
                            proj.Create(folder, outpath);
                            OpenGui(outpath);
                        }
                    }
                }

                if (Theme.IconMenuItem(Icons.Open, "Open", true))
                {
                    string f;
                    if ((f = FileDialog.Open(projectFilters)) != null)
                    {
                        OpenGui(f);
                    }
                }
                recentFiles.Menu();
                if (!playing && selected is SaveableTab saveable)
                {
                    if (Theme.IconMenuItem(Icons.Save, $"Save '{saveable.Title}'", true))
                    {
                        saveable.Save();
                    }
                }
                else
                {
                    Theme.IconMenuItem(Icons.Save, "Save", false);
                }

                if (ImGui.MenuItem("Compile", Project != null && !playing))
                {
                    CompileProject();
                }
                if (Theme.IconMenuItem(Icons.Quit, "Quit", 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.MenuItem("Commodity Trader", "", ref TestApi.HasCommodityTraderAction);
                    ImGui.MenuItem("Ship Dealer", "", ref TestApi.HasShipDealerAction);
                    ImGui.EndMenu();
                }
                ImGui.EndMenu();
            }
            if (Project != null && ImGui.BeginMenu("View"))
            {
                ImGui.MenuItem("Project", "", ref projectWindow.IsOpen);
                ImGui.MenuItem("Resources", "", ref resourceEditor.IsOpen);
                ImGui.EndMenu();
            }

            if (Project != null && !playing && ImGui.BeginMenu("Play"))
            {
                foreach (var file in projectWindow.GetClasses())
                {
                    if (ImGui.MenuItem(file))
                    {
                        StartPlay(Path.GetFileNameWithoutExtension(file));
                    }
                }

                ImGui.EndMenu();
            }
            if (Project != null && playing && ImGui.MenuItem("Stop"))
            {
                playing      = false;
                _playContext = null;
                _playData    = null;
            }
            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 * ImGuiHelper.Scale), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            if (playing)
            {
                try
                {
                    Player(delta);
                }
                catch (Exception e)
                {
                    var detail = new StringBuilder();
                    BuildExceptionString(e, detail);
                    CrashWindow.Run("Interface Edit", "Runtime Error", detail.ToString());
                    playing      = false;
                    _playContext = null;
                    _playData    = null;
                }
            }
            else
            {
                Tabs();
            }
            //Status Bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f * ImGuiHelper.Scale), 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{(Project != null ? " - Editing: " : "")}{(Project?.ProjectFile ?? "")}");
            if (playing)
            {
                ImGui.SameLine();
                ImGui.Text($"Mouse Wanted: {mouseWanted}");
            }
            ImGui.End();
            recentFiles.DrawErrors();
            //Finish Render
            ImGui.PopFont();
            guiHelper.Render(RenderContext);
        }