-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSettings.cs
More file actions
101 lines (89 loc) · 3.06 KB
/
Copy pathSettings.cs
File metadata and controls
101 lines (89 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
namespace DDSLoader
{
[KSPAddon(KSPAddon.Startup.Instantly, false)]
public class Settings : MonoBehaviour
{
public static int MipmapBias = 0;
public static int NormalMipmapBias = 0;
static List<Regex> normalList = new List<Regex>();
static List<Regex> readableList = new List<Regex>();
public void Awake()
{
foreach (var config in GameDatabase.Instance.GetConfigNodes("DDSLoader"))
{
string sMipmapBias = config.GetValue("mipmapBias");
if (sMipmapBias != null)
int.TryParse(sMipmapBias, out MipmapBias);
string sNormalMipmapBias = config.GetValue("normalMipmapBias");
if (sNormalMipmapBias != null)
int.TryParse(sNormalMipmapBias, out NormalMipmapBias);
ConfigNode normals = config.GetNode("NORMAL_LIST");
if (normals != null)
{
foreach (ConfigNode.Value texture in normals.values)
{
Regex re = new Regex(texture.value, RegexOptions.None);
normalList.Add(re);
}
}
ConfigNode readable = config.GetNode("READABLE_LIST");
if (readable != null)
{
foreach (ConfigNode.Value texture in readable.values)
{
Regex re = new Regex(texture.value, RegexOptions.None);
readableList.Add(re);
}
}
}
foreach (ConfigNode config in GameDatabase.Instance.GetConfigNodes("ACTIVE_TEXTURE_MANAGER_CONFIG"))
{
ConfigNode normals = config.GetNode("NORMAL_LIST");
if (normals != null)
{
foreach (ConfigNode.Value texture in normals.values)
{
Regex re = new Regex(texture.value, RegexOptions.None);
normalList.Add(re);
}
}
foreach (ConfigNode overrides in config.GetNodes("OVERRIDES"))
{
if (overrides.nodes != null)
{
foreach (ConfigNode texture in overrides.nodes)
{
string readable = texture.GetValue("make_not_readable");
if (readable != null && readable == "false")
{
Regex re = new Regex(texture.name, RegexOptions.None);
readableList.Add(re);
}
}
}
}
}
}
public static bool keepReadable(string url)
{
foreach (Regex regex in readableList)
{
if (regex.IsMatch(url))
return true;
}
return false;
}
public static bool isNormal(string url)
{
foreach (Regex regex in normalList)
{
if (regex.IsMatch(url))
return true;
}
return false;
}
}
}