Skip to content

Commit

Permalink
Fixed values when in the editor in symmetry mode (symmetric parts we…
Browse files Browse the repository at this point in the history
…ren't getting updated properly)

 Added option to ignore speed limiter (in stock settings)
 Added option to have datalogs go either in mod dir or game dir (in stock settings)
 Fixed display of Max payload at min pressure
  • Loading branch information
linuxgurugamer committed Jan 15, 2021
1 parent eece6c0 commit 12ee984
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 32 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
ChangeLog

0.5.0.5
Fixed values when in the editor in symmetry mode (symmetric parts weren't getting updated properly)
Added option to ignore speed limiter (in stock settings)
Added option to have datalogs go either in mod dir or game dir (in stock settings)
Fixed display of Max payload at min pressure

0.5.0.4
Fixed issue with symmetric parts config window
Fixed issue with showing config window for multiple parts
Expand Down
2 changes: 1 addition & 1 deletion GameData/KerBalloons/KerBalloons.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MAJOR": 0,
"MINOR": 5,
"PATCH": 0,
"BUILD": 3
"BUILD": 4
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion KerBalloons.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MAJOR": 0,
"MINOR": 5,
"PATCH": 0,
"BUILD": 4
"BUILD": 5
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion Kerballoons/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

using System.Reflection;

[assembly: AssemblyVersion("0.5.0.3")]
[assembly: AssemblyVersion("0.5.0.4")]
2 changes: 1 addition & 1 deletion Kerballoons/BalloonProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static float getLift(ModuleKerBalloon thisBalloon)
lift *= liftLimit * thisBalloon.targetTWR;


if (thisBalloon.speedLimiter)
if (thisBalloon.speedLimiter && HighLogic.CurrentGame.Parameters.CustomParams<KerBSettings>().speedLimiterEnabled)
{
if (thisBalloon.vessel.verticalSpeed < thisBalloon.maxSpeed * (1 - thisBalloon.maxSpeedTolerence))
{
Expand Down
10 changes: 9 additions & 1 deletion Kerballoons/KBModuleDataRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,21 @@ public override void OnStart(StartState state)

public void DoReset()
{
string SaveDir = "GameData/KerBalloons/LogData/";
if (!HighLogic.CurrentGame.Parameters.CustomParams<KerBSettings>().saveInModFolder)
{
SaveDir = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KerBalloonDataLogs/";
}
if (!Directory.Exists(SaveDir))
Directory.CreateDirectory(SaveDir);

anim.Stop();
DateTime now = DateTime.Now;
optionstring = "";
dateFormat = "MM'-'dd'-'yyyy HH'-'mm'-'ss";
hourFormat = "HH':'mm':'ss";
saveFile = base.vessel.mainBody.ToString() + "-" + now.ToString(dateFormat) + ".csv";
saveFile = "GameData/KerBalloons/LogData/" + saveFile;
saveFile = SaveDir + saveFile;
EnvSensor = base.vessel.FindPartModulesImplementing<ModuleEnviroSensor>();
headerCreated = false;
foreach (ModuleEnviroSensor item in EnvSensor)
Expand Down
77 changes: 50 additions & 27 deletions Kerballoons/ModuleKerBalloon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,14 @@ public override void OnStart(StartState state)

[KSPField(isPersistant = true)]
int lastBalloonSize = 0;

Rect infoRect = new Rect(0, 0, 400, 400);
Rect winRect = new Rect(0, 0, 400, 200);
int winId = WindowHelper.NextWindowId("ModuleKerBalloonConfig");
int infoId = WindowHelper.NextWindowId("ModuleKerBalloonInfo");
bool visibleShowInfo = false;
bool visibleConfig = false;

[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "Configure Balloon")]
public void ConfigureBalloon()
{
Expand Down Expand Up @@ -217,7 +219,7 @@ void OnGUI()
}
if (visibleConfig && HighLogic.LoadedSceneIsEditor)
{
if (!visibleShowInfo && !HighLogic.CurrentGame.Parameters.CustomParams<KerBSettings>().altskin)
if (!HighLogic.CurrentGame.Parameters.CustomParams<KerBSettings>().altskin)
GUI.skin = HighLogic.Skin;
winRect = ClickThruBlocker.GUILayoutWindow(winId, winRect, ConfigBalloonWin, "KerBalloon");
}
Expand All @@ -239,37 +241,57 @@ float GetBodyG(string bodyName)
} else bodyG = (float)PhysicsGlobals.GravitationalAcceleration;
return bodyG;
}

void SetValues(BalloonInfo b)
{
Log.Info("SetValues");
Log.Info("payload: " + b.payload + ", body: " + b.recommendedBody + ", techRequired: " + b.techRequired +
", minAtmoP: " + b.minAtmoPressure.ToString("F3") + ", maxAtmoP: " + b.maxAtmoPressure.ToString("F3") +
", minScale: " + b.minScale + ", maxScale: " + b.maxScale + ", minLift: " + b.minLift + ", maxLift: " + b.maxLift +
", speedlimiter: " + b.speedLimiter + ", maxSpeed: " + b.maxSpeed + ", maxSpeedTolerence: " + b.maxSpeedTolerence +
", speedAdjustMin: " + b.speedAdjustMin + ", speedAdjustMax: " + b.speedAdjustMax);
//Log.Info("payload: " + b.payload + ", body: " + b.recommendedBody + ", techRequired: " + b.techRequired +
// ", minAtmoP: " + b.minAtmoPressure.ToString("F3") + ", maxAtmoP: " + b.maxAtmoPressure.ToString("F3") +
// ", minScale: " + b.minScale + ", maxScale: " + b.maxScale + ", minLift: " + b.minLift + ", maxLift: " + b.maxLift +
// ", speedlimiter: " + b.speedLimiter + ", maxSpeed: " + b.maxSpeed + ", maxSpeedTolerence: " + b.maxSpeedTolerence +
// ", speedAdjustMin: " + b.speedAdjustMin + ", speedAdjustMax: " + b.speedAdjustMax);

recommendedBody = b.recommendedBody;
bodyG = GetBodyG(recommendedBody);
Log.Info("recommendedBody: " + b.recommendedBody + ", bodyName: " + recommendedBody + ", bodyG: " + bodyG);
minAtmoPressure = b.minAtmoPressure;
maxAtmoPressure = b.maxAtmoPressure;
minScale = b.minScale;
maxScale = b.maxScale;
minLift = b.minLift;
maxLift = b.maxLift;
targetTWR = b.targetTWR;
speedLimiter = b.speedLimiter;
maxSpeed = b.maxSpeed;
maxSpeedTolerence = b.maxSpeedTolerence;
speedAdjustStep = b.speedAdjustStep;
speedAdjustMin = b.speedAdjustMin;
speedAdjustMax = b.speedAdjustMax;
CFGballoonObject = b.CFGballoonObject;
CFGropeObject = b.CFGropeObject;
CFGcapObject = b.CFGcapObject;
CFGliftPointObject = b.CFGliftPointObject;
CFGballoonPointObject = b.CFGballoonPointObject;
foreach (var p in part.symmetryCounterparts)
{
var m = p.FindModuleImplementing<ModuleKerBalloon>();
SetSymmetryValues(balloonSize, m, b, selectedPlanet, payload);
}
SetSymmetryValues(balloonSize, this, b, selectedPlanet, payload) ;
}

void SetSymmetryValues(int balloonSize, ModuleKerBalloon mkb, BalloonInfo b, int selectedPlanet, string payload)
{
Log.Info("SetSymmetryValues, persistentId: " + mkb.part.persistentId);

mkb.balloonSize = balloonSize;
mkb.lastBalloonSize = lastBalloonSize;
mkb.recommendedBody = b.recommendedBody;
mkb.bodyG = GetBodyG(recommendedBody);
//Log.Info("recommendedBody: " + b.recommendedBody + ", bodyName: " + recommendedBody + ", bodyG: " + bodyG);
mkb.minAtmoPressure = b.minAtmoPressure;
mkb.maxAtmoPressure = b.maxAtmoPressure;
mkb.minScale = b.minScale;
mkb.maxScale = b.maxScale;
mkb.minLift = b.minLift;
mkb.maxLift = b.maxLift;
mkb.targetTWR = b.targetTWR;
mkb.liftLimit = liftLimit;
mkb.speedLimiter = b.speedLimiter;
mkb.maxSpeed = b.maxSpeed;
mkb.maxSpeedTolerence = b.maxSpeedTolerence;
mkb.speedAdjustStep = b.speedAdjustStep;
mkb.speedAdjustMin = b.speedAdjustMin;
mkb.speedAdjustMax = b.speedAdjustMax;
mkb.CFGballoonObject = b.CFGballoonObject;
mkb.CFGropeObject = b.CFGropeObject;
mkb.CFGcapObject = b.CFGcapObject;
mkb.CFGliftPointObject = b.CFGliftPointObject;
mkb.CFGballoonPointObject = b.CFGballoonPointObject;


mkb.payload = payload;
mkb.selectedPayload = selectedPayload;
mkb.bodyName = b.recommendedBody;
}


Expand Down Expand Up @@ -599,6 +621,7 @@ public void ShowInfo()
visibleShowInfo = !visibleShowInfo;
availPlanets.Clear();
availPayloads.Clear();
infoId = WindowHelper.NextWindowId("ModuleKerBalloonInfo" + part.persistentId);
}

Vector2 infoPos;
Expand Down
9 changes: 9 additions & 0 deletions Kerballoons/StockSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public class KerBSettings : GameParameters.CustomParameterNode
toolTip = "Use alternate skin")]
public bool altskin = false;

[GameParameters.CustomParameterUI("Enable Speed Limiter",
toolTip = "Limit the top speed of the balloon")]
public bool speedLimiterEnabled = true;

[GameParameters.CustomParameterUI("Log data in mod folder",
toolTip = "If true, will save to folder KerBalloons/LogData, if false,\n" +
"will save in the save folder: saves/<save>/KerBalloonDataLogs")]
public bool saveInModFolder = false;



public override void SetDifficultyPreset(GameParameters.Preset preset)
Expand Down

0 comments on commit 12ee984

Please sign in to comment.