Skip to content

Commit

Permalink
V0.13a
Browse files Browse the repository at this point in the history
Re-compile to integrate KabinKraziness correctly.
Fixed AppLauncher and Toolbar Icon settings.
  • Loading branch information
Jamie Leighton committed Apr 7, 2015
1 parent e050df0 commit b1ee514
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 22 deletions.
64 changes: 52 additions & 12 deletions AYController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ public void Awake()
AYgameSettings = AmpYear.Instance.AYgameSettings;
vesselProdPartsList = new Dictionary<uint, PwrPartList>();
vesselConsPartsList = new Dictionary<uint, PwrPartList>();
/*
if (ToolbarManager.ToolbarAvailable && AYsettings.UseAppLauncher == false)
{
button1 = ToolbarManager.Instance.add("AmpYear", "button1");
button1.TexturePath = "AmpYear/Icons/toolbarIcon";
button1.TexturePath = "REPOSoftTech/AmpYear/Icons/toolbarIcon";
button1.ToolTip = "AmpYear";
button1.Visibility = new GameScenesVisibility(GameScenes.FLIGHT, GameScenes.EDITOR);
button1.OnClick += (e) => GuiVisible = !GuiVisible;
Expand All @@ -285,6 +286,7 @@ public void Awake()
else
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
}
* */
this.Log_Debug("AYController Awake complete");
}

Expand All @@ -297,7 +299,7 @@ private void OnGUIAppLauncherReady()
this.stockToolbarButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn, onAppLaunchToggleOff, DummyVoid,
DummyVoid, DummyVoid, DummyVoid, ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH |
ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW,
(Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOff", false));
(Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOff", false));
}
}

Expand All @@ -307,19 +309,40 @@ private void DummyVoid()

public void onAppLaunchToggleOn()
{
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOn", false));
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOn", false));
GuiVisible = true;
}

public void onAppLaunchToggleOff()
{
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOff", false));
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOff", false));
GuiVisible = false;
}

