Пример #1
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);
        }
Пример #2
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();
        }
Пример #3
0
        protected override void Draw(double elapsed)
        {
            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);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save(UtfFilters);
                        if (f != null)
                        {
                            ActiveTab.DocumentName = System.IO.Path.GetFileName(f);
                            ActiveTab.UpdateTitle();
                            string errText = "";
                            if (!ActiveTab.Utf.Save(f, ref errText))
                            {
                                openError = true;
                                if (errorText == null)
                                {
                                    errorText = new TextBuffer();
                                }
                                errorText.SetText(errText);
                            }
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            bool openLoading = false;

            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))
                {
                    showOptions = true;
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        openLoading   = true;
                        finishLoading = false;
                        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();
                    }
                }
                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();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }
            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
            }
            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-2019");
                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 (ImGui.BeginPopupModal("Processing", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)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.Title : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            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();
            //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();

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (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);
            }
            if (showOptions)
            {
                ImGui.Begin("Options", ref showOptions, ImGuiWindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    switch (cFilter)
                    {
                    case 0:
                        RenderState.PreferredFilterLevel = TextureFiltering.Linear;
                        break;

                    case 1:
                        RenderState.PreferredFilterLevel = TextureFiltering.Bilinear;
                        break;

                    case 2:
                        RenderState.PreferredFilterLevel = TextureFiltering.Trilinear;
                        break;

                    default:
                        RenderState.AnisotropyLevel      = anisotropyLevels[cFilter - 3];
                        RenderState.PreferredFilterLevel = TextureFiltering.Anisotropic;
                        break;
                    }
                }
                ImGui.End();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Пример #4
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);
        }
Пример #5
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            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 (ImGui.MenuItem("New", "Ctrl-N", false, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    tabs.Add(t);
                }
                if (ImGui.MenuItem("Open", "Ctrl-O", false, true))
                {
                    var f = FileDialog.Open();
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f));
                        ActiveTab = t;
                        tabs.Add(t);
                    }
                }
                if (ActiveTab == null)
                {
                    ImGui.MenuItem("Save", "Ctrl-S", false, false);
                }
                else
                {
                    if (ImGui.MenuItem(string.Format("Save '{0}'", ActiveTab.Title), "Ctrl-S", false, true))
                    {
                        var f = FileDialog.Save();
                        if (f != null)
                        {
                            ActiveTab.Title = System.IO.Path.GetFileName(f);
                            ActiveTab.Utf.Save(f);
                        }
                    }
                }
                if (ImGui.MenuItem("Quit", "Ctrl-Q", false, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (ImGui.MenuItem("Resources"))
                {
                    tabs.Add(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (ImGui.MenuItem("About"))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

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

            size.Y -= menu_height;
            //Window
            ImGuiExt.RootDock(0, menu_height, size.X, size.Y - 25);
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            for (int i = 0; i < tabs.Count; i++)
            {
                if (!tabs[i].Draw())                   //No longer open
                {
                    if (tabs[i] is UtfTab && ((UtfTab)tabs[i]) == ActiveTab)
                    {
                        ActiveTab = null;
                    }
                    tabs[i].Dispose();
                    tabs.RemoveAt(i);
                    i--;
                }
            }
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

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

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.EndWindow();
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
            }
            toAdd.Clear();
        }
        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);
        }
