public void DrawUI() { //ClientTop = 0; if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Exit")) { _wnd.Close(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Tools")) { if (ImGui.MenuItem("Reload Shared Config")) { _ctrl.Send(new Net.ReloadSharedConfigMessage()); } if (ImGui.MenuItem("Kill All")) { _ctrl.Send(new Net.KillAllMessage(_ctrl.Name, new KillAllArgs())); } ImGui.EndMenu(); } //var mainMenuSize = ImGui.GetWindowSize(); //ClientTop = mainMenuSize.Y; ImGui.EndMenuBar(); } }
private void ViewportRender() { if (ImGui.BeginMenuBar()) { DrawViewportMenu(); ImGui.EndMenuBar(); } var pos = ImGui.GetCursorPos(); if (ImGui.BeginChild("viewport_child1")) { DrawViewport(); ImGui.SetCursorPos(new System.Numerics.Vector2(pos.X + 20, pos.Y - 40)); ImGui.Text($"Projection: {(Pipeline._context.Camera.IsOrthographic ? "Orthographic" : "Perspective")}"); ImGui.SetCursorPosX(pos.X + 20); ImGui.Text($"Direction: {Pipeline._context.Camera.Direction}"); ImGui.SetCursorPosX(pos.X + 20); ImGui.Text($"Mode: {Pipeline._context.Camera.Mode}"); ImGui.SetCursorPosX(pos.X + 20); ImGui.Text($"Bloom Enable: {Pipeline._context.EnableBloom}"); if (camera_speed_start_notify > 0) { ImGui.SetCursorPosX(pos.X + 20); ImGui.Text($"Camera Speed {Pipeline._camera.KeyMoveSpeed}"); } } ImGui.EndChild(); }
public override void Render() { if (!ImGui.Begin(_name)) { return; } if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("View")) { if (ImGui.MenuItem("Show Overlay", true)) { } if (ImGui.MenuItem("Show Underlay", true)) { } if (ImGui.MenuItem("Show NPCs", true)) { } if (ImGui.MenuItem("Show NPC paths", true)) { } if (ImGui.MenuItem("Show trigger zones", true)) { } } ImGui.EndMenuBar(); } ImGui.End(); }
protected override void DrawWindowContent() { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Edit", Context.Scene != null)) { if (ImGui.MenuItem("Add Entity")) { if (Context != null) { Context.Scene.CreateEntity(); } } if (ImGui.MenuItem("Remove Entity", Context.ActiveEntity != null)) { Context.Scene.DestroyEntity(Context.ActiveEntity); Context.ActiveEntity = null; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (Context.Scene != null) { DrawEntityNode(Context.Scene.HierarchyRoot, ""); } }
protected override void OnDraw() { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Settings")) { if (ImGui.MenuItem("Keep Aspect", "", keepAspect, true)) { keepAspect = !keepAspect; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } currSize = ImGui.GetContentRegionAvail(); if (keepAspect) { currSize = GetAspectArea(currSize); } if (prevSize != currSize) { AppScreen.Resolution = (Vec2i)currSize; } prevSize = currSize; EntityIterator.PerformIteration(EntityWorld.Active, new RenderCamera() { imageSize = currSize }, new EntityQuery().Any(TypeCache.ReadType <C_Camera>())); }
protected override void RenderImGui() { if (ImGui.BeginMenuBar()) { ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.3f, 0.3f, 0.3f, 1f)); MenuBarButtons(); if (_currentFileName != null) { ImGui.Text($"File: {_currentFileName}"); } else if (_currentAsset != null) { ImGui.Text("File: Unsaved File"); } if (_currentFileName != null && Engine.Host is Win32Platform winPlat && ImGui.Button("Show File")) { IAssetStore?store = Engine.AssetLoader.GetStore(_currentFileName); string folderRoot = store == null ? DebugAssetStore.AssetDevPath : store.Folder; string fullPath = Path.GetFullPath(Path.Join(folderRoot, _currentFileName)); winPlat.OpenFolderAndSelectFile(fullPath); } if (_unsavedChanges) { ImGui.TextColored(new Vector4(1, 0, 0, 1), "Unsaved changes!"); } ImGui.PopStyleColor(); ImGui.EndMenuBar(); } }
public void Render() { ImGui.BeginWindow("BadgerEdit 1.1", ref isOpened, new Vector2(800, 600), 0.5f, WindowFlags.MenuBar); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Open")) { fp.Show(FilePickerMode.Open, LoadFile); } ImGui.Separator(); if (ImGui.MenuItem("Save")) { fp.Show(FilePickerMode.Save, SaveFile); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } fp.Draw(); RenderWindowContents(); ImGui.EndWindow(); }
private void DrawTopMenuBar() { ImGui.BeginMenuBar(); if (ImGui.BeginMenu("File", true)) { ShowModalFilePopup(); if (ImGui.MenuItem("About", null)) { } ImGui.Separator(); if (ImGui.MenuItem("Exit", "Alt+F4")) { NativeWindow.Visible = false; } ImGui.EndMenu(); } if (ImGui.BeginMenu("View", true)) { ImGui.Checkbox("Selectable right frame text", ref _selectableText); ImGui.Checkbox("Wrap right frame text", ref _wrapRightFrame); ImGui.EndMenu(); } ImGui.EndMenuBar(); }
public override void Render(CommandList cl) { if (ImGui.BeginMenuBar()) { RenderChildren(cl); ImGui.EndMenuBar(); } }
private void RenderMainMenuBar() { if (!ImGui.BeginMenuBar()) { return; } RenderFileMenu(); RenderGameObjectsMenu(); ImGui.EndMenuBar(); }
public void DrawGUI() { ImGui.Begin(title, ref windowActive, ImGuiWindowFlags.None); if (ImGui.BeginMenuBar()) { menus.ForEach(x => x.Draw()); ImGui.EndMenuBar(); } OnGUI(); ImGui.End(); }
/// <summary> /// Draw Window's Content /// </summary> protected override void DrawWindowContent() { //Menu if (ImGui.BeginMenuBar()) { DrawFileMenu(); ImGui.EndMenuBar(); } ImGui.Text("FPS:" + (1.0f / ImGui.GetIO().DeltaTime).ToString()); ImGui.Text("Proccess:" + m_ProcessName); ImGui.InputTextWithHint("", "type to search", ref m_SearchText, 20); DrawAssemblersHeader(); }
protected override void DrawWindowContent() { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Edit", Context.ActiveEntity != null)) { if (ImGui.BeginMenu("Add Component")) { for (int i = 0; i < EditorLayer.Instance.CoreComponentTypes.Length; i++) { if (ImGui.MenuItem(EditorLayer.Instance.CoreComponentTypes[i].Name)) { Context.ActiveEntity.AddComponent <Component>((Component)Activator.CreateInstance(EditorLayer.Instance.CoreComponentTypes[i])); } } ImGui.Separator(); for (int i = 0; i < EditorLayer.Instance.ComponentTypeRegistry.Count; i++) { if (ImGui.MenuItem(EditorLayer.Instance.ComponentTypeRegistry[i].Name)) { Context.ActiveEntity.AddComponent <Component>((Component)Activator.CreateInstance(EditorLayer.Instance.ComponentTypeRegistry[i])); } } ImGui.EndMenu(); } ImGui.Separator(); if (ImGui.BeginMenu("Remove Component")) { var components = Context.ActiveEntity.Components; for (int i = 0; i < components.Count; i++) { if (ImGui.MenuItem(components[i].GetType().Name)) { Context.ActiveEntity.RemoveComponent(components[i]); } } ImGui.EndMenu(); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (Context.ActiveEntity != null) { DrawComponents(Context.ActiveEntity); } }
private void DrawMenuBar() { bool newAtlas = false; bool openFile = false; if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("New Atlas from Folder")) { newAtlas = true; } if (ImGui.MenuItem("Load Atlas or PNG")) { openFile = true; } if (ImGui.MenuItem("Save Atlas", _spriteAtlasData.SourceRects.Count > 0)) { _spriteAtlasData.SaveToFile(_sourceAtlasFile); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (newAtlas) { ImGui.OpenPopup("new-atlas"); } if (openFile) { ImGui.OpenPopup("open-file"); } NewAtlasPopup(); OpenFilePopup(); }
public override void Update() { if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("New Scene", "ctrl+n")) { } if (ImGui.MenuItem("Open Scene", "ctrl+o")) { FilePickerManager.PickFile(OnOpenScene); } if (ImGui.MenuItem("Save Scene", "ctrl+s")) { } ImGui.EndMenu(); } ImGui.EndMainMenuBar(); } ImGui.Begin("Scene", ImGuiWindowFlags.MenuBar); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Create GameObject")) { if (ImGui.MenuItem("Empty")) { Editor.Scene.AddGameObject(new GameObject()); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } foreach (var gameObject in Editor.Scene.GameObjects) { ImGui.Button(gameObject.Name); } ImGui.End(); }
protected void DrawUserInterface(GameTime gameTime) { if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Quit")) { Exit(); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } ImGui.EndMainMenuBar(); } }
private void DrawMenuBar() { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("View")) { foreach (var document in documents) { if (document.IsOpen) { if (ImGui.BeginMenu(document.Title)) { if (ImGui.MenuItem("Dock", !document.IsDocked)) { document.IsDocked = true; } ImGui.EndMenu(); } } else { if (ImGui.MenuItem($"Open {document.Title}", !document.IsOpen)) { document.IsOpen = true; document.IsDocked = true; } } } ImGui.EndMenu(); } ImGui.EndMenuBar(); } }
private static void SubmitDockableUi() { { //Declare Standalone Windows here #if DEBUG //Debug Window { if (ImGui.Button("Throw Another Exception")) { ExceptionManager.PushExceptionForRendering ( $"DummyException:{new Random().Next()}", new Exception("hAaaaa") ); } } #endif // Color Picker if (CPickerIsEnable) { ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver); if (ImGui.Begin("FFX Color Picker", ref CPickerIsEnable)) { Vector2 mEme = ImGui.GetWindowSize(); if (mEme.X > mEme.Y) { ImGui.SetNextItemWidth(mEme.Y * 0.80f); } ImGui.ColorPicker4("CPicker", ref CPicker, ImGuiColorEditFlags.AlphaPreviewHalf | ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.NoTooltip); if (ImGui.IsItemDeactivatedAfterEdit()) { var actionList = new List <Action>(); if (CPickerRed.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerGreen.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerBlue.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt" || CPickerAlpha.Attribute(FfxHelperMethods.Xsi + "type").Value == "FFXFieldInt") { actionList.Add(new ModifyXAttributeString(CPickerRed.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat")); actionList.Add(new ModifyXAttributeString(CPickerGreen.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat")); actionList.Add(new ModifyXAttributeString(CPickerBlue.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat")); actionList.Add(new ModifyXAttributeString(CPickerAlpha.Attribute(FfxHelperMethods.Xsi + "type"), "FFXFieldFloat")); } actionList.Add(new ModifyXAttributeFloat(CPickerRed.Attribute("Value"), CPicker.X)); actionList.Add(new ModifyXAttributeFloat(CPickerGreen.Attribute("Value"), CPicker.Y)); actionList.Add(new ModifyXAttributeFloat(CPickerBlue.Attribute("Value"), CPicker.Z)); actionList.Add(new ModifyXAttributeFloat(CPickerAlpha.Attribute("Value"), CPicker.W)); SelectedFfxWindow.ActionManager.ExecuteAction(new CompoundAction(actionList)); } ImGui.Separator(); ImGui.Text("Brightness Multiplier"); ImGui.SliderFloat("###Brightness Multiplier", ref ColorOverload, 0, 10f); ImGui.SameLine(); if (ImGuiAddons.ButtonGradient("Multiply Color")) { List <Action> actions = new List <Action>(); CPicker.X *= ColorOverload; CPicker.Y *= ColorOverload; CPicker.Z *= ColorOverload; actions.Add(new EditPublicCPickerVector4(new Vector4(CPicker.X *= ColorOverload, CPicker.Y *= ColorOverload, CPicker.Z *= ColorOverload, CPicker.W))); actions.Add(new ModifyXAttributeFloat(CPickerRed.Attribute("Value"), CPicker.X)); actions.Add(new ModifyXAttributeFloat(CPickerGreen.Attribute("Value"), CPicker.Y)); actions.Add(new ModifyXAttributeFloat(CPickerBlue.Attribute("Value"), CPicker.Z)); SelectedFfxWindow.ActionManager.ExecuteAction(new CompoundAction(actions)); } ImGui.End(); } } // Keyboard Guide if (_keyboardInputGuide) { ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver); ImGui.Begin("Keyboard Guide", ref _keyboardInputGuide, ImGuiWindowFlags.MenuBar); ImGui.BeginMenuBar(); ImGui.EndMenuBar(); ImGui.ShowUserGuide(); ImGui.End(); } if (_axbyDebugger) { ImGui.SetNextWindowDockID(mainViewPortDockSpaceID, ImGuiCond.FirstUseEver); ImGui.Begin("axbxDebug", ref _axbyDebugger); if (SelectedFfxWindow.NodeListEditor != null) { if (SelectedFfxWindow.NodeListEditor.Any() & (SelectedFfxWindow.ShowFfxEditorFields || SelectedFfxWindow.ShowFfxEditorProperties)) { int integer = 0; foreach (XNode node in SelectedFfxWindow.NodeListEditor.ElementAt(0).Parent.Nodes()) { ImGui.Text($"Index = '{integer} Node = '{node}')"); integer++; } } } ImGui.End(); } if (MainUserInterface.IsSearchBarOpen) { var viewport = ImGui.GetMainViewport(); ImGui.SetNextWindowSize(new Vector2(300, 80)); ImGui.SetNextWindowPos(new Vector2(viewport.Pos.X + viewport.Size.X - 15, viewport.Pos.Y + 38), ImGuiCond.None, new Vector2(1, 0)); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0); if (ImGui.Begin("Action Search", ref MainUserInterface.IsSearchBarOpen, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove)) { ImGui.SetNextItemWidth(190); ImGui.InputText("Action Search", ref MainUserInterface.SearchBarString, 1024); ImGui.Checkbox("Search By ID", ref MainUserInterface.IsSearchById); ImGui.End(); } } } }
public void Draw(ref bool isGameViewFocused) { var viewport = ImGui.GetMainViewport(); ImGui.SetNextWindowPos(viewport.GetWorkPos()); ImGui.SetNextWindowSize(viewport.GetWorkSize()); ImGui.SetNextWindowViewport(viewport.ID); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); var windowFlags = ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoDocking; windowFlags |= ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove; windowFlags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoNavFocus; //windowFlags |= ImGuiWindowFlags.NoBackground; ImGui.Begin("Root", windowFlags); ImGui.PopStyleVar(3); ImGui.DockSpace(ImGui.GetID("DockSpace"), Vector2.Zero, ImGuiDockNodeFlags.None); float menuBarHeight = 0; if (ImGui.BeginMenuBar()) { menuBarHeight = ImGui.GetWindowHeight(); if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Exit", "Alt+F4", false, true)) { Environment.Exit(0); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Jump")) { if (ImGui.BeginMenu("Faction: " + _faction.Side)) { foreach (var side in _playableSides) { if (ImGui.MenuItem(side.Side)) { _faction = side; ImGui.SetWindowFocus(side.Name); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Map: " + _map.Item1.Name)) { foreach (var mapCache in _maps) { if (ImGui.MenuItem(mapCache.Value)) { _map = (mapCache.Key, mapCache.Value); } } ImGui.EndMenu(); } if (ImGui.Button("Go!")) { var random = new Random(); var faction2 = _playableSides[random.Next(0, _playableSides.Count())]; if (_map.Item1.IsMultiplayer) { _context.Game.StartMultiPlayerGame( _map.Item1.Name, new EchoConnection(), new PlayerSetting?[] { new PlayerSetting(null, _faction, new ColorRgb(255, 0, 0), PlayerOwner.Player), new PlayerSetting(null, faction2, new ColorRgb(255, 255, 255), PlayerOwner.EasyAi), }, 0 ); } else { _context.Game.StartSinglePlayerGame(_map.Item1.Name); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Windows")) { foreach (var view in _views) { if (ImGui.MenuItem(view.DisplayName, null, view.IsVisible, true)) { view.IsVisible = true; ImGui.SetWindowFocus(view.Name); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Preferences")) { var isVSyncEnabled = _context.Game.GraphicsDevice.SyncToVerticalBlank; if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true)) { _context.Game.GraphicsDevice.SyncToVerticalBlank = isVSyncEnabled; } var isFullscreen = _context.Game.Window.Fullscreen; if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true)) { _context.Game.Window.Fullscreen = isFullscreen; } ImGui.EndMenu(); } if (_context.Game.Configuration.UseRenderDoc && ImGui.BeginMenu("RenderDoc")) { var renderDoc = Game.RenderDoc; if (ImGui.MenuItem("Trigger Capture")) { renderDoc.TriggerCapture(); } if (ImGui.BeginMenu("Options")) { bool allowVsync = renderDoc.AllowVSync; if (ImGui.Checkbox("Allow VSync", ref allowVsync)) { renderDoc.AllowVSync = allowVsync; } bool validation = renderDoc.APIValidation; if (ImGui.Checkbox("API Validation", ref validation)) { renderDoc.APIValidation = validation; } int delayForDebugger = (int)renderDoc.DelayForDebugger; if (ImGui.InputInt("Debugger Delay", ref delayForDebugger)) { delayForDebugger = Math.Clamp(delayForDebugger, 0, int.MaxValue); renderDoc.DelayForDebugger = (uint)delayForDebugger; } bool verifyBufferAccess = renderDoc.VerifyBufferAccess; if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess)) { renderDoc.VerifyBufferAccess = verifyBufferAccess; } bool overlayEnabled = renderDoc.OverlayEnabled; if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled)) { renderDoc.OverlayEnabled = overlayEnabled; } bool overlayFrameRate = renderDoc.OverlayFrameRate; if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate)) { renderDoc.OverlayFrameRate = overlayFrameRate; } bool overlayFrameNumber = renderDoc.OverlayFrameNumber; if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber)) { renderDoc.OverlayFrameNumber = overlayFrameNumber; } bool overlayCaptureList = renderDoc.OverlayCaptureList; if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList)) { renderDoc.OverlayCaptureList = overlayCaptureList; } ImGui.EndMenu(); } if (ImGui.MenuItem("Launch Replay UI")) { renderDoc.LaunchReplayUI(); } ImGui.EndMenu(); } DrawTimingControls(); var fpsText = $"{ImGui.GetIO().Framerate:N2} FPS"; var fpsTextSize = ImGui.CalcTextSize(fpsText).X; ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - fpsTextSize); ImGui.Text(fpsText); ImGui.EndMenuBar(); } foreach (var view in _views) { view.Draw(ref isGameViewFocused); } var launcherImage = _context.Game.LauncherImage; if (launcherImage != null) { var launcherImageMaxSize = new Vector2(150, 150); var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio( new SizeF(launcherImage.Width, launcherImage.Height), new Size((int)launcherImageMaxSize.X, (int)launcherImageMaxSize.Y)); const int launcherImagePadding = 10; ImGui.SetNextWindowPos(new Vector2( _context.Game.Window.ClientBounds.Width - launcherImageSize.Width - launcherImagePadding, menuBarHeight + launcherImagePadding)); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); ImGui.Begin("LauncherImage", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration); ImGui.Image( _context.ImGuiRenderer.GetOrCreateImGuiBinding(_context.Game.GraphicsDevice.ResourceFactory, launcherImage), new Vector2(launcherImageSize.Width, launcherImageSize.Height), Vector2.Zero, Vector2.One, Vector4.One, Vector4.Zero); ImGui.End(); ImGui.PopStyleVar(); } ImGui.End(); }
public void Draw(Sdl2Window window) { ImGui.SetNextWindowPos(Vector2.Zero, ImGuiCond.Always, Vector2.Zero); ImGui.SetNextWindowSize(new Vector2(window.Width, window.Height), ImGuiCond.Always); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0); bool open = false; ImGui.Begin("OpenSAGE Big Editor", ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize); var wasOpenClicked = false; if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Open...", "Ctrl+O", false, true)) { wasOpenClicked = true; } if (ImGui.MenuItem("Close", null, false, _bigArchive != null)) { OpenBigFile(null); } ImGui.Separator(); if (ImGui.MenuItem("Exit", "Alt+F4", false, true)) { Environment.Exit(0); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } const string openFilePopupId = "Open Big Archive##OpenBigArchive"; if (wasOpenClicked) { ImGui.OpenPopup(openFilePopupId); } bool fileOpenPopupOpen = true; if (ImGui.BeginPopupModal(openFilePopupId, ref fileOpenPopupOpen, ImGuiWindowFlags.AlwaysAutoResize)) { DrawOpenFileDialog(); ImGui.EndPopup(); } if (_bigArchive != null) { DrawFilesList(); ImGui.SameLine(); DrawFileContent(); } else { ImGui.Text("Open a .big file to see its contents here."); } ImGui.End(); ImGui.PopStyleVar(); }
protected override void DrawWindowElements() { if (ImGuiNative.igBeginPopupContextWindow(false, "Hierarchy Context Menu", 1)) { MainMenuBar.DrawCreateMenu(); ImGui.EndPopup(); } if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Create")) { MainMenuBar.DrawCreateMenu(); ImGui.EndMenu(); } ImGui.EndMenuBar(); } var indentLevel = 0; foreach (var gameObject in FindObjectsOfType <GameObject>()) { if (gameObject.transform.parent == null) { var tempQueue = new Stack <Queue <GameObject> >(); var gameObjectStacks = new Stack <Queue <GameObject> >(); var gameObjectQueue = new Queue <GameObject>(); gameObjectQueue.Enqueue(gameObject); gameObjectStacks.Push(gameObjectQueue); var currentStack = gameObjectStacks.Peek(); var currentObject = gameObjectQueue.Peek(); while (gameObjectStacks.Count > 0) { while (currentStack.Count > 0) { var min = new Vector2( ImGui.GetLastItemRectMin().X, ImGui.GetLastItemRectMax().Y); var max = new Vector2( ImGui.GetWindowContentRegionWidth(), ImGui.GetLastItemRectMax().Y + 5f); if (ImGui.IsMouseDragging(0, -1) && ImGui.IsMouseHoveringRect(min, max, false)) { Editor.hoveredObject = this; placeAbove = currentObject; ImGui.Separator(); //Gizmos.DrawRectangle( // new OpenTK.Vector2(min.X, min.Y), // new OpenTK.Vector2(max.X, max.Y), Color4.White, Color4.White); } var collapsed = false; var selected = Editor.selectedObject == currentObject || Editor.hoveredObject == currentObject; //ImGui.PushStyleColor(ColorTarget.HeaderHovered, Vector4.Zero); //ImGui.PushStyleColor(ColorTarget.HeaderActive, Vector4.Zero); //ImGui.PushStyleColor(ColorTarget.h, Vector4.Zero); if (selected) { ImGuiNative.igPushStyleColor( ColorTarget.Text, new Vector4(143f / 255f, 143f / 255f, 200f / 255f, 1f)); } var flags = TreeNodeFlags.OpenOnArrow; if (currentObject.transform.childCount <= 0) { flags |= TreeNodeFlags.Leaf; } if (selected) { flags |= TreeNodeFlags.Selected; } collapsed = ImGui.TreeNodeEx(currentObject.name, flags); if (selected) { ImGui.PopStyleColor(); } //ImGui.PopStyleColor(); if (ImGui.IsMouseDragging(0, -1) && Editor.draggedObject != null && ImGui.IsLastItemHoveredRect()) { Editor.hoveredObject = currentObject; } if (ImGui.IsLastItemActive() && ImGui.IsMouseDragging(0, -1)) { ImGui.SetTooltip(currentObject.name); Editor.draggedObject = currentObject; } if (ImGui.IsLastItemHovered() && ImGui.IsMouseClicked(0)) { Editor.selectedObject = currentObject; } if (ImGui.BeginPopupContextItem("GameObject Context Menu")) { if (ImGui.Selectable("Delete")) { ; // Object.Destroy(currentObject); } ImGui.EndPopup(); } if (collapsed) { ImGui.TreePop(); } if (collapsed && currentObject.transform.childCount > 0) { ImGuiNative.igIndent(); indentLevel++; currentStack.Dequeue(); tempQueue.Push(new Queue <GameObject>()); foreach (var child in currentObject.transform) { tempQueue.Peek().Enqueue(child.gameObject); } gameObjectStacks.Push(tempQueue.Peek()); currentStack = tempQueue.Peek(); currentObject = tempQueue.Peek().Peek(); } else { currentStack.Dequeue(); if (currentStack.Count > 0) { currentObject = currentStack.Peek(); } } } gameObjectStacks.Pop(); if (gameObjectStacks.Count > 0) { if (indentLevel > 0) { ImGuiNative.igUnindent(); indentLevel--; } currentStack = gameObjectStacks.Peek(); if (currentStack.Count > 0) { currentObject = currentStack.Peek(); } } } } for (var i = 0; i < indentLevel; ++i, --indentLevel) { ImGuiNative.igUnindent(); } } //if (m_DraggedObject != null) //{ // m_Dragging = true; // ImGui.SetTooltip(m_DraggedObject.name); // if (!ImGui.IsMouseDown(0) && m_DraggedObject != m_HoveringObject) // { // m_DraggedObject.transform.SetParent(m_HoveringObject?.transform); // ImGuiNative.igSetWindowFocus(); // m_Dragging = false; // } //} //else if (ImGui.IsWindowFocused()) // ImGui.SetTooltip(""); //if (!m_Dragging) // m_DraggedObject = null; }
public static void DrawUI(int width, int height, ref ViewportOptions options, GroupNode rootNode) { ImGui.SetNextWindowPos(System.Numerics.Vector2.Zero); ImGui.SetNextWindowSize(new System.Numerics.Vector2(250, 350)); bool opened = true; ImGui.Begin("Model Loader Window", ref opened, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Load Model", !loading)) { if (ImGui.MenuItem("Open")) { LoadModel(rootNode, options.ShowEnvironmentMap); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Options")) { ImGui.Checkbox("Dir Light Follow Camera", ref options.DirectionalLightFollowCamera); ImGui.SliderFloat("Dir Light Intensity", ref options.DirectionLightIntensity, 0, 1, "", ImGuiSliderFlags.ClampOnInput); ImGui.SliderFloat("Ambient Light Intensity", ref options.AmbientLightIntensity, 0, 1, "", ImGuiSliderFlags.ClampOnInput); ImGui.Separator(); ImGui.Checkbox("Show EnvironmentMap", ref options.ShowEnvironmentMap); ImGui.Checkbox("Enable SSAO", ref options.EnableSSAO); ImGui.Checkbox("Enable FXAA", ref options.EnableFXAA); ImGui.Checkbox("Enable Frustum", ref options.EnableFrustum); ImGui.Checkbox("Enable DpiScale", ref options.EnableDpiScale); if (ImGui.Checkbox("Show Wireframe", ref options.ShowWireframe)) { options.ShowWireframeChanged = true; } ImGui.Separator(); ImGui.ColorPicker3("Background Color", ref options.BackgroundColor); ImGui.EndMenu(); } if (!showImGuiDemo && ImGui.BeginMenu("ImGui Demo")) { if (ImGui.MenuItem("Show")) { showImGuiDemo = true; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (ImGui.CollapsingHeader("Mouse Gestures", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.Text("Mouse Right: Rotate"); ImGui.Text("Mouse Middle: Pan"); ImGui.Separator(); if (!string.IsNullOrEmpty(SomeTextFromOutside)) { ImGui.Text(SomeTextFromOutside); } } ImGui.Separator(); ImGui.Text("FPS"); ImGui.PlotLines("", ref fps[0], fps.Length, 0, $"{fps[currFPSIndex]}", 30, 70, new System.Numerics.Vector2(200, 50)); ImGui.Text("Rendering Latency Ms"); ImGui.PlotLines("", ref latency[0], latency.Length, 0, $"{latency[currFPSIndex]}ms", 0, 5, new System.Numerics.Vector2(200, 50)); fps[currFPSIndex] = 1000f / (float)options.Viewport.RenderHost.RenderStatistics.LatencyStatistics.AverageValue; latency[currFPSIndex] = (float)options.Viewport.RenderHost.RenderStatistics.LatencyStatistics.AverageValue; frustumTest[currFPSIndex] = (float)options.Viewport.RenderHost.RenderStatistics.FrustumTestTime * 1000; ImGui.Text("Frustum Test Ms"); ImGui.PlotLines("", ref frustumTest[0], frustumTest.Length, 0, $"{frustumTest[currFPSIndex]}ms", 0, 5, new System.Numerics.Vector2(200, 50)); currFPSIndex = (currFPSIndex + 1) % frameDataLength; if (!loading && ImGui.CollapsingHeader("Scene Graph", ImGuiTreeNodeFlags.DefaultOpen)) { DrawSceneGraph(rootNode); } if (!loading && scene != null && scene.Animations != null) { DrawAnimations(ref options); } if (!loading && !string.IsNullOrEmpty(exception)) { ImGui.Separator(); ImGui.Text(exception); } if (loading) { ImGui.Text($"Loading: {modelName}"); var progress = ((float)(Stopwatch.GetTimestamp() - currentTime) / Stopwatch.Frequency) * 100 % 100; ImGui.ProgressBar(progress / 100, new System.Numerics.Vector2(width, 20), ""); } ImGui.End(); if (showImGuiDemo) { opened = false; ImGui.ShowDemoWindow(ref showImGuiDemo); } }
public override void OnImGuiRender() { var windowFlags = ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoBringToFrontOnFocus; var dockspaceFlags = ImGuiDockNodeFlags.PassthruCentralNode; var io = ImGui.GetIO(); ImGui.SetMouseCursor(ImGui.IsAnyItemHovered() ? ImGuiMouseCursor.Hand : ImGuiMouseCursor.Arrow); if (useDocking) { ImGuiViewportPtr viewport = ImGui.GetMainViewport(); ImGui.SetNextWindowPos(viewport.Pos); ImGui.SetNextWindowSize(viewport.Size); ImGui.SetNextWindowViewport(viewport.ID); //ImGui.SetNextWindowBgAlpha(0); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); ImGui.Begin("Dockspace", ref dockspaceOpen, windowFlags); ImGui.PopStyleVar(); ImGui.PopStyleVar(); ImGui.PopStyleVar(); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 2.0f); } if (io.ConfigFlags.HasFlag(ImGuiConfigFlags.DockingEnable)) { var dockspaceID = ImGui.GetID("MyDockSpace"); ImGui.DockSpace(dockspaceID, Vector2.Zero, dockspaceFlags); } if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Close")) { app.OnEvent(new WindowCloseEvent()); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Window")) { if (ImGui.MenuItem("ImGui Demo", "", showDemoWindow)) { showDemoWindow = !showDemoWindow; } if (ImGui.MenuItem("Viewport", "", showViewportWindow)) { showViewportWindow = !showViewportWindow; } if (ImGui.MenuItem("Console", "", showConsoleWindow)) { showConsoleWindow = !showConsoleWindow; } if (ImGui.MenuItem("Debug", "", showDebugWindow)) { showDebugWindow = !showDebugWindow; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } // Viewport Window if (showViewportWindow) { ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); ImGui.Begin("Viewport", ref showViewportWindow); viewportSize = ImGui.GetContentRegionAvail(); int textureId = framebuffer.colorAttachment; ImGui.Image((IntPtr)textureId, viewportSize); ImGui.PopStyleVar(); ImGui.End(); } //Debug Window if (showDebugWindow) { ImGui.Begin("Debug", ref showDebugWindow); ImGui.Text("Renderer Info:"); ImGui.Text("Vendor: " + vendorString); ImGui.Text("Renderer: " + rendererString); ImGui.Text("Version: " + versionString); ImGui.Text($"Frame Time: {io.DeltaTime * 1000:F}ms"); ImGui.Text($"FPS: {1 / io.DeltaTime:F}"); ImGui.Separator(); ImGui.Text("Window Info:"); ImGui.Text("Title: " + app.GetWindow().Title); ImGui.Text("Width: " + app.GetWindow().Width); ImGui.Text("Height: " + app.GetWindow().Height); ImGui.Checkbox("VSync", ref (app.GetWindow().GetNativeWindow() as WindowsWindow).VSync); ImGui.Separator(); string[] cameras = { "Orthographic", "Perspective" }; ImGui.Text("Camera:"); ImGui.Combo("Selected Camera", ref selectedCameraIndex, cameras, cameras.Length); //selectedCamera = selectedCameraIndex == 0 ? orthoCamera : (Camera)persCamera; // Camera Position Float3 { ImGui.Text("Camera Position"); var hovered = ImGui.IsItemHovered(); if (hovered) { ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); } Vector3 pos = new Vector3(orthoCamera.Position.X, orthoCamera.Position.Y, orthoCamera.Position.Z); ImGui.DragFloat3("#position", ref pos, 0.1f); if (hovered && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left)) { orthoCamera.Position = new OpenTK.Mathematics.Vector3(0, 0, -1); } else { orthoCamera.Position = new OpenTK.Mathematics.Vector3(pos.X, pos.Y, pos.Z); } } { ImGui.Text("Camera Rotation"); var hovered = ImGui.IsItemHovered(); if (hovered) { ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); } Vector3 rot = new Vector3(orthoCamera.Rotation.X, orthoCamera.Rotation.Y, orthoCamera.Rotation.Z); ImGui.DragFloat3("#rotation", ref rot, 0.1f); if (hovered && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left)) { orthoCamera.Rotation = new OpenTK.Mathematics.Vector3(0, 0, 0); } else { orthoCamera.Rotation = new OpenTK.Mathematics.Vector3(rot.X, rot.Y, rot.Z); } } ImGui.DragFloat("Camera Speed", ref orthoCamera.Speed, 0.1f); ImGui.Checkbox("Enable deltaTime", ref EnableDeltaTime); ImGui.Separator(); ImGui.Text("Square:"); ImGui.DragFloat3("Square Position", ref squarePos, 0.1f); ImGui.DragFloat("Square Speed", ref squareSpeed, 0.1f); ImGui.Separator(); var clearColor = Renderer.GetClearColor(); ImGui.ColorPicker4("Clear Color", ref clearColor); Renderer.SetClearColor(clearColor); ImGui.End(); } //Console Window if (showConsoleWindow) { ImGui.Begin("Console", ref showConsoleWindow); if (ImGui.Button("Clear")) { Logger.Logs.Clear(); } foreach (var log in Logger.Logs) { Vector4 col = Vector4.One; switch (log.Severity) { case Severity.Info: col = Vector4.One; break; case Severity.Warn: col = new Vector4(251f / 255f, 195f / 255f, 42 / 255f, 1); break; case Severity.Error: col = new Vector4(255, 0, 0, 1); break; } ImGui.Text(log.Time.ToString(Logger.format)); ImGui.SameLine(); ImGui.TextColored(col, $"[{log.Severity}]"); ImGui.SameLine(); ImGui.Text(log.Message); } ImGui.End(); } if (showDemoWindow) { ImGui.ShowDemoWindow(ref showDemoWindow); } //Dockspace End if (useDocking) { ImGui.PopStyleVar(); ImGui.End(); } }
/// <summary> /// Create the GUI components. /// Example at https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp /// </summary> /// <param name="samplesByCategory">Sample ordered list to load into sample tree.</param> private void ImGuiLayout(SortedList <string, List <TGCSample> > samplesByCategory) { ImGui.SetNextWindowPos(new NumericVector2(0, 0)); ImGui.SetNextWindowSize(new NumericVector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 6f, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - 100)); ImGui.Begin("TGC samples explorer", ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoMove); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Close", "Ctrl+W")) { Game.Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("View")) { if (ImGui.MenuItem("Full screen")) { Game.Graphics.ToggleFullScreen(); } ImGui.Separator(); if (ImGui.MenuItem("FPS")) { /* Do stuff */ } if (ImGui.MenuItem("Cartesian axes")) { /* Do stuff */ } if (ImGui.MenuItem("Fixed render loop")) { /* Do stuff */ } if (ImGui.MenuItem("Wireframe")) { /* Do stuff */ } ImGui.Separator(); if (ImGui.MenuItem("Reset view setting")) { /* Do stuff */ } ImGui.EndMenu(); } if (ImGui.BeginMenu("Tools")) { if (ImGui.MenuItem("Settings")) { /* Do stuff */ } ImGui.EndMenu(); } if (ImGui.BeginMenu("Help")) { if (ImGui.MenuItem("Documentation")) { /* Do stuff */ } if (ImGui.MenuItem("About")) { AboutVisible = !AboutVisible; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (ImGui.CollapsingHeader("TGCLogoSample information", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.Text("Name: " + ActiveSample.Name); ImGui.TextWrapped("Description: " + ActiveSample.Description); ImGui.TextWrapped( $"Application average {1000f / ImGui.GetIO().Framerate:F3} ms/frame ({ImGui.GetIO().Framerate:F1} FPS)"); } if (ImGui.CollapsingHeader("Samples", ImGuiTreeNodeFlags.DefaultOpen)) { var i = 0; foreach (var entry in samplesByCategory) { if (ImGui.TreeNode(entry.Key)) { var j = 0; foreach (var sample in entry.Value) { var nodeFlags = ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.Bullet; if (ActiveSampleCategoryIndex == i && ActiveSampleTreeNode == j) { nodeFlags |= ImGuiTreeNodeFlags.Selected; } ImGui.TreeNodeEx(new IntPtr(j), nodeFlags, sample.Name); if (ImGui.IsItemClicked()) { ActiveSampleCategoryIndex = i; ActiveSampleTreeNode = j; LoadSample(sample.Name); } j++; } ImGui.TreePop(); } i++; } } if (AboutVisible) { ShowAboutWindow(); } ImGui.End(); }
public override void Draw() { if (ImGui.BeginPopupModal("Choose Path")) { ImGui.Text("Enter path:\n\n"); ImGui.InputText("###ScratchPathInput", ref this.pathInput, 1000); if (ImGui.Button("OK", new Vector2(120, 0))) { ImGui.CloseCurrentPopup(); this.watcher.Load(this.pathInput); this.pathInput = string.Empty; } ImGui.SetItemDefaultFocus(); ImGui.SameLine(); if (ImGui.Button("Cancel", new Vector2(120, 0))) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Load & Watch")) { ImGui.OpenPopup("Choose Path"); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } var flags = ImGuiTabBarFlags.Reorderable | ImGuiTabBarFlags.TabListPopupButton | ImGuiTabBarFlags.FittingPolicyScroll; if (ImGui.BeginTabBar("ScratchDocTabBar", flags)) { if (ImGui.TabItemButton("+", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip)) { this.documents.Add(new ScratchpadDocument()); } var docs = this.documents.Concat(this.watcher.TrackedScratches).ToArray(); for (var i = 0; i < docs.Length; i++) { var isOpen = true; if (ImGui.BeginTabItem(docs[i].Title + (docs[i].HasUnsaved ? "*" : string.Empty) + "###ScratchItem" + i, ref isOpen)) { if (ImGui.InputTextMultiline("###ScratchInput" + i, ref docs[i].Content, 20000, new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput)) { docs[i].HasUnsaved = true; } ImGuiHelpers.ScaledDummy(3); if (ImGui.Button("Compile & Reload")) { docs[i].Status = this.Execution.RenewScratch(docs[i]); } ImGui.SameLine(); if (ImGui.Button("Dispose all")) { this.Execution.DisposeAllScratches(); } ImGui.SameLine(); if (ImGui.Button("Dump processed code")) { try { var code = this.Execution.MacroProcessor.Process(docs[i].Content); Log.Information(code); ImGui.SetClipboardText(code); } catch (Exception ex) { Log.Error(ex, "Could not process macros"); } } ImGui.SameLine(); if (ImGui.Button("Toggle Log")) { this.dalamud.DalamudUi.ToggleLog(); } ImGui.SameLine(); ImGui.Checkbox("Use Macros", ref docs[i].IsMacro); ImGui.SameLine(); switch (docs[i].Status) { case ScratchLoadStatus.Unknown: ImGui.TextColored(ImGuiColors.DalamudGrey, "Compile scratch to see status"); break; case ScratchLoadStatus.FailureCompile: ImGui.TextColored(ImGuiColors.DalamudRed, "Error during compilation"); break; case ScratchLoadStatus.FailureInit: ImGui.TextColored(ImGuiColors.DalamudRed, "Error during init"); break; case ScratchLoadStatus.Success: ImGui.TextColored(ImGuiColors.HealerGreen, "OK!"); break; default: throw new ArgumentOutOfRangeException(); } ImGui.SameLine(); ImGui.TextColored(ImGuiColors.DalamudGrey, docs[i].Id.ToString()); ImGui.EndTabItem(); } } ImGui.EndTabBar(); } }
protected override void DrawWindowContent() { bool resetView = false; bool openRename = false; if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("View", Context.Scene != null)) { if (ImGui.MenuItem("Reset")) { resetView = true; } ImGui.EndMenu(); } if (ImGui.BeginMenu("Image", Context.Scene != null)) { if (ImGui.MenuItem("Load")) { LoadAsset(); } if (ImGui.MenuItem("Unload", SelectedTextureAsset != null)) { UnloadAsset(); } ImGui.Separator(); if (ImGui.MenuItem("Rename", SelectedTextureAsset != null)) { openRename = true; } ImGui.EndMenu(); } ImGui.PushItemWidth(256); PropertyDrawer.DrawEditorValue(this.GetType().GetField(nameof(SelectedTextureAsset)), this); ImGui.PopItemWidth(); ImGui.EndMenuBar(); } if (openRename) { ImGui.OpenPopup("renameasset"); } if (ImGui.BeginPopup("renameasset")) { byte[] bytes = new byte[256]; Encoding.UTF8.GetBytes(SelectedTextureAsset.Name).CopyTo(bytes, 0); ImGui.Text("Rename"); if (ImGui.InputText("New name", bytes, (uint)bytes.Length)) { ; } { // ! always trim end null bytes!!! string text = Encoding.UTF8.GetString(bytes).TrimEnd('\0'); SelectedTextureAsset.Name = text; } ImGui.EndPopup(); } if (SelectedTextureAsset != null) { //ImGui.SetCursorPos(WindowSize / 2 - currentTexture.Texture.Size / 2); var zoomedImageSize = SelectedTextureAsset.Texture.Size * zoom; if (zoomedImageSize.X < WindowSize.X && zoomedImageSize.Y < WindowSize.Y) { ImGui.SetCursorPos((WindowSize - zoomedImageSize) * 0.5f); } ImGui.PushStyleColor(ImGuiCol.Button, 0xff000000); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xff000000); ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xff000000); ImGui.ImageButton(new IntPtr(SelectedTextureAsset.Texture.ID), SelectedTextureAsset.Texture.Size * zoom, new Vector2(0, 1), new Vector2(1, 0), 0); ImGui.PopStyleColor(3); bool imageHovered = ImGui.IsItemHovered(); if (resetView) { ResetView(); } if (viewPos.X != ImGui.GetScrollX() + WindowSize.X / 2 || viewPos.Y != ImGui.GetScrollY() + WindowSize.Y / 2) { viewPos.X = ImGui.GetScrollX() + WindowSize.X / 2; viewPos.Y = ImGui.GetScrollY() + WindowSize.Y / 2; } if (imageHovered) { MouseMove(); //var io = ImGui.GetIO(); //float my_tex_w = SelectedTextureAsset.Texture.Width; //float my_tex_h = SelectedTextureAsset.Texture.Height; //Vector2 pos = ImGui.GetCursorScreenPos(); //ImGui.BeginTooltip(); //float region_sz = 32.0f; //float region_x = io.MousePos.X - pos.X - region_sz * 0.5f; //float region_y = io.MousePos.Y - pos.Y - region_sz * 0.5f; //float zoom = 4.0f; //if (region_x < 0.0f) { region_x = 0.0f; } //else if (region_x > my_tex_w - region_sz) { region_x = my_tex_w - region_sz; } //if (region_y < 0.0f) { region_y = 0.0f; } //else if (region_y > my_tex_h - region_sz) { region_y = my_tex_h - region_sz; } //ImGui.Text($"Min: ({region_x:F2}, {region_y:F2})"); //ImGui.Text($"Max: ({region_x + region_sz:F2}, {region_y + region_sz:F2})"); //Vector2 uv0 = new Vector2((region_x) / my_tex_w, (region_y) / my_tex_h); //Vector2 uv1 = new Vector2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h); //ImGui.Image(new IntPtr(SelectedTextureAsset.Texture.ID), new Vector2(region_sz * zoom, region_sz * zoom), uv0, uv1); //ImGui.EndTooltip(); } else { // correct image pos ImGui.SetScrollX(viewPos.X - WindowSize.X / 2); ImGui.SetScrollY(viewPos.Y - WindowSize.Y / 2); } if (ImGui.IsWindowHovered()) { MouseZoom(); } } }
protected override void DrawWindowContent() { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("View")) { if (ImGui.BeginMenu("Mode")) { PropertyDrawer.DrawEditorValue(typeof(ViewportPanel).GetMember(nameof(ViewportPanel.ProjectioMode))[0], this); if (CurrentCamera != null) { PropertyDrawer.DrawEditorValue(typeof(ViewportPanel).GetMember(nameof(ViewportPanel.CurrentCamera))[0], this); } ImGui.EndMenu(); } ImGui.Separator(); if (ImGui.MenuItem("Focus")) { if (Context.ActiveEntity?.Transform != null) { CurrentCamera.Position = Context.ActiveEntity.Transform.Position; } } ImGui.Separator(); if (ImGui.MenuItem("Reset")) { CurrentCamera.Position = new Vector3(0, 0, 0); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (Context.Scene != null) { // resize check { Vector2 viewportPanelSize = ImGui.GetContentRegionAvail(); if (viewportPanelSize != viewportSize && viewportPanelSize.X > 0 && viewportPanelSize.Y > 0) { viewportSize = viewportPanelSize; pipeline.Framebuffer.Resize((uint)viewportSize.X, (uint)viewportSize.Y); CurrentCamera.Resize(viewportSize.X, viewportSize.Y); } } // draw the framebuffer as image ImGui.Image(new IntPtr(pipeline.Framebuffer.ColorAttachments[pipeline.FbStructureIndex.Color]), viewportSize, new Vector2(0, 1), new Vector2(1, 0)); pipeline.Framebuffer.Bind(); Renderer.Clear(); pipeline.Framebuffer.ClearAttachment((uint)pipeline.FbStructureIndex.Id, 0); // interaction if (ImGui.IsItemHovered() && Focused) { // camera var io = ImGui.GetIO(); if (io.MouseWheel != 0) { CurrentCamera?.Zoom(io.MouseWheel); } if (ImGui.IsMouseDown(ImGuiMouseButton.Middle)) { if ((io.KeyMods & ImGuiKeyModFlags.Shift) > 0) { CurrentCamera?.Pan(io.MouseDelta * new Vector2(-1, 1)); } else { CurrentCamera?.Move(io.MouseDelta * new Vector2(-1, 1)); } } // selection else if (EnableSelect && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { Vector2 texpos = ImGui.GetMousePos() - new Vector2(WindowContentAreaMin.X, WindowContentAreaMax.Y); texpos.Y = -texpos.Y; int result = pipeline.Framebuffer.ReadPixel((uint)Context.Scene.Pipeline.FbStructureIndex.Id, (int)texpos.X, (int)texpos.Y); EditorApplication.Log.Trace($"selected entity id {result}"); Context.ActiveEntity = Context.Scene.GetEntity(result); } } // draw Context.Scene.Pipeline = pipeline; if (CurrentCamera != null) { Context.Scene.OnRenderEditor(CurrentCamera.ViewProjectionMatrix); } Framebuffer.Unbind(); } }
private void DrawMainUi(ref bool isGameViewFocused) { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Installation")) { foreach (var installation in _installations) { if (ImGui.MenuItem(installation.Game.DisplayName, null, _selectedInstallation == installation, true)) { ChangeInstallation(installation); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Preferences")) { bool isVSyncEnabled = _isVSyncEnabled; if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true)) { SetVSync(isVSyncEnabled); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } ImGui.BeginChild("sidebar", new Vector2(250, 0), true, 0); if (_launcherImage != null) { var availableSize = ImGui.GetContentRegionAvail(); var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio( new SizeF(_launcherImage.Width, _launcherImage.Height), new Size((int)availableSize.X, (int)availableSize.Y)); ImGui.Image( _imGuiRenderer.GetOrCreateImGuiBinding(_gameWindow.GraphicsDevice.ResourceFactory, _launcherImage), new Vector2(launcherImageSize.Width, launcherImageSize.Height), Vector2.Zero, Vector2.One, Vector4.One, Vector4.Zero); } ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FilePath, i == _currentFile)) { _currentFile = i; RemoveAndDispose(ref _contentView); _game.ContentManager.Unload(); _contentView = AddDisposable(new ContentView( new Views.AssetViewContext(_game, _gamePanel, _imGuiRenderer, entry))); } ImGuiUtility.DisplayTooltipOnHover(entry.FilePath); } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_contentView != null) { ImGui.BeginChild("content"); ImGui.Text(_contentView.DisplayName); if (isGameViewFocused) { var message = "Press [ESC] to unfocus the 3D view."; ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(message).X); ImGui.TextColored(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), message); } ImGui.BeginChild("content view"); _contentView.Draw(ref isGameViewFocused); ImGui.EndChild(); ImGui.EndChild(); } }
public void Draw(Sdl2Window window) { ImGui.SetNextWindowPos(Vector2.Zero, ImGuiCond.Always, Vector2.Zero); ImGui.SetNextWindowSize(new Vector2(window.Width, window.Height), ImGuiCond.Always); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0); bool open = false; ImGui.Begin("OpenSAGE Big Editor", ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize); var wasOpenClicked = false; var wasExportAllClicked = false; var wasImportFilesClicked = false; var wasImportFileClicked = false; if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Open...", "Ctrl+O", false, true)) { wasOpenClicked = true; } if (ImGui.MenuItem("Close", null, false, _bigArchive != null)) { OpenBigFile(null); } ImGui.Separator(); if (ImGui.MenuItem("Exit", "Alt+F4", false, true)) { Environment.Exit(0); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Edit")) { if (ImGui.MenuItem("Export All", "Ctrl+E", false, _bigArchive != null)) { wasExportAllClicked = true; } ImGui.Separator(); if (ImGui.MenuItem("Import Files", "Ctrl+Shift+I", false, _bigArchive != null)) { wasImportFilesClicked = true; } if (ImGui.MenuItem("Import File...", "Ctrl+I", false, _bigArchive != null)) { wasImportFileClicked = true; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (wasOpenClicked) { var openDialog = new OpenFileDialog("Open .big file"); openDialog.Open(result => OpenBigFile(result.FileName), "Big archive(*.big) | *.big"); } if (wasExportAllClicked) { var dirDialog = new DirectoryDialog("Select folder for export files"); dirDialog.Open(result => Export(result.FileName)); } if (wasImportFilesClicked) { var dirDialog = new DirectoryDialog("Select folder for import files"); dirDialog.Open(result => Import(result.FileName)); } if (wasImportFileClicked) { var openDialog = new OpenFileDialog("Select file which you want to import"); openDialog.Open(result => ImportFile(result.FileName)); } if (_bigArchive != null) { ImGui.BeginChild("body", new Vector2(0, -36), false, 0); DrawFilesList(new Vector2(window.Width, window.Height)); ImGui.SameLine(); DrawFileContent(); ImGui.EndChild(); // end body DrawStatusPanel(); } else { ImGui.Text("Open a .big file to see its contents here."); } ImGui.End(); ImGui.PopStyleVar(); }
/// <summary>Draws this instance.</summary> public override void Draw() { windowPos = viewportPtr.Pos + extraWindowPos; windowSize = viewportPtr.Size - extraWindowSize; ImGui.SetNextWindowPos(windowPos); ImGui.SetNextWindowSize(windowSize); ImGui.SetNextWindowViewport(viewportPtr.ID); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0.0f); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0.0f, 0.0f)); bool open = true; ImGui.Begin("DockSpace", ref open, windowFlags); ImGui.PopStyleVar(); ImGui.PopStyleVar(2); uint dockspaceid = ImGui.GetID("MyDockSpace"); ImGui.DockSpace(dockspaceid, new Vector2(0.0f, 0.0f), dockspaceFlags); var buttonDefault = ImGui.GetStyle().Colors[(int)ImGuiCol.Button]; buttonPressed = new Vector4(0.078f, 0.095f, 0.108f, 1.000f); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0)); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f); if (ImGui.BeginMenuBar()) { ImGui.PushStyleColor(ImGuiCol.Button, (button[0] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.MOUSEPOINTER, new System.Numerics.Vector2(30, 0))) { ClickButton(0); } ImGui.PopStyleColor(); ImGui.PushStyleColor(ImGuiCol.Button, (button[1] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.HANDPAPERO, new System.Numerics.Vector2(30, 0))) { ClickButton(1); } ImGui.PopStyleColor(); ImGui.PushStyleColor(ImGuiCol.Button, (button[2] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.ARROWS, new System.Numerics.Vector2(30, 0))) { ClickButton(2); } ImGui.PopStyleColor(); ImGui.PushStyleColor(ImGuiCol.Button, (button[3] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.RETWEET, new System.Numerics.Vector2(30, 0))) { ClickButton(3); } ImGui.PopStyleColor(); ImGui.PushStyleColor(ImGuiCol.Button, (button[4] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.EXPAND, new System.Numerics.Vector2(30, 0))) { ClickButton(4); } ImGui.PopStyleColor(); ImGui.PushStyleColor(ImGuiCol.Button, (button[5] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.ARROWSALT, new System.Numerics.Vector2(30, 0))) { ClickButton(5); } ImGui.PopStyleColor(); ImGui.SameLine((ImGui.GetWindowSize().X / 2) - 50); ImGui.PushStyleColor(ImGuiCol.Button, (button[6] == 1) ? buttonPressed : buttonDefault); if (ImGui.Button(Icon.PLAY, new Vector2(30, 0))) { ClickButton(6); } ImGui.PopStyleColor(); ImGui.EndMenuBar(); } ImGui.PopStyleVar(2); ImGui.End(); }