コード例 #1
0
        public bool Load()
        {
            bool b = false;

            try
            {
                if (File.Exists(fullPath))
                {
                    ConfigNode node      = ConfigNode.Load(fullPath);
                    ConfigNode unwrapped = node.GetNode(GetType().Name);
                    ConfigNode.LoadObjectFromConfig(this, unwrapped);
                    b = true;
                }
                else
                {
                    BasicOrbit.BasicLogging("Settings file could not be found [{0}]", fullPath);
                    b = false;
                }
            }
            catch (Exception e)
            {
                BasicOrbit.BasicLogging("Error while loading settings file from [{0}]\n{1}", fullPath, e);
                b = false;
            }

            return(b);
        }
コード例 #2
0
        private void Awake()
        {
            if (loaded)
            {
                Destroy(gameObject);
            }

            DontDestroyOnLoad(gameObject);

            loaded = true;

            instance = this;

            fullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName).Replace("\\", "/");

            if (Load())
            {
                BasicOrbit.BasicLogging("Settings file loaded");
            }
            else
            {
                if (Save())
                {
                    BasicOrbit.BasicLogging("New Settings files generated at:\n{0}", fullPath);
                }
            }
        }
コード例 #3
0
        private void OnDestroy()
        {
            instance = null;

            apo.IsActive     = false;
            peri.IsActive    = false;
            inc.IsActive     = false;
            ecc.IsActive     = false;
            LAN.IsActive     = false;
            period.IsActive  = false;
            radar.IsActive   = false;
            terrain.IsActive = false;

            closest.IsActive  = false;
            distance.IsActive = false;
            relInc.IsActive   = false;
            relVel.IsActive   = false;

            if (orbitPanel != null)
            {
                Destroy(orbitPanel.gameObject);
            }

            if (targetPanel != null)
            {
                Destroy(targetPanel.gameObject);
            }

            if (maneuverPanel != null)
            {
                Destroy(maneuverPanel.gameObject);
            }

            settings.orbitPosition    = orbitHUD.Position;
            settings.targetPosition   = targetHUD.Position;
            settings.maneuverPosition = maneuverHUD.Position;

            if (appLauncher != null)
            {
                Destroy(appLauncher);
            }

            if (settings.Save())
            {
                BasicOrbit.BasicLogging("Settings file saved");
            }

            GameEvents.OnGameSettingsApplied.Remove(onGameSettings);
        }
コード例 #4
0
        private ConfigNode AsConfigNode()
        {
            try
            {
                ConfigNode node = new ConfigNode(GetType().Name);

                node = ConfigNode.CreateConfigFromObject(this, node);
                return(node);
            }
            catch (Exception e)
            {
                BasicOrbit.BasicLogging("Failed to generate settings file node...\n{0}", e);
                return(new ConfigNode(GetType().Name));
            }
        }
コード例 #5
0
        public bool Save()
        {
            bool b = false;

            try
            {
                ConfigNode node    = AsConfigNode();
                ConfigNode wrapper = new ConfigNode(GetType().Name);
                wrapper.AddNode(node);
                wrapper.Save(fullPath);
                b = true;
            }
            catch (Exception e)
            {
                BasicOrbit.BasicLogging("Error while saving settings file from [{0}]\n{1}", fullPath, e);
                b = false;
            }

            return(b);
        }
