示例#1
0
        // MOARdV: Spaceplane Guidance can not be implemented cleanly, because
        // MJ's MechJebModuleSpaceplaneGuidance is missing the 'public'
        // keyword.  We could use another controller (like ourself), but that
        // means one is forced to use our menu to turn it off (the MJ GUI is
        // not able to change the setting), and vice versa.  Since every other
        // place where we interface with MJ, we use MJ's objects as the
        // controller, this breaks our design model.  If/when MJ makes the
        // module public, all of the commented code here related to it can be
        // uncommented, and this missive can be deleted.
        //private void SpaceplaneGuidance(int index, TextMenu.Item tmi)
        //{
        //	UpdateJebReferences();
        //	if (activeJeb != null) {
        //		var autopilot = activeJeb.GetComputerModule<MechJebModuleSpaceplaneAutopilot>();
        //		if (autopilot != null) {
        //			MechJebModuleSpaceplaneGuidance is not currently public.  Can't use it.
        //			var autopilotController = activeJeb.GetComputerModule<MechJebModuleSpaceplaneGuidance>();
        //			if (autopilotController != null) {
        //				if (autopilot.enabled && autopilot.mode == MechJebModuleSpaceplaneAutopilot.Mode.HOLD) {
        //					autopilot.AutopilotOff();
        //				} else if (!autopilot.enabled) {
        //					autopilot.HoldHeadingAndAltitude(autopilotController);
        //				}
        //			}
        //		}
        //	}
        //}

        private void CircularizeMenu(int index, TextMenu.Item tmi)
        {
            currentMenu = MJMenu.CircularizeMenu;

            activeMenu               = new TextMenu();
            activeMenu.labelColor    = JUtil.ColorToColorTag(itemColorValue);
            activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);
            activeMenu.menuTitle     = "== Circularize Menu:";

            activeMenu.Add(new TextMenu.Item("At Next Ap", DoCircularize, (int)MechJebModuleManeuverPlanner.TimeReference.APOAPSIS));
            activeMenu.Add(new TextMenu.Item("At Next Pe", DoCircularize, (int)MechJebModuleManeuverPlanner.TimeReference.PERIAPSIS));
            activeMenu.Add(new TextMenu.Item("In 15s", DoCircularize, (int)MechJebModuleManeuverPlanner.TimeReference.X_FROM_NOW));
        }
示例#2
0
        private void TargetMenu(int index, TextMenu.Item tmi)
        {
            currentMenu = MJMenu.TargetMenu;

            activeMenu               = new TextMenu();
            activeMenu.labelColor    = JUtil.ColorToColorTag(itemColorValue);
            activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);

            foreach (MechJebModuleSmartASS.Target target in targetTargets)
            {
                activeMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)target].Replace('\n', ' '), SelectTarget));
            }
        }
示例#3
0
        private void TargetMenu(int index, TextMenu.Item tmi)
        {
            currentMenu = MJMenu.TargetMenu;

            activeMenu = new TextMenu();
            activeMenu.labelColor = JUtil.ColorToColorTag(itemColorValue);
            activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);

            foreach (MechJebModuleSmartASS.Target target in targetTargets)
            {
                activeMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)target].Replace('\n', ' '), SelectTarget));
            }
        }
示例#4
0
        // MOARdV: Spaceplane Guidance can not be implemented cleanly, because
        // MJ's MechJebModuleSpaceplaneGuidance is missing the 'public'
        // keyword.  We could use another controller (like ourself), but that
        // means one is forced to use our menu to turn it off (the MJ GUI is
        // not able to change the setting), and vice versa.  Since every other
        // place where we interface with MJ, we use MJ's objects as the
        // controller, this breaks our design model.  If/when MJ makes the
        // module public, all of the commented code here related to it can be
        // uncommented, and this missive can be deleted.
        //private void SpaceplaneGuidance(int index, TextMenu.Item tmi)
        //{
        //    UpdateJebReferences();
        //    if (activeJeb != null) {
        //        var autopilot = activeJeb.GetComputerModule<MechJebModuleSpaceplaneAutopilot>();
        //        if (autopilot != null) {
        //            MechJebModuleSpaceplaneGuidance is not currently public.  Can't use it.
        //            var autopilotController = activeJeb.GetComputerModule<MechJebModuleSpaceplaneGuidance>();
        //            if (autopilotController != null) {
        //                if (autopilot.enabled && autopilot.mode == MechJebModuleSpaceplaneAutopilot.Mode.HOLD) {
        //                    autopilot.AutopilotOff();
        //                } else if (!autopilot.enabled) {
        //                    autopilot.HoldHeadingAndAltitude(autopilotController);
        //                }
        //            }
        //        }
        //    }
        //}
        private void CircularizeMenu(int index, TextMenu.Item tmi)
        {
            currentMenu = MJMenu.CircularizeMenu;

            activeMenu = new TextMenu();
            activeMenu.labelColor = JUtil.ColorToColorTag(itemColorValue);
            activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);
            activeMenu.menuTitle = "== Circularize Menu:";

            activeMenu.Add(new TextMenu.Item("At Next Ap", DoCircularize, (int)TimeReference.APOAPSIS));
            activeMenu.Add(new TextMenu.Item("At Next Pe", DoCircularize, (int)TimeReference.PERIAPSIS));
            activeMenu.Add(new TextMenu.Item("In 15s", DoCircularize, (int)TimeReference.X_FROM_NOW));
        }
