diff --git a/isometric-park-fna/UI/Graph.cs b/isometric-park-fna/UI/Graph.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/UI/Graph.cs @@ -0,0 +1,62 @@ + +using System; +using Num = System.Numerics; +using System.Linq; +using System.Runtime.InteropServices; + +using ImGuiNET; + +using isometricparkfna.Messages; +using isometricparkfna.Components; +using isometricparkfna.Engines; + +namespace isometricparkfna.UI +{ + + public static class GraphWindow + { + public static bool hadFocus = false; + + public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine) + { + bool newShow = true; + ImGui.PushFont(font); + + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; + StyleSets.defaultSet.push(); + + if(GraphWindow.hadFocus) + { + ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); + } + ImGui.SetNextWindowSize(new Num.Vector2(400, 250)); + + ImGui.Begin("Graph", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings); + if (GraphWindow.hadFocus) + { + ImGui.PopStyleColor(); + } + GraphWindow.hadFocus = ImGui.IsWindowFocused(); + + // ImGui.Text("Lorem Ipsum"); + + var totals = sim.allBudgets().Select(b => (float)b.money).ToArray(); + + + + if (totals.Length > 0) + { + ImGui.PlotLines("MainGraph", ref totals[0], totals.Length, 0, null, float.MaxValue, float.MaxValue, new Num.Vector2(350, 200)); + } + + + + + ImGui.End(); + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; + StyleSets.defaultSet.pop(); + ImGui.PopFont(); + + } + } +}