# HG changeset patch # User Alys Brooks # Date 2021-10-03 18:30:38 # Node ID ef53046b356139277d39c9b20f65ea9cef8e3b3a # Parent 10352dbe4f5729a3311af2a382393c5a67564efb Add image to dialog window (DialogInterface). diff --git a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs --- a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs +++ b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs @@ -195,10 +195,6 @@ } - - - - foreach(var entity in ReadEntities()) { var type = GetComponent(entity).type; @@ -233,7 +229,6 @@ } } - this.messages.Clear(); this.typeMessages.Clear(); this.contractStatusMessages.Clear(); 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 @@ -70,7 +70,7 @@ if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) { var visibilityComponent = GetComponent(entity); - AddComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible }); + 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 @@ -82,6 +82,7 @@ private DebugWindow debugWindow; public ImGuiImageMap imageMap; + public ImGuiImageMap portraitsMap; public bool show_another_window; @@ -194,10 +195,14 @@ var imageMapTexture = Content.Load(@"photos_converted3"); this.imageMap = new ImGuiImageMap(500, 400, imageMapTexture, _imGuiRenderer); + var portraitMapTexture = Content.Load(@"portraits"); + this.portraitsMap = new ImGuiImageMap(500, 400, portraitMapTexture, _imGuiRenderer); + Line.initialize(GraphicsDevice); Quad.Initialize(GraphicsDevice, texture); Logging.Success("Initialized Quad texture."); ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); + DialogInterface.LoadContent(this._imGuiRenderer, this.portraitsMap); //Must be done before SetFontMessage is sent var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), diff --git a/isometric-park-fna/ImGuiImageMap.cs b/isometric-park-fna/ImGuiImageMap.cs --- a/isometric-park-fna/ImGuiImageMap.cs +++ b/isometric-park-fna/ImGuiImageMap.cs @@ -1,5 +1,6 @@ using System; +using System.Diagnostics; using Num = System.Numerics; using Microsoft.Xna.Framework; @@ -16,7 +17,9 @@ public ImGuiImageMap(int tileWidth, int tileHeight, Texture2D ImageMapTexture, ImGuiRenderer renderer) : base(tileWidth, tileHeight, ImageMapTexture) { - this.ImGuiTexture = renderer.BindTexture(this.ImageMapTexture); + Logging.Info("Constructed ImGuiImageMap."); + this.ImGuiTexture = renderer.BindTexture(ImageMapTexture); + Debug.Assert(this.ImGuiTexture != null); } } } diff --git a/isometric-park-fna/ImageMap.cs b/isometric-park-fna/ImageMap.cs --- a/isometric-park-fna/ImageMap.cs +++ b/isometric-park-fna/ImageMap.cs @@ -1,4 +1,4 @@ - +using System.Diagnostics; using Num = System.Numerics; using Microsoft.Xna.Framework; @@ -17,6 +17,11 @@ { this.TileHeight = tileHeight; this.TileWidth = tileWidth; + this.ImageMapTexture = ImageMapTexture; + Debug.Assert(ImageMapTexture != null); + Debug.Assert(tileHeight != null); + Debug.Assert(tileWidth != null); + Logging.Info("Constructed ImageMap."); } public Rectangle GetSourceRectangle(int tileIndex) diff --git a/isometric-park-fna/UI/Dialog.cs b/isometric-park-fna/UI/Dialog.cs --- a/isometric-park-fna/UI/Dialog.cs +++ b/isometric-park-fna/UI/Dialog.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Collections.Generic; using ImGuiNET; +using ImGuiNET.SampleProgram.XNA; using isometricparkfna.Utils; using TraceryNet; using Num = System.Numerics; @@ -112,6 +113,18 @@ { public static bool hadFocus = false; + + public static ImGuiImageMap map; + private static IntPtr _imGuiTexture; + + public static void LoadContent(ImGuiRenderer _imGuiRenderer, + ImGuiImageMap map) + { + DialogInterface.map = map; + var _xnaTexture = map.ImageMapTexture; + DialogInterface._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture); + } + public static void RenderDialog(Entity entity, ImGuiWindowBridgeEngine bridgeEngine, ref bool show, ref bool paused, ImFontPtr font, DialogComponent dialogComponent) { @@ -135,6 +148,12 @@ } DialogInterface.hadFocus = ImGui.IsWindowFocused(); + ImGui.Columns(2); + + Widgets.MapImage(DialogInterface.map, new Num.Vector2(150, 100), 1); + + ImGui.NextColumn(); + if (dialogComponent.CurrentDialog != null) { @@ -142,6 +161,8 @@ ImGui.TextWrapped(messageText); } + ImGui.Columns(1); + if ((dialogComponent.Options != null) && dialogComponent.Options.Count > 0) { for(int i = 0; i < dialogComponent.Options.Count; i++) 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 @@ -95,6 +95,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest