Skip to content

Commit

Permalink
Deleted about 1150 lines of unneeded code related to the Toolbar
Browse files Browse the repository at this point in the history
	Added exclusion list for experiments and manufacturers
  • Loading branch information
linuxgurugamer committed Jun 10, 2018
1 parent 7846f96 commit 8b43d1d
Show file tree
Hide file tree
Showing 29 changed files with 367 additions and 1,185 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.9.2.2
Deleted about 1150 lines of unneeded code related to the Toolbar
Added exclusion list for experiments and manufacturers

1.9.2.1
fixed the missed repopulating a list after a revert??

1.9.2
Adoption by LGG
Added support for ToolbarController
Expand Down
39 changes: 39 additions & 0 deletions GameData/ScienceAlert/ExcludedExperiments.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
KEI_EXCLUDED_EXPERIMENTS
{
experiment = SEP_SolarwindSpectrum
experiment = SEP_CCIDscan
experiment = error
experiment = waitWhat

experiment = hullcampicture

// Following from the WildBlueIndustries mod
experiment = WBISpaceResearch
experiment = WBISpaceAdaptionStudy
experiment = WBIPowerToolsEvaluation
experiment = WBIConstructionTechniques
experiment = WBICrystalGrowth
experiment = WBIIceCreamResearch
experiment = WBITemperatureStudy
experiment = WBIThermalStudy
experiment = WBIGooStudy
experiment = WBICryogenicResourceStudy
experiment = WBILongTermCryogenicMiniStudy
experiment = WBIMESS
experiment = WBICryogenicStudy
experiment = WBILongTermCryogenicStudy
experiment = WBICryogenicRadiationStudy
experiment = WBISurfaceConstructionStudy
experiment = WBIKNUTS
experiment = WBIBRE
experiment = WBISAME
experiment = WBICoreSampleAnalysis
experiment = WBIBiomeAnalysis
experiment = WBISoilAnalysis
experiment = WBIMetallurgyAnalysis
experiment = WBIChemicalAnalysis
experiment = WBIExtractionAnalysis

experiment = GravioliumStudy
experiment = wbiSaucerResearchExperiment
}
4 changes: 4 additions & 0 deletions GameData/ScienceAlert/ExcludedManufacturers.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KEI_EXCLUDED_MANUFACTURERS
{
manufacturer = Station Science Directorate
}
2 changes: 1 addition & 1 deletion GameData/ScienceAlert/ScienceAlert.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 1,
"MINOR": 9,
"PATCH": 2,
"BUILD": 0
"BUILD": 2
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion ScienceAlert.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 1,
"MINOR": 9,
"PATCH": 2,
"BUILD": 1
"BUILD": 2
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
Binary file removed Source/.ScienceAlert.csproj.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

using System.Reflection;

[assembly: AssemblyVersion("1.9.2.0")]
[assembly: AssemblyVersion("1.9.2.2")]
216 changes: 216 additions & 0 deletions Source/ReeperCommon/Log.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using System.Collections;
using System.Diagnostics;

namespace ReeperCommon
{
#if false
internal class Log
{
[System.Flags]
Expand Down Expand Up @@ -138,4 +143,215 @@ internal static void Error(string message, params object[] strParams)
Write(message, LogMask.Error, strParams);
}
}
#else


