# HG changeset patch # User Alys Brooks # Date 2021-08-17 04:25:27 # Node ID 3dd8c2d5f8e8b77a6089bf6eef1125a439464cd9 # Parent 75599c84186615fc7536c25f1960279521323177 Add Images to widgets. 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 @@ -80,7 +80,7 @@ private ImGuiRenderer _imGuiRenderer; private DebugWindow debugWindow; - public ImageMap imageMap; + public ImGuiImageMap imageMap; public bool show_another_window; private bool showInitial; @@ -194,7 +194,8 @@ var texture = Content.Load(@"solid_tileset"); ImageMap.ImageMapTexture = Content.Load(@"photos_converted3"); - this.imageMap = new ImageMap(500, 400); + ImGuiImageMap.ImGuiTexture = _imGuiRenderer.BindTexture(ImageMap.ImageMapTexture); + this.imageMap = new ImGuiImageMap(500, 400); Line.initialize(GraphicsDevice); Quad.Initialize(GraphicsDevice, texture); diff --git a/isometric-park-fna/ImGuiImageMap.cs b/isometric-park-fna/ImGuiImageMap.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/ImGuiImageMap.cs @@ -0,0 +1,20 @@ + +using System; + +using Num = System.Numerics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace isometricparkfna +{ + public class ImGuiImageMap : ImageMap + { + public static IntPtr ImGuiTexture; + + public ImGuiImageMap(int tileWidth, int tileHeight) : base(tileWidth, tileHeight) + { + } + + + } +} 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,5 +1,4 @@ -using System; using Num = System.Numerics; using Microsoft.Xna.Framework; 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,12 +31,12 @@ public static class ContractWindow { - private static ImageMap map; + private static ImGuiImageMap map; private static IntPtr _imGuiTexture; private static Dictionary hadFocus = new Dictionary(); - public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map) + public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImGuiImageMap map) { ContractWindow.map = map; @@ -82,7 +82,7 @@ ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused()); } - ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(details.image_index), map.GetSourceUVEnd(details.image_index), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used + Widgets.MapImage(map, new Num.Vector2(250, 200), details.image_index); // Here, the previously loaded texture is used ImGui.PushFont(italicFont); ImGui.TextWrapped(details.description); diff --git a/isometric-park-fna/UI/Menu.cs b/isometric-park-fna/UI/Menu.cs --- a/isometric-park-fna/UI/Menu.cs +++ b/isometric-park-fna/UI/Menu.cs @@ -15,6 +15,7 @@ public const int MENU_BAR_HEIGHT = 20; + private static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) { if (active) { @@ -47,23 +48,10 @@ ImGui.PopStyleColor(3); } - var dimensions = ImGui.CalcTextSize(indicator); - - ImGui.PushStyleColor(ImGuiCol.Text, indicatorColor); - //Found through trial and error: - ImGui.SetCursorPosX(ImGui.GetCursorPosX() -(dimensions.X + 10)); - ImGui.Text(indicator); - ImGui.PopStyleColor(); - + Widgets.Indicator(indicator, indicatorColor); - if (ImGui.IsItemHovered()) - { - var rect = ImGui.GetItemRectMax(); - ImGui.SetNextWindowPos(rect + new Num.Vector2(15, 0)); - ImGui.BeginTooltip(); - ImGui.Text(tooltip); - ImGui.EndTooltip(); - } + Widgets.Tooltip(tooltip); + return result; } @@ -72,7 +60,7 @@ { if (bridgeEngine.showContractIndicator) { - return Menu.activeButtonIndicator("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white, "(!)", StyleSets.red, "Contract offre is about to expire:\n" + string.Join("\n", bridgeEngine.contracts)); + return Menu.activeButtonIndicator("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white, "(!)", StyleSets.red, "Contract offer is about to expire:\n" + string.Join("\n", bridgeEngine.contracts)); } else { 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 @@ -45,6 +45,7 @@ + @@ -57,20 +58,7 @@ - - - - - - - - - - - - - - +