static public void DumpCurrentTreeToFile( string sFileName, string sTreeName )
        {
            // only attempt to dump if the current game mode has a tech tree, and the tech tree is present

            if ( HighLogic.CurrentGame != null && ( HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX )
                && AssetBase.RnDTechTree != null && AssetBase.RnDTechTree.GetTreeNodes() != null )
            {
			    ConfigNode fileConfigNode = new ConfigNode();

			    ConfigNode treeConfigNode = new ConfigNode( "TECH_TREE" );

                treeConfigNode.AddValue( "name", sTreeName );

                AddAllTechNodesToTreeNode( treeConfigNode );

                AddPlanetScienceValuesToTreeNode( treeConfigNode );

                fileConfigNode.AddNode( treeConfigNode );

			    fileConfigNode.Save( KSPUtil.ApplicationRootPath.Replace( "\\", "/" ) + "GameData/ATC/" + sFileName, 
                    "Config file representing the stock tech tree\r\n" +
                    "// WARNING: This file should not be edited directly, but rather should either be altered using ModuleManager commands within your own .cfg files OR\r\n" +
                    "// a new tree .cfg should be created which settings.cfg can then be set to point to." );

                m_bHasTreeAlreadyBeenDumped = true;
            }
        }
예제 #2
0
 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save ()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (nodeName);
     clsNode.AddNode (node);
     clsNode.Save (path);
 }
예제 #3
0
 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (GetType ().Name);
     clsNode.AddNode (node);
     clsNode.Save (filePath);
 }
예제 #4
0
		public void Save()
		{
			ConfigNode settings = new ConfigNode("SmartStage");
			settings.AddValue("autoUpdateStaging", autoUpdateStaging);
			settings.AddValue("showInFlight", plugin.showInFlight);
			settings.Save(KSP.IO.IOUtils.GetFilePathFor(typeof(MainWindow), "settings.cfg"));
		}
예제 #5
0
 private ConfigNode createSettings()
 {
     ConfigNode node = new ConfigNode();
     node.AddValue(DEBUG_VALUE, false);
     node.Save(SETTINGS_FILE);
     return node;
 }
        public void Save()
        {
            ConfigNode node = new ConfigNode ("KerbalAnimationSuite_Settings");

            node.AddValue ("AllowEditorMusic", AllowEditorMusic.ToString());

            node.Save (Path);
        }
 public static void SaveAnimationNames(string url)
 {
     ConfigNode node = new ConfigNode ();
     foreach (var name in KerbalAnimationSuite.Instance.AnimationNames)
     {
         node.AddValue (name.Key, name.Value);
     }
     node.Save (KSPUtil.ApplicationRootPath + "GameData/" + url + ".dat");
 }
예제 #8
0
 public void Save()
 {
     try
     {
         ConfigNode save = new ConfigNode();
         ConfigNode.CreateConfigFromObject(this, 0, save);
         save.Save(File);
     }
     catch (Exception e) { RTLog.Notify("An error occurred while attempting to save: " + e.Message); }
 }
        public void Save(string fileURL)
        {
            ConfigNode configNode = new ConfigNode("CUTSCENE_DEFINITION");
            
            string fullPath = string.Join(Path.DirectorySeparatorChar.ToString(), new string[] {
                KSPUtil.ApplicationRootPath, "GameData", fileURL });

            OnSave(configNode);

            configNode.Save(fullPath);
        }
예제 #10
0
        public void Save()
        {
            ConfigNode root = new ConfigNode();
            ConfigNode rt = new ConfigNode("REMOTE_TECH");
            root.AddNode(rt);

            mCore.Network.Save(rt);
            mCore.Gui.Save(rt);
            mCore.Renderer.Save(rt);

            root.Save("RemoteTech.cfg", " RemoteTech2 configuration file.");
        }
예제 #11
0
 /// <summary>
 /// Saves the current RTSettings object to the RemoteTech_Settings.cfg
 /// </summary>
 public void Save()
 {
     try
     {
         ConfigNode details = new ConfigNode("RemoteTechSettings");
         ConfigNode.CreateConfigFromObject(this, 0, details);
         ConfigNode save = new ConfigNode();
         save.AddNode(details);
         save.Save(File);
     }
     catch (Exception e) { RTLog.Notify("An error occurred while attempting to save: " + e.Message); }
 }
