Skip to content

Commit

Permalink
Added alternate "Default" directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ducakar committed Nov 17, 2015
1 parent 3839862 commit 55ad9dd
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
7 changes: 7 additions & 0 deletions GameData/TextureReplacer/@Default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ TextureReplacer
keepLoaded = ^Kopernicus/Textures/ ^Romfarer/textures/
keepLoaded = ^WarpPlugin/PlanetResourceData/

// Additional paths for general texture replacement. Contents of these
// directories are treated as if they were in `TextureReplacer/Default/`.
// Do not forget the final `/` after the last directory.
// The list must be space- and/or comma-separated and in one line.
// Duplicated lists are joined.
paths =

// Skinning quality for animated meshes. It defines how many bones should be
// when interpolating vertices of animated meshes.
// `auto` - default (no change).
Expand Down
4 changes: 2 additions & 2 deletions GameData/TextureReplacer/TextureReplacer.version
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"VERSION": {
"MAJOR": 2,
"MINOR": 4,
"PATCH": 10,
"PATCH": 11,
"BUILD": 0
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 0,
"PATCH": 4
"PATCH": 5
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ Known Issues
Change Log
----------

* 2.4.11
- added alternate directories for general texture replacement
* 2.4.10
- added compatibility for DeepFreeze
* 2.4.9
Expand Down
2 changes: 1 addition & 1 deletion TextureReplacer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Global
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 2.4.10
version = 2.4.11
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion TextureReplacer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
[assembly: AssemblyCopyright("© 2014 Davorin Učakar, Ryan Bray")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.4.10.*")]
[assembly: AssemblyVersion("2.4.11.*")]
26 changes: 18 additions & 8 deletions TextureReplacer/Replacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Replacer
public static readonly string HUD_NAVBALL = "HUDNavBall";
public static readonly string IVA_NAVBALL = "IVANavBall";
// General texture replacements.
readonly List<string> paths = new List<string> { DIR_TEXTURES };
readonly Dictionary<string, Texture2D> mappedTextures = new Dictionary<string, Texture2D>();
// NavBalls' textures.
Texture2D hudNavBallTexture = null;
Expand Down Expand Up @@ -122,6 +123,7 @@ void updateNavball(Vessel vessel)
*/
public void readConfig(ConfigNode rootNode)
{
Util.addLists(rootNode.GetValues("paths"), paths);
Util.parse(rootNode.GetValue("skinningQuality"), ref skinningQuality);
Util.parse(rootNode.GetValue("logTextures"), ref logTextures);
}
Expand All @@ -146,18 +148,26 @@ public void load()
foreach (GameDatabase.TextureInfo texInfo in GameDatabase.Instance.databaseTexture)
{
Texture2D texture = texInfo.texture;
if (texture == null || !texture.name.StartsWith(DIR_TEXTURES, StringComparison.Ordinal))
if (texture == null)
continue;

string originalName = texture.name.Substring(DIR_TEXTURES.Length);
foreach (string path in paths)
{
if (!texture.name.StartsWith(path, StringComparison.Ordinal))
continue;

string originalName = texture.name.Substring(path.Length);

if (originalName.StartsWith("GalaxyTex_", StringComparison.Ordinal))
texture.wrapMode = TextureWrapMode.Clamp;
// Since we are merging multiple directories, we must expect conflicts.
if (!mappedTextures.ContainsKey(originalName))
{
if (originalName.StartsWith("GalaxyTex_", StringComparison.Ordinal))
texture.wrapMode = TextureWrapMode.Clamp;

// This in wrapped inside an 'if' clause just in case if corrupted GameDatabase contains
// non-consecutive duplicated entries for some strange reason.
if (!mappedTextures.ContainsKey(originalName))
mappedTextures.Add(originalName, texture);
mappedTextures.Add(originalName, texture);
}
break;
}
}

Shader headShader = Shader.Find("Bumped Diffuse");
Expand Down
4 changes: 2 additions & 2 deletions TextureReplacer/TextureReplacer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<RootNamespace>TextureReplacer</RootNamespace>
<AssemblyName>TextureReplacer</AssemblyName>
<ReleaseVersion>2.4.10</ReleaseVersion>
<ReleaseVersion>2.4.11</ReleaseVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
Expand All @@ -33,7 +33,7 @@
<CustomCommands>
<Command type="AfterBuild" command="cp ${TargetFile} GameData/TextureReplacer/Plugins" workingdir="${SolutionDir}" />
<Command type="AfterBuild" command="cp README.md GameData/TextureReplacer" workingdir="${SolutionDir}" />
<Command type="AfterBuild" command="cp ${TargetFile} /home/davorin/Apps/KSP-test/GameData/TextureReplacer/Plugins" workingdir="${SolutionDir}" />
<Command type="AfterBuild" command="cp ${TargetFile} &quot;/run/media/davorin/Windows 7/KSP-test/GameData/TextureReplacer/Plugins&quot;" workingdir="${SolutionDir}" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>
Expand Down

0 comments on commit 55ad9dd

Please sign in to comment.