public static class Log
{
public enum LEVEL
{
OFF = 0,
ERROR = 1,
WARNING = 2,
INFO = 3,
DETAIL = 4,
TRACE = 5,
PERFORMANCE = 6
};

public static LEVEL level = LEVEL.INFO;

private static readonly String PREFIX = "ExperimentTracker" + ": ";

public static LEVEL GetLevel()
{
return level;
}

public static void SetLevel(LEVEL level)
{
UnityEngine.Debug.Log("log level " + level);
Log.level = level;
}

public static LEVEL GetLogLevel()
{
return level;
}

private static bool IsLevel(LEVEL level)
{
return level == Log.level;
}

public static bool IsLogable(LEVEL level)
{
return level <= Log.level;
}

public static void Trace(String msg)
{
if (IsLogable(LEVEL.TRACE))
{
UnityEngine.Debug.Log(PREFIX + msg);
}
}

public static void Detail(String msg)
{
if (IsLogable(LEVEL.DETAIL))
{
UnityEngine.Debug.Log(PREFIX + msg);
}
}

[ConditionalAttribute("DEBUG")]
public static void Info(String msg)
{
if (IsLogable(LEVEL.INFO))
{
UnityEngine.Debug.Log(PREFIX + msg);
}
}

[ConditionalAttribute("DEBUG")]
public static void Test(String msg)
{
//if (IsLogable(LEVEL.INFO))
{
UnityEngine.Debug.LogWarning(PREFIX + "TEST:" + msg);
}
}

public static void Warning(String msg)
{
if (IsLogable(LEVEL.WARNING))
{
UnityEngine.Debug.LogWarning(PREFIX + msg);
}
}

public static void Error(String msg)
{
if (IsLogable(LEVEL.ERROR))
{
UnityEngine.Debug.LogError(PREFIX + msg);
}
}

public static void Exception(Exception e)
{
Log.Error("exception caught: " + e.GetType() + ": " + e.Message);
}


internal static void Write(string message, LEVEL level)
{

switch (level)
{
case LEVEL.ERROR:
Error(message);
return;
case LEVEL.DETAIL:
Detail(message);
return;
case LEVEL.WARNING:
Warning(message);
return;
case LEVEL.INFO:
Info(message);
return;
case LEVEL.PERFORMANCE:
UnityEngine.Debug.Log("[PERF] " + message);
return;
}
UnityEngine.Debug.Log(message);
}


internal static void Write(string message, LEVEL level, params object[] strParams)
{

Write(string.Format(message, strParams), level);

}
internal static void Debug(string message, params object[] strParams)
{
Write(message, LEVEL.INFO, strParams);
}

internal static void Normal(string message, params object[] strParams)
{
Write(message, LEVEL.INFO, strParams);
}

internal static void Warning(string message, params object[] strParams)
{
Write(message, LEVEL.WARNING, strParams);
}

internal static void Error(string message, params object[] strParams)
{
Write(message, LEVEL.ERROR, strParams);
}

internal static void SaveInto(ConfigNode parentNode)
{
#if false
ConfigNode configNode = parentNode.AddNode(new ConfigNode("LogSettings"));
configNode.AddValue("LogMask", (int)Level);
string[] names = System.Enum.GetNames(typeof(LogMask));
System.Array values = System.Enum.GetValues(typeof(LogMask));
configNode.AddValue("// Bit index", "message type");
for (int i = 0; i < names.Length - 1; i++)
{
configNode.AddValue($"// Bit {i}", values.GetValue(i));
}
Debug("[ScienceAlert].SaveInto = {0}", configNode.ToString());
#endif
}

internal static void LoadFrom(ConfigNode parentNode)
{
#if false
if (parentNode == null || !parentNode.HasNode("LogSettings"))
{
Warning("[ScienceAlert] failed, did not find LogSettings in: {0}", parentNode != null ? parentNode.ToString() : "<null ConfigNode>");
return;
}
ConfigNode node = parentNode.GetNode("LogSettings");
try
{
if (!node.HasValue("LogMask"))
{
throw new System.Exception("[ScienceAlert]:No LogMask value in ConfigNode");
}
string value = node.GetValue("LogMask");
int num = 0;
if (int.TryParse(value, out num))
{
if (num == 0)
{
Warning("[ScienceAlert]: Log disabled");
}
Level = (LogMask)num;
Debug("[ScienceAlert]:Loaded LogMask = {0} from ConfigNode", Level.ToString());
}
else
{
Debug("[ScienceAlert]: LogMask value '{0}' cannot be converted to LogMask", value);
}
}
catch (System.Exception ex)
{
Warning("[ScienceAlert] failed with exception: {0}", ex);
}
}
#endif
}


#endif
}
}
2 changes: 1 addition & 1 deletion Source/ScienceAlert.Experiments/EvaReportObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override bool Deploy()

var evas = FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceExperiment>();
foreach (var exp in evas)
if (!exp.Deployed && exp.experimentID == experiment.id)
if (!exp.Deployed && exp.experimentID == experiment.id && !ExcludeFilters.IsExcluded(exp))
{
exp.DeployExperiment();
break;
Expand Down
8 changes: 4 additions & 4 deletions Source/ScienceAlert.Experiments/ExperimentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ExperimentManager : MonoBehaviour

void Awake()
{
Log.Write("ExperimentManager.Awake", Log.LogMask.Debug);
Log.Write("ExperimentManager.Awake", Log.LEVEL.INFO);

vesselStorage = gameObject.AddComponent<StorageCache>();
biomeFilter = GetComponent<BiomeFilter>();
Expand Down Expand Up @@ -102,7 +102,7 @@ public void OnVesselDestroyed(Vessel vessel)

private System.Collections.IEnumerator UpdateObservers()
{
Log.Write("ExperimentManager.UpdateObservers", Log.LogMask.Debug);
Log.Write("ExperimentManager.UpdateObservers", Log.LEVEL.INFO);

while (true)
{
Expand Down Expand Up @@ -187,7 +187,7 @@ private System.Collections.IEnumerator UpdateObservers()

public int RebuildObserverList()
{
Log.Write("ExperimentManager.RebuildObserverList", Log.LogMask.Debug);
Log.Write("ExperimentManager.RebuildObserverList", Log.LEVEL.INFO);

observers.Clear();
ScanInterface scanInterface = GetComponent<ScanInterface>();
Expand All @@ -199,7 +199,7 @@ public int RebuildObserverList()
foreach (var expid in ResearchAndDevelopment.GetExperimentIDs())
if (expid != "evaReport" && expid != "surfaceSample") // special cases

if (FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceExperiment>().Any(mse => mse.experimentID == expid))
if (FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceExperiment>().Any(mse => mse.experimentID == expid && !ExcludeFilters.IsExcluded(mse)))
observers.Add(new ExperimentObserver(vesselStorage, ProfileManager.ActiveProfile[expid], biomeFilter, scanInterface, expid));

observers.Add(new SurfaceSampleObserver(vesselStorage, ProfileManager.ActiveProfile["surfaceSample"], biomeFilter, scanInterface));
Expand Down
4 changes: 2 additions & 2 deletions Source/ScienceAlert.Experiments/ExperimentObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public virtual void Rescan()
.FindPartModulesImplementing<ModuleScienceExperiment>();

foreach (var potential in potentials)
if (potential.experimentID == experiment.id)
if (potential.experimentID == experiment.id && !ExcludeFilters.IsExcluded(potential))
modules.Add(potential);
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public virtual bool Deploy()


#region Properties

protected ModuleScienceExperiment GetNextOnboardExperimentModule()
{
foreach (var module in modules)
Expand Down
Loading

0 comments on commit 8b43d1d

Please sign in to comment.