예제 #12
0
        public void SaveSettings()
        {
            ConfigNode settings = new ConfigNode("SETTINGS");
            settings.AddValue("stopTimeWarpOnFailure", stopTimeWarpOnFailure);
            settings.AddValue("alertMessageOnFailure", alertMessageOnFailure);
            settings.AddValue("highlightFailedPart", highlightFailedPart);

            ConfigNode root = new ConfigNode();
            root.AddNode(settings);

            root.Save("GameData/KerbalMechanics/Settings.cfg");
        }
예제 #13
0
        public void Save(string file)
        {
            try
            {
                ConfigNode save = new ConfigNode();
                ConfigNode.CreateConfigFromObject(PlanetSettings.Instance, save);
                save.Save(file);
            }
            catch
            {

            }
        }
        public static void DoExport()
        {
            ConfigNode configNode = new ConfigNode("CUSTOM_WAYPOINTS");
            ScenarioCustomWaypoints.Instance.OnSave(configNode);

            configNode.Save(CustomWaypointsFileName,
                "Waypoint Manager Custom Waypoints File\r\n" +
                "//\r\n" +
                "// This file contains an extract of Waypoint Manager custom waypoints.");

            int count = configNode.nodes.Count;
            ScreenMessages.PostScreenMessage("Exported " + count + " waypoint" + (count != 1 ? "s" : "") + " to " + CustomWaypointsFileName,
                6.0f, ScreenMessageStyle.UPPER_CENTER);
        }
예제 #15
0
        public static void ApplySettings()
        {
            Debug.Log("CactEye 2: Settings saved to " + ConfigFilePath);

            ConfigNode Settings = new ConfigNode();
            ConfigNode CactEye2 = Settings.AddNode("CactEye2");
            CactEye2.AddValue("DebugMode", DebugMode);
            Debug.Log("CactEye 2: DebugMode = " + DebugMode.ToString());
            CactEye2.AddValue("SunDamage", SunDamage);
            Debug.Log("CactEye 2: SunDamage = " + SunDamage.ToString());
            CactEye2.AddValue("GyroDecay", GyroDecay);
            Debug.Log("CactEye 2: GyroDecay = " + GyroDecay.ToString());
            Settings.Save(ConfigFilePath);
        }
        public static void SaveConfigs()
        {
            ConfigNode node = new ConfigNode();
            ConfigNode settings = node.AddNode("PWingsSettings");
            settings.AddValue(nameof(keyTranslation), keyTranslation.ToString());
            settings.AddValue(nameof(keyTipScale), keyTipScale.ToString());
            settings.AddValue(nameof(keyRootScale), keyRootScale.ToString());
            settings.AddValue(nameof(moveSpeed), moveSpeed);
            settings.AddValue(nameof(scaleSpeed), scaleSpeed);
            settings.AddValue(nameof(uiRectWindowEditor), uiRectWindowEditor);
            settings.AddValue(nameof(uiKeyCodeEdit), uiKeyCodeEdit.ToString());

            node.Save(KSPUtil.ApplicationRootPath + Path.DirectorySeparatorChar + "GameData" + Path.DirectorySeparatorChar + "PWingsPlugin" + Path.DirectorySeparatorChar + "PluginData" + Path.DirectorySeparatorChar + "settings.cfg");
        }
        public static void SaveCustomStressTemplates()
        {
            ConfigNode node = new ConfigNode("@FARAeroStress[default]:FOR[FerramAerospaceResearch]");
            int i = 0;
            node.AddNode(new ConfigNode("!FARPartStressTemplate,*"));

            foreach (FARPartStressTemplate template in StressTemplates)
            {
                node.AddNode(CreateAeroStressConfigNode(template, i));
                i++;
            }

            ConfigNode saveNode = new ConfigNode();
            saveNode.AddNode(node);
            saveNode.Save(KSPUtil.ApplicationRootPath.Replace("\\", "/") + "GameData/FerramAerospaceResearch/CustomFARAeroStress.cfg");
        }