public void Start()
{
this.Log_Debug("AYController Start");

if (ToolbarManager.ToolbarAvailable && AYsettings.UseAppLauncher == false)
{
button1 = ToolbarManager.Instance.add("AmpYear", "button1");
button1.TexturePath = "REPOSoftTech/AmpYear/Icons/toolbarIcon";
button1.ToolTip = "AmpYear";
button1.Visibility = new GameScenesVisibility(GameScenes.FLIGHT, GameScenes.EDITOR);
button1.OnClick += (e) => GuiVisible = !GuiVisible;
}
else
{
// Set up the stock toolbar
this.Log_Debug("Adding onGUIAppLauncher callbacks");
if (ApplicationLauncher.Ready)
{
OnGUIAppLauncherReady();
}
else
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
}

// Find out which mods are present
ALPresent = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "AviationLights");
NFEPresent = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "NearFutureElectrical");
Expand Down Expand Up @@ -615,12 +638,12 @@ private void FixedUpdate()
if (tmpSol.panelState == ModuleDeployableSolarPanel.panelStates.RETRACTED)
{
tmpSol.Extend();
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Extending Solar Panels!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Extending Solar Panels!", 5.0f, ScreenMessageStyle.UPPER_CENTER);
this.Log("Extending solar array");
}
}
else
ScreenMessages.PostScreenMessage("Electricity Levels Critical! In Atmosphere can not Extend Solar Panels!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage("Electricity Levels Critical! In Atmosphere can not Extend Solar Panels!", 5.0f, ScreenMessageStyle.UPPER_CENTER);
}
}
else
Expand Down Expand Up @@ -725,7 +748,7 @@ private void FixedUpdate()
if (!hasPower && EmgcyShutActive)
{
tmpWheel.DisableMotor();
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Disabling Wheel Motors!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Disabling Wheel Motors!", 5.0f, ScreenMessageStyle.UPPER_CENTER);
this.Log("Disabling Wheel motors");
}
}
Expand Down Expand Up @@ -779,7 +802,7 @@ private void FixedUpdate()
if (!hasPower && EmgcyShutActive && (mode == GameState.FLIGHT && tmpLight.isOn))
{
tmpLight.LightsOff();
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Turning off Lights!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage("Electricity Levels Critical! Turning off Lights!", 5.0f, ScreenMessageStyle.UPPER_CENTER);
this.Log("Turning off lights");
}
}
Expand Down Expand Up @@ -1319,9 +1342,9 @@ private void subsystemUpdate()
if (TimeWarp.CurrentRateIndex > 3)
{
TimeWarp.SetRate(0, false);
ScreenMessages.PostScreenMessage(FlightGlobals.ActiveVessel.vesselName + " - Not Enough Power to run TimeWarp - Deactivated.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(FlightGlobals.ActiveVessel.vesselName + " - Not Enough Power to run TimeWarp - Deactivated.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
}
hasPower = false; //hasPower is false - ie no main power
hasPower = totalElectricCharge >= minimum_sufficient_charge; //set hasPower
this.Log_Debug("drawing reserve power");
if (totalReservePower > minimum_sufficient_charge) // if reserve power available > minimum charge required
{
Expand Down Expand Up @@ -2190,7 +2213,10 @@ private void loadVesselSettings(Vessel newvessel)
{
this.Log_Debug("AYController Vessel Loading Settings " + newvessel.name + " (" + newvessel.id + ")");
for (int i = 0; i < Enum.GetValues(typeof(Subsystem)).Length; i++)
{
subsystemToggle[i] = info.subsystemToggle[i];
subsystemDrain[i] = info.subsystemDrain[i];
}
for (int i = 0; i < Enum.GetValues(typeof(GUISection)).Length; i++)
guiSectionEnableFlag[i] = info.guiSectionEnableFlag[i];
managerEnabled = info.managerEnabled;
Expand All @@ -2209,7 +2235,11 @@ private void loadVesselSettings(Vessel newvessel)
{
this.Log_Debug("AYController Vessel Setting Default Settings");
for (int i = 0; i < Enum.GetValues(typeof(Subsystem)).Length; i++)
{
subsystemToggle[i] = false;
subsystemDrain[i] = 0.0;
}

for (int i = 0; i < Enum.GetValues(typeof(GUISection)).Length; i++)
guiSectionEnableFlag[i] = false;
managerEnabled = true;
Expand All @@ -2221,6 +2251,16 @@ private void loadVesselSettings(Vessel newvessel)
KKLoadVesselSettings(info, true);
}
}
if (!KKPresent) //KabinKraziness not present turn off settings for KabinKraziness on vessel
{
subsystemToggle[3] = false;
subsystemToggle[4] = false;
subsystemToggle[5] = false;
subsystemDrain[3] = 0.0;
subsystemDrain[4] = 0.0;
subsystemDrain[5] = 0.0;
guiSectionEnableFlag[2] = false;
}
}

private void DbgListVesselInfo(VesselInfo info)
Expand Down Expand Up @@ -2352,7 +2392,7 @@ public void setSubsystemEnabled(Subsystem subsystem, bool enabled)
if (cv.Autopilot.CanSetMode(VesselAutopilot.AutopilotMode.StabilityAssist))
cv.ActionGroups.SetGroup(KSPActionGroup.SAS, enabled);
else
ScreenMessages.PostScreenMessage(cv.vesselName + " - Cannot Engage SAS - Autopilot function not available", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(cv.vesselName + " - Cannot Engage SAS - Autopilot function not available", 5.0f, ScreenMessageStyle.UPPER_CENTER);
break;

case Subsystem.RCS:
Expand All @@ -2367,7 +2407,7 @@ public void setSubsystemEnabled(Subsystem subsystem, bool enabled)

public void EmergencyPowerDown()
{
ScreenMessages.PostScreenMessage(FlightGlobals.ActiveVessel.vesselName + " - Emergency Power Procedures Activated. Shutdown Subsystems.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(FlightGlobals.ActiveVessel.vesselName + " - Emergency Power Procedures Activated. Shutdown Subsystems.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
setSubsystemEnabled(Subsystem.CLIMATE, false);
setSubsystemEnabled(Subsystem.MASSAGE, false);
setSubsystemEnabled(Subsystem.MUSIC, false);
Expand Down
45 changes: 36 additions & 9 deletions AYSController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ public Boolean GuiVisible
}
}
}

public void Awake()
{
AYsettings = AmpYear.Instance.AYsettings;
AYgameSettings = AmpYear.Instance.AYgameSettings;

/*
// create toolbar button
if (ToolbarManager.ToolbarAvailable && AYsettings.UseAppLauncher == false)
{
button1 = ToolbarManager.Instance.add("AmpYear", "button1");
button1.TexturePath = "AmpYear/Icons/toolbarIcon";
button1.TexturePath = "REPOSoftTech/AmpYear/Icons/toolbarIcon";
button1.ToolTip = "AmpYear";
button1.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
button1.OnClick += (e) => GuiVisible = !GuiVisible;
Expand All @@ -145,10 +145,11 @@ public void Awake()
}
else
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
}
}*/
this.Log_Debug("AYSCController Awake complete");
}

private void OnGUIAppLauncherReady()
{
this.Log_Debug("OnGUIAppLauncherReady");
Expand All @@ -157,7 +158,7 @@ private void OnGUIAppLauncherReady()
this.Log_Debug("Adding AppLauncherButton");
this.stockToolbarButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn, onAppLaunchToggleOff, DummyVoid,
DummyVoid, DummyVoid, DummyVoid, ApplicationLauncher.AppScenes.SPACECENTER,
(Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOff", false));
(Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOff", false));
}
}

Expand All @@ -167,13 +168,13 @@ private void DummyVoid()

private void onAppLaunchToggleOn()
{
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOn", false));
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOn", false));
GuiVisible = true;
}

private void onAppLaunchToggleOff()
{
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("AmpYear/Icons/AYIconOff", false));
this.stockToolbarButton.SetTexture((Texture)GameDatabase.Instance.GetTexture("REPOSoftTech/AmpYear/Icons/AYIconOff", false));
GuiVisible = false;
}

Expand All @@ -199,6 +200,32 @@ public void OnDestroy()

public void Start()
{
//AYsettings = AmpYear.Instance.AYsettings;
//AYgameSettings = AmpYear.Instance.AYgameSettings;

// create toolbar button
if (ToolbarManager.ToolbarAvailable && AYsettings.UseAppLauncher == false)
{
button1 = ToolbarManager.Instance.add("AmpYear", "button1");
button1.TexturePath = "REPOSoftTech/AmpYear/Icons/toolbarIcon";
button1.ToolTip = "AmpYear";
button1.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
button1.OnClick += (e) => GuiVisible = !GuiVisible;
}
else
{
// Set up the stock toolbar
this.Log_Debug("AYSCController Adding onGUIAppLauncher callbacks");
if (ApplicationLauncher.Ready)
{
OnGUIAppLauncherReady();
}
else
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);

}

this.Log_Debug("AYSCController Awake complete");
this.Log_Debug("AYSController Start");
KKPresent = KKClient.KKInstalled;

Expand Down Expand Up @@ -336,7 +363,7 @@ private void windowSC(int id)
}

GUILayout.BeginHorizontal();
GUILayout.Box("Use Application Launcher", statusStyle, GUILayout.Width(300));
GUILayout.Box("Use Application Launcher (restart required)", statusStyle, GUILayout.Width(300));
InputAppL = GUILayout.Toggle(InputAppL, "", GUILayout.MinWidth(30.0F)); //you can play with the width of the text box
GUILayout.EndHorizontal();

Expand Down
2 changes: 1 addition & 1 deletion AYSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public AYSettings()
RECHARGE_RESERVE_THRESHOLD = 0.95;
POWER_LOW_WARNING_AMT = 5;
UseAppLauncher = true;
debugging = false;
debugging = true;
}

//Settings Functions Follow
Expand Down
Binary file modified AmpYear.zip
Binary file not shown.

0 comments on commit b1ee514

Please sign in to comment.