示例#1
0
        internal void AddLastVessel(ProtoVessel pVessel)
        {
            QData _lastVessel = LastVesselLastIndex();

            if (_lastVessel != null)
            {
                if (_lastVessel.protoVessel.vesselID == pVessel.vesselID)
                {
                    Log("Kept the last Vessel: " + pVessel.vesselName, "QGoTo");
                    return;
                }
            }
            if (pVessel.vesselType == VesselType.Unknown || pVessel.vesselType == VesselType.SpaceObject || pVessel.vesselType == VesselType.Debris)
            {
                Warning(string.Format("Can't save the last Vessel: ({0}) {1}", pVessel.vesselType.ToString(), pVessel.vesselName), "QGoTo");
                return;
            }
            LastVessels.Add(new QData(pVessel));
            Log(string.Format("Saved the last Vessel: ({0}){1}", LastVessels.Count, pVessel.vesselName), "QGoTo");
            if (LastVessels.Count > 10)
            {
                Log("Delete the first vessel from last Vessel: " + LastVessels[0].protoVessel.vesselName, "QGoTo");
                LastVessels.RemoveAt(0);
            }
            Log("Last Vessel has keep " + LastVessels.Count + " vessels", "QGoTo");
        }
示例#2
0
 public void LastVessel()
 {
     SavedGoTo = GoTo.None;
     if (CanLastVessel)
     {
         int   _index      = -1;
         QData _lastVessel = LastVesselLastIndex(out _index);
         if (_lastVessel != null)
         {
             int _idx = _lastVessel.idx;
             if (_idx != -1)
             {
                 ClearSpaceCenter();
                 string _saveGame = GamePersistence.SaveGame(SaveGame, HighLogic.SaveFolder, SaveMode.OVERWRITE);
                 Log(GetText(GoTo.LastVessel));
                 FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                 InputLockManager.ClearControlLocks();
                 LastVessels.RemoveAt(_index);
                 Warning("Remove from the last Vessels: " + _lastVessel.protoVessel.vesselName, "QGoTo");
                 return;
             }
         }
     }
     Warning("You can't " + GetText(GoTo.LastVessel), "QGoTo");
     ScreenMessages.PostScreenMessage("You can't " + GetText(GoTo.LastVessel), 10, ScreenMessageStyle.UPPER_RIGHT);
 }
示例#3
0
        QData LastVesselLastIndex(out int index)
        {
            index = -1;
            QData _lastVessel = null;

            while (LastVessels.Count > 0)
            {
                index       = LastVessels.Count - 1;
                _lastVessel = LastVessels [index];
                if (_lastVessel != null)
                {
                    ProtoVessel _pVessel = _lastVessel.protoVessel;
                    if (_pVessel != null)
                    {
                        if (pVesselExists(_pVessel))
                        {
                            if (_lastVessel.idx != -1)
                            {
                                break;
                            }
                        }
                    }
                }
                LastVessels.RemoveAt(index);
                Warning("Remove a vessel from the last Vessels", "QGoTo");
            }
            return(_lastVessel);
        }
示例#4
0
文件: QG_GUI.cs 项目: tivec/QuickMods
        void OnFlightReady()
        {
            Vessel _vessel = FlightGlobals.ActiveVessel;

            if (_vessel != null)
            {
                ProtoVessel _pVessel = _vessel.protoVessel;
                if (_pVessel != null)
                {
                    int   _index;
                    QData _QData = LastVesselLastIndex(out _index);
                    if (_QData != null)
                    {
                        ProtoVessel _QDataPVessel = _QData.protoVessel;
                        if (_QDataPVessel != null)
                        {
                            if (_QDataPVessel == _pVessel)
                            {
                                LastVessels.RemoveAt(_index);
                                Warning("Remove the current vessel from the last Vessels: " + _pVessel.vesselName);
                            }
                        }
                    }
                }
            }
            Log("OnFlightReady", "QGUI");
        }
