|
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
7 | 7 | using System.Linq; |
| 8 | +using TSMapEditor.CCEngine; |
8 | 9 | using TSMapEditor.Models; |
9 | 10 | using TSMapEditor.Models.ArtConfig; |
10 | 11 | using TSMapEditor.Rendering; |
11 | | -using TSMapEditor.Rendering.ObjectRenderers; |
12 | 12 |
|
13 | 13 | namespace TSMapEditor.UI.Sidebar |
14 | 14 | { |
@@ -143,6 +143,28 @@ private void SearchBox_TextChanged(object sender, EventArgs e) |
143 | 143 |
|
144 | 144 | protected abstract void InitObjects(); |
145 | 145 |
|
| 146 | + protected (Texture2D regular, Texture2D remap) GetTextureForVoxel<T>(T objectType, VoxelModel[] typeGraphicsArray, RenderTarget2D renderTarget, byte facing) where T : TechnoType, IArtConfigContainer |
| 147 | + { |
| 148 | + Renderer.BeginDraw(); |
| 149 | + |
| 150 | + var frame = typeGraphicsArray[objectType.Index].GetFrame(facing, RampType.None, false); |
| 151 | + if (frame == null || frame.Texture == null) |
| 152 | + return (null, null); |
| 153 | + |
| 154 | + var remapFrame = typeGraphicsArray[objectType.Index].GetRemapFrame(facing, RampType.None, false); |
| 155 | + |
| 156 | + Renderer.EndDraw(); |
| 157 | + |
| 158 | + // Render them as smaller textures to be independent of the voxel cache |
| 159 | + Texture2D regularTexture = Helpers.RenderTextureAsSmaller(frame.Texture, renderTarget, GraphicsDevice); |
| 160 | + Texture2D remapTexture = null; |
| 161 | + |
| 162 | + if (remapFrame != null && remapFrame.Texture != null) |
| 163 | + remapTexture = Helpers.RenderTextureAsSmaller(remapFrame.Texture, renderTarget, GraphicsDevice); |
| 164 | + |
| 165 | + return (regularTexture, remapTexture); |
| 166 | + } |
| 167 | + |
146 | 168 | protected virtual (Texture2D regular, Texture2D remap) GetObjectTextures<T>(T objectType, ShapeImage[] textures) where T : TechnoType, IArtConfigContainer |
147 | 169 | { |
148 | 170 | Texture2D texture = null; |
@@ -218,7 +240,20 @@ protected void InitObjectsBase<T>(List<T> objectTypeList, ShapeImage[] textures, |
218 | 240 |
|
219 | 241 | House ownerHouse = Map.StandardHouses.Find(h => h.ININame == ownerName); |
220 | 242 | if (ownerHouse != null) |
| 243 | + { |
221 | 244 | remapColor = ownerHouse.XNAColor; |
| 245 | + } |
| 246 | + else |
| 247 | + { |
| 248 | + // As as last resort, check if EditorRules has a remap color specified for the side |
| 249 | + string colorOverrideName = Map.EditorConfig.EditorRulesIni.GetStringValue("ObjectOwnerColors", ownerName, null); |
| 250 | + if (!string.IsNullOrWhiteSpace(colorOverrideName)) |
| 251 | + { |
| 252 | + var rulesColor = Map.Rules.Colors.Find(c => c.Name == colorOverrideName); |
| 253 | + if (rulesColor != null) |
| 254 | + remapColor = rulesColor.XNAColor; |
| 255 | + } |
| 256 | + } |
222 | 257 |
|
223 | 258 | // Prevent duplicates that can occur due to category overrides |
224 | 259 | // (For example, if objects owned by "Soviet1" are overridden to be listed under |
|
0 commit comments