コード例 #6
0
        private void OnDestroy()
        {
            if (instance != this)
            {
                return;
            }

            instance = null;

            vesselName.IsActive = false;
            apo.IsActive        = false;
            peri.IsActive       = false;
            inc.IsActive        = false;
            eqNode.IsActive     = false;
            ecc.IsActive        = false;
            LAN.IsActive        = false;
            AoPE.IsActive       = false;
            SMA.IsActive        = false;
            period.IsActive     = false;
            radar.IsActive      = false;
            altitude.IsActive   = false;
            terrain.IsActive    = false;
            velocity.IsActive   = false;
            location.IsActive   = false;

            targetName.IsActive = false;
            closest.IsActive    = false;
            distance.IsActive   = false;
            relInc.IsActive     = false;
            relVel.IsActive     = false;
            angToPro.IsActive   = false;
            closestVel.IsActive = false;
            phaseAngle.IsActive = false;

            maneuver.IsActive              = false;
            burnTime.IsActive              = false;
            maneuverApoapsis.IsActive      = false;
            maneuverPeriapsis.IsActive     = false;
            maneuverInclination.IsActive   = false;
            maneuverEccentricity.IsActive  = false;
            maneuverAngleToPro.IsActive    = false;
            maneuverPhaseAngle.IsActive    = false;
            maneuverCloseApproach.IsActive = false;
            maneuverCloseRelVel.IsActive   = false;

            if (orbitPanel != null)
            {
                Destroy(orbitPanel.gameObject);
            }

            if (targetPanel != null)
            {
                Destroy(targetPanel.gameObject);
            }

            if (maneuverPanel != null)
            {
                Destroy(maneuverPanel.gameObject);
            }

            if (panelManager != null)
            {
                Destroy(panelManager.gameObject);
            }

            BasicSettings.Instance.orbitPosition    = orbitHUD.Position;
            BasicSettings.Instance.targetPosition   = targetHUD.Position;
            BasicSettings.Instance.maneuverPosition = maneuverHUD.Position;

            if (appLauncher != null)
            {
                Destroy(appLauncher);
            }

            if (BasicSettings.Instance.Save())
            {
                BasicOrbit.BasicLogging("Settings file saved");
            }

            GameEvents.OnGameSettingsApplied.Remove(onGameSettings);
        }
コード例 #7
0
        private void loadSprites()
        {
            ContractsApp prefab = null;

            var prefabs = Resources.FindObjectsOfTypeAll <ContractsApp>();

            for (int i = prefabs.Length - 1; i >= 0; i--)
            {
                var pre = prefabs[i];

                if (pre.name != "ContractsApp")
                {
                    continue;
                }

                prefab = pre;
                break;
            }

            if (prefab != null)
            {
                GenericAppFrame      appFrame      = null;
                GenericCascadingList cascadingList = null;
                UIListItem_spacer    spacer        = null;

                try
                {
                    var fields = typeof(ContractsApp).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();

                    appFrame = fields[7].GetValue(prefab) as GenericAppFrame;

                    cascadingList = fields[9].GetValue(prefab) as GenericCascadingList;

                    spacer = fields[11].GetValue(prefab) as UIListItem_spacer;
                }
                catch (Exception e)
                {
                    BasicOrbit.BasicLogging("Error in processing toolbar panel UI: {0}", e);
                }

                if (appFrame != null)
                {
                    windowSprite = appFrame.gfxBg.sprite;
                    titleSprite  = appFrame.gfxHeader.sprite;
                    footerSprite = appFrame.gfxFooter.sprite;
                }

                if (cascadingList != null)
                {
                    buttonSprite        = cascadingList.cascadeHeader.GetComponent <Image>().sprite;
                    contentFooterSprite = cascadingList.cascadeFooter.GetComponent <Image>().sprite;
                }

                if (spacer != null)
                {
                    componentSprite = spacer.GetComponent <Image>().sprite;

                    UIStateImage stateImage = spacer.GetComponentInChildren <UIStateImage>();

                    selectedSprite   = stateImage.states[1].sprite;
                    unselectedSprite = stateImage.states[0].sprite;
                }
            }

            StageManager prefabFlight = null;

            var stages = Resources.FindObjectsOfTypeAll <StageManager>();

            for (int i = stages.Length - 1; i >= 0; i--)
            {
                var pre = stages[i];

                if (pre.name == "StageManager")
                {
                    prefabFlight = pre;
                }
            }

            if (prefabFlight != null)
            {
                StageGroup group = prefabFlight.stageGroupPrefab;

                Transform layout = group.transform.FindChild("IconLayout");

                if (layout != null)
                {
                    panelSprite = layout.GetComponent <Image>().sprite;
                }
            }

            spritesLoaded = true;
        }