Skip to content

Commit

Permalink
add TU (debug) Icon
Browse files Browse the repository at this point in the history
add multi-module functionality to TUPartVariant
fix nullref when attempting to remove the tu debug button
  • Loading branch information
shadowmage45 committed Mar 14, 2020
1 parent 3d0c0b9 commit c445391
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Binary file modified GameData/000_TexturesUnlimited/Plugins/TexturesUnlimited.dll
Binary file not shown.
Binary file added GameData/000_TexturesUnlimited/TU-Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -20,12 +20,11 @@ public class TexturesUnlimitedDebug : MonoBehaviour
public void Awake()
{
debug = TUGameSettings.Debug;
Texture2D tex;
if (debugAppButton == null && debug)//static reference; track if the button was EVER created, as KSP keeps them even if the addon is destroyed
{
//TODO create an icon for TU debug App-Launcher button
//create a new button
tex = GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/RDIcon_fuelSystems-highPerformance", false);
Texture2D tex = GameDatabase.Instance.GetTexture("000_TexturesUnlimited/TU-Icon", false);
debugAppButton = ApplicationLauncher.Instance.AddModApplication(debugGuiEnable, debugGuiDisable, null, null, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB, tex);
}
else if (debugAppButton != null && debug)
Expand All @@ -34,7 +33,7 @@ public void Awake()
debugAppButton.onTrue = debugGuiEnable;
debugAppButton.onFalse = debugGuiDisable;
}
else//button not null, but not debug mode; needs to be removed
else if (debugAppButton != null)//button not null, but not debug mode; needs to be removed
{
ApplicationLauncher.Instance.RemoveModApplication(debugAppButton);
}
Expand Down
21 changes: 19 additions & 2 deletions Plugin/SSTUTools/KSPShaderTools/Module/TUPartVariant.cs
Expand Up @@ -32,6 +32,12 @@ public class TUPartVariant : PartModule, IRecolorable
//if setup to interact with stock fairing module
[KSPField]
public bool stockFairing = false;

[KSPField]
public int moduleIndex = 0;

[KSPField]
public string sectionName = "Stock Variant";

private RecoloringData[] customColors;

Expand Down Expand Up @@ -176,7 +182,18 @@ private void editorDefaultVariantApplied(AvailablePart part, PartVariant variant

private TextureSet getSet(PartVariant variant)
{
string setName = variant.GetExtraInfoValue("textureSet");
string keyName = "textureSet";
//if module index greater than zero, always append index number to the key lookup
if (moduleIndex > 0)
{
keyName = keyName + moduleIndex.ToString();
}
string setName = variant.GetExtraInfoValue(keyName);
//if module index ==0, and initial name lookup failed, attempt by appending key-name with '0'
if (moduleIndex == 0 && string.IsNullOrEmpty(setName))
{
setName = variant.GetExtraInfoValue(keyName + "0");
}
TextureSet set = null;
if (!string.IsNullOrEmpty(setName))
{
Expand Down Expand Up @@ -271,7 +288,7 @@ private void applyConfig(Transform root, TextureSet set, bool useSetColors, bool

public string[] getSectionNames()
{
return new string[] { "Stock Variant" };
return new string[] { sectionName };
}

public RecoloringData[] getSectionColors(string name)
Expand Down

0 comments on commit c445391

Please sign in to comment.