diff --git a/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache b/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache index 5a8f5e75547049fd87cc103668ef0b15a39e7d29..b9a42296e0923fbe02ec9a8a0fcd0389964f8a69 GIT binary patch literal 15589 zc%1E<3vd)g8po$MyPKT^O#n|3P{Tt75_a>3yo4kW2zd~a@C+f$?#?Dd_T|hjkl;ZS zN))Y9!MhW*>U@@pmJhT_Ppvvs>dsTEPEpV2)hT!-B2_-CPC@1Ro6JmRw!0G&HdImN zrt;11e%=56eP8$Vc6T-$;yCU!e!vwTV{F*0Ymj_$M2Q4q?y9&H^t)RHrCV`VM`ST4 zYlSE)QY2iFSLDuf=el!qvZ~|3SX>q>!eTro3&EVMrnomK`Rc@;)=0M)uJGm-1d0N4 z0(p7 zIUMP(i#743vR?`dL8H!zWpn54v||kX%dG|;2N-D14sS8)L6qqoQfC+^w^~p{4xvn_ zcm@7-reZVQ6IWzUQ1W_0k#NLQ=q{QqL?w@=wki~K`-4HJ3zsY%v}Em4H?%2>3WV#f zfyDNEpgxc5SN7MB_=KRRS_}pSxnHQ*otKY$x+IsW4I@L9Ny9Qz=@=o!7m@M1YPob= zuEkR?d1XQF@zlsdNZb^WyA@9ZuHp{puRU7lC>q1i0AsLl)}VQSQWxM-E0fqf^g_K9 zzE%~#5Q`TNiqISn$E1+xZV_ck2ui&I3{kai2CmzjWH8Xp#JVd++`WSjov~PZ;fS>x z;~|^{pQ1{Q!%|lcnmVJS$E%qdX{+oWxG2d(!xG=`l057e2r)qwz8DL4B~f_r9=`;) zHe=9kS|AIXq;RKNdIBze&G385GGAP(j^89E&crtnYtI}s8cQEe!o?Sic;J~Eo;>7e zH~ROov%1GD)6?Z=HPahJ@cGn~j2^M{a~4*ee^zmV%9J5{)RK{@xOj=DD-setLa;~i z$YM02cq9eC5yRa+8-GrB&klqIPfcT`$183+*$p=#arVvaKm|`$< zz{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r zI7|8|D)j-T^fQF?vn=W7IojZRfhqkWA^j3d`XE*M6{hs7g!Cbn^lKa~*RM0B-yo#l zWJ$k8r9RA*eut2LmnHoHN9)Fqn9?5;(x0%TKcz|^VM-q*q(5g#AEQdc8O*(^^mJUO zkK^EOc0xnbVdYtw2SNz{q`rM}<)J4&{N@4oj{O-={BpsU$9~yx;!?Colhd-{Io%Q*5`V%jG}y{bAdo&o*V=_P5kcOJ^R-zi{_)$BEC6O*#0` z*T=r~udN@m=jF%t&S>}M>=$z`JNd7QSbJplf4|+j?#YZpf2_D_@~&~!;)JZw!99fy zYYy+p_(~7;sd*jS#=e(UicYXX{f46rtM8au{GQ0-4=m{)Iohx~dER946p_WBS)syO ziySa;KtszgDO3XDVtz7Z8G+fG|R$@ocmHETflT-oj$uYG&T4r=yP$ QxSl1jgC>A>>MZI12c@cbOaK4? diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs --- a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -128,6 +128,8 @@ //Round to the nearest $5 amount = (decimal)((contract_amount / 5) * 5) }); + AddComponent(contract, new WindowTypeComponent { type = Window.Contract}); + AddComponent(contract, new VisibilityComponent { visible = false}); } } diff --git a/isometric-park-fna/Engines/UIEngine.cs b/isometric-park-fna/Engines/UIEngine.cs --- a/isometric-park-fna/Engines/UIEngine.cs +++ b/isometric-park-fna/Engines/UIEngine.cs @@ -30,11 +30,18 @@ foreach (ref readonly var entity in ReadEntities()) { var window_type = GetComponent(entity).type; - if (window_type == windowMessage.Window) + if (window_type == windowMessage.Window && !EntityExists(windowMessage.Entity)) { var visibilityComponent = GetComponent(entity); SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible}); } + //else if (window_type == windowMessage.Window && entity == windowMessage.Entity) { + // else if (entity == windowMessage.Entity) { + else if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) { + var visibilityComponent = GetComponent(entity); + SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible}); + + } } } 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 @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; @@ -848,7 +848,27 @@ { past_fps.Enqueue(this.frameRate); +/* + if (this.frameRate > 60.0) + { + Logging.Warning(String.Format("Framerate is higher than limit: {0}", this.frameRate)); + } + if (this.frameRate < 30.0) + { + Logging.Warning(String.Format("Framerate is lower than desired: {0}", this.frameRate)); + }*/ } + /* + if (this.frameRate > 120.0) + { + Logging.Error(String.Format("Framerate is much higher than limit: {0}", this.frameRate)); + } + else if (this.frameRate < 15.0) + { + Logging.Error(String.Format("Framerate is much lower than desired: {0}", this.frameRate)); + } + */ + DebugInfo debugInfo = new DebugInfo { fps = this.frameRate, 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 @@ -7,12 +7,15 @@ Budget, Forest, News, - Contracts + Contracts, + Contract } - public struct ToggleWindowMessage : IMessage//, IHasEntity + //You must specify both or you get 0 for a window, which is the default window :( + public struct ToggleWindowMessage : IMessage, IHasEntity { public Window Window; + public Entity Entity { set; get; } } } diff --git a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs --- a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs +++ b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs @@ -25,6 +25,17 @@ this.BridgeEngine = engine; } + private (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) + getContractDetails(Entity entity) { + + var name = GetComponent(entity).DisplayName; + var status = GetComponent(entity).status; + var amount = GetComponent(entity).amount; + var tree_delta = GetComponent(entity).deltaTreesName; + return (entity, name, status, amount, tree_delta); + + } + public override void Render() { foreach (ref readonly var entity in ReadEntities()) @@ -41,19 +52,23 @@ var contract_data = new List<(Entity, string, ContractStatus, decimal, string)>(); - // var names = contracts.Select(entity => GetComponent(entity).DisplayName) foreach(var e in contracts) { - var name = GetComponent(e).DisplayName; - var status = GetComponent(e).status; - var amount = GetComponent(e).amount; - var tree_delta = GetComponent(e).deltaTreesName; - contract_data.Add((e, name, status, amount, tree_delta)); - + contract_data.Add(getContractDetails(e)); } ContractsWindow.Render(this.font, this.BridgeEngine, contract_data); break; + case Window.Contract: + + var data = getContractDetails(entity); + + ContractWindow.Render(this.font, this.BridgeEngine, entity, data.name, data.status, data.amount, data.delta_trees); + + //Logging.Trace(string.Format("Rendering Contract Window for {0}", data.name)); + + break; + default: break; } diff --git a/isometric-park-fna/UI/ContractWindow.cs b/isometric-park-fna/UI/ContractWindow.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/UI/ContractWindow.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Linq; + +using ImGuiNET; + +using isometricparkfna.Components; +using isometricparkfna.Engines; +using isometricparkfna.Messages; + +using Num = System.Numerics; + +using Encompass; + +namespace isometricparkfna.UI +{ + public static class ContractWindow + { + + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) + + { + bool newShow = true; + + // Entity newSelected; + var grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f); + var darkgrey = new Num.Vector4(0.45f, 0.45f, 0.45f, 1f); + var black = new Num.Vector4(0f, 0f, 0f, 1f); + var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f); + + 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, grey); + ImGui.PushStyleColor(ImGuiCol.FrameBg, grey); + ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, grey); + ImGui.PushStyleColor(ImGuiCol.Header, darkgrey); + ImGui.PushStyleColor(ImGuiCol.HeaderHovered, darkgrey); + ImGui.PushStyleColor(ImGuiCol.HeaderActive, darkgrey); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, grey); + ImGui.PushStyleColor(ImGuiCol.CheckMark, black); + + ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar); + ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar); + ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar); + + ImGui.PushStyleColor(ImGuiCol.Border, black); + ImGui.PushStyleColor(ImGuiCol.BorderShadow, black); + + + + ImGui.PushStyleColor(ImGuiCol.Button, grey); + ImGui.PushStyleColor(ImGuiCol.Text, black); + ImGui.SetNextWindowSize(new Num.Vector2(320, 340)); + ImGui.Begin(string.Format("Contract {0}" , name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); + + + ImGui.Separator(); + ImGui.Text(string.Format("Amount: ${0}/mo.", amount)); + + if (delta_trees != null) + { + ImGui.Text("Sustainability: "); + + + ImGui.SameLine(); + var color = new Num.Vector4(1f, 1f, 1f, 1f); + switch (delta_trees) + { + case "Unsustainable": + color = new Num.Vector4(0.95f, 0.25f, 0.25f, 1f); + break; + case "Restoration": + color = new Num.Vector4(0.25f, 0.95f, 0.25f, 1f); + break; + case "Moderately unsustainable": + case "Somewhat unsustainable": + color = new Num.Vector4(0.95f, 0.65f, 0.25f, 1f); + break; + } + ImGui.TextColored(color, delta_trees); + } + + + + if (status == ContractStatus.Proposed) + { + if (ImGui.Button("Accept")) + { + System.Console.Write(string.Format("{0} selected", entity)); + + engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Accepted }); + + } + ImGui.SameLine(); + if (ImGui.Button("Reject")) + { + System.Console.Write(string.Format("{0} rejected", entity)); + + engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Rejected }); + + } + + } + else if (status == ContractStatus.Accepted) + { + if (ImGui.Button("Cancel")) + { + System.Console.Write(string.Format("{0} canceled", entity)); + + engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Broken }); + } + + } + + ImGui.Separator(); + if (ImGui.Button("Okay")) + { + newShow = false; + } + // Logging.Trace("Almost done."); + + ImGui.End(); + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; + ImGui.PopStyleVar(4); + ImGui.PopStyleColor(15); + ImGui.PopFont(); + + // Logging.Trace("Finished."); + } + + if (!newShow) + { + engine.messages.Add(new ToggleWindowMessage {Window = Window.Contract, Entity = entity }); + } + + engine.selectedMessages.Add(new SelectMessage { Entity = entity }); + + } + } +} diff --git a/isometric-park-fna/UI/ContractsWindow.cs b/isometric-park-fna/UI/ContractsWindow.cs --- a/isometric-park-fna/UI/ContractsWindow.cs +++ b/isometric-park-fna/UI/ContractsWindow.cs @@ -20,8 +20,8 @@ private static (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) selected; - public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, - List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)> contracts) + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, +List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)> contracts) { bool newShow = true; @@ -136,6 +136,13 @@ } + if (ImGui.Button("Open")) + { + System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity)); + + engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity}); + + } if (selected.status == ContractStatus.Proposed) { @@ -176,7 +183,7 @@ ImGui.End(); ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; ImGui.PopStyleVar(4); - ImGui.PopStyleColor(16); + ImGui.PopStyleColor(15); ImGui.PopFont(); }