Description:
Add image to Contact (merge in proto-image).
Commit status:
[Not Reviewed]
References:
merge m3-contracts
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r248:dd64f6c84f8f -

1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,69
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 ImageMap
11 {
12 static public Texture2D ImageMapTexture;
13
14 public int TileWidth;
15 public int TileHeight;
16
17 public ImageMap(int tileWidth, int tileHeight )
18 {
19 this.TileHeight = tileHeight;
20 this.TileWidth = tileWidth;
21 }
22
23 public Rectangle GetSourceRectangle(int tileIndex)
24 {
25 int tileY = tileIndex / (ImageMapTexture.Width / TileWidth);
26 int tileX = tileIndex % (ImageMapTexture.Width / TileWidth);
27
28 return new Rectangle(tileX * TileWidth, tileY * TileHeight, TileWidth, TileHeight);
29 }
30 public Num.Vector2 GetSourceUVStart(int tileIndex)
31 {
32 int tileX = tileIndex % (ImageMapTexture.Width / TileWidth);
33 int tileY = tileIndex / (ImageMapTexture.Width / TileWidth);
34
35 int imageMapX = (tileX) * TileWidth;
36 int imageMapY = (tileY) * TileHeight;
37
38
39 return new Num.Vector2( ((float)imageMapX)/ImageMapTexture.Width,
40 ((float)imageMapY)/ImageMapTexture.Height);
41
42 }
43 public Num.Vector2 GetSourceUVEnd(int tileIndex)
44 {
45 int tileX = tileIndex % (ImageMapTexture.Width / TileWidth);
46 int tileY = tileIndex / (ImageMapTexture.Width / TileWidth);
47
48 int imageMapX = (tileX+1) * TileWidth;
49 int imageMapY = (tileY+1) * TileHeight;
50
51
52 return new Num.Vector2( ((float)imageMapX)/ImageMapTexture.Width,
53 ((float)imageMapY)/ImageMapTexture.Height);
54
55 }
56
57 public Rectangle GetExtendedSourceRectangle(int tileIndex, int height)
58 {
59 int tileY = tileIndex / (ImageMapTexture.Width / TileWidth);
60 int tileX = tileIndex % (ImageMapTexture.Width / TileWidth);
61
62 return new Rectangle(tileX * TileWidth, tileY * TileHeight, TileWidth, TileHeight*height);
63 }
64
65
66
67
68 }
69 }
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -8,12 +8,7
8 "restore": {
8 "restore": {
9 "projectUniqueName": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj",
9 "projectUniqueName": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj",
10 "projectName": "FNA",
10 "projectName": "FNA",
11 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj",
11 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj"
12 "frameworks": {
13 "net48": {
14 "projectReferences": {}
15 }
16 }
17 },
12 },
18 "frameworks": {
13 "frameworks": {
19 "net48": {}
14 "net48": {}
@@ -39,6 +34,7
39 },
34 },
40 "frameworks": {
35 "frameworks": {
41 "net45": {
36 "net45": {
37 "targetAlias": "net45",
42 "projectReferences": {
38 "projectReferences": {
43 "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
39 "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
44 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj"
40 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj"
@@ -54,7 +50,8
54 },
50 },
55 "frameworks": {
51 "frameworks": {
56 "net45": {
52 "net45": {
57 "runtimeIdentifierGraphPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/RuntimeIdentifierGraph.json"
53 "targetAlias": "net45",
54 "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/5.0.202/RuntimeIdentifierGraph.json"
58 }
55 }
59 }
56 }
60 }
57 }
@@ -7,8 +7,11
7 <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageRoot>
7 <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageRoot>
8 <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageFolders>
8 <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageFolders>
9 <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
9 <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10 <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
10 <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.8.0</NuGetToolVersion>
11 </PropertyGroup>
11 </PropertyGroup>
12 <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13 <SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageFolders)))" />
14 </ItemGroup>
12 <PropertyGroup>
15 <PropertyGroup>
13 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
16 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
14 </PropertyGroup>
17 </PropertyGroup>
@@ -69,6 +69,8
69 private ImGuiRenderer _imGuiRenderer;
69 private ImGuiRenderer _imGuiRenderer;
70 private DebugWindow debugWindow;
70 private DebugWindow debugWindow;
71
71
72 public ImageMap imageMap;
73
72 public bool show_another_window;
74 public bool show_another_window;
73 private bool showInitial;
75 private bool showInitial;
74 int messageIndex;
76 int messageIndex;
@@ -186,12 +188,15
186 Tile.TileSetTexture = Content.Load<Texture2D>(@"part4_tileset");
188 Tile.TileSetTexture = Content.Load<Texture2D>(@"part4_tileset");
187 var texture = Content.Load<Texture2D>(@"solid_tileset");
189 var texture = Content.Load<Texture2D>(@"solid_tileset");
188
190
189 Line.initialize(GraphicsDevice);
191 ImageMap.ImageMapTexture = Content.Load<Texture2D>(@"photos_converted");
192 this.imageMap = new ImageMap(500, 400);
190
193
194 Line.initialize(GraphicsDevice);
191 Quad.Initialize(GraphicsDevice, texture);
195 Quad.Initialize(GraphicsDevice, texture);
196 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
192
197
193 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
198 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
194 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
199 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
195
200
196 //Has to happen before Encompass stuff, so Spawners can use the grammar:
201 //Has to happen before Encompass stuff, so Spawners can use the grammar:
197 var json2 = new FileInfo(@"Content/grammar.json");
202 var json2 = new FileInfo(@"Content/grammar.json");
@@ -1,7 +1,9
1 using System;
1 using System.Collections.Generic;
2 using System.Collections.Generic;
2 using System.Linq;
3 using System.Linq;
3
4
4 using ImGuiNET;
5 using ImGuiNET;
6 using ImGuiNET.SampleProgram.XNA;
5
7
6 using isometricparkfna.Components;
8 using isometricparkfna.Components;
7 using isometricparkfna.Engines;
9 using isometricparkfna.Engines;
@@ -16,6 +18,19
16 public static class ContractWindow
18 public static class ContractWindow
17 {
19 {
18
20
21 private static ImageMap map;
22 private static IntPtr _imGuiTexture;
23
24 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
25 {
26
27 ContractWindow.map = map;
28
29 var _xnaTexture = ImageMap.ImageMapTexture;
30 ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
31 }
32
33
19 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)
34 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)
20
35
21 {
36 {
@@ -59,6 +74,7
59 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
74 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
60 ImGui.Begin(string.Format("Contract {0}" , name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
75 ImGui.Begin(string.Format("Contract {0}" , name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
61
76
77 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
62
78
63 ImGui.Separator();
79 ImGui.Separator();
64 switch (status)
80 switch (status)
@@ -33,8 +33,10
33
33
34 public ImFontPtr monoFont;
34 public ImFontPtr monoFont;
35
35
36 public ImageMap map;
36
37
37 public DebugWindow(ImGuiRenderer _imGuiRenderer, GraphicsDevice graphicsDevice)
38
39 public DebugWindow(ImGuiRenderer _imGuiRenderer, GraphicsDevice graphicsDevice, ImageMap map)
38 {
40 {
39 ImGuiIOPtr io = ImGui.GetIO();
41 ImGuiIOPtr io = ImGui.GetIO();
40 //io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-medium.ttf", 15);
42 //io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-medium.ttf", 15);
@@ -65,12 +67,14
65 _imGuiRenderer.RebuildFontAtlas(); // Required so fonts are available for rendering
67 _imGuiRenderer.RebuildFontAtlas(); // Required so fonts are available for rendering
66
68
67
69
68 _xnaTexture = CreateTexture(graphicsDevice, 300, 150, pixel =>
70 this.map = map;
69 {
71 _xnaTexture = ImageMap.ImageMapTexture;
70 var red = (pixel % 300) / 2;
72 // _xnaTexture = CreateTexture(graphicsDevice, 300, 150, pixel =>
71 return new Color(red, 1, 1);
73 // {
72 });
74 // var red = (pixel % 300) / 2;
73
75 // return new Color(red, 1, 1);
76 // });
77 //
74 // Then, bind it to an ImGui-friendly pointer, that we can use during regular ImGui.** calls (see below)
78 // Then, bind it to an ImGui-friendly pointer, that we can use during regular ImGui.** calls (see below)
75 _imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
79 _imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
76 }
80 }
@@ -119,7 +123,7
119 ImGui.InputText("Text input", _textBuffer, 100);
123 ImGui.InputText("Text input", _textBuffer, 100);
120
124
121 ImGui.Text("Texture sample");
125 ImGui.Text("Texture sample");
122 ImGui.Image(_imGuiTexture, new Num.Vector2(300, 150), Num.Vector2.Zero, Num.Vector2.One, Num.Vector4.One, Num.Vector4.One); // Here, the previously loaded texture is used
126 // ImGui.Image(_imGuiTexture, new Num.Vector2(300, 150), Num.Vector2.Zero, map.GetSourceUV(1), Num.Vector4.One, Num.Vector4.One); // Here, the previously loaded texture is used
123 }
127 }
124 }
128 }
125
129
@@ -178,8 +182,14
178 {
182 {
179 ImGui.Text(string.Format("{0}: {1}", k, additionalInfo[k]));
183 ImGui.Text(string.Format("{0}: {1}", k, additionalInfo[k]));
180 }
184 }
185
186 ImGui.Text("Texture sample");
187 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(1), map.GetSourceUVEnd(1), Num.Vector4.One, Num.Vector4.One); // Here, the previously loaded texture is used
188 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(4), map.GetSourceUVEnd(4), Num.Vector4.One, Num.Vector4.One); // Here, the previously loaded texture is used
189
181 ImGui.End();
190 ImGui.End();
182 }
191 }
192
183
193
184
194
185 if (this.show_test_window)
195 if (this.show_test_window)
@@ -42,6 +42,7
42 <Compile Include="Camera.cs" />
42 <Compile Include="Camera.cs" />
43 <Compile Include="DrawVertDeclaration.cs" />
43 <Compile Include="DrawVertDeclaration.cs" />
44 <Compile Include="ImGuiRenderer.cs" />
44 <Compile Include="ImGuiRenderer.cs" />
45 <Compile Include="ImageMap.cs" />
45 <Compile Include="FilledRectangle.cs" />
46 <Compile Include="FilledRectangle.cs" />
46 <Compile Include="Simulation.cs" />
47 <Compile Include="Simulation.cs" />
47 <Compile Include="Logging.cs" />
48 <Compile Include="Logging.cs" />
@@ -55,7 +56,8
55 <Compile Include="Utils\Extensions.cs" />
56 <Compile Include="Utils\Extensions.cs" />
56 <Compile Include="Utils\Node.cs" />
57 <Compile Include="Utils\Node.cs" />
57 <Compile Include="UI\BudgetWindow.cs" />
58 <Compile Include="UI\BudgetWindow.cs" />
58 <Compile Include="UI\ContractsWindow.cs" />
59 <Compile Include="UI\ContractWindow.cs" />
60 <Compile Include="UI\ContractsWindow.cs" />
59 <Compile Include="UI\DebugWindow.cs" />
61 <Compile Include="UI\DebugWindow.cs" />
60 <Compile Include="UI\Dialog.cs" />
62 <Compile Include="UI\Dialog.cs" />
61 <Compile Include="UI\ForestWindow.cs" />
63 <Compile Include="UI\ForestWindow.cs" />
You need to be logged in to leave comments. Login now