예제 #18
0
        public void OnDestroy()
        {
            ConfigNode settingsNode = new ConfigNode("FilterSettings");
            settingsNode.AddValue("hideUnpurchased", Core.Instance.hideUnpurchased);
            settingsNode.AddValue("debug", Core.Instance.debug);
            settingsNode.AddValue("setAdvanced", Core.Instance.setAdvanced);
            settingsNode.AddValue("replaceFbM", Core.Instance.replaceFbM);
            settingsNode.AddValue("categoryDefault", Core.Instance.categoryDefault);
            settingsNode.AddValue("subCategoryDefault", Core.Instance.subCategoryDefault);

            ConfigNode nodeToWrite = new ConfigNode();
            nodeToWrite.AddNode(settingsNode);

            #warning Need to move the save location inside PluginData so MM can't see it, cache it, and then recache it when settings are changed (or maybe just change the extension. Same effect though)
            nodeToWrite.Save(KSPUtil.ApplicationRootPath.Replace("\\", "/") + "GameData/000_FilterExtensions/Settings.cfg");
        }
예제 #19
0
		public static void Save () {
//			_logger.Trace("Save");
			var node = new ConfigNode();
			var root = node.AddNode("ScienceChecklist");
			var settings = root.AddNode("Config");

			settings.AddValue( "HideCompleteExperiments",	HideCompleteExperiments );
			settings.AddValue( "UseBlizzysToolbar",			UseBlizzysToolbar );
			settings.AddValue( "CompleteWithoutRecovery",	CompleteWithoutRecovery );
			settings.AddValue( "CheckDebris",				CheckDebris );
			settings.AddValue( "AllFilter",					AllFilter );



//			_logger.Debug("Saving to" + _file);
			node.Save(_file);
		}
        internal override void Awake()
        {
            String FilePath = System.IO.Path.Combine(
                System.Reflection.Assembly.GetExecutingAssembly().Location,
                "Settings.cfg").Replace("\\", "/");

            ConfigNode cnLoad = new ConfigNode();
            cnLoad = ConfigNode.Load(FilePath);
            ConfigNode.LoadObjectFromConfig(settings, cnLoad);

            settings.TestString = "Hello again";

            ConfigNode cnToPrint = new ConfigNode("settings");
            cnToPrint= ConfigNode.CreateConfigFromObject(settings);
            LogFormatted(cnToPrint.ToString());

            cnToPrint.Save(FilePath);
        }
예제 #21
0
        public void LoadBeacons(string beaconFile, bool createIfNotExists = false)
        {
            beacons.Clear();
            if (System.IO.File.Exists(beaconFile))
            {
                ConfigNode beaconsNode = ConfigNode.Load(beaconFile);
                foreach (ConfigNode beacon in beaconsNode.GetNodes("Beacon"))
                {
                    beacons.Add(new Beacon(beacon));
                }
            }
            else if (createIfNotExists)
            {
                //Set the defaults and save the file
                Beacon KSC = new Beacon("KSC", SpaceCenter.Instance.Latitude, SpaceCenter.Instance.Longitude, 100000);
                beacons.Add(KSC);

                ConfigNode beaconsNode = new ConfigNode("Beacons");
                beaconsNode.AddNode(KSC.AsNode());

                beaconsNode.Save(beaconFile);
            }
        }
 private static ConfigNode CreateNewSettingsConfig()
 {
     ConfigNode node = new ConfigNode ();
     node.AddValue ("mode", "normal");
     node.AddValue ("allowProceduralGasGiants", true);
     node.AddValue ("allowAdvancedCometShader", true);
     node.AddValue ("allowAnimatedComets", true);
     node.AddValue ("allowAnimatedProceduralGasGiants", true);
     node.AddValue ("allowRefractiveAtmospheres", true);
     node.Save (ConfigPath);
     return node;
 }
