protected void renderModals()
        {
            while (_modalsToCreate.Count > 0)
            {
                ImGui.OpenPopup(_modalsToCreate.Dequeue());
            }

            while (_modalsToDestroy.Count > 0)
            {
                _modals.Remove(_modalsToDestroy.Dequeue());
            }

            foreach (KeyValuePair <string, Modal> kv in _modals)
            {
                if (ImGui.BeginPopupModal(kv.Key, ref kv.Value.Active))
                {
                    kv.Value.Component.Render();
                    ImGui.EndPopup();
                }

                if (!kv.Value.Active)
                {
                    _modalsToDestroy.Enqueue(kv.Key);
                }
            }
        }
Beispiel #2
0
        void DrawAtlasSlicerPopup()
        {
            var isOpen = true;

            if (ImGui.BeginPopupModal("atlas-slicer", ref isOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.InputInt("Width", ref _width);
                ImGui.InputInt("Height", ref _height);
                ImGui.InputInt("Max Frames", ref _frames);
                ImGui.InputInt("Padding", ref _padding);

                if (ImGui.Button("Slice"))
                {
                    GenerateRects(_width, _height, _frames, _padding);
                }

                ImGui.SameLine();

                if (ImGui.Button("Done"))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }
        }
Beispiel #3
0
        void OpenFilePopup()
        {
            var isOpen = true;

            if (ImGui.BeginPopupModal("open-file", ref isOpen, ImGuiWindowFlags.NoTitleBar))
            {
                var picker = FilePicker.GetFilePicker(this, Path.Combine(Environment.CurrentDirectory, "Content"), ".png|.atlas");
                picker.DontAllowTraverselBeyondRootFolder = true;
                if (picker.Draw())
                {
                    var file = picker.SelectedFile;
                    if (file.EndsWith(".png"))
                    {
                        _sourceImageFile = file;
                        _sourceAtlasFile = file.Replace(".png", ".atlas");
                    }
                    else
                    {
                        _sourceImageFile = file.Replace(".atlas", ".png");
                        _sourceAtlasFile = file;
                    }
                    LoadTextureAndAtlasFiles();
                    FilePicker.RemoveFilePicker(this);
                }
                ImGui.EndPopup();
            }
        }
        protected override void CustomRender()
        {
            if (_openRequested)
            {
                ImGui.OpenPopup(PopupLabel);
                _openRequested = false;
                _isOpen = true;
            }

            var popupSize = ImGui.GetIO().DisplaySize;
            popupSize = new Vector2(popupSize.X - 50, popupSize.Y - 50);
            ImGui.SetNextWindowSize(popupSize);
            const ImGuiWindowFlags flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
            if (ImGui.BeginPopupModal(PopupLabel, ref _isOpen, flags))
            {
                RenderSectionList(popupSize);

                ImGui.NewLine();
                RenderControlsSection();

                ImGui.NewLine();
                RenderImageSection(popupSize);

                ImGui.EndPopup();
            }
        }
Beispiel #5
0
        /// <summary>Shows the exit popup.</summary>
        private void ShowExitPopup()
        {
            if (exitState)
            {
                ImGui.OpenPopup("Exit?");
            }

            if (ImGui.BeginPopupModal("Exit?", ref exitState, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoSavedSettings))
            {
                ImGui.Text("Are you sure you want to exit?, Please remenber save the project.");
                if (ImGui.Button("Accept", new System.Numerics.Vector2((ImGui.GetContentRegionAvail().X / 2) - 5.0f, 35.0f)))
                {
                    //eventHandler.Invoke(this, EventType.ExitEditor);
                    exitState = false;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();

                if (ImGui.Button("Cancel", new System.Numerics.Vector2(ImGui.GetContentRegionAvail().X, 35.0f)))
                {
                    exitState = false;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }
        }
Beispiel #6
0
        public bool Draw(ref string selected)
        {
            string label = null;

            if (selected != null)
            {
                try
                {
                    var info = new FileInfo(selected);
                    label = PickDirectory ? info.FullName : info.Name;
                }
                catch (Exception)
                {
                    label = "<Select>";
                }
            }
            if (ImGui.Button($"{Id}: {label}"))
            {
                ImGui.OpenPopup(Id);
            }

            bool result = false;
            bool p_open = true;

            if (ImGui.BeginPopupModal(Id, ref p_open, ImGuiWindowFlags.NoTitleBar))
            {
                result = DrawFolder(ref selected, true);
                ImGui.EndPopup();
            }

            return(result);
        }
        private static void RenderException(RenderableException exception)
        {
            string exceptionTitle   = exception.Title;
            string exceptionSummary = exception.ExceptionSummary;

            if (!ImGui.IsPopupOpen(exceptionTitle))
            {
                ImGui.OpenPopup(exceptionTitle);
            }
            if (ImGui.IsPopupOpen(exceptionTitle))
            {
                Vector2 textInputSize = SetExceptionScreenPositionAndSize();
                if (ImGui.BeginPopupModal(exceptionTitle, ref _isRenderingTopException, ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize))
                {
                    bool escapePressed = ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape));

                    ImGui.InputTextMultiline("TextInput", ref exceptionSummary, 1024, textInputSize, ImGuiInputTextFlags.ReadOnly);
                    ImGui.EndPopup();
                    if (escapePressed)
                    {
                        _isRenderingTopException = false;
                    }
                }
            }
        }
Beispiel #8
0
        protected override void CustomRender()
        {
            if (_openRequested)
            {
                ImGui.OpenPopup(PopupLabel);
                _isOpen        = true;
                _openRequested = false;
            }

            var wasOpen = _isOpen;

            ImGui.SetNextWindowSize(new Vector2(700, 500));
            if (ImGui.BeginPopupModal(PopupLabel, ref _isOpen, ImGuiWindowFlags.Modal))
            {
                ImGui.TextWrapped(_message);
                ImGui.NewLine();

                ImGui.Separator();

                if (ImGui.Button("Close"))
                {
                    _isOpen = false;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            if (wasOpen && !_isOpen)
            {
                ModalClosed?.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #9
0
        /// <summary>
        /// displays a simple dialog with some text and a couple buttons. Note that ImGui.OpenPopup( name ) has to be called
        /// in the same ID scope as this call.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="message"></param>
        /// <param name="okButton"></param>
        /// <param name="cxlButton"></param>
        /// <returns></returns>
        public static bool SimpleDialog(string name, string message, string okButton = "OK",
                                        string cxlButton = "Cancel")
        {
            var result   = false;
            var junkBool = true;

            if (ImGui.BeginPopupModal(name, ref junkBool, ImGuiWindowFlags.AlwaysAutoResize))
            {
                result = false;

                ImGui.TextWrapped(message);
                MediumVerticalSpace();
                ImGui.Separator();
                SmallVerticalSpace();

                if (ImGui.Button(cxlButton, new System.Numerics.Vector2(120, 0)))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SetItemDefaultFocus();
                ImGui.SameLine();
                if (ImGui.Button(okButton, new System.Numerics.Vector2(120, 0)))
                {
                    result = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            return(result);
        }
Beispiel #10
0
        private void RenderSaveProfileMenu()
        {
            if (ImGui.BeginPopupModal($"Save Profile", WindowFlags.AlwaysAutoResize))
            {
                currentFileName = ImGuiExtension.InputText("File Name", currentFileName, 100, InputTextFlags.AlwaysInsertMode);
                if (!String.IsNullOrEmpty(currentFileName))
                {
                    if (ImGui.Button("Save"))
                    {
                        LoadedProfile profileToSave = LoadSaveTrigger != null
                            ? new LoadedProfile()
                        {
                            Composite = LoadSaveTrigger
                        }
                            : Plugin.Settings.LoadedProfile;

                        BaseTreeRoutinePlugin <BuildYourOwnRoutineSettings, BaseTreeCache> .SaveSettingFile <Profile.LoadedProfile>(Plugin.ProfileDirectory + currentFileName, profileToSave);

                        currentFileName = "";
                        forceOpenSave   = false;
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                }

                if (ImGui.Button("Cancel"))
                {
                    currentFileName = "";
                    forceOpenSave   = false;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
        private void RenderSaveProfileMenu()
        {
            if (ImGui.BeginPopupModal("Save Profile", WindowFlags.AlwaysAutoResize))
            {
                currentFileName = ImGuiExtension.InputText("File Name", currentFileName, 100, InputTextFlags.AlwaysInsertMode);
                if (currentFileName != null && currentFileName.Length > 0)
                {
                    if (ImGui.Button("Save"))
                    {
                        BaseTreeRoutinePlugin <BuildYourOwnRoutineSettings, BaseTreeCache> .SaveSettingFile <Profile.LoadedProfile>(Plugin.ProfileDirectory + currentFileName, Plugin.Settings.LoadedProfile);

                        currentFileName = "";
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                }

                if (ImGui.Button("Cancel"))
                {
                    currentFileName = "";
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
        private void RenderTriggerMenu()
        {
            if (ImGui.BeginPopupModal(TriggerMenuLabel, WindowFlags.AlwaysAutoResize))
            {
                if (!NewTriggerMenu.Render())
                {
                    if (NewTriggerMenu.TriggerComposite != null)
                    {
                        // We saved, not canceled.
                        if (NewTriggerMenu.Parent == null)
                        {
                            // We are saving the root
                            Plugin.Settings.LoadedProfile.Composite = NewTriggerMenu.TriggerComposite;
                        }
                        else
                        {
                            // Add the saved trigger to the parent
                            NewTriggerMenu.Parent.Children.Add(NewTriggerMenu.TriggerComposite);
                        }
                    }

                    NewTriggerMenu = null;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Beispiel #13
0
 public void Run()
 {
     foreach (var p in popups)
     {
         if (p.DoOpen)
         {
             p.Data.DoFocus = p.Data.First = true;
             ImGui.OpenPopup(p.Title);
             p.DoOpen = false;
         }
         if (ImGui.BeginPopupModal(p.Title, p.Flags))
         {
             p.DrawAction(p.Data);
             if (p.Data.First)
             {
                 p.Data.First = false;
             }
             else
             {
                 p.Data.DoFocus = false;
             }
             ImGui.EndPopup();
         }
     }
 }
 void SearchDialog()
 {
     if (doOpenSearch)
     {
         ImGui.OpenPopup(ImGuiExt.IDWithExtra("Search", Unique));
         doOpenSearch      = false;
         searchDlgOpen     = true;
         searchResultsOpen = false;
     }
     if (searchResultsOpen)
     {
         SearchResults();
     }
     if (ImGui.BeginPopupModal(ImGuiExt.IDWithExtra("Search", Unique), ref searchDlgOpen, ImGuiWindowFlags.AlwaysAutoResize))
     {
         if (dialogState == 0)
         {
             SearchWindow();
         }
         else if (dialogState == 1)
         {
             SearchStatus();
         }
         else
         {
             searchResultsOpen = true;
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
 }
 public void Run()
 {
     foreach (var p in popups)
     {
         if (p.DoOpen)
         {
             p.Data.DoFocus = p.Data.First = true;
             ImGui.OpenPopup(p.Title);
             p.DoOpen = false;
         }
         bool open = true;
         bool beginval;
         if (!p.Data.NoClose)
         {
             beginval = ImGui.BeginPopupModal(p.Title, ref open, p.Flags);
         }
         else
         {
             beginval = ImGuiExt.BeginModalNoClose(p.Title, p.Flags);
         }
         if (beginval)
         {
             p.DrawAction(p.Data);
             if (p.Data.First)
             {
                 p.Data.First = false;
             }
             else
             {
                 p.Data.DoFocus = false;
             }
             ImGui.EndPopup();
         }
     }
 }
Beispiel #16
0
    private static void DrawFreshInstallNotice(Configuration config, float scale)
    {
        ImGui.OpenPopup("Compass Note");
        var contentSize   = ImGuiHelpers.MainViewport.Size;
        var modalSize     = new Vector2(400 * scale, 175 * scale);
        var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2);

        ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
        ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
        if (!ImGui.BeginPopupModal("Compass Note"))
        {
            return;
        }
        ImGui.PushTextWrapPos(ImGui.GetFontSize() * 22f);
        ImGui.TextWrapped(i18n.fresh_install_note);
        ImGui.PopTextWrapPos();
        ImGui.Spacing();
        if (ImGui.Button($"${i18n.fresh_install_note_confirm_button}###Compass_FreshInstallPopUp"))
        {
            config.FreshInstall = false;
            ImGui.CloseCurrentPopup();
        }

        ImGui.EndPopup();
    }
        public override bool Edit()
        {
            ImGui.Text(Property.Name);
            ImGui.NextColumn();
            ImGui.Text(ogString);
            ImGui.SameLine();
            if (ImGui.Button(editId))
            {
                textBuffer.SetText(ogString);
                ImGui.OpenPopup(popupId);
                open = true;
            }

            if (ImGui.BeginPopupModal(popupId, ref open, ImGuiWindowFlags.AlwaysAutoResize))
            {
                textBuffer.InputText("Value", ImGuiInputTextFlags.None, 200);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                    Property.SetValue(Object, textBuffer.GetText());
                    return(true);
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.NextColumn();
            return(false);
        }
Beispiel #18
0
 public override void Draw()
 {
     ImGui.Text("Tree");
     ImGui.SameLine(ImGui.GetWindowWidth() - 60);
     if (ImGui.Button("Finish"))
     {
         EditableUtf utf;
         if (Finish(out utf))
         {
             win.AddTab(new UtfTab(win, utf, "Untitled"));
         }
         else
         {
             ErrorPopup("Invalid UTF Structure:\nMore than one root node.");
         }
     }
     ImGui.BeginChild("##fl");
     FLPane();
     ImGui.EndChild();
     if (_openError)
     {
         ImGui.OpenPopup("Error");
     }
     if (ImGui.BeginPopupModal("Error"))
     {
         ImGui.Text(_errorText);
         if (ImGui.Button("Ok"))
         {
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
     _openError = false;
 }
Beispiel #19
0
        private void renderModals()
        {
            while (_modalsToCreate.Count > 0)
            {
                var modalName = _modalsToCreate.Dequeue();
                var modal     = _modals[modalName];
                ImGui.SetNextWindowSize(modal.InitialSize);
                ImGui.OpenPopup(modal.Id);
            }

            while (_modalsToDestroy.Count > 0)
            {
                _modals.Remove(_modalsToDestroy.Dequeue());
            }

            foreach (KeyValuePair <string, Modal> kv in _modals)
            {
                if (ImGui.BeginPopupModal(kv.Value.Id, ref kv.Value.Active))
                {
                    kv.Value.Component.Render();
                    ImGui.EndPopup();
                }

                if (!kv.Value.Active)
                {
                    _modalsToDestroy.Enqueue(kv.Key);
                }
            }
        }
Beispiel #20
0
        public static Keys HotkeySelector(string buttonName, string popupTitle, Keys currentKey)
        {
            if (ImGui.Button($"{buttonName}: {currentKey} "))
            {
                ImGui.OpenPopup(popupTitle);
            }
            if (ImGui.BeginPopupModal(popupTitle, (WindowFlags)35))
            {
                ImGui.Text($"Press a key to set as {buttonName}");
                foreach (var key in KeyCodes())
                {
                    if (!WinApi.IsKeyDown(key))
                    {
                        continue;
                    }
                    if (key != Keys.Escape && key != Keys.RButton && key != Keys.LButton)
                    {
                        ImGui.CloseCurrentPopup();
                        ImGui.EndPopup();
                        return(key);
                    }

                    break;
                }

                ImGui.EndPopup();
            }

            return(currentKey);
        }
 public static Keys HotkeySelector(string buttonName, string popupTitle, Keys currentKey)
 {
     if (ImGui.Button(string.Format("{0}: {1} ", buttonName, currentKey)))
     {
         ImGui.OpenPopup(popupTitle);
     }
     if (ImGui.BeginPopupModal(popupTitle, WindowFlags.NoTitleBar | WindowFlags.NoResize | WindowFlags.NoCollapse))
     {
         ImGui.Text(string.Format("Press a key to set as {0}", buttonName));
         foreach (Keys keyCode in KeyCodes())
         {
             if (WinApi.IsKeyDown(keyCode))
             {
                 if (keyCode != Keys.Escape)
                 {
                     if (keyCode != Keys.RButton)
                     {
                         if (keyCode != Keys.LButton)
                         {
                             ImGui.CloseCurrentPopup();
                             ImGui.EndPopup();
                             return(keyCode);
                         }
                     }
                 }
                 break;
             }
         }
         ImGui.EndPopup();
     }
     return(currentKey);
 }
Beispiel #22
0
        public void Update(bool isTopMost)
        {
            if (Title == null)
            {
                throw new InvalidOperationException("Dialog title cannot be null.");
            }

            // Check for topmost
            if (isTopMost)
            {
                ImGui.OpenPopup($"{Title}##{UniqueInstanceGUID}");
            }
            bool isOpen = true;

            bool didPopupWindow;

            if (AllowsCancelType(CancelTypes.ClickTitleBarX))
            {
                didPopupWindow = ImGui.BeginPopupModal($"{Title}##{UniqueInstanceGUID}", ref isOpen,
                                                       ImGuiWindowFlags.AlwaysAutoResize |
                                                       ImGuiWindowFlags.NoSavedSettings |
                                                       ImGuiWindowFlags.NoCollapse);
            }
            else
            {
                didPopupWindow = ImGuiEx.BeginPopupModal($"{Title}##{UniqueInstanceGUID}",
                                                         ImGuiWindowFlags.AlwaysAutoResize |
                                                         ImGuiWindowFlags.NoSavedSettings |
                                                         ImGuiWindowFlags.NoCollapse);
            }

            if (didPopupWindow)
            {
                if (isTopMost)
                {
                    BuildInsideOfWindow();
                }



                ImGui.EndPopup();
            }

            if (!isOpen && AllowsCancelType(CancelTypes.ClickTitleBarX))
            {
                CancelType = CancelTypes.ClickTitleBarX;
                Dismiss();
            }

            if (AllowsCancelType(CancelTypes.PressEscape) && Main.Input.KeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                CancelType = CancelTypes.PressEscape;
                Dismiss();
            }
            else if (AllowsCancelType(CancelTypes.PressEnter) && Main.Input.KeyDown(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                CancelType = CancelTypes.PressEnter;
                Dismiss();
            }
        }
Beispiel #23
0
        public static Keys HotkeySelector(string buttonName, string popupTitle, Keys currentKey)
        {
            if (buttonName.Contains("##"))
            {
                buttonName = buttonName.Substring(0, buttonName.LastIndexOf("##"));
            }
            ImGui.PushID(buttonName);
            if (ImGui.Button($"{buttonName}: {currentKey} "))
            {
                ImGui.OpenPopup(popupTitle);
            }
            if (ImGui.BeginPopupModal(popupTitle, (WindowFlags)35))
            {
                if (!MenuPlugin.HandleForKeySelector)
                {
                    ImGui.CloseCurrentPopup();
                    ImGui.EndPopup();
                    ImGui.PopID();

                    if (MenuPlugin.HandledForKeySelectorKey != Keys.Escape)
                    {
                        return(MenuPlugin.HandledForKeySelectorKey);
                    }
                    else
                    {
                        return(currentKey);
                    }
                }
                ImGui.Text($"Press a key to set as {buttonName}");
                ImGui.EndPopup();
            }

            ImGui.PopID();
            return(currentKey);
        }
Beispiel #24
0
        public static void FloatEditor(string title, ref float[] floats, LUtfNode selectedNode)
        {
            if (ImGui.BeginPopupModal(title))
            {
                bool remove = false;
                bool add    = false;
                ImGui.Text(string.Format("Count: {0} ({1} bytes)", floats.Length, floats.Length * 4));
                ImGui.SameLine();
                add = ImGui.Button("+");
                ImGui.SameLine();
                remove = ImGui.Button("-");
                ImGui.Separator();
                //Magic number 94px seems to fix the scrollbar thingy
                var h = ImGui.GetWindowHeight();
                ImGui.BeginChild("##scroll", new Vector2(0, h - 94), false, 0);
                ImGui.Columns(4, "##columns", true);
                for (int i = 0; i < floats.Length; i++)
                {
                    ImGui.InputFloat("##" + i, ref floats[i], 0, 0);
                    ImGui.NextColumn();
                    if (i % 4 == 0 && i != 0)
                    {
                        ImGui.Separator();
                    }
                }
                ImGui.EndChild();
                if (ImGui.Button("Ok"))
                {
                    var bytes = new byte[floats.Length * 4];
                    fixed(byte *ptr = bytes)
                    {
                        var f = (float *)ptr;

                        for (int i = 0; i < floats.Length; i++)
                        {
                            f[i] = floats[i];
                        }
                    }

                    selectedNode.Data = bytes;
                    floats            = null;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    floats = null; ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
                if (add)
                {
                    Array.Resize(ref floats, floats.Length + 1);
                }
                if (remove && floats.Length > 1)
                {
                    Array.Resize(ref floats, floats.Length - 1);
                }
            }
        }
Beispiel #25
0
        public override void Render()
        {
            ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 2f);
            ImGui.OpenPopup("Editing Entity");
            ImGui.BeginPopupModal("Editing Entity", ref Visible, ImGuiWindowFlags.AlwaysAutoResize);

            bool changed   = false;
            Type firstType = MainEntity.GetType();

            if (SelectedEntities.TrueForAll((e) => e.GetType() == firstType))
            {
                PropertyList properties = MainEntity.Properties;
                foreach (Property property in properties)
                {
                    if (AddEntry(MainEntity, SelectedEntities, property))
                    {
                        changed = true;
                    }
                }
            }

            if (changed)
            {
                MapEditor.Instance.Renderer.GetRoom(SelectedEntities[0].Room).Dirty = true;
            }

            ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 2f);
            ImGui.PopStyleVar();

            if (ImGui.Button("Delete", new System.Numerics.Vector2(60f, 20f)))
            {
                MapEditor.Instance.State.Apply(new EntityRemovalAction(
                                                   MapEditor.Instance.State.SelectedRoom,
                                                   SelectedEntities
                                                   ));
                Tool.Deselect();
                Visible = false;
            }
            UIHelper.Tooltip("Delete this Entity");

            ImGui.SameLine();
            if (ImGui.Button("OK", new System.Numerics.Vector2(35f, 20f)))
            {
                var newAttrs = new List <Attributes>(SelectedEntities.Count);
                for (int i = 0; i < SelectedEntities.Count; i++)
                {
                    newAttrs.Add(MiscHelper.CloneDictionary(SelectedEntities[i].Attributes));
                }
                MapEditor.Instance.State.Apply(new BulkEntityEditAction(
                                                   MapEditor.Instance.State.SelectedRoom,
                                                   SelectedEntities,
                                                   InitialAttributes,
                                                   newAttrs
                                                   ));
                Visible = false;
            }

            ImGui.EndPopup();
        }
Beispiel #26
0
 public static bool BeginWindow(string title, ref bool isOpened, float x, float y, float width, float height,
                                bool autoResize = false)
 {
     ImGui.SetNextWindowPos(new ImGuiVector2(width + x, height + y), ImGuiCond.Appearing,
                            new ImGuiVector2(1, 1));
     ImGui.SetNextWindowSize(new ImGuiVector2(width, height), ImGuiCond.Appearing);
     return(ImGui.BeginPopupModal(title, ref isOpened,
                                  autoResize ? ImGuiWindowFlags.AlwaysAutoResize : ImGuiWindowFlags.None));
 }
Beispiel #27
0
        void Popups()
        {
            popups.Run();
            //Float Editor
            if (floatEditor)
            {
                ImGui.OpenPopup("Float Editor##" + Unique);
                floatEditor = false;
            }
            DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode);
            if (intEditor)
            {
                ImGui.OpenPopup("Int Editor##" + Unique);
                intEditor = false;
            }
            DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode);
            //Error
            if (doError)
            {
                ImGui.OpenPopup("Error##" + Unique);
                doError = false;
            }
            bool wOpen = true;

            if (ImGui.BeginPopupModal("Error##" + Unique, ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##generic" + Unique);
                doConfirm = false;
            }
            wOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##generic" + Unique, ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Beispiel #28
0
            private void DrawDeleteModal()
            {
                if (_deleteIndex == null)
                {
                    return;
                }

                ImGui.OpenPopup(DialogDeleteMod);

                var _ = true;

                ImGui.SetNextWindowPos(ImGui.GetMainViewport().GetCenter(), ImGuiCond.Appearing, Vector2.One / 2);
                var ret = ImGui.BeginPopupModal(DialogDeleteMod, ref _, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDecoration);

                if (!ret)
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndPopup);

                if (Mod == null)
                {
                    _deleteIndex = null;
                    ImGui.CloseCurrentPopup();
                    return;
                }

                ImGui.Text("Are you sure you want to delete the following mod:");
                var halfLine = new Vector2(ImGui.GetTextLineHeight() / 2);

                ImGui.Dummy(halfLine);
                ImGui.TextColored(DeleteModNameColor, Mod.Data.Meta.Name);
                ImGui.Dummy(halfLine);

                var buttonSize = ImGuiHelpers.ScaledVector2(120, 0);

                if (ImGui.Button(ButtonYesDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    var mod = Mod;
                    Cache.RemoveMod(mod);
                    _modManager.DeleteMod(mod.Data.BasePath);
                    ModFileSystem.InvokeChange();
                    ClearSelection();
                }

                ImGui.SameLine();

                if (ImGui.Button(ButtonNoDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    _deleteIndex = null;
                }
            }
Beispiel #29
0
        private void renderFileSaveDialog()
        {
            ImGui.SetNextWindowSize(_dialogStartSize, Condition.FirstUseEver);
            if (ImGui.BeginPopupModal($"Save file...##{GetHashCode()}", ref _open))
            {
                renderTopBar();
                renderFileList();
                renderBottomBar();

                ImGui.EndPopup();
            }
        }
            private void DrawDeleteModal()
            {
                if (_deleteIndex == null)
                {
                    return;
                }

                ImGui.OpenPopup(DialogDeleteMod);

                var _ = true;

                ImGui.SetNextWindowPos(ImGui.GetMainViewport().GetCenter(), ImGuiCond.Appearing, Vector2.One / 2);
                var ret = ImGui.BeginPopupModal(DialogDeleteMod, ref _, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDecoration);

                if (!ret)
                {
                    return;
                }

                if (Mod?.Mod == null)
                {
                    ImGui.CloseCurrentPopup();
                    ImGui.EndPopup();
                    return;
                }

                ImGui.Text("Are you sure you want to delete the following mod:");
                // todo: why the f**k does this become null??????
                ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
                ImGui.TextColored(new Vector4(0.7f, 0.1f, 0.1f, 1), Mod?.Mod?.Meta?.Name ?? "Unknown");
                ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight()) / 2);

                var buttonSize = new Vector2(120, 0);

                if (ImGui.Button(ButtonYesDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    Service <ModManager> .Get().DeleteMod(Mod?.Mod);

                    ClearSelection();
                    _base.ReloadMods();
                }

                ImGui.SameLine();

                if (ImGui.Button(ButtonNoDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    _deleteIndex = null;
                }

                ImGui.EndPopup();
            }