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 @@ -103,6 +103,7 @@ var start_x = random_generator.Next(0, 50); var start_y = random_generator.Next(0, 50); + var image_index = random_generator.Next(1, 7); int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares; int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares; @@ -128,6 +129,7 @@ //Round to the nearest $5 amount = (decimal)((contract_amount / 5) * 5) }); + AddComponent(contract, new ImageComponent {ImageIndex = image_index}); AddComponent(contract, new WindowTypeComponent { type = Window.Contract}); AddComponent(contract, new VisibilityComponent { visible = false}); } 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,14 +25,15 @@ this.BridgeEngine = engine; } - private (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) + private (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index) 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); + var image_index = GetComponent(entity).ImageIndex; + return (entity, name, status, amount, tree_delta, image_index); } @@ -50,7 +51,7 @@ case Window.Contracts: var contracts = ReadEntities(); - var contract_data = new List<(Entity, string, ContractStatus, decimal, string)>(); + var contract_data = new List<(Entity, string, ContractStatus, decimal, string, int)>(); foreach(var e in contracts) { @@ -63,7 +64,7 @@ var data = getContractDetails(entity); - ContractWindow.Render(this.font, this.BridgeEngine, entity, data.name, data.status, data.amount, data.delta_trees); + ContractWindow.Render(this.font, this.BridgeEngine, entity, data.name, data.status, data.amount, data.delta_trees, data.image_index); //Logging.Trace(string.Format("Rendering Contract Window for {0}", data.name)); 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 @@ -31,7 +31,7 @@ } - public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int imageIndex) { bool newShow = true; @@ -74,7 +74,7 @@ ImGui.SetNextWindowSize(new Num.Vector2(320, 340)); 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(2), map.GetSourceUVEnd(2), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used + 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) 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 @@ -17,11 +17,11 @@ { public static bool show_all; - private static (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) selected; + private static (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index) selected; public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, -List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)> contracts) +List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index)> contracts) { bool newShow = true;