Load TGA textures
This commit is contained in:
parent
1b661cbc7f
commit
1508ed111d
|
@ -7,6 +7,7 @@ using RectpackSharp;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace KeepersCompound;
|
||||
|
||||
|
@ -367,6 +368,11 @@ public partial class Mission : Node3D
|
|||
|
||||
private void LoadTextures(TxList textureList)
|
||||
{
|
||||
static string PathToKey(string baseDir, string path)
|
||||
{
|
||||
return path.TrimPrefix(baseDir).GetBaseName().ToLower();
|
||||
}
|
||||
|
||||
// TODO: This has hardcoded .png extension and relies on you placing extracted and converted images in godot user directory
|
||||
|
||||
// Collect all the fm textures here to help with case sensitivity :)
|
||||
|
@ -376,13 +382,19 @@ public partial class Mission : Node3D
|
|||
var dirPaths = Directory.GetDirectories(baseDir, "fam", options);
|
||||
options.RecurseSubdirectories = true;
|
||||
var texturePaths = new Dictionary<string, string>();
|
||||
|
||||
// Godot doesn't support runtime DDS :)
|
||||
// TODO: Load DDS BMP PCX GIF CEL
|
||||
string[] validExtensions = { "png", "tga" };
|
||||
foreach (var dirPath in dirPaths)
|
||||
{
|
||||
var paths = Directory.GetFiles(dirPath, "*.png", options);
|
||||
foreach (var path in paths)
|
||||
foreach (var path in Directory.EnumerateFiles(dirPath, "*", options))
|
||||
{
|
||||
var key = path.TrimPrefix(baseDir).GetBaseName().ToLower();
|
||||
texturePaths.Add(key, path);
|
||||
if (validExtensions.Contains(path.GetExtension().ToLower()))
|
||||
{
|
||||
// TODO: This only adds the first one found rather than the highest priority
|
||||
texturePaths.TryAdd(PathToKey(baseDir, path), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue