diff --git a/isometric-park-fna/UI/ContractWindow.cs b/isometric-park-fna/UI/ContractWindow.cs --- a/isometric-park-fna/UI/ContractWindow.cs +++ b/isometric-park-fna/UI/ContractWindow.cs @@ -71,37 +71,37 @@ 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.SetNextWindowSize(new Num.Vector2(320, 360)); + ImGui.Begin(string.Format("Contract {0}", name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(imageIndex), map.GetSourceUVEnd(imageIndex), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used ImGui.Separator(); switch (status) - { - case ContractStatus.Proposed: - ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), status.ToString()); - break; - case ContractStatus.Active: - case ContractStatus.Accepted: - ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), status.ToString()); - break; - case ContractStatus.Rejected: - case ContractStatus.Broken: - case ContractStatus.Expired: - // if (ContractsWindow.show_all) - // { + { + case ContractStatus.Proposed: + ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), status.ToString()); + break; + case ContractStatus.Active: + case ContractStatus.Accepted: + ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), status.ToString()); + break; + case ContractStatus.Rejected: + case ContractStatus.Broken: + case ContractStatus.Expired: + // if (ContractsWindow.show_all) + // { - // ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), contract.status.ToString()); - // } - ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), status.ToString()); - break; - case ContractStatus.Completed: - ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), status.ToString()); - break; - default: + // ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), contract.status.ToString()); + // } + ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), status.ToString()); break; - } + case ContractStatus.Completed: + ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), status.ToString()); + break; + default: + break; + } ImGui.Text(string.Format("Amount: ${0}/mo.", amount)); if (delta_trees != null) @@ -127,37 +127,7 @@ 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 }); - } - - } + ContractStatusButtons(engine, entity, status); if (ImGui.Button("Okay")) { @@ -182,5 +152,38 @@ engine.selectedMessages.Add(new SelectMessage { Entity = entity }); } + + public static void ContractStatusButtons(ImGuiWindowBridgeEngine engine, Entity entity, ContractStatus status) + { + 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 }); + } + + } + } } } 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 @@ -144,35 +144,7 @@ } - if (selected.status == ContractStatus.Proposed) - { - if (ImGui.Button("Accept")) - { - System.Console.Write(string.Format("{0} selected", ContractsWindow.selected.entity)); - - engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Accepted }); - - } - ImGui.SameLine(); - if (ImGui.Button("Reject")) - { - System.Console.Write(string.Format("{0} rejected", ContractsWindow.selected.entity)); - - engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Rejected }); - - } - - } - else if (selected.status == ContractStatus.Accepted) - { - if (ImGui.Button("Cancel")) - { - System.Console.Write(string.Format("{0} canceled", ContractsWindow.selected.entity)); - - engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Broken }); - } - - } + ContractWindow.ContractStatusButtons(engine, selected.entity, selected.status); ImGui.Separator(); if (ImGui.Button("Okay"))