|
8 | 8 | using System.Linq;
|
9 | 9 | using Color = System.Drawing.Color;
|
10 | 10 | using Mesh = SAModel.Direct3D.Mesh;
|
| 11 | +using SAModel.Direct3D.TextureSystem; |
11 | 12 |
|
12 | 13 | namespace SAModel.SAEditorCommon.SETEditing
|
13 | 14 | {
|
@@ -85,6 +86,50 @@ public static Texture[] GetTextures(string name, SplitTools.NJS_TEXLIST texnames
|
85 | 86 | return texlist.ToArray();
|
86 | 87 | }
|
87 | 88 | }
|
| 89 | + // This is primarily used for SA2 level objects that pull from multiple texture sources. |
| 90 | + // Copied from pieces of SAMDL's code. |
| 91 | + public static Texture[] GetTexturesMultiSource(List<string> name, SplitTools.NJS_TEXLIST texnames = null, Device dev = null) |
| 92 | + { |
| 93 | + Texture[] result = null; |
| 94 | + if (texnames == null) |
| 95 | + return result; |
| 96 | + else |
| 97 | + { |
| 98 | + List<BMPInfo> texturedata = new List<BMPInfo>(); |
| 99 | + Direct3D.TextureSystem.BMPInfo[] texturebmps = null; |
| 100 | + if (texturebmps != null && texturebmps.Length > 0) |
| 101 | + texturedata.AddRange(texturebmps); |
| 102 | + for (int i = 0; i < name.Count; i++) |
| 103 | + { |
| 104 | + if (LevelData.TextureBitmaps.ContainsKey(name[i])) |
| 105 | + texturedata.AddRange(LevelData.TextureBitmaps[name[i]]); |
| 106 | + else if (LevelData.TextureBitmaps.ContainsKey(name[i].ToUpperInvariant())) |
| 107 | + texturedata.AddRange(LevelData.TextureBitmaps[name[i].ToUpperInvariant()]); |
| 108 | + else if (LevelData.TextureBitmaps.ContainsKey(name[i].ToLowerInvariant())) |
| 109 | + texturedata.AddRange(LevelData.TextureBitmaps[name[i].ToLowerInvariant()]); |
| 110 | + } |
| 111 | + texturebmps = texturedata.ToArray(); |
| 112 | + if (LevelData.TextureBitmaps == null || dev == null) |
| 113 | + return result; |
| 114 | + List<Texture> texlist = new List<Texture>(); |
| 115 | + List<BMPInfo> texinfo = new List<BMPInfo>(); |
| 116 | + List<string> dupnames = new List<string>(); |
| 117 | + for (int i = 0; i < texnames.TextureNames.Length; i++) |
| 118 | + { |
| 119 | + for (int b = 0; b < texturebmps.Length; b++) |
| 120 | + { |
| 121 | + if (string.IsNullOrEmpty(texnames.TextureNames[i]) || (texnames.TextureNames[i].ToLowerInvariant() == texturebmps[b].Name.ToLowerInvariant() && !dupnames.Contains(texnames.TextureNames[i].ToLowerInvariant()))) |
| 122 | + { |
| 123 | + texinfo.Add(texturebmps[b]); |
| 124 | + texlist.Add(texturebmps[b].Image.ToTexture(dev)); |
| 125 | + dupnames.Add(texturebmps[b].Name.ToLowerInvariant()); |
| 126 | + continue; |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + return texlist.ToArray(); |
| 131 | + } |
| 132 | + } |
88 | 133 |
|
89 | 134 | public static HitResult CheckQuestionBoxHit(Vector3 Near, Vector3 Far, Viewport Viewport, Matrix Projection, Matrix View, MatrixStack transform)
|
90 | 135 | {
|
|
0 commit comments