예제 #23
0
        void SaveGUI()
        {
            try
            {
                ConfigNode save = new ConfigNode();
                ConfigNode.CreateConfigFromObject(this, 0, save);

                save.AddValue("disabled", disabled.ToString());
                save.AddValue("mode", visibility_mode.ToString());
                save.AddValue("active", MainWindowActive.ToString());

                save.AddValue("showMain", showMainWindow.ToString());
                save.AddValue("xMain", MainWindowRect.x.ToString());
                save.AddValue("yMain", MainWindowRect.y.ToString());

                save.AddValue("showBody", showBodyWindow.ToString());
                save.AddValue("xBody", BodyWindowRect.x.ToString());
                save.AddValue("yBody", BodyWindowRect.y.ToString());

                save.AddValue("showConfig", showConfigWindow.ToString());
                save.AddValue("xConfig", ConfigWindowRect.x.ToString());
                save.AddValue("yConfig", ConfigWindowRect.y.ToString());

                save.Save(gui_path);
            }
            catch (Exception e) { Debug.Log("[PR] Saving not successful: " + e.Message); }
        }
예제 #24
0
		public static ConfigNode getPluginSaveFile() {
			ConfigNode config = ConfigNode.Load (PluginHelper.getPluginSaveFilePath ());
			if (config == null) {
				config = new ConfigNode ();
				config.AddValue("writtenat",DateTime.Now.ToString());
				config.Save(PluginHelper.getPluginSaveFilePath ());
			}
			return config;
		}
예제 #25
0
파일: Editor.cs 프로젝트: erendrake/AGExt
        public void CheckExistingShips()
        {
            List<string> existingShipsList = new List<string>();
            string fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/Ships/VAB";
            int fileLen = fileDir.Length;
            string[] fileList = Directory.GetFiles(fileDir);
            //print("sc3 " + loadShipList.Length);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7),true));
            }
                fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/Ships/SPH";
            
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), false));
            }
            fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "Ships/SPH";
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), false));
            }
            fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "Ships/VAB";
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), true));
            }
            //ConfigNode AGXBaseNode = AGextScenario.LoadBaseNode();
            ConfigNode AGXEditorNode = new ConfigNode("EDITOR");
            AGXEditorNode.AddValue("name", "editor");
            if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
            {
                AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
            }
            foreach (ConfigNode VslNode in AGXEditorNode.nodes)
            {
                if (!existingShipsList.Contains(VslNode.name))
                {
                    AGXEditorNode.RemoveNode(VslNode.name);
                    //AGXBaseNode.RemoveNode("EDITOR");
                    //AGXBaseNode.AddNode(AGXEditorNode);
                    AGXEditorNode.Save(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //print("Existing ship check node save " + AGXEditorNode);
                    goto BreakOut;
                }
            }
        BreakOut:
            fileList = null;

            
        }
