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); }
public override void DrawEditor() { ImGui.PushItemWidth(-1); if (ImGui.BeginCombo("##ItemUiCategorySearchFilterBox", uiCategoriesArray[this.selectedCategory])) { ImGui.SetNextItemWidth(-1); ImGui.InputTextWithHint("###ItemUiCategorySearchFilterFilter", "Filter", ref categorySearchInput, 60); var isFocused = ImGui.IsItemActive(); if (!focused) { ImGui.SetKeyboardFocusHere(); } ImGui.BeginChild("###ItemUiCategorySearchFilterDisplay", popupSize, true); if (!focused) { ImGui.SetScrollY(0); focused = true; } var c = 0; var l = 0; for (var i = 0; i < uiCategoriesArray.Length; i++) { if (i > 0 && categorySearchInput.Length > 0 && !uiCategoriesArray[i].ToLowerInvariant().Contains(categorySearchInput.ToLowerInvariant())) { continue; } if (i != 0) { c++; l = i; } if (!ImGui.Selectable(uiCategoriesArray[i], selectedCategory == i)) { continue; } selectedCategory = i; ImGui.CloseCurrentPopup(); } ImGui.EndChild(); if (!isFocused && c <= 1) { selectedCategory = l; ImGui.CloseCurrentPopup(); } ImGui.EndCombo(); } else if (focused) { focused = false; categorySearchInput = string.Empty; } ImGui.PopItemWidth(); }
/// <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(); } }
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(); } }
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; }
public static Keys HotkeySelector(string buttonName, string popupTitle, Keys currentKey) { if (ImGui.Button($"{buttonName}: {currentKey} ")) { ImGui.OpenPopup(popupTitle); } if (ImGui.BeginPopup(popupTitle, (ImGuiWindowFlags)35)) { ImGui.Text($"Press a key to set as {buttonName}"); foreach (var key in KeyCodes()) { if (!Input.IsKeyDown(key)) { continue; } if (key != Keys.Escape && key != Keys.RButton && key != Keys.LButton) { ImGui.CloseCurrentPopup(); ImGui.EndPopup(); return(key); } break; } ImGui.EndPopup(); } return(currentKey); }
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); } }
void DrawCreateEntityPopup() { if (ImGui.BeginPopup("create-entity")) { ImGui.Text("New Entity Name:"); ImGui.InputText("##newEntityName", ref _newEntityName, 25); if (ImGui.Button("Cancel")) { _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.GetItemRectSize().X); ImGui.PushStyleColor(ImGuiCol.Button, Microsoft.Xna.Framework.Color.Green.PackedValue); if (ImGui.Button("Create")) { _newEntityName = _newEntityName.Length > 0 ? _newEntityName : Utils.RandomString(8); var newEntity = new Entity(_newEntityName); newEntity.Transform.Position = Core.Scene.Camera.Transform.Position; Core.Scene.AddEntity(newEntity); _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.PopStyleColor(); } }
void Rename(PopupData data) { ImGui.Text("Name: "); ImGui.SameLine(); bool entered = ImGui.InputText("", text.Pointer, (uint)text.Size, InputTextFlags.EnterReturnsTrue, text.Callback); if (data.DoFocus) { ImGui.SetKeyboardFocusHere(); } if (entered || ImGui.Button("Ok")) { var n = text.GetText().Trim(); if (n.Length == 0) { ErrorPopup("Node name cannot be empty"); } else { renameNode.Name = text.GetText(); } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
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(); } }
unsafe void ColorPicker(PopupData data) { bool old4 = pickcolor4; ImGui.Checkbox("Alpha?", ref pickcolor4); if (old4 != pickcolor4) { if (old4 == false) { color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1); } if (old4 == true) { color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z); } } ImGui.Separator(); if (pickcolor4) { ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar); } else { ImGui.ColorPicker3("Color", ref color3); } ImGui.Separator(); if (ImGui.Button("Ok")) { ImGui.CloseCurrentPopup(); if (pickcolor4) { var bytes = new byte[16]; fixed(byte *ptr = bytes) { var f = (System.Numerics.Vector4 *)ptr; f[0] = color4; } selectedNode.Data = bytes; } else { var bytes = new byte[12]; fixed(byte *ptr = bytes) { var f = (System.Numerics.Vector3 *)ptr; f[0] = color3; } selectedNode.Data = bytes; } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
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(); } }
public void Draw() { ImGui.PushID(_scopeId); var isOpen = ImGui.CollapsingHeader(_postProcessor.GetType().Name.Replace("PostProcessor", string.Empty)); NezImGui.ShowContextMenuTooltip(); if (ImGui.BeginPopupContextItem()) { if (ImGui.Selectable("Remove PostProcessor")) { isOpen = false; Core.Scene.RemovePostProcessor(_postProcessor); ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (isOpen) { ImGui.Indent(); foreach (var inspector in _inspectors) { inspector.Draw(); } ImGui.Unindent(); } ImGui.PopID(); }
/// <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); }
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(); } }
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 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(); }
void PickObject(PopupData data) { ImGui.Combo("Object", ref dumpindex, dumpoptions); if (ImGui.Button("Ok")) { var output = FileDialog.Save(); if (output != null) { if (dumpindex == 0) { DumpStatus(DumpObject.DumpObj(dumpcmp, output)); } else { var mdl = dumpcmp.Models[dumpoptions[dumpindex]]; DumpStatus(DumpObject.DumpObj(mdl, output)); } ImGui.CloseCurrentPopup(); } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
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); }
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); }
private void DrawModAddButton() { if (ImGui.BeginPopupContextItem(LabelAddModPopup)) { if (_keyboardFocus) { ImGui.SetKeyboardFocusHere(); _keyboardFocus = false; } var newName = ""; if (ImGui.InputTextWithHint("##AddMod", "New Mod Name...", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue)) { try { var newDir = TexToolsImport.CreateModFolder(new DirectoryInfo(_base._plugin.Configuration !.CurrentCollection), newName); var modMeta = new ModMeta { Author = "Unknown", Name = newName, Description = string.Empty, }; var metaPath = Path.Combine(newDir.FullName, "meta.json"); File.WriteAllText(metaPath, JsonConvert.SerializeObject(modMeta, Formatting.Indented)); _base.ReloadMods(); SelectModByDir(newDir.Name); } catch (Exception e) { PluginLog.Error($"Could not create directory for new Mod {newName}:\n{e}"); } ImGui.CloseCurrentPopup(); } if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape))) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } ImGui.PushFont(UiBuilder.IconFont); if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), SelectorButtonSizes)) { _keyboardFocus = true; ImGui.OpenPopup(LabelAddModPopup); } ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.SetTooltip(TooltipAdd); } }
public void Draw() { ImGui.PushID(_scopeId); var isOpen = ImGui.CollapsingHeader(_name); NezImGui.ShowContextMenuTooltip(); if (ImGui.BeginPopupContextItem()) { if (ImGui.Selectable("Remove Renderer")) { if (Core.Scene is ECScene s) { isOpen = false; s.RemoveRenderer(_renderer); ImGui.CloseCurrentPopup(); } } ImGui.EndPopup(); } if (isOpen) { ImGui.Indent(); _materialInspector.Draw(); ImGui.Checkbox("shouldDebugRender", ref Renderer.ShouldDebugRender); var value = Renderer.RenderTargetClearColor.ToNumerics(); if (ImGui.ColorEdit4("renderTargetClearColor", ref value)) { Renderer.RenderTargetClearColor = value.ToXNAColor(); } if (Renderer.Camera != null) { if (NezImGui.LabelButton("Camera", Renderer.Camera.Entity.Name)) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(Renderer.Camera.Entity); } } ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); NezImGui.DisableNextWidget(); var tempBool = Renderer.WantsToRenderToSceneRenderTarget; ImGui.Checkbox("wantsToRenderToSceneRenderTarget", ref tempBool); NezImGui.DisableNextWidget(); tempBool = Renderer.WantsToRenderAfterPostProcessors; ImGui.Checkbox("wantsToRenderAfterPostProcessors", ref tempBool); ImGui.PopStyleVar(); ImGui.Unindent(); } ImGui.PopID(); }
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); } } }
public static void DrawPopup(ConfigWindow window) { if (_mod == null) { return; } using var popup = ImRaii.Popup(PopupName); if (!popup) { return; } if (ImGui.IsWindowAppearing()) { ImGui.SetKeyboardFocusHere(); } ImGui.InputTextMultiline("##editDescription", ref _newDescription, 4096, ImGuiHelpers.ScaledVector2(800, 800)); ImGui.Dummy(window._defaultSpace); var buttonSize = ImGuiHelpers.ScaledVector2(100, 0); var width = 2 * buttonSize.X + 4 * ImGui.GetStyle().FramePadding.X + ImGui.GetStyle().ItemSpacing.X; ImGui.SetCursorPosX((800 * ImGuiHelpers.GlobalScale - width) / 2); var oldDescription = _newDescriptionIdx == Input.Description ? _mod.Description : _mod.Groups[_newDescriptionIdx].Description; var tooltip = _newDescription != oldDescription ? string.Empty : "No changes made yet."; if (ImGuiUtil.DrawDisabledButton("Save", buttonSize, tooltip, tooltip.Length > 0)) { switch (_newDescriptionIdx) { case Input.Description: Penumbra.ModManager.ChangeModDescription(_mod.Index, _newDescription); break; case >= 0: Penumbra.ModManager.ChangeGroupDescription(_mod, _newDescriptionIdx, _newDescription); break; } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel", buttonSize) || ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape))) { _newDescriptionIdx = Input.None; _newDescription = string.Empty; ImGui.CloseCurrentPopup(); } }
void MinMaxWarning(PopupData data) { ImGui.Text("Min was bigger than max, swapped."); if (ImGui.Button("Ok")) { ImGui.CloseCurrentPopup(); } }
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(); } }
private unsafe void ShowModalFilePopup() { ImGui.Text("Enter file path and press Enter"); if (ImGui.InputText("", _filePathInputBuff, _filePathInputLength, InputTextFlags.EnterReturnsTrue | InputTextFlags.AutoSelectAll, null)) { string path = Marshal.PtrToStringAnsi(_filePathInputBuff); TryOpenAssembly(path); ImGui.CloseCurrentPopup(); } }
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; } }
private void ItemCreatePopup(List <Shortcut> shortcuts) { if (ImGui.BeginPopup("addItem")) { _sh ??= new Shortcut(); ItemBaseUI(_sh, false); if (ImGui.Button("Create")) { shortcuts.Add(_sh); config.Save(); _sh = null; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Import")) { try { shortcuts.Add(plugin.ImportShortcut(ImGui.GetClipboardText())); config.Save(); ImGui.CloseCurrentPopup(); } catch (Exception e) // Try as a bar instead { try { var bar = plugin.ImportBar(ImGui.GetClipboardText()); foreach (var sh in bar.ShortcutList) { shortcuts.Add(sh); } config.Save(); ImGui.CloseCurrentPopup(); } catch (Exception e2) { PluginLog.LogError("Invalid import string!"); PluginLog.LogError($"{e.GetType()}\n{e.Message}"); PluginLog.LogError($"{e2.GetType()}\n{e2.Message}"); } } } if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Import a shortcut from the clipboard,\n" + "or import all of another bar's shortcuts."); } ClampWindowPos(); ImGui.EndPopup(); } }
void DrawEntityContextMenuPopup(Entity entity) { if (ImGui.BeginPopup("entityContextMenu")) { if (ImGui.Selectable("Clone Entity " + entity.Name)) { var clone = entity.Clone(Core.Scene.Camera.Position); entity.Scene.AddEntity(clone); } if (ImGui.Selectable("Destroy Entity")) { entity.Destroy(); } if (ImGui.Selectable("Create Child Entity", false, ImGuiSelectableFlags.DontClosePopups)) { ImGui.OpenPopup("create-new-entity"); } if (ImGui.BeginPopup("create-new-entity")) { ImGui.Text("New Entity Name:"); ImGui.InputText("##newChildEntityName", ref _newEntityName, 25); if (ImGui.Button("Cancel")) { _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.GetItemRectSize().X); ImGui.PushStyleColor(ImGuiCol.Button, Microsoft.Xna.Framework.Color.Green.PackedValue); if (ImGui.Button("Create")) { _newEntityName = _newEntityName.Length > 0 ? _newEntityName : Utils.RandomString(8); var newEntity = new Entity(_newEntityName); newEntity.Transform.SetParent(entity.Transform); entity.Scene.AddEntity(newEntity); _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.PopStyleColor(); ImGui.EndPopup(); } ImGui.EndPopup(); } }