Skip to content

Commit b2509ab

Browse files
authored
Textures v0.2.1
Textures v0.2.1
2 parents 4bcc97e + 0c5b77b commit b2509ab

7 files changed

Lines changed: 58 additions & 9 deletions

File tree

Textures/Changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
**v0.2.1**
2+
3+
- Minor fix for database loading
4+
5+
16
**v0.2.0**
27

38
- Improved modularity
Binary file not shown.

Textures/GameData/Sigma/Replacements/Textures/Plugins/SigmaReplacementsTextures.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"MAJOR": 0,
1515
"MINOR": 2,
16-
"PATCH": 0,
16+
"PATCH": 1,
1717
"BUILD": 0
1818
},
1919
"KSP_VERSION":
1.5 KB
Binary file not shown.

[Source]/SigmaReplacements/Common/Info.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ internal Info GetFor(ProtoCrewMember kerbal)
128128
return null;
129129
}
130130

131+
// New Empty Info
132+
internal Info()
133+
{
134+
}
131135

132136
// New Info
133137
internal Info(ConfigNode requirements, ConfigNode info)

[Source]/SigmaReplacements/Textures/SettingsLoader.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SigmaReplacements
66
namespace Textures
77
{
88
[KSPAddon(KSPAddon.Startup.Instantly, true)]
9-
class SettingsLoader : MonoBehaviour
9+
class FirstSettingsLoader : MonoBehaviour
1010
{
1111
void OnDestroy()
1212
{
@@ -20,5 +20,21 @@ void OnDestroy()
2020
TextureInfo info = new TextureInfo(InfoNodes);
2121
}
2222
}
23+
24+
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
25+
class SecondSettingsLoader : MonoBehaviour
26+
{
27+
void Start()
28+
{
29+
// User Settings
30+
ConfigNode[] InfoNodes = UserSettings.ConfigNode.GetNodes("Texture");
31+
32+
Debug.Log("SettingsLoader", "Texture nodes found = " + (InfoNodes?.Length ?? 0));
33+
34+
if (!(InfoNodes?.Length > 0)) return;
35+
36+
TextureInfo info = new TextureInfo(InfoNodes);
37+
}
38+
}
2339
}
2440
}

[Source]/SigmaReplacements/Textures/TextureInfo.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TextureInfo : Info
1010
{
1111
internal static Dictionary<Texture, Texture> Database = new Dictionary<Texture, Texture>();
1212

13-
internal TextureInfo(ConfigNode[] InfoNodes) : base(new ConfigNode(), new ConfigNode())
13+
internal TextureInfo(ConfigNode[] InfoNodes)
1414
{
1515
List<Texture> bulkReplace = new List<Texture>();
1616

@@ -21,16 +21,40 @@ class TextureInfo : Info
2121

2222
if (newTex != null)
2323
{
24-
string[] originals = InfoNodes[i].GetValues("original");
25-
for (int j = 0; j < originals?.Length; j++)
24+
if (!Database.ContainsKey(newTex))
2625
{
27-
Texture oldTex = null;
28-
oldTex = Parse(originals[j], oldTex);
29-
if (oldTex != null && !Database.ContainsKey(oldTex) && !Database.ContainsKey(newTex))
26+
string[] originals = InfoNodes[i].GetValues("original");
27+
for (int j = 0; j < originals?.Length; j++)
3028
{
31-
Database.Add(oldTex, newTex);
29+
Texture oldTex = null;
30+
oldTex = Parse(originals[j], oldTex);
31+
if (oldTex != null)
32+
{
33+
if (!Database.ContainsKey(oldTex))
34+
{
35+
Database.Add(oldTex, newTex);
36+
Debug.Log("SettingsLoader", "Added definition to replacements database.");
37+
Debug.Log("SettingsLoader", "[ " + newTex.name + " ] == replaces ==> [ " + oldTex.name + " ]");
38+
}
39+
else
40+
{
41+
Debug.Log("SettingsLoader", "Original texture already in the database = " + oldTex.name);
42+
}
43+
}
44+
else
45+
{
46+
Debug.Log("SettingsLoader", "Original texture not found = " + originals[j]);
47+
}
3248
}
3349
}
50+
else
51+
{
52+
Debug.Log("SettingsLoader", "Replacement texture already in the database = " + newTex.name);
53+
}
54+
}
55+
else
56+
{
57+
Debug.Log("SettingsLoader", "Replacement texture not found = " + InfoNodes[i].GetValue("replacement"));
3458
}
3559

3660
bulkReplace = ParseFolders(InfoNodes[i]?.GetNode("Folders")?.GetValues("path"), bulkReplace);

0 commit comments

Comments
 (0)