Skip to content

Commit

Permalink
Remove Chache Test
Browse files Browse the repository at this point in the history
  • Loading branch information
GER-Space committed Nov 13, 2019
1 parent 06081ea commit a271b0a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/UI2/Editor/Instance/GrassEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ internal static void CreateContent()
new DialogGUILabel("V: ", HighLogic.UISkin.label),
new DialogGUITextInput("0", false, 10, SetTarmacVStr, GetTarmacVStr, TMPro.TMP_InputField.ContentType.DecimalNumber, 25)),
new DialogGUIHorizontalLayout(
new DialogGUIButton(" R", ReloadBlendMask, 21f, 21.0f, false, HighLogic.UISkin.label),
new DialogGUILabel("BlendMaskTexture", KKStyle.whiteLabel),
new DialogGUITextInput(BlendMaskTexture, false, 40, SetBlendMaskTexture, delegate { return GetTextureName("blendMaskTextureName"); }, TMPro.TMP_InputField.ContentType.Standard, 25),
new DialogGUIButton(" S", delegate { OpenTextureSelector("blendMaskTextureName", TextureUsage.BlendMask); }, 21f, 21.0f, false, HighLogic.UISkin.label))
Expand All @@ -122,6 +123,13 @@ internal static void CreateContent()
}


internal static void ReloadBlendMask()
{
KKGraphics.RemoveCache(selectedMod.blendMaskTextureName);
selectedMod.ApplySettings();
}


internal static string SetTarmacUStr(string newUvalue)
{
float uValue = float.Parse(newUvalue);
Expand Down
31 changes: 30 additions & 1 deletion src/Utilities/KKGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,42 @@ internal static Texture2D LoadNormalFromFile(string fileName, int width, int hei
}


/// <summary>
/// Remove a Cached Texture, so it is loaded from Disk during next access
/// </summary>
/// <param name="textureName"></param>
internal static void RemoveCache(string textureName)
{
string textureKey;
int index = 0;
textureName.Replace("\\", "/");
if (textureName.StartsWith("BUILTIN:"))
{
{
Log.Normal("Builtin Textures don't change");
return;
}

}
else
{
textureKey = Regex.Replace(textureName, "/", "_") + index.ToString();
}

if (cachedTextures.ContainsKey(textureKey))
{
cachedTextures.Remove(textureKey);
}
}



/// <summary>
/// return a buildin or GameDatabase Texture
/// </summary>
/// <param name="textureName"></param>
/// <returns></returns>
internal static Texture2D GetTexture(string textureName, bool asNormal = false, int index = 0, bool createMibMaps = false)
internal static Texture2D GetTexture(string textureName, bool asNormal = false, int index = 0, bool createMibMaps = false )
{
if (string.IsNullOrEmpty(textureName))
{
Expand Down

0 comments on commit a271b0a

Please sign in to comment.