Skip to content

Commit

Permalink
Fix DDS textures
Browse files Browse the repository at this point in the history
  • Loading branch information
GER-Space committed Apr 29, 2018
1 parent 271b384 commit 5268b54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Binary file modified GameData/KerbalKonstructs/KerbalKonstructs.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("1.4.3.0")]
[assembly: AssemblyInformationalVersion("1.4.3.0")]
[assembly: AssemblyFileVersion("1.4.3.1")]
[assembly: AssemblyInformationalVersion("1.4.3.1")]
[assembly: KSPAssembly("KerbalKonstructs", 0, 9)]
19 changes: 12 additions & 7 deletions src/Utilities/KKGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class KKGraphics

private static Dictionary<string, Texture2D> cachedTextures = new Dictionary<string, Texture2D>();

private static List<string> imageExtentions = new List<string> { ".png", ".tga" , ".jpg" , ".dds"};
private static List<string> imageExtentions = new List<string> { ".png", ".tga" , ".jpg"};

/// <summary>
/// Load all shaders into the system and fill our shader database.
Expand Down Expand Up @@ -117,7 +117,7 @@ internal static Texture2D GetTexture(string textureName, bool asNormal = false,
Texture2D tmpTexture = null;

//// Otherwise search the game database for one loaded from GameData/
if (GameDatabase.Instance.ExistsTexture(textureName))
if (GameDatabase.Instance.ExistsTexture(textureName) && (GetImageExtention(textureName) != null))
{
// Get the texture URL
tmpTexture = GameDatabase.Instance.GetTexture(textureName, asNormal);
Expand All @@ -126,6 +126,11 @@ internal static Texture2D GetTexture(string textureName, bool asNormal = false,
foundTexture = new Texture2D(tmpTexture.width, tmpTexture.height, TextureFormat.ARGB32, false);
foundTexture.LoadImage(System.IO.File.ReadAllBytes("GameData/" + textureName + GetImageExtention(textureName)), false);
}
else
{
Log.UserWarning("TextureLoader faild. Fallback to GameDatabase");
foundTexture = GameDatabase.Instance.GetTexture(textureName, asNormal);
}

//// Otherwise search the game database for one loaded from GameData/
//if (GameDatabase.Instance.ExistsTexture(textureName))
Expand All @@ -145,23 +150,23 @@ private static string GetImageExtention(string imageName)
string path = (KSPUtil.ApplicationRootPath + "GameData/" + imageName).Substring(0, pathIndex +1);
string imageShortName = (KSPUtil.ApplicationRootPath + "GameData/" + imageName).Substring(pathIndex + 1);

Log.Normal("path: " + path);
Log.Normal("imageShortName: " + imageShortName);
//Log.Normal("path: " + path);
//Log.Normal("imageShortName: " + imageShortName);

foreach (var filename in System.IO.Directory.GetFiles(path, (imageShortName + ".*")))
{
Log.Normal("Found Filename: " + filename);
//Log.Normal("Found Filename: " + filename);
foreach (string pattern in imageExtentions)
{
Log.Normal("pattern:" + pattern);
//Log.Normal("pattern:" + pattern);
if (filename.Contains(pattern))
{
return pattern;
}
}
}

Log.UserError("Could not find an image with the name");
Log.UserError("Could not find an image with the name: " + imageName);
return null;
}

Expand Down

0 comments on commit 5268b54

Please sign in to comment.