Skip to content

Commit

Permalink
Merge pull request #74 from Nils277/development
Browse files Browse the repository at this point in the history
1.3.6
  • Loading branch information
Nils277 authored May 11, 2022
2 parents ad40dc2 + 7ba765d commit 8ba79dd
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 46 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.3.6 *-Spaaaaaace-*
*[Released 11.MAY.2022]*

**Bug Fixes:**

* Fixed incorrect volume of parts with switchable resources
* Fixed incompatibility issues with Simple Repaint

# v1.3.4 *-Over the shoulder boulder holder-*
*[Released 28.APRIL.2022]*

Expand Down
5 changes: 5 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.3.6 [Released 11.MAY.2022] ~Spaaaaaace~
Bug Fixes:
- Fixed incorrect volume of parts with switchable resources
- Fixed incompatibility issues with Simple Repaint
-------------------------------------------------------
v1.3.4 [Released 28.APRIL.2022] ~Over the shoulder boulder holder~
Update:
- Recompile for KSP 1.12.3
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"VERSION": {
"MAJOR": 1,
"MINOR": 3,
"PATCH": 4
"PATCH": 6
},

"KSP_VERSION": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//Ignore parts that cause problems in combination with Simple Repaint

@PART[*]:HAS[@MODULE[ModuleKerbetrotterResourceSwitch]]:BEFORE[zzz_SimpleRepaint]
{
%SR_Ignore = true
}