예제 #26
0
파일: Editor.cs 프로젝트: erendrake/AGExt
        public static void EditorSaveToFile()
        {
            //print("EditorSaveToFile called"); 
            string errLine = "1";
            try
            {
                ConfigNode AGXEditorNode = new ConfigNode("EDITOR");
                AGXEditorNode.AddValue("name", "editor");
                errLine = "2";
                if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
                {
                    errLine = "3";
                    AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //print("AGX ConfigNode Load Okay! (Saving)");
                }
               // else
                //{
                    //errLine = "4";
                    //print("AGX ConfigNode not found, creating..... (Saving)");
                    //errLine = "5";
                    //AGXEditorNode.AddValue("name", "Action Groups Extended save file");
                    //AGXEditorNode.AddNode("FLIGHT");
                    //errLine = "6";
                    //AGXEditorNode.AddNode("EDITOR");
                    //errLine = "7";
                    //AGXEditorNode.Save(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //errLine = "8";
                //}

                errLine = "9";
                //ConfigNode AGXEditorNode = AGXBaseNode.GetNode("EDITOR");
                errLine = "10";
                string hashedShipName = AGextScenario.EditorHashShipName(EditorLogic.fetch.shipNameField.Text, inVAB);
                errLine = "11";
                ConfigNode thisVsl = new ConfigNode(hashedShipName);
                errLine = "12";
                thisVsl.AddValue("name", EditorLogic.fetch.shipNameField.Text);
                errLine = "13";
                thisVsl.AddValue("currentKeyset", CurrentKeySet.ToString());
                errLine = "14";
                thisVsl.AddValue("groupNames", SaveGroupNames(""));
                errLine = "15";
                thisVsl.AddValue("groupVisibility", SaveGroupVisibility(""));
                errLine = "16";
                thisVsl.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
                errLine = "17";
                try
                {
                    errLine = "17c";
                    foreach (Part p in EditorLogic.SortedShipList)
                    {
                        errLine = "17d";
                        List<AGXAction> thisPartsActions = new List<AGXAction>();
                        thisPartsActions.AddRange(CurrentVesselActions.FindAll(p2 => p2.prt == p));
                        errLine = "18";
                        if (thisPartsActions.Count > 0)
                        {
                            ConfigNode partTemp = new ConfigNode("PART");
                            errLine = "19";
                            partTemp.AddValue("name", p.name);
                            partTemp.AddValue("vesselID", "0");
                            partTemp.AddValue("relLocX", (p.transform.position - EditorLogic.startPod.transform.position).x);
                            if (!inVAB)
                            {
                                partTemp.AddValue("relLocZ", ((p.transform.position - EditorLogic.startPod.transform.position).y) * -1f);
                                partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).z);
                            }
                            else
                            {
                                partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).y);
                                partTemp.AddValue("relLocZ", (p.transform.position - EditorLogic.startPod.transform.position).z);
                            }
                            errLine = "20";
                            foreach (AGXAction agxAct in thisPartsActions)
                            {
                                errLine = "21";
                                partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
                            }
                            errLine = "22";

                            thisVsl.AddNode(partTemp);
                            errLine = "23";
                        }
                       // print("part OrgPart "+ p.ConstructID+" " + p.orgPos + " " + p.orgRot);
                    }
                }
                catch
                {
                    print("AGExt No parts to save ");
                }
                errLine = "23";
                if(AGXEditorNode.HasNode(hashedShipName))
                {
                    errLine = "23";
                    AGXEditorNode.RemoveNode(hashedShipName);
                }
                errLine = "24";
                AGXEditorNode.AddNode(thisVsl);
                errLine = "25";
                //AGXBaseNode.RemoveNode("EDITOR");
                errLine = "26";
                //AGXBaseNode.AddNode(AGXEditorNode);
                errLine = "27";
                AGXEditorNode.Save(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                //print("Saved this node " + AGXEditorNode);
                errLine = "28";
            }
            catch (Exception e)
            {
                print("AGX EditorSaveToFile FAIL " + errLine + " " + e);
            }
        }
