Exemplo n.º 1
0
        public void Start()
        {
            Log.Info("Start");

            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            Instance = this;
            clsGPSMath.Reset();

            Events["DeactivateReceiver"].active = true;
            Events["ActivateReceiver"].active   = false;
            gyReceiverOn = true;

            gyKerbalGPSInitialised = false;
            giLastVesselCount      = 0;

            gbDisplayMode    = MODE_GPS_POSITION;
            gLastSVCheckTime = DateTime.Now;

            FileIO.LoadData(this);
            // GPSToolbar.AppLauncherKerbalGPS.localStart(this.gameObject);
            GameEvents.onHideUI.Add(this.HideUI);
            GameEvents.onShowUI.Add(this.ShowUI);
            GameEvents.onGamePause.Add(this.HideUIWhenPaused);
            GameEvents.onGameUnpause.Add(this.ShowUIwhenPaused);
        }
Exemplo n.º 2
0
        static void SaveWindowPositions(KerbalGPS Instance, ConfigNode settings)
        {
            ConfigNode winPos = new ConfigNode();

            SaveWinPos(winPos, "varWindowPos", Instance.varWindowPos);
            SaveWinPos(winPos, "varDestWindowPos", Instance.varDestWindowPos);
            settings.AddNode(WINDOWPOSNODE, winPos);
        }
Exemplo n.º 3
0
        static void LoadWindowPositions(KerbalGPS Instance, ConfigNode settings)
        {
            ConfigNode winPos = settings.GetNode(WINDOWPOSNODE);

            if (winPos == null)
            {
                Log.Info("Unable to load window positions");
                return;
            }

            Instance.varWindowPos     = GetWinPos(winPos, "varWindowPos", KerbalGPS.GPS_GUI_WIDTH, KerbalGPS.GPS_GUI_HEIGHT);
            Instance.varDestWindowPos = GetWinPos(winPos, "varDestWindowPos", KerbalGPS.GPS_GUI_WIDTH, Instance.GPS_DEST_GUI_HEIGHT);
        }
Exemplo n.º 4
0
        static public void LoadData(KerbalGPS Instance)
        {
            gdDestinations.Clear();
            if (File.Exists(PLUGINDATA))
            {
                ConfigNode dataFile = ConfigNode.Load(PLUGINDATA);
                if (dataFile != null)
                {
                    Log.Info("Datafile opened and loaded");
                    ConfigNode dataNode = dataFile.GetNode(DATANODE);
                    if (dataNode != null)
                    {
                        Log.Info("Nodes loaded");

                        // load screen  coordinates here
                        LoadWindowPositions(Instance, dataNode);


                        ConfigNode[] entries = dataNode.GetNodes(DESTNODE);
                        Log.Info("Entries loaded: " + entries.Length);
                        foreach (var entry in entries)
                        {
                            GPS_Coordinates coordinates = new GPS_Coordinates();

                            coordinates.sDestName          = entry.GetValue("sDestName");
                            coordinates.sCelestialBodyName = entry.GetValue("sCelestialBodyName");
                            if (coordinates.sCelestialBodyName == null)
                            {
                                coordinates.sCelestialBodyName = FlightGlobals.GetHomeBody().name;
                            }
                            coordinates.fDestLat = (float)Double.Parse(SafeLoad(entry.GetValue("fDestLat"), KerbalGPS.DEF_DESTLAT));
                            coordinates.fDestLon = (float)Double.Parse(SafeLoad(entry.GetValue("fDestLon"), KerbalGPS.DEF_DESTLON));
                            gdDestinations.Add(coordinates.sDestName, coordinates);
                            Log.Info("sDestName: " + coordinates.sDestName + ",  fDestLat: " + coordinates.fDestLat + ", fDestLon: " + coordinates.fDestLon);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        static public void SaveData(KerbalGPS Instance)
        {
            ConfigNode dataFile = new ConfigNode(DATANODE);
            ConfigNode dataNode = new ConfigNode(DATANODE);

            dataFile.AddNode(dataNode);

            // Save screen coordinates here
            SaveWindowPositions(Instance, dataNode);

            foreach (var entry in gdDestinations)
            {
                ConfigNode n = new ConfigNode();

                n.AddValue("sDestName", entry.Key);
                n.AddValue("sCelestialBodyName", entry.Value.sCelestialBodyName);
                n.AddValue("fDestLat", entry.Value.fDestLat);
                n.AddValue("fDestLon", entry.Value.fDestLon);
                dataNode.AddNode(DESTNODE, n);
            }
            dataFile.Save(PLUGINDATA);
        }