diff --git a/.vscode/launch.json b/.vscode/launch.json --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "args": [], "env": { "LD_LIBRARY_PATH": "${workspaceFolder}/isometric-park-fna/bin/Debug/netcoreapp3.1/lib64", - "DYLD_LIBRARY_PATH": "${workspaceFolder}/isometric-park-fna/bin/Debug/netcoreapp3.1/osx" + "DYLD_LIBRARY_PATH": "${workspaceFolder}/fnalibs/osx" }, "cwd": "${workspaceFolder}/isometric-park-fna/bin/Debug/netcoreapp3.1", "console": "integratedTerminal", diff --git a/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache b/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache index 5a09ccce96524ac15d0ed2f96e247bbf294eb106..f71212068a6b67be7122ae73268c6bc65832f429 GIT binary patch literal 20937 zc%1EA3v?9K8J@e@-Rx|T<bFJhWniLWq|?C0*L9!Yo1|-XFshB=0;Nm$rH4A|6(8@MZ@T%eru$D(4gVowUDTM`X-a3U|dpmCkh&D-&plCyye#d(Qg zk{E|0#dVvZ4AbDN6k0@1?DCb1 zT$t~SitUoG3it8`)z3b~>5_s?1uhl2P9f4NW2a#33Fan-C4W@J-^%Sq;C6Kua?p&s z0Kzh$kD=8_+-k9fr-ukv3X$t&a1REru>#!Su~8T`cR<5x>>X;Es_qX{ZS~aI%lZ*kwb;u8xPX7yOb8^#crb)qt+k(&vY=r-ph~dIT=C zIN=QTU1afKD&=CF3_K14w^;~0aKy*svrQT>O!`W5F>ZbB;3H)iQICmj-tG~9jmSvdqyCY&~42G?DQo0ksVbX~Sh#7Koh zMgoMZFhaG3V+k;?#+U&MF{$-ylv7#lu-AZ?1Y$CXDIlhTNCzaPIUq_vl!7P&QI3TJ_)R_SvUO^? zx@3jbTT(b0u;c&jHZEch@Ewv`INh;@7Ctl9IyKV0%+c`ht%-EIbf6R+v7ou_IitJ>q%U(e2N_=#3SX|((F00q7s{r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cQ@19B)sEmqS5)x| z+opuu(?#`hH{s(o6d%he(@8+Dr$TQapf}Q>H|wDV6&fB7+9g9z#C_H=%un$LC!A;^ zO!&o_0EF^V=X4{q`7Jjqt&b9mB>m0T9h2+i!laEdxx&0Hzu_H&*p4s#7qhAD;SB|*j z+28G$)YOuGKc9Zti9}KAAdeCtkI{^L!qmtosnAam&`;C&?Wck~Pk_8YFXqp8qi2gh5&Js)VT<8f z1b#}!cEWzaq(ovR5=%?08~Qdn+${WBhwUcP>K1)k-Aty{O|TI;g<3bK5_L13RyQ-u z>L$vf)JT-4Z@yM(?#NFhcp|~I1Yc*Yoa-UQHxMa)lRm|7BvbqrsGJ3f#7ZQVmROtg zm2)$s)vZKYb?Vbz zkt$LDYoscgsS8cLSV#3@J>kVgH0Y(K(2Z2+1@RLg0Sbr%0y~&pQm|m0 zACFlfz>Bqfj1yaVx%!mj%GUdrO%MV*0T_8Cf=P_#sZPD8wrbn21VA?p;3hKwv{vJ? io`BjwgStfzwN2%+nE<$z2GC;$fVQe!&^Gm5%KrdVsdNMY diff --git a/isometric-park-fna.sln b/isometric-park-fna.sln --- a/isometric-park-fna.sln +++ b/isometric-park-fna.sln @@ -11,7 +11,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET", "ImGui.NET\ImGui.NET.csproj", "{0023328E-2EFD-448B-BD85-A76769CD106A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "encompass-cs", "encompass-cs\encompass-cs\encompass-cs.csproj", "{93842D17-2CBE-40A9-AA4C-A2BCE836B817}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "encompass-cs", "encompass-cs\encompass-cs\encompass-cs.csproj", "{D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -71,18 +71,18 @@ {0023328E-2EFD-448B-BD85-A76769CD106A}.Debug|x64.Build.0 = Debug|Any CPU {0023328E-2EFD-448B-BD85-A76769CD106A}.Release|x64.ActiveCfg = Release|Any CPU {0023328E-2EFD-448B-BD85-A76769CD106A}.Release|x64.Build.0 = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|anycpu.ActiveCfg = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|anycpu.Build.0 = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|anycpu.ActiveCfg = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|anycpu.Build.0 = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|x86.ActiveCfg = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|x86.Build.0 = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|x86.ActiveCfg = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|x86.Build.0 = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|x64.ActiveCfg = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Debug|x64.Build.0 = Debug|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|x64.ActiveCfg = Release|Any CPU - {93842D17-2CBE-40A9-AA4C-A2BCE836B817}.Release|x64.Build.0 = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|anycpu.ActiveCfg = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|anycpu.Build.0 = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|anycpu.ActiveCfg = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|anycpu.Build.0 = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x86.ActiveCfg = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x86.Build.0 = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x86.ActiveCfg = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x86.Build.0 = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x64.ActiveCfg = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x64.Build.0 = Debug|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x64.ActiveCfg = Release|Any CPU + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/isometric-park-fna/Components/WindowTypeComponent.cs b/isometric-park-fna/Components/WindowTypeComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/WindowTypeComponent.cs @@ -0,0 +1,10 @@ +using Encompass; + +using isometricparkfna.Messages; + +namespace isometricparkfna.Components { + + public struct WindowTypeComponent : IComponent { + public Window type; + } +} diff --git a/isometric-park-fna/Engines/InputEngine.cs b/isometric-park-fna/Engines/InputEngine.cs --- a/isometric-park-fna/Engines/InputEngine.cs +++ b/isometric-park-fna/Engines/InputEngine.cs @@ -6,6 +6,7 @@ using Encompass; using isometricparkfna.Messages; +using isometricparkfna.Components; namespace isometricparkfna.Engines { @@ -18,6 +19,8 @@ typeof(ToggleVisibilityMessage), typeof(TogglePauseMessage), typeof(GameRateMessage))] + [Reads(typeof(WindowTypeComponent), + typeof(VisibilityComponent))] public class InputEngine : Engine { private KeyboardState keyboardPrev; @@ -141,6 +144,10 @@ SendMessage(new ToggleWindowMessage{Window = Window.News}); } + if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O)) + { + SendMessage(new ToggleWindowMessage{Window = Window.Contracts}); + } if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G)) { SendMessage(new ToggleVisibilityMessage{Element = Element.Grid}); diff --git a/isometric-park-fna/Engines/UIEngine.cs b/isometric-park-fna/Engines/UIEngine.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Engines/UIEngine.cs @@ -0,0 +1,35 @@ + + + +using Microsoft.Xna.Framework.Input; + +using Encompass; + +using isometricparkfna.Messages; +using isometricparkfna.Components; + +namespace isometricparkfna.Engines { + + [Receives(typeof(ToggleWindowMessage), typeof(ToggleVisibilityMessage))] + [Reads(typeof(WindowTypeComponent), typeof(VisibilityComponent))] + [Writes(typeof(VisibilityComponent))] + class UIEngine : Engine + { + + public override void Update(double dt) + { + foreach (ref readonly var windowMessage in ReadMessages()) + { + foreach (ref readonly var entity in ReadEntities()) + { + var window_type = GetComponent(entity).type; + if (window_type == windowMessage.Window) + { + var visibilityComponent = GetComponent(entity); + SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible}); + } + } + } + } + } +} \ No newline at end of file diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -90,6 +90,7 @@ private BudgetWindow budgetWindow; public bool showForest; public bool showNews; + public bool showContracts; //Encompass private WorldBuilder WorldBuilder = new WorldBuilder(); @@ -186,20 +187,32 @@ Line.initialize(GraphicsDevice); + //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: + this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); + //let's see if this works: // WorldBuilder = new WorldBuilder(); var dummy_entity = WorldBuilder.CreateEntity(); - WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, FNAGame.width, FNAGame.height)); + WorldBuilder.AddEngine(new UIEngine()); + WorldBuilder.AddEngine(new GameBridgeEngine(this)); WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(); WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine); + WorldBuilder.AddEngine(new ContractSpawner()); + WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); + WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, this.imGuiWindowBridgeEngine), 2); + var contractWindow = WorldBuilder.CreateEntity(); + WorldBuilder.SetComponent(contractWindow, new VisibilityComponent{visible = false}); + WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent{type = isometricparkfna.Messages.Window.Contracts}); + + // var budgetWindow = WorldBuilder.CreateEntity(); // WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true}); // WorldBuilder.SetComponent(budgetWindow, new BudgetComponent()); @@ -226,7 +239,6 @@ } ); - this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); var json2 = new FileInfo(@"Content/grammar.json"); @@ -710,7 +722,9 @@ drawTileAt(1, 1, 140, 2); drawTileAt(3, 2, 140, 2); + _imGuiRenderer.BeforeLayout(gameTime); World.Draw(); + // _imGuiRenderer.AfterLayout(); batch.End(); #region draw_header @@ -797,7 +811,7 @@ }; //Finally, draw the debug window - _imGuiRenderer.BeforeLayout(gameTime); + // _imGuiRenderer.BeforeLayout(gameTime); var additionalInfo = new Dictionary(); diff --git a/isometric-park-fna/Messages/ToggleWindowMessage.cs b/isometric-park-fna/Messages/ToggleWindowMessage.cs --- a/isometric-park-fna/Messages/ToggleWindowMessage.cs +++ b/isometric-park-fna/Messages/ToggleWindowMessage.cs @@ -6,7 +6,8 @@ Debug, Budget, Forest, - News + News, + Contracts } public struct ToggleWindowMessage : IMessage//, IHasEntity diff --git a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using System.Collections.Generic; + +using isometricparkfna.UI; +using isometricparkfna.Engines; +using isometricparkfna.Components; +using isometricparkfna.Messages; + +using ImGuiNET; + +using Encompass; +using SpriteFontPlus; + +namespace isometricparkfna.Renderers +{ + public class ImGuiWindowRenderer : GeneralRenderer + { + private ImFontPtr font; + private ImGuiWindowBridgeEngine BridgeEngine; + public ImGuiWindowRenderer(ImFontPtr font, ImGuiWindowBridgeEngine engine) + { + this.font = font; + this.BridgeEngine = engine; + } + + public override void Render() + { + foreach (ref readonly var entity in ReadEntities()) + { + var window_type = GetComponent(entity).type; + var visible = GetComponent(entity).visible; + + if (visible) + { + switch (window_type) + { + case Window.Contracts: + var contracts = ReadEntities(); + + var names = new List(); + + // var names = contracts.Select(entity => GetComponent(entity).DisplayName) + foreach(var e in contracts) + { + names.Add(GetComponent(e).DisplayName); + + } + + ContractsWindow.Render(this.font, this.BridgeEngine, names); + break; + default: + break; + } + } + + } + + } + + } +} \ No newline at end of file diff --git a/isometric-park-fna/UI/ContractsWindow.cs b/isometric-park-fna/UI/ContractsWindow.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/UI/ContractsWindow.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; + +using ImGuiNET; + +using isometricparkfna.Engines; +using isometricparkfna.Messages; + +using Num = System.Numerics; + +namespace isometricparkfna.UI +{ + public static class ContractsWindow + { + + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List contracts ) + { + bool newShow = true; + if (newShow) + { + ImGui.PushFont(font); + + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; + ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f); + ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f); + ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f); + ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f); + ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + + var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f); + ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar); + ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar); + ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar); + + ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f)); + ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f)); + + + + ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); + ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f)); + ImGui.SetNextWindowSize(new Num.Vector2(400, 400)); + ImGui.Begin("Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); + ImGui.ListBoxHeader("Contracts:"); + foreach (var contract in contracts) + { + // ImGui.Text(contract); + ImGui.Selectable(contract, false); + } + ImGui.ListBoxFooter(); + if (ImGui.Button("Okay")) + { + newShow = false; + } + + ImGui.End(); + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; + ImGui.PopStyleVar(4); + ImGui.PopStyleColor(12); + ImGui.PopFont(); + } + + if (!newShow) + { + engine.messages.Add(new ToggleWindowMessage {Window = Window.Contracts }); + } + + } + } +} \ No newline at end of file diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -52,6 +52,7 @@ + @@ -73,7 +74,7 @@ ..\packages\ImGui.NET.1.78.0\lib\netstandard2.0\ImGui.NET.dll - {93842D17-2CBE-40A9-AA4C-A2BCE836B817} + {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F} encompass-cs