예제 #27
0
파일: Editor.cs 프로젝트: erendrake/AGExt
         List<string> showAllPartsListTitles; //list of all parts with actions to show in group window
        //static Part partLastHighlight = null;
        ////static Color partHighlighLastColor;
        //static Part.HighlightType partHighlightLastType;
        //static Material[] partHighlightLastMaterial;

       
        
       
        public void Start()
        {
            //foreach (Part p in 

            //var EdPnl = EditorPanels.Instance.actions;
            //EditorActionGroups.Instance.groupActionsList.AddValueChangedDelegate(OnGroupActionsListChange);
            KSPActs[1] = KSPActionGroup.Custom01;
            KSPActs[2] = KSPActionGroup.Custom02;
            KSPActs[3] = KSPActionGroup.Custom03;
            KSPActs[4] = KSPActionGroup.Custom04;
            KSPActs[5] = KSPActionGroup.Custom05;
            KSPActs[6] = KSPActionGroup.Custom06;
            KSPActs[7] = KSPActionGroup.Custom07;
            KSPActs[8] = KSPActionGroup.Custom08;
            KSPActs[9] = KSPActionGroup.Custom09;
            KSPActs[10] = KSPActionGroup.Custom10;
            
            TestWin = new Rect(600, 300, 100, 200);
            RenderingManager.AddToPostDrawQueue(0, AGXOnDraw);
            AGEditorSelectedParts = new List<AGXPart>();
            PartActionsList = new List<BaseAction>();
            ScrollPosSelParts = Vector2.zero;
            ScrollPosSelPartsActs = Vector2.zero;
            ScrollGroups = Vector2.zero;
            CurGroupsWin = Vector2.zero;
            
            //AGXVsl = new AGXVessel();
            
            AGXWinStyle = new GUIStyle(HighLogic.Skin.window);
            
            BtnTexRed.SetPixel(0, 0, new Color(1, 0, 0, .5f));
            BtnTexRed.Apply();
            BtnTexGrn.SetPixel(0, 0, new Color(0, 1, 0, .5f));
            BtnTexGrn.Apply();
            
            AGXguiNames = new Dictionary<int,string>();
            
            
            AGXguiKeys = new Dictionary<int, KeyCode>();
           

           
            for (int i = 1; i <= 250; i = i + 1)
            {
                AGXguiNames[i] = "";
                AGXguiKeys[i] = KeyCode.None;
            }

            
            KeyCodeNames = new List<String>();
            KeyCodeNames.AddRange(Enum.GetNames(typeof(KeyCode)));
            KeyCodeNames.Remove("None");
            JoyStickCodes.AddRange(KeyCodeNames.Where(JoySticks));
            KeyCodeNames.RemoveAll(JoySticks);
           AGExtNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
           if (AGExtNode.GetValue("EditShow") == "0")
           {
               AGXShow = false;
           }
           else
           {
               AGXShow = true;
           }
           CurrentKeySet = Convert.ToInt32(AGExtNode.GetValue("ActiveKeySet"));
           //LoadCurrentKeySet();
           CurrentKeySetName = AGExtNode.GetValue("KeySetName" + CurrentKeySet);
           CurrentVesselActions = new List<AGXAction>();
           AGXRoot = null;
           GroupsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdGroupsX")), Convert.ToInt32(AGExtNode.GetValue("EdGroupsY")), 250, 530);
           SelPartsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdSelPartsX")), Convert.ToInt32(AGExtNode.GetValue("EdSelPartsY")), 365, 270);
           KeyCodeWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdKeyCodeX")), Convert.ToInt32(AGExtNode.GetValue("EdKeyCodeY")), 410, 730);
           KeySetWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdKeySetX")), Convert.ToInt32(AGExtNode.GetValue("EdKeySetY")), 185, 335);
           CurActsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdCurActsX")), Convert.ToInt32(AGExtNode.GetValue("EdCurActsY")), 345, 140);
            


           LoadCurrentKeyBindings();


           if (ToolbarManager.ToolbarAvailable) //check if toolbar available, load if it is
           {


               AGXBtn = ToolbarManager.Instance.add("AGX", "AGXBtn");
               AGXBtn.TexturePath = "Diazo/AGExt/icon_button";
               AGXBtn.ToolTip = "Action Groups Extended";
               AGXBtn.OnClick += (e) =>
               {
                   //List<UnityEngine.Transform> UIPanelList = new List<UnityEngine.Transform>(); //setup list to find Editor Actions UI transform into a list. Could not figure out how to find just a transform
                   //UIPanelList.AddRange(FindObjectsOfType<UnityEngine.Transform>().Where(n => n.name == "PanelActionGroups")); //actual find command
                   if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
                   {
                       if (AGXShow)
                       {
                           //UIPanelList.First().Translate(new Vector3(500f, 0, 0), UIPanelList.First().parent.transform); //hide UI panel
                           AGXShow = false;
                           AGExtNode.SetValue("EditShow", "0");
                           EditorPanels.Instance.panelManager.BringIn(EditorPanels.Instance.actions);

                       }
                       else
                       {
                           // UIPanelList.First().Translate(new Vector3(-500f, 0, 0), UIPanelList.First().parent.transform); //show UI panel
                           AGXShow = true;
                           AGExtNode.SetValue("EditShow", "1");
                           EditorPanels.Instance.panelManager.Dismiss();
                       }
                       AGExtNode.Save(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
                   }
                   else
                   {
                       EditorLogic.fetch.SelectPanelActions();
                   }
               };
           }
           else
           {
               AGXShow = true; //toolbar not installed, show AGX regardless
           }
           
           DetachedPartActions = new List<AGXAction>();
          
            DetachedPartReset = new Timer();
           DetachedPartReset.Interval = 500;
           
           DetachedPartReset.Stop();
           DetachedPartReset.AutoReset = true;
           
           DetachedPartReset.Elapsed += new ElapsedEventHandler(ResetDetachedParts);

           SelectedWithSym = new List<Part>();
           SelectedWithSymActions = new List<AGXDefaultCheck>();

           EditorPanels.Instance.actions.AddValueChangedDelegate(OnUIChanged); //detect when EditorPanel moves. this ONLY detects editor panel, going from parts to crew will NOT trigger this
           EditorLogic.fetch.crewPanelBtn.AddValueChangedDelegate(OnOtherButtonClick); //detect when Part button clicked at top of screen
           EditorLogic.fetch.partPanelBtn.AddValueChangedDelegate(OnOtherButtonClick); //detect when Crew button clicked at top of screen
           EditorLogic.fetch.loadBtn.AddValueChangedDelegate(OnLoadButtonClick); //load button clicked to check for deleted ships
           EditorLogic.fetch.saveBtn.AddValueChangedDelegate(OnSaveButtonClick); //run save when save button clicked. auto-save from Scenario module only runs on leaving editor! not on clicking save button
           EditorLogic.fetch.launchBtn.AddValueChangedDelegate(OnSaveButtonClick);
           EditorLogic.fetch.exitBtn.AddValueChangedDelegate(OnSaveButtonClick);
           EditorLogic.fetch.newBtn.AddValueChangedDelegate(OnSaveButtonClick);

           IsGroupToggle = new Dictionary<int, bool>();
           ShowGroupInFlight = new bool[6, 251];
           ShowGroupInFlightNames = new string[6];
           
           ShowGroupInFlightNames[1] = "Group 1";
           ShowGroupInFlightNames[2] = "Group 2";
           ShowGroupInFlightNames[3] = "Group 3";
           ShowGroupInFlightNames[4] = "Group 4";
           ShowGroupInFlightNames[5] = "Group 5";
           
           
           
            for (int i = 1; i <= 250; i++)
           {
               IsGroupToggle[i] = false;
               for (int i2 = 1; i2 <= 5; i2++)
               {
                   ShowGroupInFlight[i2, i] = true;
               }
           }
            AGXSkin = (GUISkin)MonoBehaviour.Instantiate(HighLogic.Skin);
            AGXWinStyle = new GUIStyle(AGXSkin.window);
            AGXLblStyle = new GUIStyle(AGXSkin.label);
            AGXFldStyle = new GUIStyle(AGXSkin.textField);
            AGXFldStyle.fontStyle = FontStyle.Normal;
            //AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1);
            AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            AGXLblStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            AGXLblStyle.wordWrap = false;

            AGXBtnStyle = new GUIStyle(AGXSkin.button);
            AGXBtnStyle.fontStyle = FontStyle.Normal;
            AGXBtnStyle.alignment = TextAnchor.MiddleCenter;
            AGXBtnStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            //AGXScrollStyle.normal.background = null;
            //print("AGX " + AGXBtnStyle.normal.background);
            byte[] importTxt = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTexture.png");
            byte[] importTxtRed = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureRed.png");
            byte[] importTxtGreen = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureGreen.png");
            byte[] importPartCenter = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/PartLocationCross.png");
            //byte[] testXport = AGXBtnStyle.normal.background.EncodeToPNG();
            //File.WriteAllBytes(Application.dataPath + "/SavedScreen.png", testXport);
            ButtonTexture.LoadImage(importTxt);
            ButtonTexture.Apply();
            ButtonTextureRed.LoadImage(importTxtRed);
            ButtonTextureRed.Apply();
            ButtonTextureGreen.LoadImage(importTxtGreen);
            ButtonTextureGreen.Apply();
            AGXBtnStyle.normal.background = ButtonTexture;
            AGXBtnStyle.onNormal.background = ButtonTexture;
            AGXBtnStyle.onActive.background = ButtonTexture;
            AGXBtnStyle.onFocused.background = ButtonTexture;
            AGXBtnStyle.onHover.background = ButtonTexture;
            AGXBtnStyle.active.background = ButtonTexture;
            AGXBtnStyle.focused.background = ButtonTexture;
            AGXBtnStyle.hover.background = ButtonTexture;
            PartCenter.LoadImage(importPartCenter);
            PartCenter.Apply();
            //EditorLoadFromFile();
            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                inVAB = true;
            }
            else
            {
                inVAB = false;
            }
            GameEvents.onPartAttach.Add(PartAttaching);// this game event only fires for part removed, not child parts
            GameEvents.onPartRemove.Add(PartRemove);
            EditorLoadFromFile();
            //print("Loading now");
           LoadFinished = true;
           
           }
        public static void SaveCustomAeroDataToConfig()
        {
            ConfigNode node = new ConfigNode("@FARAeroData[default]:FOR[FerramAerospaceResearch]");
            node.AddValue("%massPerWingAreaSupported", massPerWingAreaSupported);
            node.AddValue("%massStressPower", massStressPower);
            node.AddValue("%ctrlSurfTimeConstant", FARControllableSurface.timeConstant);
            node.AddValue("%ctrlSurfTimeConstantFlap", FARControllableSurface.timeConstantFlap);
            node.AddValue("%ctrlSurfTimeConstantSpoiler", FARControllableSurface.timeConstantSpoiler);

            node.AddNode(new ConfigNode("!BodyAtmosphericData,*"));

            foreach (KeyValuePair<int, double[]> pair in bodyAtmosphereConfiguration)
            {
                node.AddNode(CreateAtmConfigurationConfigNode(pair.Key, pair.Value));
            }

            ConfigNode saveNode = new ConfigNode();
            saveNode.AddNode(node);
            saveNode.Save(KSPUtil.ApplicationRootPath.Replace("\\", "/") + "GameData/FerramAerospaceResearch/CustomFARAeroData.cfg");
        }