示例#5
0
        void PostInitSC()
        {
            if (LastVessels.Count < 1)
            {
                FlightState _flightState = HighLogic.CurrentGame.flightState;
                if (_flightState != null)
                {
                    List <ProtoVessel> _pVessels = _flightState.protoVessels;
                    for (int _i = _pVessels.Count - 1; _i >= 0; --_i)
                    {
                        ProtoVessel _pVessel = _pVessels[_i];
                        if (_pVessel != null)
                        {
                            AddLastVessel(_pVessel);
                        }
                    }
                }
            }
            else
            {
                List <QData> _lastVessels = LastVessels;
                LastVessels = new List <QData> ();
                for (int _i = _lastVessels.Count - 1; _i >= 0; --_i)
                {
                    QData _lastVessel = _lastVessels[_i];
                    if (pVesselExists(_lastVessel.protoVessel))
                    {
                        LastVessels.Add(_lastVessel);
                    }
                    else
                    {
                        Warning("Remove from the last Vessels: " + _lastVessel.protoVessel.vesselName, "QGoTo");
                    }
                }
            }
            if (SavedGoTo != GoTo.None)
            {
                switch (SavedGoTo)
                {
                case GoTo.Administration:
                    administration();
                    break;

                case GoTo.AstronautComplex:
                    astronautComplex();
                    break;

                case GoTo.RnD:
                    RnD();
                    break;

                case GoTo.MissionControl:
                    missionControl();
                    break;
                }
                SavedGoTo = GoTo.None;
            }
        }
示例#6
0
        public string GetText(GoTo goTo, bool force = false)
        {
            switch (goTo)
            {
            case GoTo.TrackingStation:
                return("Go to the Tracking Station");

            case GoTo.SpaceCenter:
                return("Go to the Space Center");

            case GoTo.MissionControl:
                return("Go to the Mission Control");

            case GoTo.Administration:
                return("Go to the Administration");

            case GoTo.RnD:
                return("Go to the Research and Dev.");

            case GoTo.AstronautComplex:
                return("Go to the Astronaut Complex");

            case GoTo.VAB:
                return("Go to the Vehicle Assembly");

            case GoTo.SPH:
                return("Go to the Space Plane Hangar");

            case GoTo.LastVessel:
                QData _lastVessel = LastVesselLastIndex();
                return(string.Format("Go to the {0}", (_lastVessel != null && !force ? "vessel: " + _lastVessel.protoVessel.vesselName : "last Vessel")));

            case GoTo.Recover:
                return("Recover");

            case GoTo.Revert:
                return("Revert to Launch");

            case GoTo.RevertToEditor:
                return("Revert to Editor");

            case GoTo.RevertToSpaceCenter:
                return("Revert to SpaceCenter");

            case GoTo.MainMenu:
                return("Go to The Main Menu");

            case GoTo.Settings:
                return("Go to the Settings");

            case GoTo.Configurations:
                return("QuickGoTo: Settings");
            }
            return(string.Empty);
        }
示例#7
0
        public string GetText(GoTo goTo, bool force = false)
        {
            switch (goTo)
            {
            case GoTo.TrackingStation:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_ts"));

            case GoTo.SpaceCenter:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_sc"));

            case GoTo.MissionControl:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_mc"));

            case GoTo.Administration:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_admin"));

            case GoTo.RnD:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_rnd"));

            case GoTo.AstronautComplex:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_ac"));

            case GoTo.VAB:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_vab"));

            case GoTo.SPH:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_sph"));

            case GoTo.LastVessel:
                QData _lastVessel = LastVesselLastIndex();
                return(Localizer.Format("quickgoto_goto") + " " + (_lastVessel != null && !force ? Localizer.Format("quickgoto_vessle") + _lastVessel.protoVessel.vesselName : Localizer.Format("quickgoto_lastVessel")));

            case GoTo.Recover:
                return(Localizer.Format("quickgoto_recover"));

            case GoTo.Revert:
                return(Localizer.Format("quickgoto_revert") + " " + Localizer.Format("quickgoto_launch"));

            case GoTo.RevertToEditor:
                return(Localizer.Format("quickgoto_revert") + " " + Localizer.Format("quickgoto_editor"));

            case GoTo.RevertToSpaceCenter:
                return(Localizer.Format("quickgoto_revert") + " " + Localizer.Format("quickgoto_sc"));

            case GoTo.MainMenu:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_mainMenu"));

            case GoTo.Settings:
                return(Localizer.Format("quickgoto_goto") + " " + Localizer.Format("quickgoto_toSettings"));

            case GoTo.Configurations:
                return(RegisterToolbar.MOD + Localizer.Format("quickgoto_settings"));
            }
            return(string.Empty);
        }