@PART[*]:HAS[@MODULE[ModuleKerbetrotterTextureShift]]:BEFORE[zzz_SimpleRepaint]
{
%SR_Ignore = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ public void FixedUpdate()

if ((joint == null) && (hasParent) && (isValidAttachment) && !isInitializing)
{
Debug.Log("[KERBETROTTER] FixedUpdate: Creating Joint");
InitJoint();
UpdateUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ public void setDefaultProfile()
/// <param name="height">The hover height</param>
public void setHoverHeight(float height)
{
//Debug.Log("[HOVER] Height Set: " + height + " Enabled: " + hoverEnabled);
if (hoverEnabled)
{
hoverHeight = height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ public override void OnStart(StartState state)
if ((part.Modules[i] is ModuleEngines) && (((ModuleEngines)part.Modules[i]).engineID == engineName))
{
engine = (ModuleEngines)part.Modules[i];
//Debug.Log("[ENGINE ANIMATION] Found ModuleEngines");
}
if (part.Modules[i] is ModuleKerbetrotterEngine)
{
kEngine = (ModuleKerbetrotterEngine)part.Modules[i];
//Debug.Log("[ENGINE ANIMATION] Found ModuleKerbetrotterEngine");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ private bool checkCrew(int level)
{
return true;
}
//Debug.Log("[KPBS] Title:" + crew[i].experienceTrait.Title + " Desc:" + crew[i].experienceTrait.Description + " Needed: " + neededSkill);
}
return false;
}
Expand Down Expand Up @@ -548,7 +547,6 @@ private void setTarget(Part target, bool isTarget)
{
if (isTarget)
{
//Debug.Log("LYNX_NUCLEAR: Setting Target: " + target.name);
target.highlightColor.r = transferColor.r;
target.highlightColor.g = transferColor.g;
target.highlightColor.b = transferColor.b;
Expand All @@ -557,7 +555,6 @@ private void setTarget(Part target, bool isTarget)
//set the default highlight color
else
{
//Debug.Log("LYNX_NUCLEAR: Resetting Target: " + target.name);
target.highlightColor.r = defaultColor.r;
target.highlightColor.g = defaultColor.g;
target.highlightColor.b = defaultColor.b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace KerbetrotterTools
{
/// <summary>
/// This class allows to switch some of the models from parts
/// This module rotates a transform towards another. On of the axes will not rotate
/// </summary>
public class ModuleKerbetrotterConstrainedLookAt : PartModule
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace KerbetrotterTools
{
/// <summary>
/// Module switching between to internal models (required for JSIATP)
/// Module switching between two internal models (required for JSIATP)
/// </summary>
class ModuleKerbetrotterInternalSwitch : PartModule, ModuleKerbetrotterMeshToggle.MeshToggleListener
{
Expand Down Expand Up @@ -166,7 +166,6 @@ private void refresh()
List<ModuleKerbetrotterMeshToggle> switcher = part.FindModulesImplementing<ModuleKerbetrotterMeshToggle>();
if ((switcher.Count > 0) && (MeshToggleIndex < switcher.Count))
{
Debug.Log("[Kerbetrotter] Found switcher");
switcher[MeshToggleIndex].addListener(this);
stateEnabled = switcher[MeshToggleIndex].transformsVisible;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Nils277 (https://github.com/Nils277)
* Copyright (C) 2022 Nils277 (https://github.com/Nils277)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,7 +49,7 @@ class ModuleKerbetrotterTextureShift : PartModule, ISwitchListener
#region-------------------------Private Members----------------------

//The material containing the texture
private List<Material> materials = new List<Material>();
//private List<Material> materials = new List<Material>();

//The list of resources that can be switched in the tank
private Dictionary<string, Vector2> setups = new Dictionary<string, Vector2>();
Expand All @@ -71,7 +71,7 @@ public override void OnStart(StartState state)

loadSetups(part.partInfo.partConfig);

materials.Clear();
/*materials.Clear();
string[] transforms = transformNames.Split(',');
for (int i = 0; i < transforms.Length; i++)
{
Expand All @@ -80,7 +80,7 @@ public override void OnStart(StartState state)
{
materials.Add(textureTransform.GetComponent<Renderer>().material);
}
}
}*/

//set the used setup if already set
if (currentSetup != string.Empty)
Expand Down Expand Up @@ -111,6 +111,8 @@ public void onSwitch(string setup)
{
currentSetup = setup;

List<Material> materials = getMaterials();

if (materials.Count > 0)
{
if (setups.ContainsKey(setup))
Expand All @@ -128,6 +130,7 @@ public void onSwitch(string setup)
materials[i].SetTextureOffset(textureName, new Vector2(0, 0));
}
}

}
}

Expand Down Expand Up @@ -156,7 +159,7 @@ private void loadSetups(ConfigNode node)
//load the name of the resource to load
if (propConfig[i].HasValue("Offset"))
{

string[] offests = propConfig[i].GetValue("Offset").Split(',');
try
{
Expand All @@ -178,6 +181,30 @@ private void loadSetups(ConfigNode node)
}
}

/// <summary>
/// Get the list of materials that are available
/// </summary>
/// <returns></returns>
private List<Material> getMaterials()
{
List<Material> materials = new List<Material>();
string[] transforms = transformNames.Split(',');
for (int i = 0; i < transforms.Length; i++)
{
Transform[] textureTransforms = part.FindModelTransforms(transforms[i].Trim());
foreach (Transform textureTransform in textureTransforms)
{
Renderer[] renderers = textureTransform.GetComponents<Renderer>();
foreach (Renderer renderer in renderers)
{
materials.Add(renderer.material);
}
}
}

return materials;
}

#endregion
}
}
}
6 changes: 3 additions & 3 deletions Sources/Plugin/KerbetrotterTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.4")]
[assembly: AssemblyFileVersion("1.3.4")]
[assembly: KSPAssembly("KerbetrotterTools", 1, 0x1340)]
[assembly: AssemblyVersion("1.3.6")]
[assembly: AssemblyFileVersion("1.3.6")]
[assembly: KSPAssembly("KerbetrotterTools", 1, 0x1360)]
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ private void apply()
{
if (mSwitch.needsPreparation())
{
Debug.Log("Switching Needs preparation");
SwitchingProgressDialog<T> dialog = new SwitchingProgressDialog<T>(mSwitch, mSelection);
dialog.show(mSetups[mSwitch.SelectedSetup].guiName, mSetups[mSelection].guiName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
 /*
/*
* Copyright (C) 2021 Nils277 (https://github.com/Nils277)
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -41,7 +41,7 @@ class KerbetrotterResourceSetup : BaseSetup
/// Constructor of the resource setup
/// </summary>
/// <param name="node">The config not to contruct the setup from</param>
public KerbetrotterResourceSetup(ConfigNode node) : base(node)
public KerbetrotterResourceSetup(ConfigNode node, float multiplier) : base(node)
{
if (node.HasValue("animateVenting"))
{
Expand All @@ -53,7 +53,7 @@ public KerbetrotterResourceSetup(ConfigNode node) : base(node)
resources = new KerbetrotterResourceDefinition[resourceSubNodes.Length];
for (int i = 0; i < resources.Length; i++)
{
KerbetrotterResourceDefinition resourceDefinition = new KerbetrotterResourceDefinition(resourceSubNodes[i]);
KerbetrotterResourceDefinition resourceDefinition = new KerbetrotterResourceDefinition(resourceSubNodes[i], multiplier);
resources[i] = resourceDefinition;
costModifier += resourceDefinition.cost;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public override string getInfo(bool name = true)
{
info.AppendLine(guiName);
}

foreach (KerbetrotterResourceDefinition resource in resources)
{
if (resource.maxAmount > 0)
Expand Down Expand Up @@ -153,7 +153,7 @@ public class KerbetrotterResourceDefinition

#region-------------------------Public Methods-----------------------

public KerbetrotterResourceDefinition(ConfigNode node)
public KerbetrotterResourceDefinition(ConfigNode node, double multiplier)
{
if (node.HasValue("name"))
{
Expand All @@ -165,23 +165,23 @@ public KerbetrotterResourceDefinition(ConfigNode node)
{
if (node.HasValue("amount"))
{
amount = float.Parse(node.GetValue("amount"), CultureInfo.InvariantCulture.NumberFormat);
amount = float.Parse(node.GetValue("amount"), CultureInfo.InvariantCulture.NumberFormat) * multiplier;
}
if (node.HasValue("maxAmount"))
{
maxAmount = float.Parse(node.GetValue("maxAmount"), CultureInfo.InvariantCulture.NumberFormat);
maxAmount = float.Parse(node.GetValue("maxAmount"), CultureInfo.InvariantCulture.NumberFormat) * multiplier;
}

if (node.HasValue("isTweakable"))
{
isTweakable = bool.Parse(node.GetValue("isTweakable"));
}
cost = (float)(maxAmount * PartResourceLibrary.Instance.resourceDefinitions[name].unitCost);
cost = (float)(maxAmount * PartResourceLibrary.Instance.resourceDefinitions[name].unitCost) * (float)multiplier;
}
}

#endregion
}
#endregion
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public override void OnStart(StartState state)
if (selectedSetup == -1)
{
selectedSetup = 0;
//Debug.Log("[KerbetrotterTools:ConverterSwitch] Found default type: " + selectedConverter);
activeSetup = setups[selectedSetup].ID;
}

Expand Down
Loading

0 comments on commit 8ba79dd

Please sign in to comment.