예제 #29
0
        public void SavePlan(FlightPlan plan)
        {
            if (plan.planet == null)
            {
                Deb.Err("SavePlan: plan has no planet");
                return;
            }

            if (plan.name == currentName)
            {
                Deb.Log("SavePlan: same name, overwrite current");
                plan.description = currentDesc;
            }
            else
            {
                current = plan.Clone();
                current.name = currentName;
                current.description = currentDesc;
                plan = current;
            }

            flightPlan = current;

            List<FlightPlan> plans_for_planet = null;

            if (!flightPlansDict.TryGetValue(planet.name, out plans_for_planet))
            {
                Deb.Log("SavePlan: creating new plan list for planet {0}", planet.name);
                plans_for_planet = new List<FlightPlan>();
                flightPlansDict[planet.name] = plans_for_planet;
            }

            bool plan_present = false;

            foreach (var pplan in plans_for_planet)
            {
                if (System.Object.ReferenceEquals(plan, pplan))
                {
                    plan_present = true;
                    break;
                }
            }

            if (!plan_present)
            {
                Deb.Log("SavePlan: plan not present, create one in list");
                plans_for_planet.Add(plan);
            }

            ConfigNode rootNode = new ConfigNode();

            ConfigNode node = rootNode.AddNode(flightPlansNodeName);

            // plan_list will be key/value pair
            foreach (var pair in flightPlansDict)
            {
                ConfigNode listNode = node.AddNode(pair.Key);

                foreach (var aplan in pair.Value)
                {
                    listNode.AddNode(aplan.ToConfigNode());
                }
            }

            rootNode.Save(GetFlightPlanURI());
        }
 /// <summary>
 /// Saves the object to a ConfigNode structure in a file
 /// </summary>
 /// <param name="fileFullName">Absolute Path to the file to load the ConfigNode structure from</param> 
 /// <returns>Success of Save</returns>
 public Boolean Save(String fileFullName)
 {
     Boolean blnReturn = false;
     try
     {
         //Encode the current object
         ConfigNode cnToSave = this.AsConfigNode;
         //Wrap it in a node with a name of the class
         ConfigNode cnSaveWrapper = new ConfigNode(this.GetType().Name);
         cnSaveWrapper.AddNode(cnToSave);
         //Save it to the file
         cnSaveWrapper.Save(fileFullName);
         blnReturn = true;
     }
     catch (Exception ex)
     {
         LogFormatted("Failed to Save ConfigNode to file({0})-Error:{1}", fileFullName, ex.Message);
         blnReturn = false;
     }
     return blnReturn;
 }