示例#5
0
        public void Start()
        {
            // I guess I shouldn't have expected Squad to actually do something nice for a modder like that.
            // In 0.23, loading in non-alphabetical order is still broken.

            // But now we have KSPAssembly and KSPAssemblyDependency, which actually sidestep the issue, and finally
            // Mu told someone about it and now I can avoid this path hardlinking.
            // Actually, better yet. Let it check for the new canonical location instead. Because f**k installation problems.
            if (!JSI.InstallationPathWarning.Warn())
            {
                return;
            }

            if (!string.IsNullOrEmpty(itemColor))
            {
                itemColorValue = ConfigNode.ParseColor32(itemColor);
            }
            if (!string.IsNullOrEmpty(selectedColor))
            {
                selectedColorValue = ConfigNode.ParseColor32(selectedColor);
            }
            if (!string.IsNullOrEmpty(unavailableColor))
            {
                unavailableColorValue = ConfigNode.ParseColor32(unavailableColor);
            }

            UpdateJebReferences();

            topMenu.labelColor    = JUtil.ColorToColorTag(itemColorValue);
            topMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            topMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);

            // If MechJeb is installed, but not found on the craft, menu options can't be populated correctly.
            if (activeJeb != null)
            {
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.OFF], SmartASS_Off));
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.KILLROT].Replace('\n', ' '), SmartASS_KillRot));
                nodeMenuItem = new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.NODE], SmartASS_Node);
                topMenu.Add(nodeMenuItem);
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.ModeTexts[(int)MechJebModuleSmartASS.Mode.ORBITAL], OrbitalMenu));
                targetMenuItem = new TextMenu.Item(MechJebModuleSmartASS.ModeTexts[(int)MechJebModuleSmartASS.Mode.TARGET], TargetMenu);
                topMenu.Add(targetMenuItem);
                // Analysis disable once RedundantCast
                forceRollMenuItem = new TextMenu.Item(String.Format("Force Roll: {0:f0}", (activeSmartass != null) ? (double)activeSmartass.rol : 0.0), ToggleForceRoll);
                topMenu.Add(forceRollMenuItem);
                topMenu.Add(new TextMenu.Item("Execute Next Node", ExecuteNode, (int)MJMenu.ExecuteNodeMenu));
                topMenu.Add(new TextMenu.Item("Ascent Guidance", AscentGuidance, (int)MJMenu.AscentGuidanceMenu));
                topMenu.Add(new TextMenu.Item("Land Somewhere", LandingGuidance, (int)MJMenu.LandingGuidanceMenu));
                topMenu.Add(new TextMenu.Item("Docking Guidance", DockingGuidance, (int)MJMenu.DockingGuidanceMenu));
                //topMenu.Add(new TextMenu.Item("Hold Alt & Heading", SpaceplaneGuidance, (int)MJMenu.SpacePlaneMenu));
                topMenu.Add(new TextMenu.Item("Circularize", CircularizeMenu, (int)MJMenu.CircularizeMenu));
            }
            activeMenu = topMenu;
        }
示例#6
0
        public void Start()
        {
            // I guess I shouldn't have expected Squad to actually do something nice for a modder like that.
            // In 0.23, loading in non-alphabetical order is still broken.
            JSI.InstallationPathWarning.Warn("MechJeb2RPM");

            if (!string.IsNullOrEmpty(itemColor))
            {
                itemColorValue = ConfigNode.ParseColor32(itemColor);
            }
            if (!string.IsNullOrEmpty(selectedColor))
            {
                selectedColorValue = ConfigNode.ParseColor32(selectedColor);
            }
            if (!string.IsNullOrEmpty(unavailableColor))
            {
                unavailableColorValue = ConfigNode.ParseColor32(unavailableColor);
            }


            UpdateJebReferences();

            topMenu.labelColor    = JUtil.ColorToColorTag(itemColorValue);
            topMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            topMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);

            // If MechJeb is installed, but not found on the craft, menu options can't be populated correctly.
            if (activeJeb != null)
            {
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.OFF], SmartASS_Off));
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.KILLROT].Replace('\n', ' '), SmartASS_KillRot));
                nodeMenuItem = new TextMenu.Item(MechJebModuleSmartASS.TargetTexts[(int)MechJebModuleSmartASS.Target.NODE], SmartASS_Node);
                topMenu.Add(nodeMenuItem);
                topMenu.Add(new TextMenu.Item(MechJebModuleSmartASS.ModeTexts[(int)MechJebModuleSmartASS.Mode.ORBITAL], OrbitalMenu));
                targetMenuItem = new TextMenu.Item(MechJebModuleSmartASS.ModeTexts[(int)MechJebModuleSmartASS.Mode.TARGET], TargetMenu);
                topMenu.Add(targetMenuItem);
                // Analysis disable once RedundantCast
                forceRollMenuItem = new TextMenu.Item(String.Format("Force Roll: {0:f0}", (double)activeSmartass.rol), ToggleForceRoll);
                topMenu.Add(forceRollMenuItem);
                topMenu.Add(new TextMenu.Item("Execute Next Node", ExecuteNode, (int)MJMenu.ExecuteNodeMenu));
                topMenu.Add(new TextMenu.Item("Ascent Guidance", AscentGuidance, (int)MJMenu.AscentGuidanceMenu));
                topMenu.Add(new TextMenu.Item("Land Somewhere", LandingGuidance, (int)MJMenu.LandingGuidanceMenu));
                topMenu.Add(new TextMenu.Item("Docking Guidance", DockingGuidance, (int)MJMenu.DockingGuidanceMenu));
                //topMenu.Add(new TextMenu.Item("Hold Alt & Heading", SpaceplaneGuidance, (int)MJMenu.SpacePlaneMenu));
                topMenu.Add(new TextMenu.Item("Circularize", CircularizeMenu, (int)MJMenu.CircularizeMenu));
            }
            activeMenu = topMenu;
        }