diff --git a/src/ArchiveEditor.cs b/src/ArchiveEditor.cs index f34d3a0..9c0b540 100644 --- a/src/ArchiveEditor.cs +++ b/src/ArchiveEditor.cs @@ -9,7 +9,7 @@ namespace MapStudio.UI { - public class ArchiveEditor + internal class ArchiveEditor { public static void Load(IArchiveFile file, NodeBase root) { diff --git a/src/DockedWindows/Animation/AnimationGraphWindow.cs b/src/DockedWindows/Animation/AnimationGraphWindow.cs index 8859952..b07a08b 100644 --- a/src/DockedWindows/Animation/AnimationGraphWindow.cs +++ b/src/DockedWindows/Animation/AnimationGraphWindow.cs @@ -107,14 +107,6 @@ private void Init() this.Opened = true; } - public void ClearNodes() { - AnimationHierarchy.TreeView.Nodes.Clear(); - } - - public void AddNode(TreeNode node) { - AnimationHierarchy.TreeView.Nodes.Add(node); - } - public void ResetAnimations() { AnimationPlayer.Reset(); diff --git a/src/DockedWindows/Animation/DopeSheetEditor.cs b/src/DockedWindows/Animation/DopeSheetEditor.cs index 0f6c138..1ac1cfb 100644 --- a/src/DockedWindows/Animation/DopeSheetEditor.cs +++ b/src/DockedWindows/Animation/DopeSheetEditor.cs @@ -194,8 +194,8 @@ private void DrawDopeSheet(UIFramework.TreeNode node, ref float cursorPosY) { if (node is TrackNodeVisibility) DrawVisSheet((TrackNodeVisibility)node, cursorPosY); - if (node is TextureTrackNode) - DrawTexSheet((TextureTrackNode)node, cursorPosY); + // if (node is TextureTrackNode) + // DrawTexSheet((TextureTrackNode)node, cursorPosY); //Draw the dope sheet according to the tree hiearchy if (node is AnimationTree.TrackNode) diff --git a/src/DockedWindows/AssetWindow/AssetViewWindow.cs b/src/DockedWindows/AssetWindow/AssetViewWindow.cs index d5d2d89..d262cf6 100644 --- a/src/DockedWindows/AssetWindow/AssetViewWindow.cs +++ b/src/DockedWindows/AssetWindow/AssetViewWindow.cs @@ -13,7 +13,6 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using Toolbox.Core.ViewModels; namespace MapStudio.UI { @@ -41,9 +40,7 @@ public class AssetViewWindow : DockWindow public AssetItem SelectedAsset { get { return selectedAsset; } - set { - selectedAsset = value; - } + set { selectedAsset = value; } } private AssetItem selectedAsset = null; @@ -63,8 +60,6 @@ public AssetItem SelectedAsset private IAssetLoader ActiveCategory = null; private IAssetViewFileTypeList FileTypeList = null; - public Action SelectionChanged; - public AssetViewWindow(DockSpaceWindow parent) : base(parent) { //Defaults @@ -408,17 +403,6 @@ private void DrawListView() ImGui.EndGroup(); - if (isSelected && obj.ContextMenus.Count > 0) - { - if (ImGui.BeginPopupContextItem("##ASSET_POPUP", ImGuiPopupFlags.MouseButtonRight)) - { - foreach (var menuItem in obj.ContextMenus) - ImGuiHelper.LoadMenuItem(menuItem); - - ImGui.EndPopup(); - } - } - ImGui.SetCursorPos(pos); bool select = ImGui.Selectable($"##{obj.Name}", isSelected, ImGuiSelectableFlags.AllowItemOverlap, itemSize); @@ -449,12 +433,8 @@ private void DrawListView() } if (select) { - if (selectedAsset != obj) - { - selectedAsset = obj; - SelectionChanged?.Invoke(); - } - } + selectedAsset = obj; + } if (isDoubleClicked) doubleClickedAsset = obj; @@ -681,17 +661,10 @@ public class AssetItem /// public string[] Categories { get; set; } - /// - /// - /// - public List ContextMenus = new List(); - public bool Favorited = false; public object Tag { get; set; } - public Action PropertyUI = null; - public string DisplayName { get; internal set; } /// diff --git a/src/DockedWindows/Console/ConsoleWindow.cs b/src/DockedWindows/Console/ConsoleWindow.cs index 1fcf287..f1f7055 100644 --- a/src/DockedWindows/Console/ConsoleWindow.cs +++ b/src/DockedWindows/Console/ConsoleWindow.cs @@ -55,11 +55,8 @@ public override void Render() if (!string.IsNullOrEmpty(info)) WriteText(info); - ImGuiHelper.BeginBoldText(); if (displayErrors) WriteText(StudioLogger.GetErrorLog(), ThemeHandler.Theme.Error); if (displayWarnings) WriteText(StudioLogger.GetWarningLog(), ThemeHandler.Theme.Warning); - ImGuiHelper.EndBoldText(); - if (displayInfo) WriteText(StudioLogger.GetLog()); ImGui.EndChild(); diff --git a/src/DockedWindows/Outliner/Outliner.cs b/src/DockedWindows/Outliner/Outliner.cs index ec84174..df0cc92 100644 --- a/src/DockedWindows/Outliner/Outliner.cs +++ b/src/DockedWindows/Outliner/Outliner.cs @@ -31,10 +31,9 @@ public class Outliner : DockWindow public NodeBase SelectedNode => SelectedNodes.LastOrDefault(); - public void AddSelection(NodeBase node, bool change_event = true) { + public void AddSelection(NodeBase node) { SelectedNodes.Add(node); - if (change_event) - SelectionChanged?.Invoke(node, EventArgs.Empty); + SelectionChanged?.Invoke(node, EventArgs.Empty); } public void RemoveSelection(NodeBase node) { @@ -320,20 +319,11 @@ private void CalculateCount(NodeBase node, ref int counter) CalculateCount(c, ref counter); } - public void DeselectAllButNode(NodeBase n) - { - foreach (var node in SelectedNodes) - if (node != n) - node.IsSelected = false; - SelectedNodes.Clear(); - } - public void DeselectAll() { foreach (var node in SelectedNodes) node.IsSelected = false; SelectedNodes.Clear(); - SelectionChanged?.Invoke(null, EventArgs.Empty); } public void DrawNode(NodeBase node, float itemHeight, int level = 0) @@ -374,7 +364,7 @@ public void DrawNode(NodeBase node, float itemHeight, int level = 0) //Node was selected manually outside the outliner so update the list if (node.IsSelected && !SelectedNodes.Contains(node)) - AddSelection(node, false); + AddSelection(node); //Node was deselected manually outside the outliner so update the list if (!node.IsSelected && SelectedNodes.Contains(node)) diff --git a/src/DockedWindows/Properties/PropertyWindow.cs b/src/DockedWindows/Properties/PropertyWindow.cs index c895724..b488732 100644 --- a/src/DockedWindows/Properties/PropertyWindow.cs +++ b/src/DockedWindows/Properties/PropertyWindow.cs @@ -34,11 +34,6 @@ public override void Render() public void Render(AssetItem asset) { - if (asset.PropertyUI != null) - { - asset.PropertyUI.Invoke(); - } - if (asset.Tag != null) ImguiBinder.LoadProperties(asset.Tag, (sender, e) => { diff --git a/src/DockedWindows/Viewport/Pipeline.cs b/src/DockedWindows/Viewport/Pipeline.cs index 2540276..5ed1ef2 100644 --- a/src/DockedWindows/Viewport/Pipeline.cs +++ b/src/DockedWindows/Viewport/Pipeline.cs @@ -154,43 +154,6 @@ public void AddFile(FileEditor editor, string name) }); } - public Image SaveAsScreenshot(Framebuffer outputBuffer, Camera camera, int width, int height, bool useAlpha = false) - { - var cam = _context.Camera; - - _context.UpdateViewport = true; - - //Resize the current viewport - Width = camera.Width; - Height = camera.Height; - - this.OnResize(outputBuffer); - - _context.Camera = camera; - - if (_context.SceneRender != null) - { - _context.SceneRender.Render(_context, outputBuffer); - } - else - { - RenderScene(new RenderFrameArgs() - { - DisplayAlpha = useAlpha, - DisplayBackground = !useAlpha, - DisplayOrientationGizmo = false, - DisplayGizmo = false, - DisplayCursor3D = false, - DisplayFloor = false, - }, outputBuffer); - } - - _context.UpdateViewport = true; - _context.Camera = cam; - - return outputBuffer.ReadImagePixels(useAlpha); - } - public Image SaveAsScreenshot(Framebuffer outputBuffer, int width, int height, bool useAlpha = false) { _context.UpdateViewport = true; @@ -207,6 +170,7 @@ public Image SaveAsScreenshot(Framebuffer outputBuffer, int width, int h } else { + RenderScene(new RenderFrameArgs() { DisplayAlpha = useAlpha, @@ -296,11 +260,6 @@ public void RenderScene(RenderFrameArgs frameArgs, Framebuffer outputBuffer) SetViewport(); - - //Background - if (frameArgs.DisplayBackground) - _background.Draw(_context, Pass.OPAQUE); - DrawSceneNoPostEffects(); _context.CurrentShader = null; @@ -313,6 +272,11 @@ public void RenderScene(RenderFrameArgs frameArgs, Framebuffer outputBuffer) _context.Scene.ShadowRenderer.DrawDebugShadowPrePass(_context); _context.Scene.ShadowRenderer.DrawDebugQuad(_context); } + + //Background + if (frameArgs.DisplayBackground) + _background.Draw(_context, Pass.OPAQUE); + //Draw ui _context.UIDrawer.Render(_context); diff --git a/src/DockedWindows/Viewport/Viewport.cs b/src/DockedWindows/Viewport/Viewport.cs index e90f6de..bf2f5e3 100644 --- a/src/DockedWindows/Viewport/Viewport.cs +++ b/src/DockedWindows/Viewport/Viewport.cs @@ -94,11 +94,6 @@ public Image SaveAsScreenshot(int width, int height, bool alpha = false) return Viewports[0].SaveAsScreenshot(Pipeline, width, height, alpha); } - public Image SaveAsScreenshot(Camera camera, int width, int height, bool alpha = false) - { - return Viewports[0].SaveAsScreenshot(Pipeline, camera, width, height, alpha); - } - private void SetScreenLayoutDefault() { Viewports.Clear(); @@ -753,6 +748,5 @@ private void EnterSelectionMode() Pipeline._context.TransformTools.UpdateTransformMode(TransformEngine.TransformActions.Translate); ReloadMenus(); - } - } + } } } diff --git a/src/DockedWindows/Viewport/ViewportScreen.cs b/src/DockedWindows/Viewport/ViewportScreen.cs index 32f3c2f..e252343 100644 --- a/src/DockedWindows/Viewport/ViewportScreen.cs +++ b/src/DockedWindows/Viewport/ViewportScreen.cs @@ -63,7 +63,7 @@ public void RenderViewportDisplay(ViewportRenderer Pipeline) //Store the focus state for handling key events IsFocused = ImGui.IsWindowFocused(); - if (ImGui.IsMouseClicked(ImGuiMouseButton.Right) && ImGui.IsWindowHovered() && !IsFocused) + if (ImGui.IsAnyMouseDown() && ImGui.IsWindowHovered() && !IsFocused) { IsFocused = true; ImGui.FocusWindow(ImGui.GetCurrentWindow()); @@ -129,7 +129,7 @@ public void RenderViewportDisplay(ViewportRenderer Pipeline) { Pipeline._context.CurrentMousePoint = new OpenTK.Vector2(mouseInfo.X, mouseInfo.Y); Pipeline._context.Scene.SpawnMarker.IsVisible = true; - Pipeline._context.Scene.SpawnMarker.SetCursor(GLContext.ActiveContext, false); + Pipeline._context.Scene.SpawnMarker.SetCursor(false); GLContext.ActiveContext.UpdateViewport = true; } @@ -214,18 +214,6 @@ public GLTexture2D SaveAsScreenshotGLTexture(ViewportRenderer renderer, int widt return GLTexture2D.FromBitmap(bitmap); } - public Image SaveAsScreenshot(ViewportRenderer renderer, Camera camera, int width, int height, bool enableAlpha = false) - { - //Save into an fbo that supports an alpha channel - Framebuffer fbo = new Framebuffer(FramebufferTarget.Framebuffer, - width, height, PixelInternalFormat.Rgba16f, 1); - - var bitmap = renderer.SaveAsScreenshot(fbo, camera, width, height, enableAlpha); - fbo.Dispose(); - - return bitmap; - } - public Image SaveAsScreenshot(ViewportRenderer renderer, int width, int height, bool enableAlpha = false) { //Save into an fbo that supports an alpha channel Framebuffer fbo = new Framebuffer(FramebufferTarget.Framebuffer, @@ -254,8 +242,6 @@ private void UpdateCamera(GLContext context) Workspace.ActiveWorkspace?.OnMouseDown(mouseInfo); } - Workspace.ActiveWorkspace?.OnMouseMove(mouseInfo); - if (ImGui.IsMouseReleased(ImGuiMouseButton.Left) || ImGui.IsMouseReleased(ImGuiMouseButton.Right) || ImGui.IsMouseReleased(ImGuiMouseButton.Middle)) @@ -264,11 +250,9 @@ private void UpdateCamera(GLContext context) _mouseDown = false; } - if (IsFocused) - - context.OnMouseMove(mouseInfo, keyInfo, _mouseDown); + context.OnMouseMove(mouseInfo, keyInfo, _mouseDown); - if (ImGuiController.ApplicationHasFocus && ImGui.IsWindowHovered()) + if (ImGuiController.ApplicationHasFocus && IsFocused) context.OnMouseWheel(mouseInfo, keyInfo); else context.ResetPrevious(); diff --git a/src/Editors/FileEditor.cs b/src/Editors/FileEditor.cs index 6afb6df..16949c2 100644 --- a/src/Editors/FileEditor.cs +++ b/src/Editors/FileEditor.cs @@ -181,20 +181,10 @@ public virtual void RenderSaveFileSettings() } ImGui.EndCombo(); } - - string quality = Yaz0.Quality.ToString(); - List options = new List() + if (ImGui.DragInt("Yaz0 Level (1 fast, 9 slow)", ref Runtime.Yaz0CompressionLevel, 1, 1, 9)) { - "Fast (Default)", - "Medium (CTlib)", - "Best {LibYaz0}", - "Nintendo (Original)", - }; - ImguiCustomWidgets.ComboScrollable("Yaz0 Level", quality, ref quality, options, () => - { - Yaz0.Quality = (Yaz0.QualityLevel)options.IndexOf(quality); - }); + } } /// @@ -305,6 +295,6 @@ public virtual void AssetViewportDrop(AssetItem item, Vector2 screenCoords) { } public virtual void OnMouseMove(MouseEventInfo mouseInfo) { } public virtual void OnMouseDown(MouseEventInfo mouseInfo) { } public virtual void OnMouseUp(MouseEventInfo mouseInfo) { } - public virtual void OnKeyDown(KeyEventInfo keyEventInfo, bool isRepeat) { } + public virtual void OnKeyDown(KeyEventInfo keyEventInfo) { } } } diff --git a/src/Icons/IconManager.cs b/src/Icons/IconManager.cs index 1763421..bb45660 100644 --- a/src/Icons/IconManager.cs +++ b/src/Icons/IconManager.cs @@ -8,7 +8,7 @@ namespace MapStudio.UI { public class IconManager { - public static Dictionary Icons = new Dictionary(); + static Dictionary Icons = new Dictionary(); //Open Font Icons public const char MATERIAL_MASK_ICON = '\ue067'; diff --git a/src/Imgui/Helpers/ImGuiHelper.cs b/src/Imgui/Helpers/ImGuiHelper.cs index 0cc86f5..0fc3c87 100644 --- a/src/Imgui/Helpers/ImGuiHelper.cs +++ b/src/Imgui/Helpers/ImGuiHelper.cs @@ -83,9 +83,6 @@ public static void Tooltip(string tooltip, string shortcut = "") { ImGui.BeginTooltip(); ImGui.Text(TranslationSource.GetText(tooltip)); - if (!string.IsNullOrEmpty(shortcut)) - ImGui.Text($"Shortcut: {shortcut}"); - ImGui.EndTooltip(); } } diff --git a/src/Imgui/Helpers/ImguiCustomWidgets.cs b/src/Imgui/Helpers/ImguiCustomWidgets.cs index 55120ad..0914669 100644 --- a/src/Imgui/Helpers/ImguiCustomWidgets.cs +++ b/src/Imgui/Helpers/ImguiCustomWidgets.cs @@ -95,8 +95,6 @@ public static bool ComboScrollable(string key, string text, ref T selectedIte public static bool ComboScrollable(string key, string text, ref T selectedItem, IEnumerable items, Action propertyChanged = null, ImGuiComboFlags flags = ImGuiComboFlags.None) { - bool edited = false; - if (ImGui.BeginCombo(key, text, flags)) //Check for combo box popup and add items { foreach (T item in items) @@ -105,15 +103,13 @@ public static bool ComboScrollable(string key, string text, ref T selectedIte if (ImGui.Selectable(item.ToString(), isSelected)) { selectedItem = item; propertyChanged?.Invoke(); - - edited = true; } if (isSelected) ImGui.SetItemDefaultFocus(); } ImGui.EndCombo(); - return edited; + return true; } if (ImGui.IsItemHovered()) //Check for combo box hover { @@ -126,8 +122,6 @@ public static bool ComboScrollable(string key, string text, ref T selectedIte { //Shift upwards if possible selectedItem = list[index + 1]; propertyChanged?.Invoke(); - - edited = true; } } if (delta > 0) //Check for mouse scroll change going down @@ -139,11 +133,11 @@ public static bool ComboScrollable(string key, string text, ref T selectedIte selectedItem = list[index - 1]; propertyChanged?.Invoke(); - edited = true; + return true; } } } - return edited; + return false; } public static TransformOutput Transform(OpenTK.Vector3 position, OpenTK.Vector3 rotation, OpenTK.Vector3 scale) @@ -361,12 +355,6 @@ public static void DragHorizontalSeperator(string name, float height, float widt ImGui.PopStyleVar(); } - public static bool ButtonToggle(string label, bool isValue, Vector2 size) - { - bool v = isValue; - return ButtonToggle(label, ref v, size); - } - public static bool ButtonToggle(string label, ref bool isValue, Vector2 size) { if (isValue) @@ -375,13 +363,12 @@ public static bool ButtonToggle(string label, ref bool isValue, Vector2 size) ImGui.PushStyleColor(ImGuiCol.Button, selectionColor); } else - ImGui.PushStyleColor(ImGuiCol.Button, ThemeHandler.Theme.FrameBgActive); + ImGui.PushStyleColor(ImGuiCol.Button, new Vector4()); - /* ImGui.PushStyleColor(ImGuiCol.Button, color); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, color); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, color);*/ + /* ImGui.PushStyleColor(ImGuiCol.Button, color); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, color); + ImGui.PushStyleColor(ImGuiCol.ButtonActive, color);*/ - ImGui.AlignTextToFramePadding(); bool clicked = ImGui.Button(label, size); ImGui.PopStyleColor(1); diff --git a/src/Imgui/Helpers/ImguiPropertyColumn.cs b/src/Imgui/Helpers/ImguiPropertyColumn.cs index b1eee99..d019b9d 100644 --- a/src/Imgui/Helpers/ImguiPropertyColumn.cs +++ b/src/Imgui/Helpers/ImguiPropertyColumn.cs @@ -36,22 +36,6 @@ public static bool RadioButton(string label, ref bool value) return edit; } - public static bool Bool(string label, ref bool value, string tool_tip) - { - if (!string.IsNullOrEmpty(tool_tip)) - LabelTip(label, tool_tip); - else - Label(label); - - ImGui.PushItemWidth(ImGui.GetColumnWidth(1) - 5); - bool edit = ImGui.Checkbox($"##{label}", ref value); - ImGui.PopItemWidth(); - - ImGui.NextColumn(); - - return edit; - } - public static bool Bool(string label, ref bool value) { Label(label); @@ -78,20 +62,6 @@ public static bool Text(string label, ref string value) return edit; } - - public static bool SliderInt(string label, ref int value, int min, int max) - { - Label(label); - - ImGui.PushItemWidth(ImGui.GetColumnWidth(1) - 5); - bool edit = ImGui.SliderInt($"##{label}", ref value, min, max); - ImGui.PopItemWidth(); - - ImGui.NextColumn(); - - return edit; - } - public static bool SliderFloat(string label, ref float value, float min, float max) { Label(label); @@ -167,56 +137,6 @@ public static bool InputInt(string label, ref int value, int speed = 1) return edit; } - public static bool DragSByte(string label, ref sbyte value) - { - int v = value; - bool edit = DragInt(label, ref v); - if (edit) - value = (sbyte)v; - - return edit; - } - - public static bool DragByte(string label, ref byte value) - { - int v = value; - bool edit = DragInt(label, ref v); - if (edit) - value = (byte)v; - - return edit; - } - - public static bool SliderByte(string label, ref byte value, int min, int max) - { - int v = value; - bool edit = SliderInt(label, ref v, min, max); - if (edit) - value = (byte)v; - - return edit; - } - - public static bool DragShort(string label, ref short value) - { - int v = value; - bool edit = DragInt(label, ref v); - if (edit) - value = (short)v; - - return edit; - } - - public static bool DragUShort(string label, ref ushort value) - { - int v = value; - bool edit = DragInt(label, ref v); - if (edit) - value = (ushort)v; - - return edit; - } - public static bool DragInt(string label, ref int value, float speed = 0.01f) { Label(label); @@ -282,24 +202,6 @@ public static bool DragFloat4(string label, ref Vector4 value, float speed = 0.0 return edit; } - public static bool ColorEdit4(string label, ref OpenTK.Vector4 value, ImGuiColorEditFlags flags) - { - Label(label); - - var vec4 = new Vector4(value.X, value.Y, value.Z, value.W); - - ImGui.PushItemWidth(ImGui.GetColumnWidth(1) - 5); - bool edit = ImGui.ColorEdit4($"##{label}", ref vec4, flags); - ImGui.PopItemWidth(); - - if (edit) - value = new OpenTK.Vector4(vec4.X, vec4.Y, vec4.Z, vec4.W); - - ImGui.NextColumn(); - - return edit; - } - public static bool ColorEdit4(string label, ref Vector4 value, ImGuiColorEditFlags flags) { Label(label); @@ -352,18 +254,5 @@ static void Label(string label) ImGui.Text(label); ImGui.NextColumn(); } - - static void LabelTip(string label, string tool_tip) - { - if (!DoLabel) - return; - - ImGui.Text(label); - ImGui.SameLine(); - ImGui.Text("?"); - ImGuiHelper.Tooltip(tool_tip); - - ImGui.NextColumn(); - } } } diff --git a/src/Imgui/ImGuiController/ImGuiController.cs b/src/Imgui/ImGuiController/ImGuiController.cs index 0e541e6..87a7bef 100644 --- a/src/Imgui/ImGuiController/ImGuiController.cs +++ b/src/Imgui/ImGuiController/ImGuiController.cs @@ -44,6 +44,8 @@ public class ImGuiController : IDisposable public static ImFontPtr FontIconSolid; public static ImFontPtr FontIconRegular; + public static ImFontPtr FontZoomed; + public static ImFontPtr FontJKZoomed; /// /// Constructs a new ImGuiController. /// @@ -54,6 +56,11 @@ public ImGuiController(int width, int height) var context = ImGui.CreateContext(); + /* unsafe + { + imnodesNET.imnodes.SetImGuiContext((IntPtr)context.NativePtr); + imnodesNET.imnodes.Initialize(); + }*/ ImGui.SetCurrentContext(context); var io = ImGui.GetIO(); @@ -104,6 +111,17 @@ public ImGuiController(int width, int height) DefaultFontBold = io.Fonts.AddFontFromFileTTF(Path.Combine(Runtime.ExecutableDir,"Lib","Fonts","FontBold.ttf"), 16, nativeConfig); FontOperator = io.Fonts.AddFontFromFileTTF(Path.Combine(Runtime.ExecutableDir, "Lib", "Fonts", "FontBold.ttf"), 40, nativeConfig); + + //For zooming in text editor + FontZoomed = io.Fonts.AddFontFromFileTTF(Path.Combine(Runtime.ExecutableDir, "Lib", "Fonts", "Font.ttf"), 32, nativeConfig); + + ImFontConfig configJK = new ImFontConfig + { + MergeMode = 1, + PixelSnapH = 1, + GlyphMinAdvanceX = 25, + }; + FontJKZoomed = AddFontFromFileTTF(Path.Combine(Runtime.ExecutableDir, "Lib", "Fonts", "NotoSansCJKjp-Medium.otf"), 32, configJK, io.Fonts.GetGlyphRangesJapanese()); } io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset; diff --git a/src/Theme/ThemeHandler.cs b/src/Theme/ThemeHandler.cs index 60522c1..b6aac75 100644 --- a/src/Theme/ThemeHandler.cs +++ b/src/Theme/ThemeHandler.cs @@ -45,7 +45,6 @@ public class ThemeHandler public virtual Vector4 TextSelectedBg { get; set; } public virtual Vector4 NavHighlight { get; set; } public virtual Vector4 Error { get; set; } - public virtual Vector4 Ok { get; set; } = new Vector4(0, 1, 0, 1); public virtual Vector4 Warning { get; set; } public static Vector4 ActiveTextHighlight { get; set; } public static Vector4 HyperLinkText { get; set; } diff --git a/src/UIFramework/Framework.cs b/src/UIFramework/Framework.cs index a938fd6..7b0eeb6 100644 --- a/src/UIFramework/Framework.cs +++ b/src/UIFramework/Framework.cs @@ -58,9 +58,9 @@ public Framework(MainWindow window, GraphicsMode gMode, string asssemblyVersion, private void Update() { - if (!ProcessLoading.IsLoading) - return; - + //if (!ProcessLoading.IsLoading) + // return; + return; var cont = OpenTK.Graphics.GraphicsContext.CurrentContext; cont.Update(this.WindowInfo); diff --git a/src/UIFramework/TreeView/TreeNode.cs b/src/UIFramework/TreeView/TreeNode.cs index a1fd6e2..3d3973e 100644 --- a/src/UIFramework/TreeView/TreeNode.cs +++ b/src/UIFramework/TreeView/TreeNode.cs @@ -20,7 +20,6 @@ public class TreeNode : ISelectableElement public EventHandler OnSelected; public EventHandler OnChecked; public EventHandler OnHeaderRenamed; - public EventHandler OnDoubleClick; //Render events public EventHandler IconDrawer; diff --git a/src/Workspace/GameTimer.cs b/src/Workspace/GameTimer.cs index 14a74ff..5f391b1 100644 --- a/src/Workspace/GameTimer.cs +++ b/src/Workspace/GameTimer.cs @@ -43,7 +43,7 @@ public GameTimer() animationTimer = new System.Timers.Timer() { - Interval = (int)(1000.0f / FrameRate), + Interval = (int)(1000.0f / 60.0f), }; animationTimer.Elapsed += timer_Tick; } diff --git a/src/Workspace/Workspace.cs b/src/Workspace/Workspace.cs index 238722c..6244f75 100644 --- a/src/Workspace/Workspace.cs +++ b/src/Workspace/Workspace.cs @@ -147,40 +147,31 @@ public Workspace(GlobalSettings settings, string name) : base(name) UVWindow = new UVWindow(this); Windows.Add(GraphWindow.PropertyWindow); - AssetViewWindow.SelectionChanged += delegate + Outliner.SelectionChanged += delegate { - var asset = AssetViewWindow.SelectedAsset; - if (asset != null) - PropertyWindow.SelectedObject = asset; - }; - - Outliner.SelectionChanged += (o, e) => - { - var node = Outliner.SelectedNode; - //Assign the active file format if outliner has it selected - if (node != null) + if (Outliner.SelectedNode != null) { //Select the active file to edit if one is selected - if (node.Tag is FileEditor && node.Tag != ActiveEditor) - ActiveEditor = (FileEditor)node.Tag; + if (Outliner.SelectedNode.Tag is FileEditor && Outliner.SelectedNode.Tag != ActiveEditor) + ActiveEditor = (FileEditor)Outliner.SelectedNode.Tag; //Select an animation for playback in the timeline window - if (node.Tag is STAnimation) { - TimelineWindow.AddAnimation((STAnimation)node.Tag); - GraphWindow.AddAnimation((STAnimation)node.Tag); + if (Outliner.SelectedNode.Tag is STAnimation) { + TimelineWindow.AddAnimation((STAnimation)Outliner.SelectedNode.Tag); + GraphWindow.AddAnimation((STAnimation)Outliner.SelectedNode.Tag); } //Load a material to the UV window if one is selected - if (node.Tag is STGenericMaterial) { - UVWindow.Load((STGenericMaterial)node.Tag); + if (Outliner.SelectedNode.Tag is STGenericMaterial) { + UVWindow.Load((STGenericMaterial)Outliner.SelectedNode.Tag); } //Load a mesh to the UV window if one is selected - if (node.Tag is STGenericMesh) { - UVWindow.Load((STGenericMesh)node.Tag); + if (Outliner.SelectedNode.Tag is STGenericMesh) { + UVWindow.Load((STGenericMesh)Outliner.SelectedNode.Tag); } } - PropertyWindow.SelectedObject = node; + PropertyWindow.SelectedObject = Outliner.SelectedNode; }; ToolWindow.UIDrawer += delegate { @@ -232,6 +223,9 @@ public override void Render() if (ImGui.IsWindowFocused()) Workspace.UpdateActive(this); + if (ViewportWindow.IsFocused) + PropertyWindow.SelectedObject = GetSelectedNode(); + base.Render(); } @@ -400,28 +394,17 @@ public void SetupActiveEditor(FileEditor editor) //Init the gl scene editor.Scene.Init(); - bool isDeselectAll = false; - //Viewport on selection changed editor.Scene.SelectionUIChanged = null; editor.Scene.SelectionUIChanged += (o, e) => { - if (isDeselectAll) - return; - - if (o == null || !((NodeBase)o).IsSelected) { - PropertyWindow.SelectedObject = null; + if (o == null) { return; } if (ViewportWindow.IsFocused) { - isDeselectAll = true; - - // if (!KeyEventInfo.State.KeyCtrl && !KeyEventInfo.State.KeyShift) - // Outliner.DeselectAllButNode((NodeBase)o); - - isDeselectAll = false; - + if (!KeyEventInfo.State.KeyCtrl && !KeyEventInfo.State.KeyShift) + Outliner.DeselectAll(); ScrollToSelectedNode((NodeBase)o); } @@ -686,7 +669,7 @@ private void SaveFileData(IFileFormat fileFormat, string filePath) ProcessLoading.Instance.Update(0,100, $"Saving {name}", "Saving"); //Save current file - var log = Toolbox.Core.IO.STFileSaver.SaveFileFormat(fileFormat, filePath, (o, s) => { + Toolbox.Core.IO.STFileSaver.SaveFileFormat(fileFormat, filePath, (o, s) => { ProcessLoading.Instance.Update(70, 100, $"Compressing {fileFormat.FileInfo.Compression.ToString()}", "Saving"); }); //Reload the file if an archive with an open stream @@ -721,7 +704,7 @@ private void SaveFileData(IFileFormat fileFormat, string filePath) ProcessLoading.Instance.Update(100, 100, $"Saving {name}", "Saving"); ProcessLoading.Instance.IsLoading = false; - TinyFileDialog.MessageBoxInfoOk($"File {filePath} has been saved! {log.SaveTime}"); + TinyFileDialog.MessageBoxInfoOk($"File {filePath} has been saved!"); PrintErrors(); } @@ -877,12 +860,13 @@ public void OnKeyDown(KeyEventInfo keyInfo, bool isRepeat) if (!isRepeat) this.GraphWindow?.OnKeyDown(keyInfo); - ActiveEditor.OnKeyDown(keyInfo, isRepeat); - if (Outliner.IsFocused && !isRepeat) ViewportWindow.Pipeline._context.OnKeyDown(keyInfo, isRepeat, ViewportWindow.IsFocused); else if (ViewportWindow.IsFocused) { + if (!isRepeat) + ActiveEditor.OnKeyDown(keyInfo); + ViewportWindow.Pipeline._context.OnKeyDown(keyInfo, isRepeat, true); if (keyInfo.IsKeyDown(InputSettings.INPUT.Scene.ShowAddContextMenu)) ViewportWindow.LoadAddContextMenu(); @@ -922,9 +906,26 @@ public void OnApplicationEnter() { public new void Dispose() { //Dispose files + + void DisposeArchive(IFileFormat fileFormat) + { + foreach (var f in ((IArchiveFile)fileFormat).Files) + { + if (f.FileFormat is IArchiveFile) + DisposeArchive(f.FileFormat); + + if (f.FileFormat is IDisposable) + ((IDisposable)f.FileFormat).Dispose(); + } + } + foreach (var file in Resources.Files) + { if (file is IDisposable) ((IDisposable)file).Dispose(); + if (file is IArchiveFile) + DisposeArchive(file); + } //Dispose renderables foreach (var render in DataCache.ModelCache.Values)