Пример #8
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            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();
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f));
                        ActiveTab = t;
                        AddTab(t);
                    }
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.Title), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save();
                        if (f != null)
                        {
                            ActiveTab.Title = System.IO.Path.GetFileName(f);
                            ActiveTab.Utf.Save(f);
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (ImGui.MenuItem("Resources"))
                {
                    tabs.Add(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                ImGui.Separator();
                ImGui.Text("Icons from Icons8: https://icons8.com/");
                ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

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

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

            ImGui.BeginWindow("tabwindow", ref childopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            ImGui.BeginChild("###tabcontent");
            if (selected != null)
            {
                selected.Draw();
                selected.SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            ImGui.EndWindow();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

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

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.EndWindow();
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Пример #9
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            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);
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f));
                        ActiveTab = t;
                        AddTab(t);
                    }
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save(UtfFilters);
                        if (f != null)
                        {
                            ActiveTab.DocumentName = System.IO.Path.GetFileName(f);
                            ActiveTab.UpdateTitle();
                            ActiveTab.Utf.Save(f);
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            bool openerror = false;

            if (ImGui.BeginMenu("Tools"))
            {
                if (ImGui.MenuItem("Options"))
                {
                    showOptions = true;
                }
                if (ImGui.MenuItem("Log"))
                {
                    showLog = true;
                }
                if (ImGui.MenuItem("Resources"))
                {
                    AddTab(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (ImGui.MenuItem("Import Collada"))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        List <ColladaObject> dae = null;
                        try
                        {
                            dae = ColladaSupport.Parse(input);
                            AddTab(new ColladaTab(dae, System.IO.Path.GetFileName(input), this));
                        }
                        catch (Exception ex)
                        {
                            if (errorText != null)
                            {
                                errorText.Dispose();
                            }
                            var str = "Import Error:\n" + ex.Message + "\n" + ex.StackTrace;
                            errorText = new TextBuffer();
                            errorText.SetText(str);
                            openerror = true;
                        }
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openerror)
            {
                ImGui.OpenPopup("Error");
            }
            if (ImGui.BeginPopupModal("Error", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                ImGui.InputTextMultiline("##etext", errorText.Pointer, (uint)errorText.Size,
                                         new Vector2(430, 200), InputTextFlags.ReadOnly, errorText.Callback);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                ImGui.Separator();
                ImGui.Text("Icons from Icons8: https://icons8.com/");
                ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

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

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

            ImGui.BeginWindow("tabwindow", ref childopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.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.Title : ""), new Vector2(-1, h1), false, WindowFlags.Default);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                selected.SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, WindowFlags.Default);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                ImGui.InputTextMultiline("##logtext", logBuffer.Pointer, 32768, new Vector2(-1, h2 - 24),
                                         InputTextFlags.ReadOnly, logBuffer.Callback);
                ImGui.EndChild();
            }
            ImGui.EndWindow();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

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

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.EndWindow();
            if (showOptions)
            {
                ImGui.BeginWindow("Options", ref showOptions, WindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters);
                if (cFilter != pastC)
                {
                    switch (cFilter)
                    {
                    case 0:
                        RenderState.PreferredFilterLevel = TextureFiltering.Linear;
                        break;

                    case 1:
                        RenderState.PreferredFilterLevel = TextureFiltering.Bilinear;
                        break;

                    case 2:
                        RenderState.PreferredFilterLevel = TextureFiltering.Trilinear;
                        break;

                    default:
                        RenderState.AnisotropyLevel      = anisotropyLevels[cFilter - 3];
                        RenderState.PreferredFilterLevel = TextureFiltering.Anisotropic;
                        break;
                    }
                }
                ImGui.EndWindow();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Пример #10
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);
        }
Пример #11
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            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 (ImGui.MenuItem("Open", "Ctrl-O", false, true))
                {
                    var f = FileDialog.Open();
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        tabs.Add(new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f)));
                    }
                }
                if (ImGui.MenuItem("Quit", "Ctrl-Q", false, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (ImGui.MenuItem("About"))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (ImGui.BeginPopupModal("About"))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

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

            size.Y -= menu_height;
            ImGuiExt.RootDock(0, menu_height, size.X, size.Y - 25f);
            for (int i = 0; i < tabs.Count; i++)
            {
                if (!tabs[i].Draw())                   //No longer open
                {
                    tabs[i].Dispose();
                    tabs.RemoveAt(i);
                    i--;
                }
            }
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.BeginWindow("statusbar", ref sbopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            ImGui.Text(string.Format("FPS: {0}", (int)Math.Round(frequency)));
            ImGui.EndWindow();
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
            }
            toAdd.Clear();
        }