Description:
Add Images to widgets.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r411:3dd8c2d5f8e8 -

@@ -0,0 +1,20
1
2 using System;
3
4 using Num = System.Numerics;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
7
8 namespace isometricparkfna
9 {
10 public class ImGuiImageMap : ImageMap
11 {
12 public static IntPtr ImGuiTexture;
13
14 public ImGuiImageMap(int tileWidth, int tileHeight) : base(tileWidth, tileHeight)
15 {
16 }
17
18
19 }
20 }
@@ -80,7 +80,7
80 private ImGuiRenderer _imGuiRenderer;
80 private ImGuiRenderer _imGuiRenderer;
81 private DebugWindow debugWindow;
81 private DebugWindow debugWindow;
82
82
83 public ImageMap imageMap;
83 public ImGuiImageMap imageMap;
84
84
85 public bool show_another_window;
85 public bool show_another_window;
86 private bool showInitial;
86 private bool showInitial;
@@ -194,7 +194,8
194 var texture = Content.Load<Texture2D>(@"solid_tileset");
194 var texture = Content.Load<Texture2D>(@"solid_tileset");
195
195
196 ImageMap.ImageMapTexture = Content.Load<Texture2D>(@"photos_converted3");
196 ImageMap.ImageMapTexture = Content.Load<Texture2D>(@"photos_converted3");
197 this.imageMap = new ImageMap(500, 400);
197 ImGuiImageMap.ImGuiTexture = _imGuiRenderer.BindTexture(ImageMap.ImageMapTexture);
198 this.imageMap = new ImGuiImageMap(500, 400);
198
199
199 Line.initialize(GraphicsDevice);
200 Line.initialize(GraphicsDevice);
200 Quad.Initialize(GraphicsDevice, texture);
201 Quad.Initialize(GraphicsDevice, texture);
@@ -1,5 +1,4
1
1
2 using System;
3
2
4 using Num = System.Numerics;
3 using Num = System.Numerics;
5 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework;
@@ -31,12 +31,12
31 public static class ContractWindow
31 public static class ContractWindow
32 {
32 {
33
33
34 private static ImageMap map;
34 private static ImGuiImageMap map;
35 private static IntPtr _imGuiTexture;
35 private static IntPtr _imGuiTexture;
36
36
37 private static Dictionary<string, bool> hadFocus = new Dictionary<string, bool>();
37 private static Dictionary<string, bool> hadFocus = new Dictionary<string, bool>();
38
38
39 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
39 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImGuiImageMap map)
40 {
40 {
41 ContractWindow.map = map;
41 ContractWindow.map = map;
42
42
@@ -82,7 +82,7
82 ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused());
82 ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused());
83 }
83 }
84
84
85 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
85 Widgets.MapImage(map, new Num.Vector2(250, 200), details.image_index); // Here, the previously loaded texture is used
86
86
87 ImGui.PushFont(italicFont);
87 ImGui.PushFont(italicFont);
88 ImGui.TextWrapped(details.description);
88 ImGui.TextWrapped(details.description);
@@ -15,6 +15,7
15
15
16 public const int MENU_BAR_HEIGHT = 20;
16 public const int MENU_BAR_HEIGHT = 20;
17
17
18
18 private static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) {
19 private static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) {
19
20
20 if (active) {
21 if (active) {
@@ -47,23 +48,10
47 ImGui.PopStyleColor(3);
48 ImGui.PopStyleColor(3);
48 }
49 }
49
50
50 var dimensions = ImGui.CalcTextSize(indicator);
51 Widgets.Indicator(indicator, indicatorColor);
51
52 ImGui.PushStyleColor(ImGuiCol.Text, indicatorColor);
53 //Found through trial and error:
54 ImGui.SetCursorPosX(ImGui.GetCursorPosX() -(dimensions.X + 10));
55 ImGui.Text(indicator);
56 ImGui.PopStyleColor();
57
58
52
59 if (ImGui.IsItemHovered())
53 Widgets.Tooltip(tooltip);
60 {
54
61 var rect = ImGui.GetItemRectMax();
62 ImGui.SetNextWindowPos(rect + new Num.Vector2(15, 0));
63 ImGui.BeginTooltip();
64 ImGui.Text(tooltip);
65 ImGui.EndTooltip();
66 }
67
55
68 return result;
56 return result;
69 }
57 }
@@ -72,7 +60,7
72 {
60 {
73 if (bridgeEngine.showContractIndicator)
61 if (bridgeEngine.showContractIndicator)
74 {
62 {
75 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));
63 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));
76 }
64 }
77 else
65 else
78 {
66 {
@@ -45,6 +45,7
45 <Compile Include="DrawVertDeclaration.cs" />
45 <Compile Include="DrawVertDeclaration.cs" />
46 <Compile Include="ImGuiRenderer.cs" />
46 <Compile Include="ImGuiRenderer.cs" />
47 <Compile Include="ImageMap.cs" />
47 <Compile Include="ImageMap.cs" />
48 <Compile Include="ImGuiImageMap.cs" />
48 <Compile Include="FilledRectangle.cs" />
49 <Compile Include="FilledRectangle.cs" />
49 <Compile Include="Simulation.cs" />
50 <Compile Include="Simulation.cs" />
50 <Compile Include="Logging.cs" />
51 <Compile Include="Logging.cs" />
@@ -57,20 +58,7
57 <Compile Include="Utils\MathUtils.cs" />
58 <Compile Include="Utils\MathUtils.cs" />
58 <Compile Include="Utils\Extensions.cs" />
59 <Compile Include="Utils\Extensions.cs" />
59 <Compile Include="Utils\Node.cs" />
60 <Compile Include="Utils\Node.cs" />
60 <Compile Include="UI\BudgetWindow.cs" />
61 <Compile Include="UI\*.cs" />
61 <Compile Include="UI\ContractWindow.cs" />
62 <Compile Include="UI\ContractsWindow.cs" />
63 <Compile Include="UI\DebugWindow.cs" />
64 <Compile Include="UI\Dialog.cs" />
65 <Compile Include="UI\ForestWindow.cs" />
66 <Compile Include="UI\Menu.cs" />
67 <Compile Include="UI\NewsWindow.cs" />
68 <Compile Include="UI\StyleSet.cs" />
69 <Compile Include="UI\StyleSets.cs" />
70 <Compile Include="UI\MainMenu.cs" />
71 <Compile Include="UI\InGameMenu.cs" />
72 <Compile Include="UI\OptionsWindow.cs" />
73 <Compile Include="UI\NewGameWindow.cs" />
74 </ItemGroup>
62 </ItemGroup>
75 <ItemGroup>
63 <ItemGroup>
76 <ProjectReference Include="..\FNA\FNA.csproj">
64 <ProjectReference Include="..\FNA\FNA.csproj">
You need to be logged in to leave comments. Login now