From 88fa0dfd82db1688c8b4537ec9d040b03bb7dbff Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 2 Dec 2022 01:51:14 +0100 Subject: [PATCH] default layout + switches + no more scroll flicker --- CUE4Parse | 2 +- FModel/Framework/ImGuiController.cs | 9 +++++++-- FModel/MainWindow.xaml.cs | 1 + FModel/ViewModels/ApplicationViewModel.cs | 15 ++++++++++++++- FModel/Views/Snooper/Material.cs | 10 ---------- FModel/Views/Snooper/Model.cs | 6 +++++- FModel/Views/Snooper/SnimGui.cs | 21 ++++++++++----------- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index bd6b84ea..f71be1eb 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit bd6b84eac5dc4c852afe330be2c286dd4b48d626 +Subproject commit f71be1eb998ee38e94a1a77994fb21e0338905c1 diff --git a/FModel/Framework/ImGuiController.cs b/FModel/Framework/ImGuiController.cs index adb766fe..e275a633 100644 --- a/FModel/Framework/ImGuiController.cs +++ b/FModel/Framework/ImGuiController.cs @@ -31,12 +31,13 @@ public class ImGuiController : IDisposable private int _windowWidth; private int _windowHeight; + // private string _iniPath; private ImFontPtr _normal; private ImFontPtr _bold; private ImFontPtr _semiBold; - private readonly System.Numerics.Vector2 _scaleFactor = System.Numerics.Vector2.One; + private readonly Vector2 _scaleFactor = Vector2.One; private static bool KHRDebugAvailable = false; @@ -44,6 +45,7 @@ public class ImGuiController : IDisposable { _windowWidth = width; _windowHeight = height; + // _iniPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "imgui.ini"); int major = GL.GetInteger(GetPName.MajorVersion); int minor = GL.GetInteger(GetPName.MinorVersion); @@ -52,6 +54,8 @@ public class ImGuiController : IDisposable IntPtr context = ImGui.CreateContext(); ImGui.SetCurrentContext(context); + // ImGui.LoadIniSettingsFromDisk(_iniPath); + var io = ImGui.GetIO(); _normal = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeui.ttf", 16); _bold = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeuib.ttf", 16); @@ -237,7 +241,8 @@ outputColor = color * texture(in_fontTexture, texCoord); private void SetPerFrameImGuiData(float deltaSeconds) { ImGuiIOPtr io = ImGui.GetIO(); - io.DisplaySize = new System.Numerics.Vector2( + // if (io.WantSaveIniSettings) ImGui.SaveIniSettingsToDisk(_iniPath); + io.DisplaySize = new Vector2( _windowWidth / _scaleFactor.X, _windowHeight / _scaleFactor.Y); io.DisplayFramebufferScale = _scaleFactor; diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index 94a9b285..7ed2e02b 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -70,6 +70,7 @@ public partial class MainWindow await _applicationView.CUE4Parse.InitInformation(); #endif await _applicationView.CUE4Parse.InitMappings(); + await _applicationView.InitImGuiSettings(); await _applicationView.InitVgmStream(); await _applicationView.InitOodle(); diff --git a/FModel/ViewModels/ApplicationViewModel.cs b/FModel/ViewModels/ApplicationViewModel.cs index 9c3a1c2d..5cbe2b20 100644 --- a/FModel/ViewModels/ApplicationViewModel.cs +++ b/FModel/ViewModels/ApplicationViewModel.cs @@ -185,4 +185,17 @@ public class ApplicationViewModel : ViewModel (OodleLZ_FuzzSafe) a, (OodleLZ_CheckCRC) b, (OodleLZ_Verbosity) c, d, e, f, g, h, i, (OodleLZ_Decode_ThreadPhase) threadModule); } } -} \ No newline at end of file + + public async Task InitImGuiSettings() + { + var imgui = Path.Combine(/*UserSettings.Default.OutputDirectory, ".data", */"imgui.ini"); + if (File.Exists(imgui)) return; + + await ApplicationService.ApiEndpointView.DownloadFileAsync("https://cdn.fmodel.app/d/configurations/imgui.ini", imgui); + if (new FileInfo(imgui).Length == 0) + { + FLogger.AppendError(); + FLogger.AppendText("Could not download ImGui settings", Constants.WHITE, true); + } + } +} diff --git a/FModel/Views/Snooper/Material.cs b/FModel/Views/Snooper/Material.cs index ce9ebade..0a76f34b 100644 --- a/FModel/Views/Snooper/Material.cs +++ b/FModel/Views/Snooper/Material.cs @@ -215,15 +215,8 @@ public class Material : IDisposable private const float _zero = 0.000001f; // doesn't actually work if _infinite is used as max value /shrug private const float _infinite = 0.0f; private const ImGuiSliderFlags _clamp = ImGuiSliderFlags.AlwaysClamp; - private void PushStyle() - { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(8, 3)); - ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 1)); - } - public void ImGuiParameters() { - PushStyle(); if (ImGui.BeginTable("parameters", 2)) { SnimGui.Layout("Roughness");ImGui.PushID(1); @@ -248,7 +241,6 @@ public class Material : IDisposable } ImGui.EndTable(); } - ImGui.PopStyleVar(2); } public void ImGuiDictionaries(string id, Dictionary dictionary, bool center = false, bool wrap = false) @@ -269,7 +261,6 @@ public class Material : IDisposable public void ImGuiTextures(Dictionary icons, Model model) { - PushStyle(); if (ImGui.BeginTable("material_textures", 2)) { SnimGui.Layout("Channel");ImGui.PushID(1); ImGui.BeginDisabled(model.NumTexCoords < 2); @@ -294,7 +285,6 @@ public class Material : IDisposable ImGui.EndTable(); } - ImGui.PopStyleVar(2); ImGui.Image(GetSelectedTexture() ?? icons["noimage"].GetPointer(), new Vector2(ImGui.GetContentRegionAvail().X), Vector2.Zero, Vector2.One, Vector4.One, new Vector4(1.0f, 1.0f, 1.0f, 0.25f)); ImGui.Spacing(); diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs index 2e10c94c..447fa4ea 100644 --- a/FModel/Views/Snooper/Model.cs +++ b/FModel/Views/Snooper/Model.cs @@ -67,12 +67,16 @@ public class Model : IDisposable if (morphTargets is not { Length: > 0 }) return; + var length = morphTargets.Length; + HasMorphTargets = true; - Morphs = new Morph[morphTargets.Length]; + Morphs = new Morph[length]; for (var i = 0; i < Morphs.Length; i++) { Morphs[i] = new Morph(Vertices, _vertexSize, morphTargets[i].Load()); + Services.ApplicationService.ApplicationView.Status.UpdateStatusLabel($"{Morphs[i].Name} ... {i}/{length}"); } + Services.ApplicationService.ApplicationView.Status.UpdateStatusLabel(""); } private Model(string name, string type, ResolvedObject[] materials, FPackageIndex skeleton, CBaseMeshLod lod, CMeshVertex[] vertices, Transform transform = null) : this(name, type) diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs index 969f7fc1..2e00de36 100644 --- a/FModel/Views/Snooper/SnimGui.cs +++ b/FModel/Views/Snooper/SnimGui.cs @@ -35,7 +35,7 @@ public class SnimGui SectionWindow("Material Inspector", s.Renderer, DrawMaterialInspector, false); - Window("Timeline", () => {}); + // Window("Timeline", () => {}); Window("World", () => DrawWorld(s), false); Window("Sockets", () => DrawSockets(s)); @@ -53,8 +53,6 @@ public class SnimGui ImGui.SetNextItemOpen(true, ImGuiCond.Appearing); if (ImGui.CollapsingHeader("Editor")) { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(8, 3)); - ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 1)); if (ImGui.BeginTable("world_editor", 2)) { Layout("Skybox");ImGui.PushID(1); @@ -70,7 +68,6 @@ public class SnimGui ImGui.EndTable(); } - ImGui.PopStyleVar(2); } ImGui.SetNextItemOpen(true, ImGuiCond.Appearing); @@ -242,8 +239,6 @@ public class SnimGui ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); MeshWindow("Details", s.Renderer, (icons, model) => { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(8, 3)); - ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 1)); if (ImGui.BeginTable("model_details", 2, ImGuiTableFlags.SizingStretchProp)) { Layout("Entity");ImGui.Text($" : ({model.Type}) {model.Name}"); @@ -257,7 +252,6 @@ public class SnimGui ImGui.EndTable(); } - ImGui.PopStyleVar(2); if (ImGui.BeginTabBar("tabbar_details", ImGuiTabBarFlags.None)) { if (ImGui.BeginTabItem("Sections") && ImGui.BeginTable("table_sections", 2, ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersOuterV, ImGui.GetContentRegionAvail())) @@ -471,6 +465,12 @@ public class SnimGui ImGui.TreePop(); } ImGui.SetNextItemOpen(true, ImGuiCond.Appearing); + if (ImGui.TreeNode("Switchs")) + { + material.ImGuiDictionaries("switchs", material.Parameters.Switchs, true); + ImGui.TreePop(); + } + ImGui.SetNextItemOpen(true, ImGuiCond.Appearing); if (ImGui.TreeNode("Colors")) { material.ImGuiDictionaries("colors", material.Parameters.Colors, true); @@ -537,7 +537,7 @@ public class SnimGui private void Window(string name, Action content, bool styled = true) { - if (ImGui.Begin(name)) + if (ImGui.Begin(name, ImGuiWindowFlags.NoScrollbar)) { Controller.PopFont(); if (styled) PushStyleCompact(); @@ -568,9 +568,8 @@ public class SnimGui private void PopStyleCompact() => ImGui.PopStyleVar(2); private void PushStyleCompact() { - var style = ImGui.GetStyle(); - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, style.FramePadding with { Y = style.FramePadding.Y * 0.6f }); - ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, style.ItemSpacing with { Y = style.ItemSpacing.Y * 0.6f }); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(8, 3)); + ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 1)); } private void NoMeshSelected() => CenteredTextColored(_errorColor, "No Mesh Selected");