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 @@ -16,6 +16,7 @@ // AddComponent AddComponent(contract, new AreaComponent{squares = message.squares}); AddComponent(contract, new NameComponent{DisplayName = message.name}); + AddComponent(contract, new ContractStatusComponent {status = ContractStatus.Proposed}); } } 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 @@ -220,8 +220,10 @@ var area = WorldBuilder.CreateEntity(); // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}}); WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)}, - name = "Contract"}); + name = "Northshore Logging"}); + WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)}, + name = "Aeres Maximalis Ltd."}); World = WorldBuilder.Build(); var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), 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 @@ -39,16 +39,18 @@ case Window.Contracts: var contracts = ReadEntities(); - var names = new List(); + var contract_data = new List<(string, ContractStatus)>(); // var names = contracts.Select(entity => GetComponent(entity).DisplayName) foreach(var e in contracts) { - names.Add(GetComponent(e).DisplayName); + var name = GetComponent(e).DisplayName; + var status = GetComponent(e).status; + contract_data.Add((name, status)); } - ContractsWindow.Render(this.font, this.BridgeEngine, names); + ContractsWindow.Render(this.font, this.BridgeEngine, contract_data); break; default: break; 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 @@ -2,6 +2,7 @@ using ImGuiNET; +using isometricparkfna.Components; using isometricparkfna.Engines; using isometricparkfna.Messages; @@ -11,62 +12,88 @@ { public static class ContractsWindow { + public static string selected; - public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List contracts ) + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List<(string name, ContractStatus status)> contracts) { - bool newShow = true; - if (newShow) - { - ImGui.PushFont(font); + 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)); + 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); + 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.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.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(string.Format("{0}\t{1}", contract.name, contract.status.ToString()), false); + if (ImGui.Selectable(contract.name, ContractsWindow.selected == contract.name)) + { + ContractsWindow.selected = contract.name; + } - ImGui.End(); - ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; - ImGui.PopStyleVar(4); - ImGui.PopStyleColor(12); - ImGui.PopFont(); + ImGui.SameLine(); + switch (contract.status) + { + case ContractStatus.Proposed: + ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), contract.status.ToString()); + break; + case ContractStatus.Active: + case ContractStatus.Accepted: + ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), contract.status.ToString()); + break; + + default: + break; + } + } + ImGui.ListBoxFooter(); + if (ImGui.Button("Select")) + { + System.Console.Write(string.Format("{0} selected", ContractsWindow.selected)); + + + } + if (ImGui.Button("Okay")) + { + newShow = false; } - if (!newShow) - { - engine.messages.Add(new ToggleWindowMessage {Window = Window.Contracts }); - } + 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 }); + } } }